Flexible Workflow: Custom Flexible Scenario – Part 2
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.
Go to the control tab of the flexible block. Double click on the runtime class created.
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.
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
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.
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
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.
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.
Thank you 🙂