Monday, 17 August 2020

Custom Flexible Workflow steps

Introduction


In this blog post, you will see how to create and configure a complex Custom Flexible Workflow for Purchase Order approval.

Below is the example scenario:
  • When the Purchase Order is created, it should be sent to the approver’s Fiori inbox for approval
  • If Contract is used in the Purchase Order and if the Purchase Order total amount is equal to Contract total amount, then auto approve the Purchase Order
  • The approval amount limit (we will call it – DOA limit) should be maintained in a custom table.
  • If the first level approver has enough DOA limit, then the workflow ends after the first level approval and the PO is released; If the first level approver does not have enough limit, then the workflow flows to second level approval and so on.

Solution


The following steps are followed to implement the requirement.
  • Create Custom Flexible Workflow
  • Configure Custom Flexible Workflow
    • Scenario Definition
    • Scenario Activation
    • Activate Flexible Workflow for Purchase Orders
  • Agent Determination Rules
    • Creating Rules
    • Include Rules in Custom Flexible Workflow
  • Custom Standard Tasks
    • Create Custom Standard Tasks
    • Include custom Standard Tasks in Flexible Workflow
  • Defining Custom Conditions
  • Defining scenario in the Fiori App
Step#1: Create Custom Flexible Workflow:

To create your own custom flexible workflow for purchase order, copy the standard flexible workflow template number WS00800238.

Activate the event linkage in the Triggering Events tab.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

Step#2: Scenario Definition

Define a new scenario for the Custom Flexible workflow in the below mentioned path.

SPRO > SAP NetWeaver > SAP Gateway Service Enablement > Content à Task Gateway > Task Gateway Service à Scenario Definition

Copy the standard scenario “WFL_FOR_PO” in to the custom one.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

Select the custom Scenario Definition and double click on the Task Definition for Scenario option in the left pane.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

Step#3: Scenario Activation

Activate the scenario defined in the above step. Follow the below path to activate the scenario.

SPRO > SAP NetWeaver > Application Server à Business Management > SAP Business Workflow > Flexible Workflow à Scenario Activation.

Click on New Entries button to add and activate the custom scenario. Deactivate the standard scenario.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

Step#4: Activate Flexible Workflow for Purchase Orders

Activate the Flexible Workflow for Purchase Orders based on the document types in the below mentioned path. The flexible workflow will trigger only for the documents type which are maintained in the below mentioned path.

SPRO > Material Management > Purchasing > Purchase Order > Release Procedure for Purchase Orders > Activate Flexible Workflow for Purchase Orders.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

Step#5: Creating Rules

Create the custom rules to determine the agents at level 1 and level 2 in transaction PFAC. The below two rules were created based on the function modules. The function modules contain the logic to determine the agents from the custom table.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

The level 2 agent is called financial approver with DoA limit.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

Step#6: Include Rules in Custom Flexible Workflow

The new custom rules can be included in the Flexible workflow as below.

◉ Go to SWDD transaction and open the Flexible workflow.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

◉ Double click on the Approve Purchase Order Scenario task. The following screen open.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

◉ Go to Rules tab and add the rules that are created in the above step. There would be some standard rules which are already defined. Click on Create button to add the custom rules in that list. Please refer to below screenshot in which the custom rules are added and highlighted.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

While adding the rules in the flexible workflow, you can bind elements from workflow container to rule container.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

Step#7: Create Custom Standard Tasks

This standard task TS90000005 checks the DoA limit of the previous approver.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

This standard task TS90000012 compares the PO total value with the Contract total value.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

Step# 8: Include custom Standard Tasks in Flexible Workflow

◉ Go to SWDD transaction and open the Flexible workflow.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

◉ Double click on the Approve Purchase Order Scenario task. The following screen open.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

◉ Go to Activities tab and add the custom standard tasks that are created in the above step. There would be some standard tasks which are already defined for Auto Release and Release of Purchase Order. Click on Create button to add the custom standard tasks in that list. Please refer to below screenshot in which the custom standard tasks are added and highlighted.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

While adding the custom standard tasks in the flexible workflow, you can bind elements from workflow container to task container.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

Step#9: Defining custom conditions

Custom conditions can be defined in the custom Flexible workflow. The newly created condition can be defined as starting condition. It means it can be defined as Start Condition for the workflow.

◉ Go to SWDD transaction and open the Flexible workflow.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

◉ Double click on the Approve Purchase Order Scenario task. The following screen open.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

◉ Go to Conditions tab and add the custom conditions here. There are some conditions which are already there. Click on the Create button to add a new condition in the flexible workflow. Give a unique name, Short Text, and Description of the condition.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

The highlighted condition is added. The Start Condition checkbox is not checked. Due to this it can not be used as start condition for Flexible workflow. But it can be used as Start Condition for Standard Task execution.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

We need to define the parameter for this condition. The value entered on the Fiori screen will be stored in this parameter. Select the condition and click on the Parameter button define the parameter name.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

After defining the parameter name, click on the Condition button to define the condition.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

In this way, we have defined the multiple conditions which are highlighted below

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

Step#10: Defining scenario in the Fiori App

Login to the Fiori launchpad. Click on the Manage Workflows app to define the scenario.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

Click on the Add button to define the Flexible Workflow Scenario. Give the title and description to the scenario. Also provide the validity start date and validity end date to the scenario.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

Go to Preconditions section to define the start condition.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

Go to the Step Sequence tab to define the steps. Click on the ADD button to add the step in the workflow.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

You can also have the pre-conditions added into the Steps. Also assign the rules to the step so that the workitem flows to the actual agent for approval.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

Similarly, added multiple steps in sequence to define the workflow.

SAP Fiori,SAP HANA, SAP HANA Cloud, SAP HANA Rules Framework, SAP S/4HANA, SAP S/4HANA Cloud

No comments:

Post a Comment