I need help with uploading attachments (TIF images and documents) to the MIRO transaction in SAP. My current code successfully updates the database tables, but the files don’t appear in the MIRO interface itself.
I’m working with business objects and business keys, but something seems wrong with my implementation. Here’s what I have so far:
SELECTION-SCREEN BEGIN OF BLOCK upload_block 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 upload_block.
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,
document_id TYPE soodk,
folder_ref TYPE soodk,
doc_data TYPE sood1,
note_key TYPE borident-objkey,
vendor_num TYPE lifnr,
upload_file 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_data.
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_ref
EXCEPTIONS
communication_failure = 1
owner_not_exist = 2
system_failure = 3
x_error = 4
OTHERS = 5.
Can someone point out what I’m missing to make the attachments visible in MIRO?
Your business object configuration and attachment process seem to have some gaps. While you are using ‘SO_FOLDER_ROOT_ID_GET’, it appears that the document record is never actually created. After uploading the file, you should call ‘SO_DOCUMENT_INSERT_API1’ to create the document object with the appropriate metadata. Ensure that you set the ‘doc_data’ with ‘object_type’ as ‘EXT’, ‘object_name’ corresponding to your filename, and ‘format_typ’ matching your file type. For MIRO, remember to use the business object type ‘BUS2081’—not whatever you are referencing in your ‘bus_obj’ parameter—and set the ‘object_id’ to the actual invoice document number from the ‘RBKP’ table. I’ve encountered this specific issue before where users try to attach to business objects that are either non-existent or referenced incorrectly. Additionally, please verify your GOS authorization in MIRO; without the ‘S_GOS_ATT’ access, while attachments may upload successfully, users will not be able to view them in the transaction.
You’re missing the step that links your document to the MIRO transaction through GOS. After uploading with SO_FOLDER_ROOT_ID_GET, you’ve got to connect your attachment to the specific MIRO document instance.
Use function module ‘BINARY_RELATION_CREATE’ to create the relationship between your document object and the MIRO business object. Your object_ref structure needs the correct BUS2081 object type (for invoice documents) and the right document number as the object key.
Also spotted an issue - you’re calling SO_CONVERT_CONTENTS_BIN wrong. You’re passing content_table as both import and export parameter. For TIF files, just use the binary content straight from GUI_UPLOAD without any conversion.
One more thing: make sure your MIRO document is saved before trying to attach anything. If it’s not saved, GOS services won’t recognize the business object instance and your attachment won’t show up in the transaction.