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

Formating Email Body In SO_NEW_DOCUMENT_SEND_API1

Hai,

I am Trying to send an email, from my program , where body of the email is simply hardcoded.

I need the email body in the below format with just 2 lines.

Hi,

line 1 :-Report Generated successfully

line 2:- This mail is SAP generated pls dont reply.

But My problem is all these lines are coming in a single line . I have done all possible experiments but of no use...

now depending on SDN..Help pls...Here is the code..

objtxt-line = 'Hi,'.
*    CONCATENATE cl_abap_char_utilities=>newline 'Hi' into objtxt-line respecting blanks.
     APPEND OBJTXT.
     CLEAR OBJTXT.

    APPEND OBJTXT.
     CLEAR OBJTXT.



    OBJTXT-LINE = P_MSG.
*    CONCATENATE cl_abap_char_utilities=>newline p_msg cl_abap_char_utilities=>newline INTO OBJTXT-LINE respecting blanks.
     APPEND OBJTXT.
     CLEAR OBJTXT.
    CONCATENATE 'DO NOT REPLY TO THIS EMAIL. '
                  'THIS IS A SAP-SYSTEM GENERATED EMAIL!!' INTO OBJTXT-LINE .
     APPEND OBJTXT.
     CLEAR OBJTXT.


  CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
    EXPORTING
      DOCUMENT_DATA                    = EMAIL_data
     PUT_IN_OUTBOX                    = 'X'
*     SENDER_ADDRESS                   = SY-UNAME
*     SENDER_ADDRESS_TYPE              = 'B'
     COMMIT_WORK                      = 'X'
*   IMPORTING
*     SENT_TO_ALL                      =
*     NEW_OBJECT_ID                    =
*     SENDER_ID                        =
    TABLES
      PACKING_LIST                     = PACKING_DETAIL
*     OBJECT_HEADER                    =
*     CONTENTS_BIN                     =
     CONTENTS_TXT                     =  objtxt
*     CONTENTS_HEX                     =
*     OBJECT_PARA                      =
*     OBJECT_PARB                      =
      RECEIVERS                        = EMAIL_SEND
   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.                                      "Commented by jm1227 - 07/18/2011
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*  ENDIF.
CASE SY-SUBRC.
      WHEN 0.
        LOOP AT S_EMAIL.
            WRITE: / S_EMAIL-low, ': succesfully sent'.
            skip.
        ENDLOOP.
      WHEN 1.
        WRITE: / 'Too many receivers specified !'.

      WHEN 2.
        WRITE: / 'No receiver got the document !'.

      WHEN 4.
        WRITE: / 'Missing send authority !'.

      WHEN OTHERS.
        WRITE: / 'Unexpected error occurred !'.
    ENDCASE.

ENDFORM.                    " SEND_MAIL

Thanks Jeevan.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Jul 18, 2011 at 01:09 PM

    Hi Kumar,

    Is your GS_PACKING_LIST-DOC_TYPE = raw or different?

    Best regards.

    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.