Adding attachments in MIRO transaction: How to do it?

Hey everyone! I’m trying to figure out how to add attachments in the MIRO transaction. I need to include both an image and a file in TIF format.

I’ve written some code that updates a table, but it’s not showing up in MIRO. I’m pretty sure I’m missing something, but I can’t figure out what. Here’s a simplified version of what I’m working with:

DATA: lv_filename TYPE string,
      lt_content TYPE TABLE OF solix,
      ls_content TYPE solix.

CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    filename = 'C:/MyDocs/sample.tif'
    filetype = 'BIN'
  TABLES
    data_tab = lt_content.

CALL FUNCTION 'SCMS_BINARY_TO_STRING'
  EXPORTING
    input_length = xstrlen( lv_content )
  IMPORTING
    text_buffer  = lv_filename
  TABLES
    binary_tab   = lt_content
    text_tab     = lt_string_content.

" More code to handle the attachment..."

I know I need to pass the business object and key, but I’m not sure how to do that correctly. Any help would be awesome! Thanks in advance!

I’ve been there, Luna. Adding attachments to MIRO can be tricky. Here’s what worked for me:

First, ditch the GUI_UPLOAD function. Instead, use cl_gui_frontend_services=>gui_upload. It’s more reliable for binary files like your TIF.

For the attachment part, you’ll need the GOS API. Create a container with GOS_CONTAINER_CREATE_API, then use GOS_ATTACHMENT_CREATE to add your file. Make sure you’re using the right object type - ‘BKPF’ usually works for MIRO.

One thing that caught me out: the key. It’s typically a combo of company code and document number. Get that wrong, and nothing shows up.

Also, don’t forget to COMMIT WORK after adding the attachment. I spent hours wondering why my attachments weren’t showing up before I realized I’d missed this step.

If you’re still stuck, check the application log for any error messages. They can be cryptic, but they’re usually a good starting point for troubleshooting.

I’ve worked with MIRO attachments before, and I can share some insights.

The key is to use the GOS (Generic Object Services) API for attaching files. First, you need to create a GOS container for your MIRO document. Use the function module GOS_CONTAINER_CREATE_API for this. Then, use GOS_ATTACHMENT_CREATE to add your file as an attachment.

Make sure you’re passing the correct object type and key for your MIRO document. The object type should be something like ‘BKPF’ for the accounting document, and the key would typically be a combination of company code and document number.

One gotcha I encountered: if you’re working with large files, you might need to chunk the data. The GOS API has size limits, so breaking larger files into smaller pieces can help.

Also, don’t forget to commit your work after adding the attachment. Sometimes, attachments don’t show up immediately if you forget this step.

Hope this helps point you in the right direction!

hey luna, i’ve done this before. u need to use GOS API for attachments. create a container with GOS_CONTAINER_CREATE_API, then use GOS_ATTACHMENT_CREATE to add ur file. make sure u got the right object type (like ‘BKPF’) and key. don’t forget to commit after adding the attachment or it might not show up right away. good luck!

Having worked extensively with MIRO transactions, I can offer some guidance on adding attachments. The process involves utilizing the GOS (Generic Object Services) API. First, create a GOS container for your MIRO document using GOS_CONTAINER_CREATE_API. Then, employ GOS_ATTACHMENT_CREATE to add your files.

Ensure you’re using the correct object type (typically ‘BKPF’ for accounting documents) and the appropriate key (usually a combination of company code and document number). Be mindful of file size limitations; you may need to chunk larger files.

One crucial step often overlooked is committing your work after adding the attachment. This ensures the attachments are properly saved and visible in the system.

Regarding your code snippet, it seems you’re on the right track with file uploading. However, you’ll need to integrate this with the GOS API calls to successfully attach the files to your MIRO transaction.