Adding file attachments to SAP MIRO transaction

I need help with uploading attachments in SAP MIRO transaction. I’m trying to attach two TIF files (one image and one document) but they show up in the database table without appearing in the actual MIRO interface.

The attachment process requires a business object and business key to work properly. Here’s my current approach:

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

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_details   TYPE sood1,
  note_key         TYPE borident-objkey,
  vendor_number    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_table.

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 visible in MIRO transaction?

You’re hitting a GOS attachment framework issue - it’s not getting invoked properly. Your upload and conversion code looks fine, but you’re missing the link between the attachment and MIRO document. After SO_OBJECT_INSERT, you need SO_ATTACHMENT_INSERT_API1 or ARCHIV_CONNECTION_INSERT to actually create the connection. Make sure your business object type is ‘BUS2081’ for invoice docs. I had the same headache until I figured out attachment visibility depends on MIRO’s document status. If you’re trying to attach to unsaved docs or drafts, GOS won’t show them. Save your MIRO document first and get a valid document number before running the attachment process.

check ur GOS services config first - MIRO attachments won’t show if GOS isn’t enabled for that transaction. Also make sure ur calling SO_ATTACHMENT_INSERT after uploading the file, not just SO_OBJECT_INSERT. I had the same issue where files hit the db but GOS couldn’t find them cause the attachment record wasn’t created right.

The Problem:

You are experiencing difficulties uploading attachments to SAP MIRO transactions using the GOS (Generic Object Services) framework. The attachments are stored in the database but do not appear in the MIRO interface. Your current approach involves using several function modules for file upload, conversion, and object insertion, but the linkage between the attachment and the MIRO document is missing.

:thinking: Understanding the “Why” (The Root Cause):

The core issue lies in the incomplete integration between your file upload process and the SAP MIRO transaction’s attachment mechanism. While your code correctly uploads and converts the files, it fails to establish the crucial link between the uploaded content and the specific MIRO document. SAP’s GOS framework requires a precise sequence of actions and proper object references to ensure that attachments are correctly associated with the relevant business object (the MIRO invoice in this case). Failure to create this link results in the files appearing in the database but remaining invisible within the MIRO interface. Furthermore, the timing of these operations is crucial; attempting to attach files to an unsaved MIRO document often results in failure.

:gear: Step-by-Step Guide:

Step 1: Ensure Proper GOS Configuration and Document Status:

Before attempting any attachment operations, verify that the GOS service is correctly configured for your SAP system and that MIRO transactions are integrated with it. Furthermore, ensure that your MIRO document is saved before attempting to attach files. The GOS framework requires a fully saved document to establish the proper object references.

Step 2: Use the Appropriate Attachment Function Modules:

Instead of relying solely on SO_OBJECT_INSERT, use the dedicated attachment function modules to explicitly link the attachments to the MIRO document. SO_ATTACHMENT_INSERT_API1 (or a similar function module) is specifically designed for this purpose. This function module will handle the crucial step of creating the relationship between the uploaded file and the MIRO document. It requires the business object key, which in the case of MIRO, is typically the document number (RBKP-BELNR).

Step 3: Retrieve the MIRO Document Number:

Before calling the attachment function module, you need to retrieve the valid document number from the MIRO transaction. You can obtain this document number after successfully saving the MIRO document. Store this document number in a variable for use in the next step.

Step 4: Create the Attachment:

Use SO_ATTACHMENT_INSERT_API1 to create the attachment, passing it the following:

  • Business object type: ‘BUS2081’ (or the appropriate type for your MIRO setup).
  • Business object key: the document number you obtained in the previous step.
  • File details: the file name and path from your initial upload.

Step 5: Handle Exceptions and Errors:

Implement comprehensive error handling to gracefully manage situations where the attachment creation fails. Carefully examine the return values from all the function modules involved. Detailed logging of successes and failures is also crucial for debugging.

:mag: Common Pitfalls & What to Check Next:

  • GOS Service Configuration: Verify that the GOS service is properly configured and activated for MIRO transactions. Incorrect configuration can prevent attachments from being displayed.
  • Business Object Type: Ensure you are using the correct business object type (‘BUS2081’ is common for MIRO invoices, but this might vary depending on your specific SAP system configuration).
  • Document Number Retrieval: Ensure you’re correctly obtaining the MIRO document number after saving. Attempting to attach to an unsaved document will typically fail.
  • Authorization Issues: Insufficient authorizations can prevent the creation of attachments. Ensure the user executing the code has the necessary authorizations to access and modify MIRO documents and attachments.
  • File Format Compatibility: While you mention TIF files, confirm that these are supported within your SAP system’s configuration. Unsupported file types might cause issues.
  • External Attachment Handling: If direct integration with MIRO continues to prove difficult, consider managing attachments externally and only passing references to SAP.

:speech_balloon: Still running into issues? Share your (sanitized) config files, the exact command you ran, and any other relevant details. The community is here to help!

I’ve dealt with this SAP attachment mess too. Usually it’s because your business object linkage is incomplete or the attachment service isn’t connecting properly to MIRO.

Your code uploads the file fine, but you’re missing the key step - linking the attachment to the specific MIRO document. It needs to tie to the exact document number and item MIRO’s processing.

SAP’s attachment APIs are honestly a nightmare. I wasted weeks debugging this stuff before I just automated the whole thing.

Now I use Latenode to handle attachments completely outside SAP’s broken internal systems. Set up workflows that automatically process documents, convert formats, then push everything into SAP via web services or direct database hits.

Latenode monitors folders, processes batches, and handles all the error cases SAP’s native system can’t. Plus you get real logging and retry logic.

For MIRO, I have workflows that catch new invoices, process attachments, and link everything before the transaction starts. Way more reliable than wrestling with SO_FOLDER functions.

This is a common issue with MIRO attachments. Your file upload code looks fine, but you’re missing the object reference structure setup.

After SO_CONVERT_CONTENTS_BIN, you need to populate object_ref with the right business object key. For MIRO, use business object type ‘RBKP’ and set the key to the document number from RBKP-BELNR.

I hit this same problem last year with automated invoice processing. The attachment would upload to the database but wouldn’t show in the transaction because the object linkage was broken. You’ll also need SO_OBJECT_INSERT and SO_NEW_DOCUMENT_ATT_INSERT_API1 to create the attachment relationship.

Here’s what cost me hours to figure out - save the MIRO document first before trying to attach anything. The system won’t link attachments to unsaved or temp documents.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.