Skip to Content

I required this type of scenario in one of my projects where I had to go with a situation with workflow where we were not having any method or standard FM (so that we could attach it in our z method) for updation which depended on the user decision or approval process. Finally I had to go with BDC for this.

  For that first I made the recording and converted it in to a Function Module.

image

 image

the code was :

FUNCTION Z_SD_WORKFLOW_CUS_PSTG_UNBLOCK.
*”———————————————————————-
*”*”Local Interface:
*”  IMPORTING
*”     VALUE(CTU)   LIKE  APQI-PUTACTIVE DEFAULT ‘X’
*”     VALUE(MODE) LIKE  APQI-PUTACTIVE DEFAULT ‘N’
*”     VALUE(UPDATE)  LIKE  APQI-PUTACTIVE DEFAULT ‘L’
*”     VALUE(GROUP) LIKE  APQI-GROUPID OPTIONAL
*”     VALUE(USER)  LIKE  APQI-USERID OPTIONAL
*”     VALUE(KEEP)   LIKE  APQI-QERASE OPTIONAL
*”     VALUE(HOLDDATE)  LIKE  APQI-STARTDATE OPTIONAL
*”     VALUE(NODATA)  LIKE  APQI-PUTACTIVE DEFAULT ‘/’
*”     VALUE(KUNNR_001) LIKE  KNA1-KUNNR DEFAULT ‘10000’
*”     VALUE(SPERR_002)  LIKE  BDCDATA-FVAL DEFAULT ”
*”  EXPORTING
*”     VALUE(SUBRC)  LIKE  SYST-SUBRC
*”  TABLES
*”      MESSTAB STRUCTURE  BDCMSGCOLL OPTIONAL
*”———————————————————————-

subrc = 0.

perform bdc_nodata      using   NODATA.

perform open_group     using   GROUP USER KEEP HOLDDATE CTU.

perform bdc_dynpro     using   ‘SAPMF02D’ ‘0500’.
perform bdc_field         using   ‘BDC_CURSOR’
                                                  ‘RF02D-KUNNR’.
perform bdc_field         using   ‘BDC_OKCODE’
                                 ‘/00’.
perform bdc_field         using  ‘RF02D-KUNNR’
                                 KUNNR_001.
perform bdc_dynpro     using   ‘SAPMF02D’ ‘0510’.
perform bdc_field          using  ‘BDC_CURSOR’
                                ‘KNA1-SPERR’.
perform bdc_field         using   ‘BDC_OKCODE’
                                 ‘=UPDA’.
perform bdc_field          using   ‘KNA1-SPERR’
                                 SPERR_002.
perform bdc_transaction tables messtab
using                      ‘XD05’
                              CTU
                              MODE
                              UPDATE.
if sy-subrc <> 0.
  subrc = sy-subrc.
  exit.
endif.

perform close_group using     CTU.

ENDFUNCTION.

 

Then attached this Z FM in Z method:

image

 

image

 

 

BEGIN_METHOD ZCUSTOMER_POSTING_UNBLOCK CHANGING CONTAINER.
DATA:

      MESSTAB LIKE BDCMSGCOLL OCCURS 0,
       CUSTOMERNO TYPE KNA1-KUNNR,
       SUBRC TYPE SYST-SUBRC.
swc_get_element container ‘CUSTOMERNO’ CUSTOMERNO.
CALL FUNCTION ‘Z_SD_WORKFLOW_CUS_PSTG_UNBLOCK’
 EXPORTING
*   CTU             = ‘X’
*   MODE            = ‘N’
*   UPDATE          = ‘L’
*   GROUP           =
*   USER            =
*   KEEP            =
*   HOLDDATE        =
*   NODATA          = ‘/’
   KUNNR_001       =  CUSTOMERNO
   SPERR_002       = ”
 IMPORTING
   SUBRC           = SUBRC
 TABLES
   MESSTAB         = MESSTAB
           .
  SWC_SET_TABLE CONTAINER ‘Messtab’ MESSTAB.
 SWC_SET_ELEMENT CONTAINER ‘Subrc’ SUBRC.

 END_METHOD.

 

*We can use MESSTAB &  SUBRC later on in our workflow for  handling error.

 

Assigned it with task:

I go for background task.

image

 

Some local task variable for binding:

 

image

 

Make the proper binding the task with workflow, in my case CUSTOMERNO.

image

 

And the  workflow.

image

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply