Adding file attachments to MIRO transaction

I need help with uploading attachments in SAP MIRO transaction

I’m working on a functionality to attach documents (specifically TIF format images and files) directly to the MIRO transaction screen. The issue I’m facing is that my code successfully updates the database tables, but the attachments don’t appear in the MIRO interface itself.

I need to properly configure the business object and business key parameters. Here’s my current approach:

SELECTION-SCREEN BEGIN OF BLOCK upload_block WITH FRAME TITLE text-upload.
PARAMETERS: file_path   TYPE localfile,
            object_id   TYPE swo_typeid,
            bus_object  TYPE swo_objtyp.
SELECTION-SCREEN END OF BLOCK upload_block.

DATA:
  file_content   TYPE STANDARD TABLE OF soli,
  content_line   TYPE soli,
  header_info    TYPE STANDARD TABLE OF soli,
  folder_member  TYPE sofmk,
  note_ref       TYPE borident,
  business_obj   TYPE borident,
  object_key     TYPE soodk,
  content_data   TYPE soli,
  folder_key     TYPE soodk,
  document_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: file_content[], header_info[].

CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    filename = 'C:\Temp\document.TIF'
    filetype = 'BIN'
  TABLES
    data_tab = upload_table.

CALL FUNCTION 'SO_CONVERT_CONTENTS_BIN'
  EXPORTING
    it_contents_bin = file_content[]
  IMPORTING
    et_contents_bin = file_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 point out what might be wrong with my implementation? The attachment process completes without errors but doesn’t show up in MIRO.

This is a pretty common issue with MIRO attachments. I’ve dealt with this before - the problem usually comes down to business object setup and timing. For MIRO transactions, you need business object type ‘BUS2081’ (invoice documents). Make sure your object key matches the actual invoice document number that MIRO generates. Here’s the catch: MIRO creates document numbers dynamically, so you can’t attach files before saving the document. I’ve had better luck using ARCHIV_CONNECTION_INSERT function module instead of the SO_* functions. Set up the right archiving object (like ‘MM_MATBEL’ for material documents) and use TOA01 customization table to link your business object with the archive. Another approach that worked for me: implement a BAdI enhancement at the MIRO save event. This triggers the attachment process after the document number exists, so the business key is available when you create the attachment link.