Recording in workflow!!!
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.
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:
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.
Some local task variable for binding:
Make the proper binding the task with workflow, in my case CUSTOMERNO.
And the workflow.







