I’m working on a requirement where I need to upload attachments (specifically TIF image files) through the MIRO transaction code. My current implementation successfully stores the data in the database tables, but the attachments don’t appear in the MIRO interface.
The process requires passing a business object type and business key. Here’s my current approach:
SELECTION-SCREEN BEGIN OF BLOCK upload_block WITH FRAME TITLE text-100.
PARAMETERS: file_path TYPE localfile,
object_id TYPE swo_typeid,
bus_obj TYPE swo_objtyp.
SELECTION-SCREEN END OF BLOCK upload_block.
DATA:
doc_content TYPE STANDARD TABLE OF soli,
content_line TYPE soli,
header_data TYPE STANDARD TABLE OF soli,
folder_member TYPE sofmk,
note_ref TYPE borident,
business_ref TYPE borident,
document_key TYPE soodk,
folder_key TYPE soodk,
doc_info 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: doc_content[], header_data[].
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\Temp\sample.TIF'
filetype = 'BIN'
TABLES
data_tab = binary_data.
CALL FUNCTION 'SO_CONVERT_CONTENTS_BIN'
EXPORTING
it_contents_bin = doc_content[]
IMPORTING
et_contents_bin = doc_content[].
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.
Can someone help identify what might be missing in my code? The database update works fine but the attachment linkage to MIRO seems incomplete.
Your main issue is with how you’re creating and linking the document. You’re skipping the actual document creation step - you need to use SO_DOCUMENT_INSERT_API1 after converting the binary content. I’ve dealt with similar MIRO attachment issues before. Here’s what works: create the document first, then link it to the business object using SO_ATTACHMENT_INSERT_API1. Double-check your business object type too - it should be ‘BUS2081’ for invoice documents. Those folder operations you’re doing aren’t needed for direct business object attachments. Don’t forget to call COMMIT WORK at the end or your changes won’t stick.
you’re missing the document creation call after converting to binary. use SO_DOCUMENT_INSERT_API1 with the right document info structure before linking anything. also check your borident structure - the objtype needs to match what’s set up in OAOR for MIRO attachments. I ran into this same problem when the document wasn’t created in SAPoffice first.
Your code handles the binary conversion fine, but you’re missing the attachment creation step. I’ve run into this with MIRO attachments before - the problem’s usually incomplete document workflow integration. After SO_CONVERT_CONTENTS_BIN runs, you need to fill out the doc_info structure with document type, description, and format specs before calling the document creation function. MIRO won’t show the attachment without the right workflow relationship through the business object framework. Also check that your object_id matches the actual MIRO document number and that the attachment service is running in your system config. I’ve seen the database writes work but MIRO still doesn’t recognize the attachment because the workflow triggers are missing.
I encountered this same issue a few months back while handling MM transaction file uploads. It seems that your code may be missing the crucial step of linking the business object. After you’ve created the document in SAPoffice, you need to properly connect the attachment to the MIRO document using appropriate BOR functions. Specifically, use ‘SO_OBJECT_INSERT’ to create the attachment and then ‘SWO_INVOKE’ or ‘SO_ATTACHMENT_INSERT_API1’ to link it with the correct business object. Ensure that your business object type matches that of the invoice document and that the business key aligns with your actual MIRO document number. Additionally, verify that attachment services are configured correctly via the OAOR transaction. Even though the database updates might succeed, MIRO won’t recognize the attachment without the proper BOR linkage.