Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
Showing results for 
Search instead for 
Did you mean: 

Reg: PDF attachment in Mail

Former Member
0 Kudos

Hi All,

We have a report to send the mail with PDF attachment.

Previously, the report was working fine. But now there is some issue.

We are using the Attachment type as ALI(ABAP List).

I have checked the settings in T.code SCOT for ABAP List and it is PDF only.

But still the attachment is like ABAP List and not as PDF.

Please guide me on this issue.

With Regards,

Gurulakshmi Varadharaj


0 Kudos

Hi Gurulakshmi,

You first send ur report to spool using an FM 'SLVC_TABLE_PS_TO_SPOOL' from that spool no. generate a PDF using an FM 'CONVERT_ABAPSPOOLJOB_2_PDF' from that obtained PDF you can attach it to the mail using the class  'CL_BCS'.

Below is a sample code for attaching the PDF and sending the mail.

DATA: l_send_request TYPE REF TO cl_bcs,         " Send request

      l_body      TYPE bcsy_text,                " Mail body

      l_attach    TYPE bcsy_text,                " Attachment

      wa_text     TYPE soli,                     " Work area for attach

      l_document  TYPE REF TO cl_document_bcs,   " Mail body

      l_sender    TYPE REF TO if_sender_bcs,     " Sender address

      l_recipient TYPE REF TO if_recipient_bcs,  " Recipient

      l_email     type ad_smtpadr,               " Email ID

      l_extension type soodk-objtp value 'OTF',  " TXT format

      l_size      TYPE sood-objlen.              " Size of Attachment

APPEND 'Test Mail ' TO l_body.

l_attach[] = st_job_output_info-otfdata[].

l_lines = LINES( l_attach ).

l_size = l_lines * 255.

  • Creates persistent send request

l_send_request = cl_bcs=>create_persistent( ).

  • Craete document for mail body

l_document = cl_document_bcs=>create_document(             i_type    = 'RAW'             i_text    = l_body             i_subject = 'Subject-Here' ).

  • Add attchment

CALL METHOD l_document->add_attachment  EXPORTING    i_attachment_type    = l_extension    "'PDF'    i_attachment_subject = 'test_delv'    i_attachment_size    = l_size    i_att_content_text   = l_attach.

  • Add the document to send request

CALL METHOD l_send_request->set_document( l_document ).

  • Sender addess

l_sender = cl_sapuser_bcs=>create( sy-uname ).CALL METHOD l_send_request->set_sender  EXPORTING    i_sender = l_sender.   L_EMAIL = <email_id>.l_recipient = cl_cam_address_bcs=>create_internet_address( l_email ).

  • Add recipient address to send request

CALL METHOD l_send_request->add_recipient  EXPORTING    i_recipient  = l_recipient    i_express    = 'X'    i_copy       = ' '    i_blind_copy = ' '    i_no_forward = ' '.

  • Trigger E-Mail immediately

l_send_request->set_send_immediately( 'X' ).

  • Send mail

CALL METHOD l_send_request->send( ).


If any doubts please see the program 'BCS_EXAMPLE_8' , BCS_EXAMPLE_9.

Hope this helps you

Reward if useful.


Manideep Settipalli

0 Kudos


Please refer BCS_EXAMPLE_8 standard program and let me know if u need any.....



Former Member
0 Kudos

you can use