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

Email Attachment

Former Member
0 Likes
519

Hi I am trying to attaching a document along with the email.

For the same I am using SO_DOCUMENT_SEND_API1 function module.

Every thing is ok Except that i am getting a blank attached document(no data).

I think there is a problem with the packing_list I am supplying to it .

here take a look

  • Creation of the entry for the compressed document

l_t_pack-head_start = 1.

l_t_pack-head_num = 0.

l_t_pack-body_start = 1.

l_t_pack-body_num = l_tablines. " contains the data to be included in the

attachment

APPEND l_t_pack.

Can any one help me and let me know the correct parametes to be set for the packing_list so that the data is also included in the attachment.

3 REPLIES 3
Read only

Former Member
0 Likes
483

check this sample code

*   create list in memory
    if r_spmon is not initial and t_repid ne ''.
      submit (t_repid) using selection-set 'EMAIL'
                              with s_werks eq yplant-pplnt
                              with  p_spmon eq r_spmon
                              exporting list to memory and return.
*   and read list from memory into table
      call function 'LIST_FROM_MEMORY'
        tables
          listobject = listobject
        exceptions
          others     = 1.

      if sy-subrc <> 0.
        message id '61' type 'E' number '731'
        with 'LIST_FROM_MEMORY'.
      endif.

      packing_list = objpack.

      call function 'TABLE_COMPRESS'

*     IMPORTING

*       COMPRESSED_SIZE       =

        tables

           in                    = listobject

           out                   = objbin

        exceptions

           others                = 1.

      if sy-subrc <> 0.
      exit.
      endif.


* Create Message Body

*   Title and Description
      docdata-obj_name  = 'TEST_ALI'.
      concatenate t_title 'for   ' yplant-pplnt into
      docdata-obj_descr separated by space .
*   Main Text
      concatenate t_title 'for' yplant-pplnt into
      objtxt  separated by space.
      append objtxt.
      objtxt = 'Have a nice day.'.
      append objtxt.
*   Write Packing List (Main)

      describe table objtxt lines tab_lines.
      read     table objtxt index tab_lines.
      docdata-doc_size = ( tab_lines - 1 ) * 2560 + strlen( objtxt ).
      clear objpack-transf_bin.
      objpack-head_start = 1.
      objpack-head_num   = 0.
      objpack-body_start = 1.
      objpack-body_num   = tab_lines.
      objpack-doc_type   = 'RAW'.
      append objpack.

* Create Message Attachment
*   Write Packing List (Attachment)
      att_type = 'ALI'.
      describe table objbin lines tab_lines.
      read     table objbin index tab_lines.
      objpack-doc_size = ( tab_lines - 1 ) * 2560 + strlen( objbin ).
      objpack-transf_bin = 'X'.
      objpack-head_start = 1.
      objpack-head_num   = 0.
      objpack-body_start = 1.
      objpack-body_num   = tab_lines.
      objpack-doc_type   = att_type.
      objpack-obj_name   = 'ATTACHMENT'.
      concatenate t_title 'for' yplant-pplnt into
      objpack-obj_descr separated by space.
      append objpack.
* Send Message
      call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'

regards

Prabhu

Read only

anversha_s
Active Contributor
0 Likes
483

hi,

chk this



* Variables for EMAIL functionality
data: maildata   like sodocchgi1.
data: mailpack   like sopcklsti1 occurs 2 with header line.
data: mailhead   like solisti1 occurs 1 with header line.
data: mailbin    like solisti1 occurs 10 with header line.
data: mailtxt    like solisti1 occurs 10 with header line.
data: mailrec    like somlrec90 occurs 0  with header line.
data: solisti1   like solisti1 occurs 0 with header line.
 
  clear:    mailpack, mailbin, mailhead.
  refresh:  mailpack, mailbin, mailhead.
 
  describe table mailtxt lines tab_lines.
  read table mailtxt index tab_lines.
  maildata-doc_size = ( tab_lines - 1 ) * 255 + strlen( mailtxt ).
 
* Creation of the entry for the compressed document
  clear mailpack-transf_bin.
  mailpack-head_start = 1.
  mailpack-head_num = 0.
  mailpack-body_start = 1.
  mailpack-body_num = tab_lines.
  mailpack-doc_type = 'RAW'.
  append mailpack.
 
  mailhead = 'TEST.TXT'.
  append mailhead.

.
." File 1 as attachment
  mailbin = 'This is file 1'.
  append mailbin.
 
  describe table mailbin lines tab_lines.
 
  mailpack-transf_bin = 'X'.
  mailpack-head_start = 1.
  mailpack-head_num = 1.
  mailpack-body_start = 1.
  mailpack-body_num = tab_lines.
  mailpack-doc_type = 'TXT'.
  mailpack-obj_name = 'TEST1'.
  mailpack-obj_descr = 'Subject'.
  mailpack-doc_size = tab_lines * 255.
  append mailpack.

rgds

Anver

Read only

Former Member
0 Likes
483

hi,

also look at the following link for a reference example.

http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm.

warm regards,

nishu