Executing the user-decision step programmatically (SAP Business Workflow)

By Raja

Scenario: To execute the "User Decision" step programmatically instead of manually executing the work item. 

Procedure: 

Let us create a sample workflow definition with a simple "User Decision" step as shown below: 

 

The workflow would look like:

 

Now execute the workflow definition and the following work item would appear in your SAP inbox: 

 

Do not make any decision and click on "Cancel and keep work item in inbox". 

Now retrieve the work item id for the above work item using the transaction SWIA.

 

You can use the function module SAP_WAPI_DECISION_COMPLETE to execute the User-decision step programmatically. 

Following is the sample code: 

REPORT ztest.

CALL FUNCTION 'SAP_WAPI_DECISION_COMPLETE'
  
EXPORTING
    workitem_id          = 
'1031471'
*   LANGUAGE             = SY-LANGU
*   USER                 = SY-UNAME
    decision_key         = 
'0001'
*   DO_COMMIT            = 'X'
* IMPORTING
*   RETURN_CODE          =
*   NEW_STATUS           =
* TABLES
*   MESSAGE_LINES        =
*   MESSAGE_STRUCT       =
          .

The important parameters to be entered are workitem_id and decision_key. Enter the decision values as '0001' for 'Approved', '0002' for 'Send for corrections' and '0003' for 'Reject'. 

After executing the above program, the work item would be executed with the option provided and the status would be set to "COMPLETED". 

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image