I need help with uploading attachments through the MIRO transaction in SAP. I’m trying to attach two TIF files (one image and one document) but my current approach only updates the database table without showing the files in MIRO interface.
My code requires a business object type and business key to work properly. Here’s what I have so far:
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-002.
PARAMETERS: file_path TYPE localfile,
object_id TYPE swo_typeid,
bus_obj TYPE swo_objtyp.
SELECTION-SCREEN END OF BLOCK block1.
DATA:
content_table TYPE STANDARD TABLE OF soli,
content_line TYPE soli,
header_table TYPE STANDARD TABLE OF soli,
folder_member TYPE sofmk,
note_ref TYPE borident,
object_ref TYPE borident,
object_key TYPE soodk,
content_wa TYPE soli,
folder_key TYPE soodk,
object_data TYPE sood1,
note_key TYPE borident-objkey,
vendor_num TYPE lifnr,
file_string TYPE string,
file_name TYPE c LENGTH 100,
file_ext TYPE c LENGTH 4.
CLEAR: content_table[], header_table[].
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\Temp\document.TIF'
filetype = 'BIN'
TABLES
data_tab = upload_table.
CALL FUNCTION 'SO_CONVERT_CONTENTS_BIN'
EXPORTING
it_contents_bin = content_table[]
IMPORTING
et_contents_bin = content_table[].
CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
EXPORTING
region = 'B'
IMPORTING
folder_id = folder_key
EXCEPTIONS
communication_failure = 1
owner_not_exist = 2
system_failure = 3
x_error = 4
OTHERS = 5.
What am I missing to make the attachments visible in MIRO transaction?
Your code is incomplete because you’re not actually creating the attachment relationship. After converting the binary content, you need to call SO_OBJECT_INSERT to create the document object in the system. Set up your object_data structure with proper document class (usually ‘RAW’ for TIF files) and document type. Then use SO_ATTACHMENT_INSERT_API1 or BDS_BUSINESSDOCUMENT_INSERT depending on your SAP version to link the document to your invoice. The key thing you’re missing is populating the object_ref structure with your invoice document details before making the attachment call. Also verify that your folder_key from SO_FOLDER_ROOT_ID_GET is being used correctly in subsequent function calls. I had similar issues until I realized the attachment process requires both document creation and explicit linking steps.
The main issue is that you’re working with the document service but not properly connecting it to the MIRO transaction workflow. After your SO_CONVERT_CONTENTS_BIN call, you need to create the document object using SO_OBJECT_INSERT with proper object data including document type and description. Then use GOS_ATTACHMENT_CREATE_API or the Services for Objects framework to establish the relationship between your attachment and the invoice document. The critical part is ensuring your business object reference points to the correct invoice document instance - for MIRO this should be the invoice document number with BUS2081 as object type. Without this proper linkage, your files remain orphaned in the system database but won’t appear in the MIRO interface’s attachment list.
you’re missing the actual attachment creation step. after uploading the file content you need to use SO_OBJECT_INSERT to create the document object first, then SO_ATTACHMENT_INSERT_API1 to link it to your miro document. also make sure your business object type is ‘BUS2081’ for invoice documents and the object key matches your invoice number format.