File Upload Issues in MIRO Transaction - Documents Not Appearing

I’m working on a custom report that needs to upload attachments to the MIRO transaction in SAP. The documents I need to attach are TIF format files including images and regular files.

My current code successfully updates the database tables, but the attachments don’t show up in the actual MIRO transaction screen. I think there might be an issue with how I’m handling the business object or business key parameters.

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:
  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_work  TYPE soli,
  folder_key    TYPE soodk,
  object_info   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_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_key
  EXCEPTIONS
    communication_failure = 1
    owner_not_exist = 2
    system_failure = 3
    x_error = 4
    OTHERS = 5.

What am I missing to make the files actually appear in MIRO?

Your code uploads and converts the file, but it’s not linking the document to the MIRO transaction. After SO_CONVERT_CONTENTS_BIN, you need to create the document object with SO_OBJECT_INSERT – include the object type and key. Then, call SO_ATTACHMENT_INSERT_API1 to attach the document, followed by SO_NEW_DOCUMENT_ATT_INSERT_API1 to create the relationship. Make sure to set your business object type to ‘BUS2081’ for invoices and ensure the object key matches your MIRO document number. Without these steps, the document remains unconnected and won’t show up in MIRO.

You’re doing this manually when it screams automation. I’ve hit MIRO attachment issues dozens of times - manual ABAP always creates these linking nightmares.

Ditch the function module wrestling. Build an automated workflow that watches for new docs, uploads them to the right SAP endpoint, and links them to MIRO transactions. No complex ABAP needed.

I built something like this for our invoices. It handles file conversion, business object linking, and validates attachments show up in MIRO correctly. No more missing docs or orphaned files.

Best part? Add error handling and retry logic. If linking fails, it automatically retries with different parameters until it works.

Skip the coding headaches and automate this: https://latenode.com

yeah, so it looks like ur missing a step. u gotta upload the files first, then call ‘SO_OBJECT_INSERT’ to link them properly. after that, use ‘BINARY_RELATION_CREATE_COMMIT’ to connect the doc to MIRO. then they should show up!

You’re not finishing the document creation process. After converting your binary content, use SO_DOCUMENT_INSERT_API1 to actually create the document in the system - make sure you include the document type and description in the header. Then use SO_DOCUMENT_REPOSITORY_MANAGER or SO_OBJECT_SEND to link your new document to the MIRO transaction. I’ve hit this same issue when the business object wasn’t referenced correctly - your object_id needs to match the actual invoice document number from the RBKP table, not some random identifier. Skip these linking steps and the system just sees your upload as an orphaned document that’s floating around unconnected to anything.

check if ur committing ur changes - u probably need ‘COMMIT WORK’ after those function calls to save to the db. also double check that ur using the right business obj type for MIRO (shud be BUS2081). without the commit, attachments just hang out in memory.