I need guidance on how to add attachments (both an image and a document in .TIF format) to the MIRO transaction. Although my code is updating the associated table correctly, I am not seeing the files appear in the MIRO interface.
I suspect there may be an issue with how I’m passing the business object and business key parameters. Here’s the code I’m currently using:
SELECTION-SCREEN BEGIN OF BLOCK attachment WITH FRAME TITLE text-001.
PARAMETERS: file_attach TYPE localfile,
obj_identifier TYPE swo_typeid,
biz_object TYPE swo_objtyp.
SELECTION-SCREEN END OF BLOCK attachment.
DATA:
content_list TYPE STANDARD TABLE OF soli,
content_line TYPE soli,
header_list TYPE STANDARD TABLE OF soli,
folder_memory TYPE sofmk,
note_data TYPE borident,
object_data TYPE borident,
obj_id TYPE soodk,
attach_content TYPE soli,
folder_id TYPE soodk,
obj_details TYPE sood1,
note_identifier TYPE borident-objkey,
vendor_id TYPE lifnr,
file_path TYPE string,
file_name TYPE c LENGTH 100,
file_type TYPE c LENGTH 4.
CLEAR: content_list[], header_list[].
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\Users\User\Desktop\attachment.TIF'
filetype = 'BIN'
TABLES
data_tab = content_list.
CALL FUNCTION 'SO_CONVERT_CONTENTS_BIN'
EXPORTING
it_contents_bin = content_list[]
IMPORTING
et_contents_bin = content_list[].
CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
EXPORTING
region = 'B'
IMPORTING
folder_id = folder_id
EXCEPTIONS
communication_failure = 1
owner_not_exist = 2
system_failure = 3
x_error = 4
OTHERS = 5.
I’d appreciate any assistance in pinpointing where I might be going wrong!
It seems you have managed to perform the file upload successfully. The next step is to ensure the attached files are linked properly to the MIRO transaction. You will need to utilize the function ‘SO_OBJECT_INSERT’ to create the document object before linking it to the MIRO transaction using ‘SO_OBJECT_SEND’ or the GOS framework. Ensure that your business object type is set to ‘BUS2081’ and that you are using the correct invoice document number as your business key. Additionally, populate the ‘object_data’ structure with the appropriate objtype and objkey values, and finalize the attachment process accordingly.
This happens all the time with MIRO attachments. The problem’s usually with document type and object service integration. After your SO_FOLDER_ROOT_ID_GET call, set the document type to ‘EXT’ in the obj_details structure for external documents. Then call SO_OBJECT_INSERT with the file extension and description. The key part is getting the GOS connection right. Use GOS_DOCUMENT_SET_STATUS to activate the document and don’t forget COMMIT WORK after your attachment operations. Also check that the MIRO document status actually allows attachments - some statuses block file additions.
you’re missing the linking step after upload. after SO_FOLDER_ROOT_ID_GET, call SO_OBJECT_INSERT to create the document, then use BINARY_RELATION_CREATE_COMMIT to link it to miro. set biz_object = ‘BUS2081’ and obj_identifier to the invoice doc number - that’s probably why it’s not showing in the interface even tho the tables updated.
The problem’s in your document creation workflow. After SO_FOLDER_ROOT_ID_GET, you need to populate the obj_details structure with document attributes - objdes (description), objlen (content length), and file_ext fields. Then use SO_OBJECT_INSERT to create the document in the SAPoffice folder. For GOS linking, call SO_OBJECT_SEND with objtype ‘BUS2081’ and the invoice document number as objkey. Set objmeth to ‘ATTA’ for attachments. I’ve seen attachments exist in tables but not display because the object status wasn’t set properly. Check that SO_OBJECT_SEND completes without exceptions and add error handling around each function call to pinpoint where it’s failing.