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

How to Put a mail to designated User with txt format

Hi Friends,

I have a small in mailing concept of BDC's. Can any one check my code and tell me why my code is not poping any message in txt file. I am not getting any data in text file but the mail is getting trigerred.

here below is the code regarding mail Concept. Please help me ASAP. This is very important. Please revert where I am wrong and correct me if you can.

Points will defintely be rewarded.

  • * To Send a mail to the conserned user when we get the 824 detailed

DATA: V_USRID TYPE PA0105-USRID, " variable for usrid

V_SUBJECT(100) TYPE C, " variable for subject line

V_SENT_ALL(1) TYPE C. " variable to sent messages

CONSTANTS: C_U(1) TYPE C VALUE 'U', " constant for U

C_X(1) TYPE C VALUE 'X', " constant for X

C_INT(3) TYPE C VALUE 'INT', " constant for INT

C_SAPRPT(6) TYPE C VALUE 'SAPRPT'," constant for SAPRPT

C_1(1) TYPE C VALUE '1', " constant for 1

C_0(1) TYPE C VALUE '0', " constant for 0

C_B(1) TYPE C VALUE 'B', " Constant for B

C_RAW(3) TYPE C VALUE 'RAW', " constant for RAW

C_TXT(3) TYPE C VALUE 'TXT', " constant for TXT

C_ERR(30) TYPE C VALUE 'Error 824 detailed file', " constant for Obj description

C_INTFC(15) TYPE C VALUE 'Interface', "constant for Obj Name in attachment

C_F(1) TYPE C VALUE 'F'. " constant for F

DATA : T_MESSAGE TYPE STANDARD TABLE OF SOLISTI1, "Segment e1edk01

T_PACKING_LIST TYPE TABLE OF SOPCKLSTI1," table for packing list

T_RECEIVERS TYPE TABLE OF SOMLRECI1, " table for receivers

WA_PACKING_LIST TYPE SOPCKLSTI1, " work area for mail list

WA_CONTENTS TYPE SOLISTI1, " work area for contents

WA_RECEIVERS TYPE SOMLRECI1, " work area for recivers

WA_MESSAGE TYPE SOLISTI1, " work area for messages

T_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

V_LINES_TXT TYPE I,

V_LINES_BIN TYPE I,

WA_DOC_DATA TYPE SODOCCHGI1. " work area for doc data

*To prepare the subject line

CONCATENATE TEXT-003 P_FILE1 INTO V_SUBJECT SEPARATED BY SPACE.

CLEAR P_FILE1.

  • Create Message Body

  • Title and Description

  • T_OBJTXT = 'test with dat file Attachment!'.

    APPEND T_OBJTXT.

    DESCRIBE TABLE T_OBJTXT LINES V_LINES_TXT.

    READ TABLE T_OBJTXT INDEX V_LINES_TXT.

    • *To append the first line description

    WA_MESSAGE-LINE+1(10) = TEXT-001.

    WA_MESSAGE-LINE+41(20) = TEXT-002.

    APPEND WA_MESSAGE TO T_MESSAGE.

    CLEAR WA_MESSAGE.

    *Add the recipients email address

    CLEAR WA_RECEIVERS.

    REFRESH T_RECEIVERS.

    WA_RECEIVERS-RECEIVER = 'v.satish.raju@accenture.com'."V_USRID.

    WA_RECEIVERS-REC_TYPE = C_U.

    WA_RECEIVERS-COM_TYPE = C_INT.

    WA_RECEIVERS-NOTIF_DEL = C_X.

    WA_RECEIVERS-NOTIF_NDEL = C_X.

    APPEND WA_RECEIVERS TO T_RECEIVERS.

    CLEAR WA_RECEIVERS.

    CLEAR WA_RECEIVERS.

    WA_RECEIVERS-RECEIVER = 'VSATISHRAJU'. " replace with <login name>

    WA_RECEIVERS-REC_TYPE = 'B'.

    WA_RECEIVERS-EXPRESS = C_X.

    APPEND WA_RECEIVERS TO T_RECEIVERS.

    CLEAR WA_RECEIVERS.

    • Describe the body of the message

    CLEAR WA_PACKING_LIST.

    REFRESH T_PACKING_LIST.

    WA_PACKING_LIST-TRANSF_BIN = SPACE.

    WA_PACKING_LIST-HEAD_START = C_1.

    WA_PACKING_LIST-HEAD_NUM = C_0.

    WA_PACKING_LIST-BODY_START = C_1.

    • WA_PACKING_LIST-BODY_NUM = V_LINES_TXT.

    DESCRIBE TABLE T_MESSAGE LINES WA_PACKING_LIST-BODY_NUM.

    WA_PACKING_LIST-DOC_TYPE = C_RAW.

    APPEND WA_PACKING_LIST TO T_PACKING_LIST.

    • * **** Attachment

    • (pdf-Attachment)

    WA_PACKING_LIST-TRANSF_BIN = C_X.

    WA_PACKING_LIST-HEAD_START = C_1.

    WA_PACKING_LIST-HEAD_NUM = C_0.

    WA_PACKING_LIST-BODY_START = C_1.

    • WA_PACKING_LIST-BODY_NUM = V_LINES_BIN. "satish

    WA_PACKING_LIST-BODY_NUM = V_LINES_TXT + 1 .

    • WA_PACKING_LIST-DOC_TYPE = 'PDF'. "comments by siva

    WA_PACKING_LIST-DOC_TYPE = C_TXT. " changes by siva

    WA_PACKING_LIST-OBJ_NAME = C_INTFC.

    • WA_PACKING_LIST-doc_size = 255 * ( V_LINES_TXT + 1 ).

    WA_PACKING_LIST-OBJ_DESCR = C_ERR.

    APPEND WA_PACKING_LIST TO T_PACKING_LIST.

    CLEAR WA_PACKING_LIST.

    *Populate the subject/generic message attributes

    WA_DOC_DATA-OBJ_LANGU = SY-LANGU.

    WA_DOC_DATA-OBJ_NAME = C_SAPRPT.

    WA_DOC_DATA-OBJ_DESCR = V_SUBJECT.

    WA_DOC_DATA-SENSITIVTY = C_F.

    CLEAR : V_SUBJECT.

    *Call the FM to post the message to SAPMAIL

    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    EXPORTING

    DOCUMENT_DATA = WA_DOC_DATA

    PUT_IN_OUTBOX = C_X

    IMPORTING

    SENT_TO_ALL = V_SENT_ALL

    TABLES

    PACKING_LIST = T_PACKING_LIST

    CONTENTS_TXT = T_MESSAGE

    • CONTENTS_BIN = T_OBJBIN

    RECEIVERS = T_RECEIVERS

    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 NE 0.

    • RAISE NO_MAIL.

    • ENDIF.

    COMMIT WORK.

    ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

    Assigned Tags

    Related questions

    1 Answer

    • author's profile photo Former Member
      Former Member
      Posted on Dec 03, 2007 at 01:55 PM

      Why dont you see output type 5 in the output condition itself? You dont have to code for this.

      Albert

      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.