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:
Now run the program like this (PATH = any file you want to attach):
and check the result in MM02/MM03:
Thanks for reading.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 9 | |
| 6 | |
| 6 | |
| 5 | |
| 5 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 |