Business Scenario:
The SAP system must record all the intermediate values of different variables in a Workflow process. Standard SAP Workflow report does not provide all the Workflow and Task container values in a single row. It is necessary to store these variables for the purpose of detailed reporting and auditing.
This document provides a custom solution for capturing run time container values in a Purchase Requisition release workflow.
Purchase Requisition Release Workflow example
For the purpose of demo, consider Standard Purchase Req. Release Workflow - WS20000077. A new activity step with a dialog task ‘Request Rejection Reason’ has been added to the outcome ‘Release Refused’. This task prompts the Reviewer to provide a Rejection / Refusal Reason.
This new container variable ‘Rejection Reason’ is not available for End Users within any standard Workflow report.
The container values can be captured by implementing Programming exit in to a sample database table as shown below.
Implement Workflow Programming Exit
METHOD if_swf_ifs_workitem_exit~event_raised.
*****************************************************************************
* This exit is called by the workflow system at different stages of work item
* processing e.g. before creation, before execution, after execution etc.
*****************************************************************************
* Data Declaration
DATA: ls_wihead TYPE swr_wihdr.
* Workflow Container object
DATA: l_wf_cont TYPE REF TO if_swf_ifs_parameter_container,
* Task Container object
l_wi_cont TYPE REF TO if_swf_ifs_parameter_container.
DATA :
ls_pr_wf_values TYPE zpr_wf_values,
l_value TYPE string,
l_rej_reason TYPE zrej_reason.
* Fetch Current Work Item Header
ls_wihead = im_workitem_context->get_header( ).
* Skip This exit if the Work item status is ERROR
CHECK ls_wihead-wi_stat NE swfco_wi_status_error
AND ls_wihead-wi_stat NE swfco_wi_status_excpcaught
AND ls_wihead-wi_stat NE swfco_wi_status_excphandlr.
* Fetch Workflow Container
l_wf_cont = im_workitem_context->get_wf_container( ).
* Fetch Work Item Container
l_wi_cont = im_workitem_context->get_wi_container( ).
* Check for current Event
CASE im_event_name.
* Event 'State Changed' indicates that the Work Item now has a new processing status
WHEN swrco_event_state_changed.
* The 'Rejection Reason' will be available in Work Item container only after Execution of Work item
IF ls_wihead-wi_stat = swfco_wi_status_completed. " STATUS - COMPLETED
CLEAR l_value.
CALL METHOD l_wi_cont->get
EXPORTING
name = 'RejectionReason'
IMPORTING
value = l_value.
WRITE l_value TO ls_pr_wf_values-rej_reason.
* Also fetch Release code from Workflow container
CLEAR l_value.
CALL METHOD l_wf_cont->get
EXPORTING
name = 'ReleaseCode'
IMPORTING
value = l_value.
WRITE l_value TO ls_pr_wf_values-REL_CODE.
* Store Rejection date and time
MOVE :
sy-datum TO ls_pr_wf_values-rej_date,
sy-uzeit TO ls_pr_wf_values-rej_time..
* Store Reviewer name
CLEAR l_value.
MOVE ls_wihead-wi_aagent TO ls_pr_wf_values-reviewer.
* Store Purchase Req.number from new task variable - Purchase Req.
CLEAR l_value.
CALL METHOD l_wi_cont->get
EXPORTING
name = 'PurchaseReq'
IMPORTING
value = l_value.
WRITE l_value TO ls_pr_wf_values-banfn.
* Update the PR Workflow values table
MODIFY zpr_wf_values FROM ls_pr_wf_values.
* Do not write COMMIT statement in this Program Exit
* The database table will be committed along with Workflow internal
* COMMIT
ENDIF.
WHEN OTHERS.
ENDCASE.
ENDMETHOD.
Working DEMO
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |