<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Multiple pdf attachments from server folder using SO_DOCUMENT_SEND_API1 in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-pdf-attachments-from-server-folder-using-so-document-send-api1/m-p/8385870#M1643339</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joao,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
  EXPORTING
    buffer = xstring
  TABLES
    binary_tab = it_pdf .&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;top convert the pdf hey string to a SOLISTI table as used by add_attachment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 05 Nov 2011 22:23:28 GMT</pubDate>
    <dc:creator>Clemenss</dc:creator>
    <dc:date>2011-11-05T22:23:28Z</dc:date>
    <item>
      <title>Multiple pdf attachments from server folder using SO_DOCUMENT_SEND_API1</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-pdf-attachments-from-server-folder-using-so-document-send-api1/m-p/8385866#M1643335</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dears,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to build a program able to send an email with multiple pdf attachments.&lt;/P&gt;&lt;P&gt;The files are stored in a folder in SAP server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am able to generate a pdf file from a spool and sucessfully attach it to the email using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'CONVERT_OTF_2_PDF'&lt;/P&gt;&lt;P&gt;      IMPORTING&lt;/P&gt;&lt;P&gt;        bin_filesize           = v_bin_filesize&lt;/P&gt;&lt;P&gt;      TABLES&lt;/P&gt;&lt;P&gt;        otf                    = job_output_info-otfdata&lt;/P&gt;&lt;P&gt;        doctab_archive         = it_docs&lt;/P&gt;&lt;P&gt;        lines                  = it_lines&lt;/P&gt;&lt;P&gt;      EXCEPTIONS&lt;/P&gt;&lt;P&gt;        err_conv_not_possible  = 1&lt;/P&gt;&lt;P&gt;        err_otf_mc_noendmarker = 2&lt;/P&gt;&lt;P&gt;        OTHERS                 = 3.&lt;/P&gt;&lt;P&gt;    IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;      LOOP AT it_lines.&lt;/P&gt;&lt;P&gt;        TRANSLATE it_lines USING ' ~'.&lt;/P&gt;&lt;P&gt;        CONCATENATE gd_buffer it_lines INTO gd_buffer.&lt;/P&gt;&lt;P&gt;      ENDLOOP.&lt;/P&gt;&lt;P&gt;      TRANSLATE gd_buffer USING '~ '.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      DO.&lt;/P&gt;&lt;P&gt;        it_mess_att_aux = gd_buffer.&lt;/P&gt;&lt;P&gt;        APPEND it_mess_att_aux.&lt;/P&gt;&lt;P&gt;        SHIFT gd_buffer LEFT BY 255 PLACES.&lt;/P&gt;&lt;P&gt;        IF gd_buffer IS INITIAL.&lt;/P&gt;&lt;P&gt;          EXIT.&lt;/P&gt;&lt;P&gt;        ENDIF.&lt;/P&gt;&lt;P&gt;      ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Internal table it_mess_att_aux is the parameter contents_bin of FM SO_DOCUMENT_SEND_API1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have now 2 files on a server folder which I would like to include as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am reading the content of the pdf files in following way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(...)&lt;/P&gt;&lt;P&gt;DATA:   gd_buffer                 TYPE string,&lt;/P&gt;&lt;P&gt;(...)&lt;/P&gt;&lt;P&gt;      OPEN DATASET lv_fileserver FOR INPUT IN BINARY MODE.&lt;/P&gt;&lt;P&gt;      IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;        MESSAGE e257(zmsgsd) WITH lv_fileserver.&lt;/P&gt;&lt;P&gt;      ELSE.&lt;/P&gt;&lt;P&gt;        CLEAR: it_mess_att_aux[], gd_buffer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        DO.&lt;/P&gt;&lt;P&gt;          READ DATASET lv_fileserver INTO gd_buffer.&lt;/P&gt;&lt;P&gt;          IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;            EXIT.&lt;/P&gt;&lt;P&gt;          ENDIF.&lt;/P&gt;&lt;P&gt;          APPEND gd_buffer TO it_mess_att_aux.&lt;/P&gt;&lt;P&gt;        ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        APPEND LINES OF it_mess_att_aux TO it_mess_att.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not understand the purpose of the statement:&lt;/P&gt;&lt;P&gt;        TRANSLATE it_lines USING ' ~'.&lt;/P&gt;&lt;P&gt;in this context. Could anyone explain it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All the files are attached to email with the desired name but corrupted and with the wrong size.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone help me build the logic to attach a pdf file from server in a email?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;João Cabrita&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 05 Nov 2011 02:35:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-pdf-attachments-from-server-folder-using-so-document-send-api1/m-p/8385866#M1643335</guid>
      <dc:creator>joaopcabrita</dc:creator>
      <dc:date>2011-11-05T02:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple pdf attachments from server folder using SO_DOCUMENT_SEND_API1</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-pdf-attachments-from-server-folder-using-so-document-send-api1/m-p/8385867#M1643336</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
     data: l_send_request type ref to cl_bcs,         " Send request
      l_body      type bcsy_text,                " Mail body
      l_success   type bcsy_text,                " Atchmnt for success
      l_error     type bcsy_text,                " Atchmnt for error
      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_size      type sood-objlen,              " Size of Attachment
      l_lines     type i,                        " Lines count
      l_email     type ad_smtpadr,               " Email ID
      l_extension type soodk-objtp value 'RAW'.  " TXT format
