Tuesday, 13 October 2020 06:07

Flexible Workflow: Custom Flexible Scenario – Part 2

Written by Mohammed Aymen
Rate this item
(0 votes)
“© 2020. SAP SE or an SAP affiliate company. All rights reserved.” “Used with permission of SAP SE”

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%20Class

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%20trigger.

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.

  1. Make sure the user who creates new workflow in the scenario has S_WFFLXDEF authorization object assigned.
  2. 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%20Workflow%20App

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%20tile%20for%20workflow

Fiori tile configuration for flex workflow

custom%20flexible%20workflow%20tile

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%20Conditions

Start Conditions

Step%20Sequences%20and%20User%20Assignment

Step Sequences and User Assignment

Create a contract in SAP and test it.

Notification

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.

Thank you ?

Read 50 times

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.