Skip to end of metadata
Go to start of metadata

Author: janagar sundaramoorthy
Submitted: <11 feb 2009>
Related Links:

  • <link>


The function module SO_NEW_DOCUMENT_ATT_SEND_API1 can be used to send a text file via mail as an attachment. However, it accepts only 255 characters in a line. If it is required to have more than 255 characters in a single line, then the following method can be used instead of dividing the line into two and sending it.The contents can be compressed and passed to the FM SO_NEW_DOCUMENT_ATT_SEND_API1 through the CONTENTS_HEX table. But this table accepts only binary values and hence the STRING has to be converted to BINARY. This can be achieved by converting STRING to XSTRING and then converting the XSTRING to BINARY by using the FMs 'SCMS_STRING_TO_XSTRING' and 'SCMS_XSTRING_TO_BINARY'.
You may also look at Thomas Jung snippet here for using it with CL_BCS:

DATA: w_subject LIKE sodocchgi1,
      i_pack_list LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
      i_objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
      i_contents_text LIKE solisti1 OCCURS 10 WITH HEADER LINE,      "FOR MAIL CONTENTS
      i_contents_bin TYPE STANDARD TABLE OF solisti1 WITH HEADER LINE, 
      i_contents_hex TYPE STANDARD TABLE OF solix WITH HEADER LINE,    "for attachment
      i_receiver LIKE somlreci1 OCCURS 1 WITH HEADER LINE,
      content_out LIKE solisti1 OCCURS 0 WITH HEADER LINE.
  lv_hex1 = cl_abap_char_utilities=>cr_lf.

*Create the body of the attachment file of the mail INTO li_contents_bin-line SEPARATED BY lc_tab.
  CONCATENATE li_contents_bin-line lv_hex1 INTO li_contents_bin-line.
  APPEND li_contents_bin.

*Converting the table contents for attachment to xstring 
  LOOP AT li_contents_bin.
        text           = li_contents_bin-line
        buffer         = li_contents-line
       failed         = 1
       OTHERS         = 2.

*Converting the table contents from xstring to binary
        buffer                = li_contents-line
        binary_tab            = li_contents_hex.
    LOOP AT li_contents_hex.
      APPEND li_contents_hex TO i_contents_hex .

* FM called for sending the mail to the intended recipients
      document_data                    = w_subject
      put_in_outbox                    = 'X'
      commit_work                      = 'X'
      sent_to_all                      = sent_to_all
      packing_list                     = i_pack_list
      object_header                    = i_objhead
      contents_hex                     = i_contents_hex
      contents_txt                     = i_contents_text
      receivers                        = i_receiver.   
  • No labels