Title
A method to send concurrent workflow work items to a dynamic number of business users.
Introduction
In this blog, we will discuss the process of sending concurrent workflow work items using a sub-workflow to a dynamic number of business users instead of using a fork.
A Business Workflow is used to automate various custom and standard business processes, such as an approval process, notification process, and other business requirements.
To do so, we need to identify the following objects:
1) A Business Object
2) A Workflow Rule for Agent Determination
3) A Workflow Task
4) A Workflow Class
Summary
A Business workflow consists of four major components: a business object, a workflow rule for agent determination, a workflow task, and a workflow class.
A business object: It consists of Interfaces, Key fields, Attributes, Methods, and Events
A workflow rule: It is used to determine a responsible agent or agents. There are various rule resolution techniques such as rule resolution with responsibility, rule resolution with function, rule resolution with organization management, and rule resolution with function asynchronously.
A workflow task: It consists of a class/business object method, container elements, bindings, and agents.
A workflow class: It is used to segregate the business logic into class methods and define events.
Step-by-step processes for creating a workflow for sending concurrent dialog work items to a dynamic number of users using a sub-workflow in a sales order creation process.
Step1. Create a sales order ( Tcode - VA01) and identify the underlying business object, which is BUS 2032 in this case.
Step 2. Create a workflow using SWDD Tcode and bind it with the business object BUS2032.
Step 3. Create a custom workflow class: ZCL_WF_SO and define the below methods:
Methods:
Step 4. Create a decision task that will send a decision work item to the workflow initiator.
Step 5. Create a task TRIGGER_SUBWORKFLOW and bind it with the GET_AGENT method of the workflow class ZCL_WF_SO.
a) The GET_AGENT method is used to determine the responsible agents from the TVARV table
b) We now pass the determined agents to a sub-workflow, which will be called multiple times, depending upon the number of agents determined, and generate concurrent dialog work items (VA03 Tcode) for them.
Step 6: Create another workflow (a sub-workflow) using SWDD Tcode and bind it with the workflow class ZCL_WF_SO.
Step 7: Create a task DISPLAY_SALES_ORDER to display the sales order and bind it with the DISPLAY_SALES_ORDER method of ZCL_WF_SO.
Step 8. Following is the sample code for the determination of the agent.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method ZCL_WF_SO=>GET_AGENT
* +-------------------------------------------------------------------------------------------------+
* | [--->] IM_INDEX TYPE INT4(optional)
* | [--->] IM_VBELN TYPE VBELN(optional)
* | [<---] EX_RC TYPE INT4
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD get_agent.
*-------------------------------------------------------------*
* Get the workflow agent information
*-------------------------------------------------------------*
DATA : lt_tvarv TYPE STANDARD TABLE OF tvarv.
DATA : lt_agents TYPE ztt_agent.
DATA : ls_agent LIKE LINE OF lt_agents.
DATA : lv_index TYPE sy-index.
DATA : lv_agent TYPE swp_initia.
DATA : lv_vbeln TYPE vbeln.
CONSTANTS: c_var1 TYPE rvari_vnam VALUE 'AGENT'.
CONSTANTS: c_rc TYPE int4 VALUE '1',
c_agent(2) VALUE 'US'.
FIELD-SYMBOLS: <lf_agents> LIKE LINE OF lt_agents.
FIELD-SYMBOLS: <lf_tvarv> LIKE LINE OF lt_tvarv.
* Get the workflow agents from the TVARV table.
FREE: lt_tvarv[].
SELECT name type numb sign low FROM tvarv
INTO CORRESPONDING FIELDS OF TABLE lt_tvarv
WHERE name EQ c_var1.
IF sy-subrc EQ 0.
IF lt_tvarv[] IS NOT INITIAL.
UNASSIGN <lf_tvarv>.
FREE lt_agents[].
LOOP AT lt_tvarv ASSIGNING <lf_tvarv>.
CLEAR ls_agent.
ls_agent = <lf_tvarv>-low.
APPEND ls_agent TO lt_agents.
ENDLOOP.
ENDIF.
ENDIF.
* Read the workflow agents and pass it to the sub-workflow
IF lt_agents[] IS NOT INITIAL.
CLEAR lv_index.
lv_index = im_index.
UNASSIGN <lf_agents>.
CLEAR lv_agent.
READ TABLE lt_agents ASSIGNING <lf_agents> INDEX lv_index.
IF sy-subrc EQ 0.
CONCATENATE c_agent <lf_agents> INTO lv_agent.
IF sy-subrc EQ 0.
CONDENSE lv_agent.
ENDIF.
CLEAR lv_vbeln.
lv_vbeln = im_vbeln.
IF ( lv_agent IS NOT INITIAL AND lv_vbeln IS NOT INITIAL ).
* Trigger the Sales order Display workflow
zcl_wf_so=>trigger_wf( EXPORTING im_vbeln = im_vbeln
im_agent = lv_agent ).
ENDIF.
ELSE.
ex_rc = c_rc.
ENDIF.
ENDIF.
ENDMETHOD.
Step 9. Execute the business case:
a) Create a new sales order using the transaction code VA01.
b) The sales order has triggered the workflow, and a decision work item has been sent to the workflow initiator.
c) If the workflow initiator chooses "yes" from the decision work item, then a subsequent task (GET_AGENT) determines the responsible agents. The task also triggers another workflow ( a sub-workflow) multiple times depending upon the number of agents determined and generates concurrent dialog work items (VA03 Tcode) for them.
Conclusion
The blog helps design new business workflows for sending concurrent work items to a dynamic number of users instead of using a fork.
I hope this article was insightful.
Any comments or suggestions will be appreciated.
Please follow the following pages for SAP ABAP Development and post your answers & questions:
ABAP Development Environment Topic Page:
https://community.sap.com/topics/abap
Post and answer questions:
https://answers.sap.com/tags/833755570260738661924709785639136
and read other posts on the topic:
https://blogs.sap.com/tags/833755570260738661924709785639136
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Subject | Kudos |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
User | Count |
---|---|
10 | |
7 | |
7 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 |