cancel
Showing results for 
Search instead for 
Did you mean: 

attach PDF file in class cl_bcs

Former Member
0 Kudos

HI Experts,

I have created a smart form and later on i converted it into a pdf file using CONVERT_OTF Function Module.

Now i have to send it to an external customer for which i m using the functionality of class CL_BCS for sending the email, can any one tell me that how and where can i attach my pdf file while i m using class CL_BCS.

Thanks

Shakun.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member

Hi,

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( ).

COMMIT WORK.

Regards,

KC

Former Member
0 Kudos

what is the maximum file attachment size  while using CL_BCS class.

PLz ..URGENT

Former Member
0 Kudos

Thanks for replying all you guys !!!!!!!!!!!!

aidan_black
Active Contributor
0 Kudos

Hi,

See the example program BCS_EXAMPLE_8 delivered with SAP Note 1324547. You can see the code by viewing the note if it is niot already in your system.

You should use parameter BIN_FILE when calling CONVERT_OTF so the PDF data is returned as type XSTRING and use the the example BCS_EXAMPLE_8 of Note 1324547 to handle the PDF data returned.

Regards,

Aidan