Skip to Content
author's profile photo Former Member
Former Member

SO_NEW_DOCUMENT_ATT_SEND_API1- problem in mail text

Hi All,

I am using FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send emails.

I have taken the reference program from the documentation of this function module given by SAP.

I want to send two attachments in text format using this FM and I am able to send the same.

The problem I am facing is that every character of text is seprated by one space. i.e. between any two characters one space is inserted in the attachement.

e.g. if I need to display :::

"This is test mail" -->

I am gettting the output as

"T h i s i s t e s t m a i l".

Is there any parameter which I need to set to avoid this problem.

Any input would be highly appreciated.

regards,

Lalit

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 31, 2008 at 08:13 AM

    Hi,

    Please refer following program for email with 2 attachment.

    REPORT ztest_mail.

    DATA : t_receiver TYPE STANDARD TABLE OF somlreci1 INITIAL SIZE 0,

    w_receiver TYPE somlreci1,

    w_document_data TYPE sodocchgi1,

    t_packing_list TYPE STANDARD TABLE OF sopcklsti1 INITIAL SIZE 0,

    w_packing_list TYPE sopcklsti1,

    sent_to_all TYPE sonv-flag,

    t_msg TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0,

    w_msg TYPE solisti1.

    DATA : l_mail_msg_length TYPE so_bd_num,

    l_attachment_length TYPE so_bd_num,

    l_t_msg_attachment TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0,

    l_w_msg_attachment TYPE solisti1,

    l_trailer_count TYPE i,

    l_trailer_count_char TYPE char9.

    l_w_msg_attachment-line = 'hi'.

    APPEND l_w_msg_attachment TO l_t_msg_attachment.

    w_document_data-priority = '1'.

    • Populate the subject/generic message attributes

    w_document_data-obj_langu = sy-langu.

    w_document_data-obj_descr = 'YOUR ACTION REQUIRED'.

    CONCATENATE 'Please check the attached files for erroneous records of employees.'

    'Also, Please check error messages in the table ZHR_ERR, if any.'

    INTO w_msg-line SEPARATED BY space.

    APPEND w_msg TO t_msg.

    w_receiver-rec_type = 'U'.

    w_receiver-receiver = email id.

    APPEND w_receiver TO t_receiver.

    • Information about structure of data tables

    CLEAR w_packing_list.

    REFRESH t_packing_list.

    w_packing_list-transf_bin = space.

    w_packing_list-head_start = 1.

    w_packing_list-head_num = 0.

    w_packing_list-body_start = 1.

    w_msg-line = 'hi'.

    APPEND w_msg TO t_msg.

    DESCRIBE TABLE t_msg LINES l_mail_msg_length.

    DESCRIBE TABLE l_t_msg_attachment LINES l_attachment_length.

    w_packing_list-body_num = l_mail_msg_length - l_attachment_length.

    w_packing_list-doc_type = 'RAW'.

    APPEND w_packing_list TO t_packing_list.

    w_packing_list-transf_bin = space.

    w_packing_list-head_start = 1.

    w_packing_list-head_num = 0.

    w_packing_list-body_start = ( l_mail_msg_length - l_attachment_length ) + 1.

    w_packing_list-body_num = l_attachment_length.

    w_packing_list-doc_type = 'RAW'.

    w_packing_list-obj_name = '1nd_attach'.

    w_packing_list-obj_descr = '1nd_attach'.

    w_packing_list-obj_langu = 'EN'.

    APPEND w_packing_list TO t_packing_list.

    w_msg-line = 'bye'.

    APPEND w_msg TO t_msg.

    DESCRIBE TABLE t_msg LINES l_mail_msg_length.

    DESCRIBE TABLE l_t_msg_attachment LINES l_attachment_length.

    w_packing_list-transf_bin = space.

    w_packing_list-head_start = 1.

    w_packing_list-head_num = 0.

    w_packing_list-body_start = ( l_mail_msg_length - l_attachment_length ) + 1.

    w_packing_list-body_num = l_attachment_length.

    w_packing_list-doc_type = 'RAW'.

    w_packing_list-obj_name = '2nd_attach'.

    w_packing_list-obj_descr = '2nd_attach'.

    w_packing_list-obj_langu = 'EN'.

    APPEND w_packing_list TO t_packing_list.

    • Call Function Module to send mail

    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    EXPORTING

    document_data = w_document_data

    put_in_outbox = 'X'

    commit_work = 'X'

    IMPORTING

    sent_to_all = sent_to_all

    • NEW_OBJECT_ID =

    TABLES

    packing_list = t_packing_list

    • OBJECT_HEADER =

    • CONTENTS_BIN =

    contents_txt = t_msg

    • CONTENTS_HEX =

    • OBJECT_PARA =

    • OBJECT_PARB =

    receivers = t_receiver

    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 syst-subrc = 0 .

    ENDIF.

    Hope this will help you.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 31, 2008 at 04:35 AM

    Hi,

    Any input on this would be highly appreciated.

    Regards,

    Lalit

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      check this coding

      objtxt = '<This is system generated message>.'.

      APPEND objtxt.

      objtxt = space.

      APPEND objtxt.

      • Mail Body of message over.

      DESCRIBE TABLE objtxt[] LINES v_lines_txt.

      CONCATENATE 'Inv.' invno INTO sub SEPARATED BY space.

      doc_chng-obj_name = sub.

      doc_chng-expiry_dat = sy-datum + 10.

      • Mail Subject

      refresh objpack[].

      CONCATENATE 'Pricol Dispatch - Invoice' invno '- Reg.' INTO sub SEPARATED BY space.

      doc_chng-obj_descr = sub.

      doc_chng-sensitivty = 'F'.

      doc_chng-doc_size = v_lines_txt * 255.

      objpack-transf_bin = ' '.

      objpack-head_start = 1.

      objpack-head_num = 0.

      objpack-body_start = 1.

      objpack-body_num = v_lines_txt.

      objpack-doc_type = 'RAW'.

      APPEND objpack.

      *PDF Attachment

      DESCRIBE TABLE so_ali[] LINES lineno.

      objpack-transf_bin = 'X'.

      objpack-head_start = 1.

      objpack-head_num = 1.

      objpack-body_start = 1.

      objpack-doc_size = lineno * 255 .

      objpack-body_num = lineno.

      objpack-doc_type = 'PDF'.

      objpack-obj_name = 'INVOICE'.

      objpack-obj_descr = 'Invoice'.

      objpack-obj_langu = 'E'.

      APPEND objpack.

      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

      EXPORTING

      document_data = doc_chng

      put_in_outbox = 'X'

      commit_work = 'X'

      TABLES

      packing_list = objpack

      contents_txt = objtxt[]

      contents_bin = so_ali[]

      *contents_hex = so_ali[]

      receivers = 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 = 0.

      PERFORM mail.

      MESSAGE 'Mail sent successfully' TYPE 'S'.

      *SUBMIT RSCONN01 WITH MODE = MODE.

      ENDIF.

  • author's profile photo Former Member
    Former Member
    Posted on Oct 31, 2008 at 05:16 AM

    hi

    try condense statement

    shiva

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 31, 2008 at 07:43 AM

    Hi

    Use "Condense statement"

    regards,

    Ramya

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 31, 2008 at 08:50 AM

    Thanks a Lot for your valueable inputs!!!

    Regards,

    Lalit

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.