* Prepare mail bidy
append 'Send multiple file as attachment of a Email.'  to l_body.
append space to l_body.
* Preparing contents of attachment with Change Log
* Header line
wa_text-line+0   = 'First column'.
wa_text-line+20  = 'Second column'.
wa_text-line+40  = 'Third column'.
wa_text-line+60  = 'Fourth column'.
wa_text-line+80  = 'Fifth column'.
wa_text-line+100 = 'Sixth column'.
wa_text-line+120 = 'Seventh column'.
wa_text-line+140 = 'Eighth column'.
append wa_text to l_success.
append wa_text to l_error.
clear : wa_text.
* Populate the data part
wa_text-line+0   = '111111111'.
wa_text-line+20  = '222222222'.
wa_text-line+40  = '333333333'.
wa_text-line+60  = '333333333'.
wa_text-line+80  = '444444444'.
wa_text-line+100 = '555555555'.
wa_text-line+120 = '666666666'.
wa_text-line+140 = '777777777'.
append wa_text to l_success.
clear : wa_text.
wa_text-line+0   = 'aaaaaaaaa'.
wa_text-line+20  = 'bbbbbbbbb'.
wa_text-line+40  = 'ccccccccc'.
wa_text-line+60  = 'ddddddddd'.
wa_text-line+80  = 'eeeeeeeee'.
wa_text-line+100 = 'fffffffff'.
wa_text-line+120 = 'ggggggggg'.
wa_text-line+140 = 'hhhhhhhhh'.
append wa_text to l_error.
clear : wa_text.
* Creates persistent send request
l_send_request = cl_bcs=&amp;gt;create_persistent( ).
* Craete document for mail body
l_document = cl_document_bcs=&amp;gt;create_document(
             i_type    = 'RAW'
             i_text    = l_body  " Mail body
             i_subject = 'Mail send as attachment' ).
* Attachment for success records
l_lines = lines( l_success ).
l_size = l_lines * 255.
* Add attchment
call method l_document-&amp;gt;add_attachment
  exporting
    i_attachment_type    = l_extension
    i_attachment_subject = 'Success'
    i_attachment_size    = l_size
    i_att_content_text   = l_success. " Attachment for success record
* Attachment for error records
l_lines = lines( l_error ).
l_size = l_lines * 255.
* Add attchment
call method l_document-&amp;gt;add_attachment
  exporting
    i_attachment_type    = l_extension
    i_attachment_subject = 'Error'
    i_attachment_size    = l_size
    i_att_content_text   = l_error. " Attachment for error record
* Add the document to send request
call method l_send_request-&amp;gt;set_document( l_document ).
* Sender addess
l_sender = cl_sapuser_bcs=&amp;gt;create( sy-uname ).
call method l_send_request-&amp;gt;set_sender
  exporting
    i_sender = l_sender.
* Recipient address
l_email = 'emailaddress'.
l_recipient = cl_cam_address_bcs=&amp;gt;create_internet_address( l_email ).

