Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

mail sending program

Hi Experts,

I am trying to send a mial with text attachement from the r/3. Everything is working fine except the data format in the text file.

I have filled the contetents table as shown below.

data:  word1(15) type c,
       word2(15) type c,
       tab_space(15) type c,
       idx type i.

word1 = 'firstword'.
word2 = 'secondword'.
tab_space = '      '.
idx = 1.
do 3 times.

concatenate word1   word2    into contents .
*insert wa_contents into table contents .

append contents.

*concatenate word1   word2    into contents .
*insert wa_contents into table contents .

append contents.

enddo.

and the packing list table as shown below

  DESCRIBE TABLE contents LINES count.
  REFRESH packing_list.
  packing_list-transf_bin = 'X'.
  packing_list-head_start = 1.
  packing_list-head_num = 1.
  packing_list-body_start = 1.
  packing_list-body_num = count.
  packing_list-doc_type = 'RAW'.

  APPEND packing_list.
  CLEAR packing_list.

* Create attachment notification
  packing_list-transf_bin = ''.
  packing_list-head_start = 1.
  packing_list-head_num   = 1.
  packing_list-body_start = 1.
  packing_list-body_num   = count.

  packing_list-doc_type   =  'TXT'.
  packing_list-obj_descr  =  'Material Infotype'.
  packing_list-obj_name   =  'Material Infotype'.
  packing_list-doc_size   =  count * 255.
  APPEND packing_list.

the mail sending code is shown below.

  CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
    EXPORTING
      document_data                  = document_data
*   PUT_IN_OUTBOX                    = ' '
*   SENDER_ADDRESS                   = SY-UNAME
*   SENDER_ADDRESS_TYPE              = 'B'
*   COMMIT_WORK                      = ' '
* IMPORTING
*   SENT_TO_ALL                      =
*   NEW_OBJECT_ID                    =
*   SENDER_ID                        =
    TABLES
      packing_list                   = packing_list
*   OBJECT_HEADER                    =
    contents_bin                     = attachment
    contents_txt                     = contents
*   CONTENTS_HEX                     =
*   OBJECT_PARA                      =
*   OBJECT_PARB                      =
      receivers                      = real_recipients
* 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
            .

The problem is in the attachment file, the data is appearing as shown below:

firstwordsecondword

firstwordsecondword

firstwordsecondword

the second and third lines are not starting from the begining of new line. I do not understand why. Is that something problem with the packing parameters.

thanks

sankar

Tags:
Former Member
Former Member replied

Hi Sankar,

Change you concatnate statement like this.

concatenate word1

word2

CL_ABAP_CHAR_UTILITIES=>CR_LF

into contents .

Regards,

Vijay

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question