cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

workflow not showing attachment

safeer_shah2
Participant
0 Likes
4,174

Dear experts ,

I am using the following code to create a workflow item and later I am attaching a file, the system is showing the attachment is created but its not showing the attachement with the workitem.

here is the code

IF sy-subrc EQ 0.

                  CALL FUNCTION 'SWW_WI_ENABLE'

              EXPORTING

                wi_id                        WORKITEMID

               DO_COMMIT                    = 'X'

             EXCEPTIONS

               UPDATE_FAILED                = 1

               NO_AUTHORIZATION             = 2

               INVALID_TYPE                 = 3

               OTHERS                       = 4

                      .

            IF sy-subrc <> 0.

   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

            ENDIF.

          CALL FUNCTION 'DEQUEUE_E_WORKITEM'

           EXPORTING

             MODE_SWWWIHEAD       = 'E'

             CLIENT               = SY-MANDT

             WI_ID                WORKITEMID

             X_WI_ID              = ' '

             _SCOPE               = '3'

             _SYNCHRON            = ' '

             _COLLECT             = ' '

                    .

ENDIF.

*     LOOP AT files_tab

*       INTO wa_files.

CALL FUNCTION 'ENQUEUE_E_WORKITEM'

   EXPORTING

     MODE_SWWWIHEAD       = 'E'

     CLIENT               = SY-MANDT

     WI_ID                WORKITEMID

     X_WI_ID              = ' '

     _SCOPE               = '2'

     _WAIT                = ' '

     _COLLECT             = ' '

   EXCEPTIONS

     FOREIGN_LOCK         = 1

     SYSTEM_FAILURE       = 2

     OTHERS               = 3

            .

IF sy-subrc <> 0.

   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

data: l_retcode LIKE  SY-SUBRC,

l_att_id  type  SWR_ATT_ID,

lt_msg  type TABLE OF SWR_MESSAG.

        CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'

          EXPORTING

            workitem_id   WORKITEMID

            att_header    = l_header

            att_bin       = l_xstring

            do_commit     = 'X'

          IMPORTING

            return_code   = l_retcode

            att_id        = l_att_id

          TABLES

            message_lines = lt_msg.

        IF sy-subrc EQ 0.

                  CALL FUNCTION 'SWW_WI_ENABLE'

              EXPORTING

                wi_id                        = WORKITEMID

               DO_COMMIT                    = 'X'

             EXCEPTIONS

               UPDATE_FAILED                = 1

               NO_AUTHORIZATION             = 2

               INVALID_TYPE                 = 3

               OTHERS                       = 4

                      .

            IF sy-subrc <> 0.

   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

            ENDIF.

              CALL FUNCTION 'DEQUEUE_E_WORKITEM'

           EXPORTING

             MODE_SWWWIHEAD       = 'E'

             CLIENT               = SY-MANDT

             WI_ID                = WORKITEMID

             X_WI_ID              = ' '

             _SCOPE               = '3'

             _SYNCHRON            = ' '

             _COLLECT             = ' '

                    .

        ENDIF.

View Entire Topic
Richa_Gupta
Contributor
0 Likes

Hi Safeer,

Make sure that you are passing the correct workitem ID in the function module to add attachement.

Also, please have a look at below link. This might help you :

Regards,

Richa

safeer_shah2
Participant
0 Likes
safeer_shah2
Participant
0 Likes

Hi Richa,

I am using the same workitem ID , you can check from my code also .