* Add recipient address to send request
call method l_send_request-&amp;gt;add_recipient
  exporting
    i_recipient  = l_recipient
    i_express    = 'X'
    i_copy       = ' '
    i_blind_copy = ' '
    i_no_forward = ' '.
l_email = 'receipentemaiil'.
l_recipient = cl_cam_address_bcs=&amp;gt;create_internet_address( l_email ).
* Add recipient address to send request
call method l_send_request-&amp;gt;add_recipient
  exporting
    i_recipient  = l_recipient
    i_express    = 'X'
    i_copy       = ' '
    i_blind_copy = ' '
    i_no_forward = ' '.
* E-Mail is placed into queue for sending. In case of very important alerts
* use the following parameter to initiate an 'immediate sending'; but notice that
* this will trigger a dedicated send process for every single message - which is
* very costly for system performance
* l_send_request-&amp;gt;set_send_immediately( 'X' ). "uncomment for immediate sending
* Send mail
call method l_send_request-&amp;gt;send( ).
commit work. */
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 05 Nov 2011 03:51:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-pdf-attachments-from-server-folder-using-so-document-send-api1/m-p/8385867#M1643336</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-05T03:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple pdf attachments from server folder using SO_DOCUMENT_SEND_API1</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-pdf-attachments-from-server-folder-using-so-document-send-api1/m-p/8385868#M1643337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi , try this ,it is working fine  .&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  DATA: i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
          i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
*          wa_doc_chng LIKE sodocchgi1,
          i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
*         i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
       i_objhead LIKE solisti1 OCCURS 0 WITH HEADER LINE,
      i_tline TYPE TABLE OF tline WITH HEADER LINE,
      i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
      wa_doc_chng LIKE sodocchgi1,
      v_lines_txt TYPE i,

       l_lines TYPE I VALUE '20'.

  CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
      format        = 'PDF'
      max_linewidth = 132
    IMPORTING
      bin_filesize  = bin_filesize
    TABLES
      otf           = int_tab_otf_final
      lines         = int_pdf_tab.
  IF sy-subrc &amp;lt;&amp;gt; 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
*****************soc ranjan***************************
*  IF full_path IS INITIAL.
**
**
*    CALL METHOD cl_gui_frontend_services=&amp;gt;file_save_dialog
*      EXPORTING
**    WINDOW_TITLE         =
**           DEFAULT_EXTENSION    = 'PDF'
**    DEFAULT_FILE_NAME    =
*           file_filter          = 'Portable Document Format (.pdf)' " for restricting saving file only as pdf
*      CHANGING
*        filename             = file_name
*        path                 = file_path
*        fullpath             = full_path
*            .
*    IF sy-subrc &amp;lt;&amp;gt; 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
**            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*    ENDIF.
*  ENDIF.

******************eoc ranjan*****************

*break-point.
  CONCATENATE full_path git_select_option-pernr INTO path SEPARATED BY '_'.
  CONCATENATE path 'PDF' INTO path SEPARATED BY '.'.
**  **************************for downloading*********************************

*  CALL FUNCTION 'GUI_DOWNLOAD'
*    EXPORTING
*      bin_filesize = bin_filesize
*      filename     = path
*      filetype     = 'BIN'
*    IMPORTING
*      filelength   = file_size
*    TABLES
*      data_tab     = int_pdf_tab.
*  IF sy-subrc &amp;lt;&amp;gt; 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
**         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*  ENDIF.
*******************************************************************

  CLEAR : lop , el , sl , cl .

*  ******************addeddd later  by ranjan  21.04.2011

DATA : desc TYPE char40 ,
      desc1 TYPE char100 .

  CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = int_pdf_tab
t_target_tab = i_record
EXCEPTIONS
convert_not_possible = 1
OTHERS = 2.
IF sy-subrc &amp;lt;&amp;gt; 0.
WRITE : / 'Error in conversion of pdf lines'(015).
ENDIF.

APPEND LINES OF i_record TO i_objbin.
*Creation of the entry for the compressed attachment
DESCRIBE TABLE i_objbin LINES bin_filesize.



i_objtxt = 'Hi'.
APPEND i_objtxt.

i_objtxt = '                                     '.
APPEND i_objtxt.

i_objtxt = 'Pls  find  the attached  salary slip ' .
APPEND i_objtxt.

