Send uploaded file as email attachment for standard transaction

GOS is available for many standard transactions we can upload files to the attachment list, how to send those attachment files through email easily?

1. Find the object type name for the standard transaction

Take the Purchase order as an example, enter ‘Purchase*’ as STEXT for table TOJTT at SE11 like below:

Then we can get the below lists for transactions related to purchases:

For my case, I find the object type name ‘FIPP’ very quickly by searching ‘Park’ for FBV3 parked document. Btw, table TOJTB(Business object repository: Basic data) contains the details for those business objects.

2. Find the attachment ID inside the standard transaction

Generally, it’s shown as ‘AttachmentForXXXX’ at the window of the attachment list. Take a billing document as an example, the attachment ID will be the document directly.

For parked documents, the attachment ID will be the combination of company code, document number, and fiscal year.

Don’t know whether exists some standard rules for this attachment ID, no idea where to check this anyway. Please let me know if exists.

3. Fetch the contents of files and send them out as attachments using BCS

  • Get the attachment list by method ‘get_atta_list’ of class ‘cl_gos_api’;
  • The deep structure gos_s_attcont contains all the details of the attachment file and its content in Cstring/Xstring format;
  • Convert the Xstring format into Table Type SOLIX_TAB(binary);
  • Use method ‘add_attachment ‘ of BCS class ‘cl_document_bcs’ to add as email attachment.

Please check this link from Jerry Wang as a code reference.