Skip to Content

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

Content in the attachment is not displaying in SAPINBOX

Hi Experts,

I am using below function module to sent mail attachment to sap inbox .

'SO_NEW_DOCUMENT_ATT_SEND_API1'


Mail is going to SAP inbox and attachment also creating , but content of attachment is not displaying in the mail.

Can you Please see below my code and provide me the solution




DATA: L_T_OBJPACK   LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE,        " SAPoffice: Description of Imported Object Components

         L_T_OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE,

         L_T_OBJTXT    LIKE SOLISTI1   OCCURS 10 WITH HEADER LINE,

         L_T_OBJBIN    LIKE SOLISTI1   OCCURS 10 WITH HEADER LINE,

         L_T_RECLIST   LIKE SOMLRECI1  OCCURS 5 WITH HEADER LINE,        " SAPoffice: Structure of the API Recipient List

         L_DATE LIKE SY-DATUM,

         V_DOCUMENT_DATA TYPE SODOCCHGI1.

   DATA:

*    Work Area declarations

         L_WA_OBJHEAD   TYPE SOLI_TAB,                                    " Work Area for Objcont and Objhead as Table Type

         L_WA_DOC_CHNG  TYPE SODOCCHGI1,                                  " Work Area - Data of an object which can be changed

*    Variables declarations

         L_LINES_TXT    TYPE I,

         L_LINES_BIN    TYPE I,

         L_OBJ_DESC(100),

         L_NAME(100).

   DATA : BEGIN OF L_T_EMAIL OCCURS 0,

   EMAIL_ID(100),

   END OF L_T_EMAIL.

*email -id

   SELECT LOW INTO TABLE L_T_EMAIL

   FROM TVARVC

   WHERE NAME EQ 'ZREUTERS_MAIL'.

   IF SY-SUBRC <> 0.

     L_T_EMAIL-EMAIL_ID = SY-UNAME.

     APPEND L_T_EMAIL.

*    MESSAGE I999 WITH 'Email IDs not maintained in TVARVC'.

   ENDIF.

*Fill in the contents of the mail body

L_T_OBJBIN-LINE = 'KIRAN'.

APPEND L_T_OBJBIN.

*L_T_OBJBIN-LINE = 'SREENI'.

*APPEND L_T_OBJBIN.

*Attachment

   REFRESH: L_T_RECLIST,

            L_T_OBJTXT,

            L_T_OBJPACK.

   CLEAR L_WA_OBJHEAD.

*Create Message Body Title and Description

   CONCATENATE 'Message file for EAI217' Sy-datum INTO L_NAME SEPARATED BY SPACE.

   L_T_OBJTXT = L_NAME.

   APPEND L_T_OBJTXT.

   CONCATENATE 'Message file for EAI217' Sy-datum INTO L_OBJ_DESC SEPARATED BY SPACE.

   DESCRIBE TABLE L_T_OBJTXT LINES L_LINES_TXT.

   READ TABLE L_T_OBJTXT INDEX L_LINES_TXT.

   L_WA_DOC_CHNG-OBJ_NAME = L_NAME.

   L_WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.

   L_WA_DOC_CHNG-OBJ_DESCR = L_OBJ_DESC.

   L_WA_DOC_CHNG-SENSITIVTY = 'O'.

   L_WA_DOC_CHNG-DOC_SIZE = STRLEN( L_T_OBJTXT ).

*Main Text

   CLEAR L_T_OBJPACK-TRANSF_BIN.

   L_T_OBJPACK-HEAD_START = 1.

   L_T_OBJPACK-HEAD_NUM = 0.

   L_T_OBJPACK-BODY_START = 1.

   L_T_OBJPACK-BODY_NUM = 1.

   L_T_OBJPACK-DOC_TYPE = 'RAW'.

   L_T_OBJPACK-DOC_SIZE = STRLEN( L_T_OBJTXT ).

   APPEND L_T_OBJPACK.

*Attachment

   DESCRIBE TABLE L_T_OBJBIN LINES L_LINES_BIN.

   READ TABLE L_T_OBJBIN INDEX L_LINES_BIN.

   CLEAR L_T_OBJPACK.

   L_T_OBJPACK-TRANSF_BIN = 'X'.

   L_T_OBJPACK-HEAD_START = 1.

   L_T_OBJPACK-HEAD_NUM = 0.

   L_T_OBJPACK-BODY_START = 1.

   L_T_OBJPACK-BODY_NUM = L_LINES_BIN.

   L_T_OBJPACK-DOC_TYPE = 'RAW'.

   L_T_OBJPACK-OBJ_NAME = 'EMAIL'.

   L_T_OBJPACK-OBJ_DESCR = ' Error file'.

   L_T_OBJPACK-DOC_SIZE STRLEN( L_T_OBJBIN ) .

*  L_T_OBJPACK-DOC_SIZE = ( 255 * ( L_LINES_BIN - 1 ) ) + STRLEN( L_T_OBJBIN ).

   APPEND L_T_OBJPACK.

   LOOP AT L_T_EMAIL.

*Maintain Recievers

     CLEAR L_T_RECLIST.

     L_T_RECLIST-RECEIVER = L_T_EMAIL-EMAIL_ID.

     L_T_RECLIST-REC_TYPE = 'B'.

     L_T_RECLIST-EXPRESS = 'X'.

     APPEND L_T_RECLIST.

   ENDLOOP.

   CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

     EXPORTING

       DOCUMENT_DATA              = L_WA_DOC_CHNG

*      PUT_IN_OUTBOX              = 'X'

       COMMIT_WORK                = 'X'

     TABLES

       PACKING_LIST               = L_T_OBJPACK

       OBJECT_HEADER              = L_WA_OBJHEAD

       CONTENTS_BIN               = L_T_OBJBIN

       CONTENTS_TXT               = L_T_OBJTXT

       RECEIVERS                  = L_T_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 NE 0.

*    MESSAGE S999(ZZ) WITH 'Mail Could not be sent'.

*  ELSE.

*    MESSAGE S999(ZZ) WITH 'Mail sent to group'.

*  ENDIF.

*ENDFORM.                    "F0005_ATTACH_AND_MAIL


Regards

kiran

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