i_objtxt = '  '.
APPEND i_objtxt.
i_objtxt = '  '.
APPEND i_objtxt.
i_objtxt = '  '.
APPEND i_objtxt.
i_objtxt = '  '.
APPEND i_objtxt.
i_objtxt = '  '.
APPEND i_objtxt.
i_objtxt = '         '.
APPEND i_objtxt.
i_objtxt = '  '.
APPEND i_objtxt.
i_objtxt = '  '.
APPEND i_objtxt.
i_objtxt = '        '.
APPEND i_objtxt.
i_objtxt = '  '.
APPEND i_objtxt.
i_objtxt = '         '.
APPEND i_objtxt.
i_objtxt = '  '.
APPEND i_objtxt.
i_objtxt = '  '.
APPEND i_objtxt.
i_objtxt = '         '.
APPEND i_objtxt.
i_objtxt = '  '.
APPEND i_objtxt.
i_objtxt = 'Regards:  '.
APPEND i_objtxt.

i_objtxt = 'Corporate HR  '.
APPEND i_objtxt.
DESCRIBE TABLE i_objtxt LINES L_LINES.

READ TABLE i_objtxt INDEX L_LINES.
wa_doc_chng-doc_size = ( L_LINES - 1 ) * 255 + STRLEN( i_objtxt ).


*Creating the entry for the compressed document
CLEAR i_objpack-transf_bin.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
i_objpack-body_num = L_LINES.
i_objpack-doc_type = 'RAW'.
APPEND i_objpack.



**
***CLEAR:  i_objpack .
***i_objpack-transf_bin = ' '.
**i_objpack-head_start = 1.
**i_objpack-head_num = 0.
**i_objpack-body_start = 1.
**i_objpack-body_num = L_LINES.
**i_objpack-doc_type = 'TXT'.
**i_objpack-obj_descr = desc1 .
**APPEND i_objpack.


*
*CLEAR: i_objhead .
*i_objhead = DESC.
*APPEND i_objhead.

*break-point .
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 1.
i_objpack-body_start = 1.
i_objpack-body_num = bin_filesize.
i_objpack-obj_name = 'Employee Payslip'.
i_objpack-obj_descr = 'Employee Payslip'.
i_objpack-doc_size = bin_filesize  * 255 .
i_objpack-doc_type = 'PDF'.
APPEND i_objpack.

CONCATENATE 'Salary Slip of Month' p_month INTO desc SEPARATED BY ' ' .



*DESCRIBE TABLE i_objtxt LINES v_lines_txt.
*READ TABLE i_objtxt INDEX v_lines_txt.

****wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 375 + STRLEN( i_objtxt ).
wa_doc_chng-obj_name = 'Payslip'.
wa_doc_chng-expiry_dat = sy-datum + 10.
wa_doc_chng-obj_descr = desc.
wa_doc_chng-sensitivty = 'F'.
wa_doc_chng-doc_size = v_lines_txt * 255.





CLEAR i_objpack.

DATA: l_usrid_long TYPE pa0105-usrid_long.
DATA : emessage(70) TYPE c.
CLEAR : l_usrid_long.





SELECT SINGLE usrid_long
FROM pa0105
INTO l_usrid_long
WHERE pernr = git_pa0001-pernr
AND subty = '0010'.
*break-point.
IF sy-subrc EQ 0.
i_reclist-receiver = l_usrid_long.                      


i_reclist-rec_type = 'U'.
i_reclist-com_type = 'INT'.
APPEND i_reclist.
ELSE.
WRITE:/ 'No email id is maintained for this personnel number' , git_pa0001-pernr.
ENDIF.



IF NOT i_reclist[] IS INITIAL.


*******************************************************************************************
***************************************for senders id *************************************
*******************************************************************************************
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
  EXPORTING
    document_data                    = wa_doc_chng
  put_in_outbox = 'X'

   sender_address                   = 'xys'
   sender_address_type              = 'SMTP'
   commit_work                      = 'X'
* IMPORTING
*   SENT_TO_ALL                      =
*   NEW_OBJECT_ID                    =
*   SENDER_ID                        =
  TABLES
