Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Jigang_Zhang张吉刚
Active Contributor
This blog describes basic steps for sending external PDF files like flyers as an attachment.

1. Where to store the external PDF at SAP?


There're at least two easy options to save the external PDF files in the SAP system:

  • Save the PDF file to the MIME repository through SE80.





  • Save the PDF file to DMS through CV01N.




2. How to fetch the stored external PDF at SAP?



  • To get PDF contents in Xstring format from the MIME repository


DATA:   lr_api TYPE REF TO if_mr_api,
lv_pdf_cont TYPE xstring,
lv_pdf_url TYPE string VALUE '/SAP/PUBLIC/TEST/flyer.pdf'.

* Get PDF xstring from MIME repository
lr_api = cl_mime_repository_api=>get_api( ).

lr_api->get( EXPORTING i_url = lv_pdf_url
IMPORTING e_content = lv_pdf_cont ).


  • To get PDF contents in Xstring format from DMS


Call Function module 'CV120_DOC_CHECKOUT' to fetch PDF contents at return table ptx_drao. Can refer to this.



3. Convert Xstring format to SOLIX_TAB and add attachments send by the BCS method.


  DATA: pdf_content TYPE solix_tab,
document TYPE REF TO cl_document_bcs,
lp_pdf_size TYPE so_obj_len,

* Create document.
document = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = it_message[] "Body of e-mail
i_subject = lv_subject ).
...

lp_pdf_size = xstrlen( lv_pdf_cont ).
pdf_content = cl_document_bcs=>xstring_to_solix(
ip_xstring = lv_pdf_cont ).

lv_att_subject = 'Flyer File'.
document->add_attachment( i_attachment_type = 'PDF'
i_attachment_subject = lv_att_subject
i_attachment_size = lp_pdf_size
i_att_content_hex = pdf_content ).
Labels in this area