Technology Blog Posts by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Sandra_Rossi
Active Contributor
3,972

There are many blog posts and questions/answers about attaching programmatically a file to a material, Sales Order, etc. (instead of doing it manually via the adequate Transaction Code MM02, VA02, etc.), a few ones provide a useful generic code where the Object Type and the Object Key vary according to the Transaction Code, but none of them explain how to determine the Object Type and Key for any Transaction Code. Here, I quickly answer this question. NB: GOS means Generic Object Services.

I won't invent the code again, you may use the generic code from the GitHub repository of @keremkoseoglu, which is based on classes (https://github.com/keremkoseoglu/ABAP-Library/blob/master/document/zcl_bc_gos_toolkit.abap). I discarded a few solutions which are form-based (e.g. https://community.sap.com/t5/application-development-blog-posts/generic-export-import-gos-attachment...).

The only issue with zcl_bc_gos_toolkit is that some little objects are missing and there's no demo program or blog post about it, so I copied the code to my GitHub "gist" and completed it (ABAP program to manage GOS attachments (github.com)).

Now, to determine the object type and key, here is a simple solution:

  • Activate the SQL trace (ST05), start the transaction (MM02 or MM03 for materials, etc.), choose an existing object, display the GOS menu, deactivate the SQL trace and search the table SRGBTBREL. You would find something like that:
    • SELECT DISTINCT  WHERE "CLIENT"= '100' AND "INSTID_A"= '000000000010040941' AND "TYPEID_A"= 'BUS1001006' AND "CATID_A"= 'BO' AND...
    • Sandra_Rossi_0-1722446074485.png
  • TYPEID_A contains the object type which is specific to each transaction code, and INSTID_A is the object key.
  • So, for MM02, the object type is BUS1001006 and the object key is 000000000010040941.

Now run the program like this (PATH = any file you want to attach):

Sandra_Rossi_0-1722445119588.png

and check the result in MM02/MM03:

Sandra_Rossi_1-1722445133074.png

Sandra_Rossi_2-1722445151848.png

Thanks for reading.

1 Comment