Technical Articles
Flexible Workflow: Custom Flexible Scenario – Part 2
Context
In the previous blog(Part 1), we created a custom flexible scenario & created the required activities & conditions. In this blog, we will configure & test the scenario.
Solution
Go to the control tab of the flexible block. Double click on the runtime class created.
Runtime Class
Based on your requirement, you can use the class methods available to call the code to perform the operation on approval. I have used the method result_callback, which on completion of approve/reject, does the necessary operations.
In the method result callback, I have written a piece of code to change the status of the workflow from created to activated.
Data: ls_por type sibflpor.
Data(ls_result) = io_result->get_result( ).
DATA(lo_cont) = io_context->get_workflow_container( ).
Move-corresponding io_context->get_leading_object_reference( ) to ls_por.
If ls_result-nature = ‘POSITIVE’.
**write your operation code here
Endif
The structure LS_POR contains the Object key, in this case the company code & Contract number.
The structure LS_RESULT contains the step response of Approve/Reject. Approve is positive & Reject is negative.
The structure LO_CONT contains the workflow container values.
Workflow Trigger
Once all this is step up, you need to call the workflow using SAP_WAPI_CREATE_EVENT FM.
Find a Exit or BADI based on whichever scenario you are working on. I used BADI_RECN_CONTRACT. On save of the contract, I called the workflow trigger method in the BADI implementation
Workflow Trigger
Note: This will only trigger the workflow if there is a workflow created in manage workflow app & it meets the conditions specified.
Configuration & Testing
Now, the workflow is active & trigger is in place. Next, let us test it.
Before we test it, there are 2 things we need to have.
- Make sure the user who creates new workflow in the scenario has S_WFFLXDEF authorization object assigned.
- Add the catalog tile SAP_BASIS_TCR_T to the user. This will provide you with the Manage workflow App tile. It will show the custom workflow created along with all the other existing ones in the list.
Manage Workflow App
The one I created is RE-FX Contract Activation.
Tip: You can also create your own Fiori tile for workflows. Below screenshot will give you an idea on creating a separate Fiori tile for your workflows. You can copy the same details as below. You just have to change the scenario ID to your custom workfow ID
Fiori tile configuration for flex workflow
custom flexible workflow tile
Note: If you cannot find the scenario, then go to the below path in SPRO and make sure your scenario is activated.
SAP Netweaver->Application Server->Business Management->SAP Business workflow->Flexible Workflow->Scenario Activation
Now your workflow is all set. Go to your scenario in Fiori launchpad tile, add a new workflow. Give start conditions, add the step and activate.
Start Conditions
Step Sequences and User Assignment
Notification
Conclusion
We have successfully created & tested a custom flexible workflow from scratch. I hope this will give you an idea on how to create a custom workflow for your requirements. There are further more possibilities with regards to flexible workflow. Hopefully will cover more of those in future blogs (Part-3, Part-4).
Thank you 🙂
Nice explanation, keep it up.
Thank you 🙂
Excellent buddy. Its just self explanatory and easier to understand as well.
Waiting for your next blog on this topic.
Regards
Sri Ram
Thanks a lot Sri.
Hi Aymen,
Nice blog with detail steps, but in the initial Screen shots you have mentioned BUS1505 but in the BADI, under Fm SA_WAPI_CREATE_EVENT you have mentioned ZBUS1505 and Event - ZCREATED, please confirm if we need to create Custom BO. I am trying to create similar workflow for Debit Memo Approval and using standard BO - BUS2096 but it gives error -SAP node type for leading object could not found (BO BUS2096) when i try to test it from Workflow Builder.
Hello Quamer,
Thanks for the feedback. You do not need a custom BO unless you are using a custom event or method in the workflow. I have changed the FM code in the blogpost. Thanks for pointing it out.
Now, coming to your error, it is because you did not maintain a Leading Object. Create a container using your BO as BOR Object and add that in the leading object. Now activate your workflow & it should work fine.
Hi Quamer,
Did you solve your problem "node type for leading object could not found" ?
I have the same problem with another object although I created a container for it and indicated the container in the leading object as Mohammed told you.
Great documentation
Do you know if there is a way to link Responsibility Management to Agents on Custom Flexible Workflow?
Hello Anish,
As of now, we do not have an option to create custom Team Category in SPRO which can be mapped to Responsibility Management for custom workflows. There are only standard ones available.
So for now the only options available is Role & User based Agent assignment.
Hi Mohammed,
Thanks for the blog.
I have a requirement when I'm creating a project through custom tcode. If the user is having SAP ID only ,then it should trigger to SAP(SBWP) only. If suppose the user is having Fiori ID means then it should trigger to fiori system only. Could you guide me how to achieve this.
Thanks in advance.