packing_list = i_objpack
object_header = i_objhead
contents_bin = i_objbin
contents_txt = i_objtxt
receivers = i_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.          .
IF sy-subrc &amp;lt;&amp;gt; 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 05 Nov 2011 07:10:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-pdf-attachments-from-server-folder-using-so-document-send-api1/m-p/8385868#M1643337</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-05T07:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple pdf attachments from server folder using SO_DOCUMENT_SEND_API1</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-pdf-attachments-from-server-folder-using-so-document-send-api1/m-p/8385869#M1643338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dears,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your inputs but I still could not manage to send emails with multiple pdf files.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am now trying it with CL_BCS Class.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For instance, BCS_EXAMPLE_5 is quite similar, but instead of sending a MSWORD file I want to send a PDF file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have changed the code from example BCS_EXAMPLE_5 like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(...)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    -------- create and set document with attachment ---------------&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    create document from internal table with text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      APPEND 'Hello world!' TO text.&lt;/P&gt;&lt;P&gt;      document = cl_document_bcs=&amp;gt;create_document(&lt;/P&gt;&lt;P&gt;                      i_type    = 'RAW'&lt;/P&gt;&lt;P&gt;                      i_text    = text&lt;/P&gt;&lt;P&gt;                      i_length  = '12'&lt;/P&gt;&lt;P&gt;                      i_subject = 'test created by BCS_EXAMPLE_2' ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    add attachment to document&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    BCS expects document content here e.g. from document upload&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    binary_content = ...&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Here I am reading the content of PDF file from server in binary mode into attachment internal table - BEGIN&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      DATA: lv_file TYPE string.&lt;/P&gt;&lt;P&gt;      CONCATENATE '&lt;/P&gt;&lt;P&gt;ECC-DEVSPECS_EMAIL' 'PT_C_ABDN040122.pdf' INTO lv_file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      OPEN DATASET lv_file FOR INPUT IN BINARY MODE.&lt;/P&gt;&lt;P&gt;      IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        DO.&lt;/P&gt;&lt;P&gt;          READ DATASET lv_file INTO wa_binary_content .&lt;/P&gt;&lt;P&gt;          IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;            EXIT.&lt;/P&gt;&lt;P&gt;          ENDIF.&lt;/P&gt;&lt;P&gt;          APPEND wa_binary_content TO binary_content.&lt;/P&gt;&lt;P&gt;        ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Here I am reading the content of PDF file from server in binary mode into attachment internal table - END&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      CALL METHOD document-&amp;gt;add_attachment&lt;/P&gt;&lt;P&gt;        EXPORTING&lt;/P&gt;&lt;P&gt;          i_attachment_type    = 'PDF'&lt;/P&gt;&lt;P&gt;          i_attachment_subject = 'My attachment'&lt;/P&gt;&lt;P&gt;          i_att_content_hex    = binary_content.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(...)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The email is sent with the pdf file attached, the file size is correct, but I cannot open the file. The file is corrupted. I think I am not generating the itab binary_content correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone help me on this matter?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;João Cabrita&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 05 Nov 2011 21:56:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-pdf-attachments-from-server-folder-using-so-document-send-api1/m-p/8385869#M1643338</guid>
      <dc:creator>joaopcabrita</dc:creator>
      <dc:date>2011-11-05T21:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple pdf attachments from server folder using SO_DOCUMENT_SEND_API1</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-pdf-attachments-from-server-folder-using-so-document-send-api1/m-p/8385870#M1643339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joao,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
  EXPORTING
    buffer = xstring
  TABLES
    binary_tab = it_pdf .&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;top convert the pdf hey string to a SOLISTI table as used by add_attachment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 05 Nov 2011 22:23:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-pdf-attachments-from-server-folder-using-so-document-send-api1/m-p/8385870#M1643339</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2011-11-05T22:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple pdf attachments from server folder using SO_DOCUMENT_SEND_API1</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-pdf-attachments-from-server-folder-using-so-document-send-api1/m-p/8385871#M1643340</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all for your inputs, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens, your suggestion solved the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;João Cabrita&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 06 Nov 2011 16:31:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-pdf-attachments-from-server-folder-using-so-document-send-api1/m-p/8385871#M1643340</guid>
      <dc:creator>joaopcabrita</dc:creator>
      <dc:date>2011-11-06T16:31:09Z</dc:date>
    </item>
  </channel>
</rss>

