How to Create and Trigger Class Based Workflow from Web Dynpro ABAP – Part 2
In the first part How to create and trigger class based workflow – part 1, we have seen creating a class using IF_WORKFLOW interface. Now we will see, how to create workflow.
Creating Workflow
Step 1: Creating Workflow.
Go to SWDD Transaction and click on Create button to create new Workflow.
Step 1.1: Creating Attributes.
Under Navigation Area Work flow container will be selected, If not select Work Flow container as shown below.
Under Workflow Container double click to create as shown below.
Enter Element Name, Description and select the created class.
Under Properties Tab select import, export and click on Ok.
Now Double click again to create emp_id Element which stores the Employee ID.
Enter attribute name, description and enter type as shown below. You can enter the data type directly by selecting ABAP dict. Data type.
Under Properties tab check import, export and click on Ok.
Similarly create one more attribute emp_name to store Employee Name.
Under Properties tab check import, export and click on Ok.
Click on Save and Save the Work flow.
Step 2: Registering Start Events for Workflow.
Click on basic data (hat symbol) as shown below.
Go to Start events Tab and select Category as CL (ABAP Class), Enter Class Name and Enter Event Name (you can select event from F4 help) as shown below.
Step 2.1: Binding Business Object Attributes to Workflow Attributes.
Click on binding as shown below
Here binding generated automatically with the matching types, if you don’t see this binding, bind manually by drag and drop from Class container to Workflow container.
Now you can see empid of Business Object is mapped with emp_id of Workflow Container. Click on OK.
Step 2.2: Activating Start Event for Workflow
Click on Activate as shown below.
Once activated it turns to green.
This means once the REGISTERED event of Class ZCL_WF_DEMO is triggered, the Workflow will Start.
Click on Save and go back to main screen.
Step 3: Creating Task
Double Click on the Undefined Step as shown below.
Select Activity Step and click on Ok.
Click on Create Task as shown below.
Enter abbreviation, Name. Under Object method, select Object category as ABAP Class. Enter Class Name and Method Name (You can select method from F4 help) as shown below.
Select the check box ‘Synchronous object method’. ( If you don’ t select the ‘Synchronous’ , for Asynchronous method you need to maintain the Terminating Events, In terminating events select the element _WI_OBJECT_ID and select the event name using F4 )
Under Execution Select Background Processing, since no user interaction is required for our scenario.
Click on Save and Click on Back Button.
It will prompt to Transfer missing elements. Click on Yes. (You can also click on No and create elements manually).
Now Click on Ok.
Continuing in next part How to create and trigger class based workflow – part 3 ( as the maximum no.of images reached )..
Again; nice work my friend. I just have a comment on the transaction used to create workflow templates. While SWDD will work just fine as you described, PFTC provides a more logical approcah as you start by defining the header and main container elements before going into the workflow builder to define the different steps.
Good Work..
Excellent work Kiran 🙂
One query: After binding task to get employee Name, while clicking on Transfer button, Is it mandatory to provide Agent assignment for that task (i.e. Here Activity Task 000004) - which can be shown under Task Properties with yellow or red button of Agent assignment?
Good... keep it up...
One query: After binding task to get employee Name, while clicking on Transfer button, Is it mandatory to provide Agent assignment for that task (i.e. Here Activity Task 000004) - which can be shown under Task Properties with yellow or red button of Agent assignment?
Hi,
Have you selected background processing checkbox? . For background processing no need of agent assignment. If you dont select background processing( Foreground ) agent assignment is required. In this scenario as no user interaction is required, select background processing. Normally for agent assignment, click on yellow button under task properties and assign the agent.
Best Regards,
Kiran
Yes, Background processing checkbox also selected in my case, Moreover for agent assignment under task properties corresponding button displayed as red colour and not allowing to click on transfer button as asking for Agent.
Is somewhere settings need to be changed? Or any other ?
Hi,
It seems like configuration problem. check swu3 configuration. Als check wf-batch user exists or not. check whether job SWWDHEX was scheduled with report RSWWDHE.
Best Regards,
Kiran.
Thanks Kiran. Do you mean it while executing SWU3 config, all the contents of left-hand panel should be in Green colour status? What can be done if not in Green colour?
How can I check if WF-BATCH user is having all the authorizations? What can be done if job SWWDHEX taking much time for execution or getting cancelled?
Hi,
Please check with your basis team. WF-BATCH user will be created automatically, once we execute the automatic customization, at that time the authorization of user who executed it will be transferred to the wf-batch. Ask your basis team to create wf-batch with SAP_ALL authorization. please check this help docu for reference : http://help.sap.com/SAPHELP_NW04s/helpdata/EN/a0/28e937a5caba6ee10000009b38f842/content.htm
<<How can I check if WF-BATCH user is having all the authorizations?>>
goto SU01 enter WF-BATCH and click on display. goto profiles tab, there you can see SAP_ALL authorization.
Best Regards,
Kiran
Hi kiran,
i followed above example but i got a problem in workflow the event is not triggering but wf template triggering but another problem at task also every work item say's in process only
what is the problem can u help me.
Regards
Mahesh
Great work.........Very usefull document....Thanks kiran
Good Job.
Hi Kiran,
I created custom class and tagged the class to the task. But I see some issue in Binding. In the class I have notification I'd as key attribute. Based on this key attribute, I am fetching multiple approvers and adding recipients using CL_BCS to send email.
While executing workflow.. I get error at the email step. In the error log details I see notification I'd is not set.
I guess there is issue in Binding. I'm new to workflow. Can you help?
Thanks
Shanthi
Hi,
In our case we have more than 32 character key fields, How we can proceed this.
For all PA info types we have 34 character key fields so Please let me know how i can proceed this.
Thanks and Regards,
Nishant