Hello everyone,
There was a requirement in a project that the users wants to control project creation with workflow. Project Builder (CJ20N) screen does not have standard workflow process working behind. First of all we need to find the triggering event works behind Project Builder (CJ20N) screen. In my case I need to start workflow process after creating project.
In this blog I will show you how to reach the standard class, events and event parameters to trigger and design a workflow.
Step 1- Figure Out How To Trigger The Workflow
Step 2- Create Global Class
Step 3- Event Linkage Configuration
Step 4- Triggering Workflow
Step 5- Debug and Find Parameters
The questions comes up through my mind.
To answer these questions I start searching and find some FMs which are;
And tried to debug those FM for finding the events and the event container but didn’t work for me.
So I decided to check event trace. For finding the event we gonna go Tcode SWELS and Switch Off the trace and Switch On again to generate the event trace.
After we switch on again, go Tcode SWEL for finding out what is the class and the event for our process. Our standard class and event is CL_PS_WBSELEMENT_EVENT-WBSELEMENTCREATED.
We need a global class for triggering the workflow we gonna design and also we need it for reaching the event parameters we find in step 1.
When we go to SWE2 for the event linkage and find our class and its event and double click on it we see how the standard event is configured and we need to make a ‘z’ configuration.
In this standard configuration we saw that SAP used an interface BI_EVENT_HANDLER_STATIC that we need in our global class to trigger the workflow and reach the event parameters.
Go to SE24 and create a class and implement the interface.
There is a method of an interface called ON_EVENT and when you implemented the interface it will show up in the methods section.
Let’s leave this method for now after steps 3 and 4 we are gonna use this to reach event parameters.
In Step 2.1 we found the standard version of linkage for our class and its event now we are gonna make the configuration for trigger the workflow.
Go to transaction SWDD to build a workflow.
Once you create your workflow you need to activate it to have a workflow number which starts with WS. We need that WS*** number for configuration in SWE2.
Go to transaction SWE2 and copy our standard class with the needed event. For my case I need the creation event.
Receiver type is our workflow number that starts with WS*** and class name will be our Z class so we can reach the parameters. The checkbox Linkage Activated must be chosen to complete and generate configuration.
Go to transaction SWDD again and implement the Start Event to trigger workflow.
Do not forget to activate and make the bindings of the event.
Now we all set. For triggering workflow all we need is go transaction CJ20N and create a project. Once the project created the workflow will be triggered and can be seen from transaction SWIA.
Place an external debug for user SAP_WFRT on the Z class ON_EVENT method.
Complete the steps for CJ20N. On the debugger screen’s locals tab you will see EVENT_CONTAINER and inside of the event container you can reach the parameters you need.
And you can simply use the below code in ON_EVENT method to get those parameters to use. For my case I needed WBSELEMENTINTERNALID you can use any other element container parameter name.
TRY.
CALL METHOD event_container->get
EXPORTING
name = 'WBSELEMENTINTERNALID'
IMPORTING
value = lv_wbsinternalid.
CATCH cx_root.
ENDTRY.
Now you can design your workflow behind transaction CJ20N and use it.
Thanks for your time.
If you think this blog is helpful please do not forget to like and share. 🙂.