How to upload documents in SAP MIRO transaction

I need help with uploading documents to SAP MIRO transaction. I’m working on a program that should attach two TIF files (one image and one document) to MIRO but I’m running into issues.

My code successfully updates the database table but the attachments don’t show up in the MIRO interface. I think there might be an issue with how I’m handling the business object and business key parameters.

Here’s my current code:

SELECTION-SCREEN BEGIN OF BLOCK main 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 main.

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_data  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.

REFRESH: content_table[], header_table[].

CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    filename = 'C:\Temp\Document.TIF'
    filetype = 'BIN'
  TABLES
    data_tab = binary_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.

Can someone help me identify what’s wrong with this approach? The database gets updated but MIRO doesn’t display the attached files.

you’re missing the attachment creation step. after uploading the file, use so_document_insert_api1 to create the document object, then link it with so_attachment_insert_api1. also check that your business object type is right - it’s usually ‘bus2081’ for miro invoices.