Skip to Content
avatar image
Former Member

attach PDF file in class cl_bcs

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Nov 17, 2010 at 02:23 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 17, 2010 at 02:39 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 17, 2010 at 03:57 PM

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

    Add comment
    10|10000 characters needed characters exceeded