SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (2024)

Introduction

In this blog post I will share my requirements and solution on adding Custom Pre-Conditions in Flexible Workflow for Overall Release of PR approval. I have also shown below how to add value help for the precondition defined.

Requirement


  • Add following preconditions to the “Manage Workflows for Purchase Requisitions” F2705 App in S4HANA 2021:



  1. Account Assignment Category

  2. Plant

  3. Requisitioner



  • Add F4 value help to the above defined preconditions.

Environment

S4HANA on Premise 2021, SAP S/4HANA 2021, S4CORE 106

Solution

SAP has given some standard predefined conditions while configuring a flexible Workflow for Purchase Requisition Approval, but we can also add our own pre-conditions.

To add custom new preconditions in Flexible Workflow SAP has given a BADI SWF_WORKFLOW_CONDITION_DEF to enhance and add your required fields in the preconditions tab.

Along with this we also need to add evaluation logic for these custom defined pre-conditions in BADI SWF_WORKFLOW_CONDITION_EVAL.

So basically BAdI SWF_WORKFLOW_CONDITION_DEF allows you to create the fields for key and value to add in the start and step conditions and SWF_WORKFLOW_CONDITION_EVAL helps in valuating the value part of these fields.

Now let’s begin.!

#STEP 1:

SWF_WORKFLOW_CONDITION_DEF Implementation

First we need to activate and assign Custom Logic App to our id in S4HANA (which I have already done, will try to add a blog for this information too 🙂 ).

Open Custom Logic App > Tab Custom Logic > "+" icon at the top right corner next to search bar:

SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (1)


Custom Logic App

Now you will see a pop-up window to add new enhancement implementation, enter following details to create the new implementation for Pre-Conditions:

Business Context: Procurement: Start and Pre-Conditions in Flexible Workflow (select from dropdown help)

BAdI Description: Providing additional conditions for scenarios (select from dropdown help)

Implementation Description: Add Preconditions for PR Scenario (this is custom text can be changed as per your requirement)

Implementation ID: PRECONDITIONS (custom text can be changed as per your requirement)

SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (2)


Pre-Condition Implementation Details

Once added a new implementation will get created and you will be navigated to the screen as below:

SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (3)


Pre-Condition Implementation Draft

The implementation gets created with a sample logic for reference.

Click on Filter tab and “+” icon to add you scenario id so that these preconditions will only be added to that scenario.

SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (4)


Scenario Id added to Filter Tab

In our case I have added scenario_id = WS02000458 ( this scenario is for Overall PR Release)

Click on SAVE.

To check other scenarios, you can refer to this SAP help link:

https://help.sap.com/docs/SAP_S4HANA_ON-PREMISE/af9ef57f504840d2b81be8667206d485/a84badfeaf0445f4bed...

Next, we have following parameters in the code:


  • CT_CONDITION


Fields -

ID: Unique ID of the additional condition

subject: Name of the additional condition

type: Condition to be added at step level (type =

if_swf_flex_ifs_condition_def=>cs_condtype-step)

or

at both of step level and workflow level (type = if_swf_flex_ifs_condition_def=>cs_condtype-start_step)


  • CT_PARAMETER

Fields-

ID: Unique ID of the additional condition

Name: Name of the additional condition

xsd_type: Data type of the additional condition (supported data types are Boolean, date, string, integer, and time)

mandatory: To indicate the additional condition is mandatory.

service_path – the service path of your OData Service

entity – the Value Help entity of your OData Service

property – the field/property in your OData Service for your field value.

In my case for Account Assignment Category and Plant I have used SAP standard CDS “S_MMPURWorkflowVH” and its equivalent OData service “S_MMPURWorkflowVH_CDS”.

Entity exposing these fields is “S_MMPURWorkflowVH”

For Requisitioner value help we are using a custom table ZPR_DEPT, hence I created a CDS view value help exposing the values of this table which you can check at the end of this blog.

Add the code as below:


  1. Create two data variables to append to ct_condition and ct_parameter.
    data : ls_condition like line of ct_condition.
    data : ls_parameter like line of ct_parameter.


  2. Define condition for Account Assignment Category, OData service used for value help is standard “S_MMPURWORKFLOWVH_CDS” and entity used is 'S_MMPURWorkflowVH'
    * Acc Assignment Category condition
    ls_condition-id = 'idAcc'.
    ls_condition-subject = 'Account Assignment Category is'.
    ls_condition-type = if_swf_flex_ifs_condition_def=>cs_condtype-start_step.
    append ls_condition to ct_condition.

    ls_parameter-id = 'idAcc'.
    ls_parameter-name = 'AccAssgnmtCate'.
    ls_parameter-xsd_type = if_swf_flex_ifs_condition_def=>cs_xstype-string.
    ls_parameter-service_path = '/sap/opu/odata/sap/S_MMPURWORKFLOWVH_CDS'.
    ls_parameter-entity = 'S_MMPURWorkflowVH'.
    ls_parameter-property = 'AccAssgnmtCat'.
    ls_parameter-mandatory = abap_false.
    append ls_parameter to ct_parameter.



  3. Define condition for Plant, OData service used for value help is standard “S_MMPURWORKFLOWVH_CDS” and entity used is 'S_MMPURWorkflowVH'
    * Plant condition
    ls_condition-id = 'id_Plant'.
    ls_condition-subject = 'Plant is'.
    ls_condition-type = if_swf_flex_ifs_condition_def=>cs_condtype-start_step.
    append ls_condition to ct_condition.

    *Parameter for Workflow level condition - Plant
    ls_parameter-id = 'id_Plant'.
    ls_parameter-name = 'Plant'.
    ls_parameter-xsd_type = if_swf_flex_ifs_condition_def=>cs_xstype-string.
    ls_parameter-service_path = '/sap/opu/odata/sap/S_MMPURWORKFLOWVH_CDS'.
    ls_parameter-entity = 'S_MMPURWorkflowVH'.
    ls_parameter-property = 'Plant'.
    ls_parameter-mandatory = abap_false.
    append ls_parameter to ct_parameter.



  4. Define condition for Requisitioner, OData service used to value help is custom “ZC_PR_DEPT_VH_CDS” and entity used is ''ZC_PR_DEPT_VH’ (At the end of this blog I have shown how to create CDS view and OData service for this.)
    * Requistioner Condition
    ls_condition-id = 'id_Req'.
    ls_condition-subject = 'Requisitioner is'.
    ls_condition-type = if_swf_flex_ifs_condition_def=>cs_condtype-start_step.
    append ls_condition to ct_condition.

    ls_parameter-id = 'id_Req'.
    ls_parameter-name = 'Requisitioner'.
    ls_parameter-xsd_type = if_swf_flex_ifs_condition_def=>cs_xstype-string.
    ls_parameter-service_path = '/sap/opu/odata/sap/ZC_PR_DEPT_VH_CDS/'.
    ls_parameter-entity = 'ZC_PR_DEPT_VH'.
    ls_parameter-property = 'ReqDept'.
    ls_parameter-mandatory = abap_false.
    append ls_parameter to ct_parameter.



Final Code will look like this:

SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (5)


SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (6)

Now, click on “Save Draft” at the bottom of your screen and then click on “Test” to check your code.

SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (7)

After this once you click on “Publish” your changes will get activated and published in the system.

PLEASE NOTE: fields you add in the pre-conditions please add in Alphabetical order i.e., Account Assignment first then Plant and then Requisitioner, if not added in this order while testing the logic you will get error.(this is something I figured out on my own and I did not find in any of the blogs, so sharing here hoping it will save someone’s time and no one will bang their head on wall thinking where they went wrong.)

#STEP 2:

SWF_WORKFLOW_CONDITION_EVAL Implementation

Ok, so now moving on to adding evaluation implementation.

Same steps: Custom Logic > + > Add Implementation Details > Create.

Please note this time select BAdI “Value evaluation of additional conditions for scenarios.”

Business Context: Procurement: Start and Pre-Conditions in Flexible Workflow (select from dropdown help)

BAdI Description: Value evaluation of additional conditions for scenarios (select from dropdown help)

Implementation Description: Evaluation of additional conditions for PR scenario (this is custom text as per your needs)

Implementation ID: VALUATEPRECONDITIONS (custom text as per your needs)

SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (8)


Evaluation Implementation Details

Add the filter for Scenario id :

SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (9)

You will see some sample code for reference.

Parameters:


  • IS_SAP_OBJECT_NODE_TYPE

Fields -

SONT_KEY_PART_1-> Purchase requisition number

SONT_KEY_PART_2 -> Purchase requisition item number


  • IS_CONDITION

Fields -

condition_id -> Unique ID of the additional condition


  • IT_PARAMETER_VALUE

Fields -

Name -> Name of parameter in workflow in Manage workflow app.

Value -> Value of parameter mentioned in workflow in Manage workflow app


  • CV_IS_TRUE (Should be set as true if the additional condition evaluation is successful)

  • I_PurchaseRequisitionItemAPI01 – CDS entity for PR header and item

Logic added as below:


  1. Reading PR details from API I_PurchaseRequisitionItemAPI01 into a local table


IF is_sap_object_node_type-sont_key_part_2 IS INITIAL.
SELECT * INTO TABLE @DATA(lt_purchaserequisition)
FROM i_purchaserequisitionitemapi01
WHERE purchaserequisition = @is_sap_object_node_type-sont_key_part_1.
ELSE.
SELECT * INTO TABLE @lt_purchaserequisition
FROM i_purchaserequisitionitemapi01
WHERE purchaserequisition = @is_sap_object_node_type-sont_key_part_1
AND purchaserequisitionitem = @is_sap_object_node_type-sont_key_part_2.
ENDIF.


  1. Reading parameter table with Pre-condition value for Account Assignment Category and compare it with the value from PR data. Please note that the key name needs to match with the parameter name defined in the pre-condition BAdI. In this case, it is 'AccAssgnmtCate'


READ TABLE lt_purchaserequisition INTO DATA(ls_purreq) INDEX 1.
READ TABLE it_parameter_value INTO DATA(ls_param_acc) WITH KEY name = 'AccAssgnmtCate'.
IF sy-subrc EQ 0.
CONDENSE ls_param_acc-value NO-GAPS.
CONDENSE ls_purreq-accountassignmentcategory NO-GAPS.
IF ls_param_acc-value = ls_purreq-accountassignmentcategory.
cv_is_true = abap_true.
ELSE.
cv_is_true = abap_false.
ENDIF.
ENDIF.

Similarly for Plant and Requisitioner:

READ TABLE it_parameter_value INTO DATA(ls_param_plant) WITH KEY name = 'Plant'.
IF sy-subrc EQ 0.
IF ls_param_plant-value = ls_purreq-plant.
cv_is_true = abap_true.
ELSE.
cv_is_true = abap_false.
ENDIF.
ENDIF.
READ TABLE it_parameter_value INTO DATA(ls_param_req) WITH KEY name = 'Requisitioner'.
IF sy-subrc EQ 0.
IF ls_param_req-value = ls_purreq-requisitionername .
cv_is_true = abap_true.
ELSE.
cv_is_true = abap_false.
ENDIF.
ENDIF.

Entire code would look something like this:

SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (10)


SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (11)


#STEP 3:

Configure Workflow:

Now when we open the “Manage Workflows for Purchase Requisitions” F2705 App, we will be able to see our preconditions along with Value help window to select from.

SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (12)

Click F4 for value help window:

SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (13)


SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (14)


SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (15)


SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (16)


#STEP 4:

Custom CDS View and OData Service for Value Help:

Now, let us see how to create CDS view for Value help.

As already mentioned above in my case we have a custom table to where we are maintaining Requisitioner data.

SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (17)


  1. I created a base CDS view first to expose the Req_Dept field from this table:


@AbapCatalog.sqlViewName: 'ZBPRDEPT'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Base View exposing ZPR_DEPT'
@VDM.viewType: #COMPOSITE
@ObjectModel.representativeKey: 'ReqDept'
@Search.searchable: true
define view ZB_PR_DEPT as select from zpr_dept {
@Search.defaultSearchElement: true
key req_dept as ReqDept
}


  1. Create a consumption CDS view which will be exposed as OData service for value help:

Use OData.publish annotation to publish OData service and Consumption.valueHelpDefinition to create value help on the base CDS view created above.

@AbapCatalog.sqlViewName: 'ZCPRDEPTVH'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Value help for Requisitioner Dept'
@ObjectModel.dataCategory:#VALUE_HELP
@OData.publish: true
@ObjectModel.createEnabled: true
define view ZC_PR_DEPT_VH as select from zpr_dept {
@Consumption.valueHelpDefinition: [{entity: { name: 'ZB_PR_DEPT',
element: 'ReqDept' }}]
key req_dept as ReqDept
}


  1. Activate the CDS views and go to Tcode : /n/IWFND/MAINT_SERVICE to add and generate metadata of the newly created OData service in the system.

Test in gateway client the service should execute with entity ZC_PR_DEPT_VH:

SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (18)

That's all from my side friends. Hope this blog helps someone who is new and looking out for more information on Flexible Workflows. I will try to add more parts to this series mentioning my entire end to end Overall PR Release requirement and solution including details on Configuring multi-level approval in Flexible WF with alternative preconditions, activating and maintaining email templates and configure My Inbox and test end to end PR creation with approval.

Thank you for your read.

Ciao.!

Tasneem Khilonawala

References:

https://launchpad.support.sap.com/#/notes/2767845

https://blogs.sap.com/2019/12/03/sap-s-4hana-cloud-flexible-workflow-with-new-custom-pre-condition-f...

https://blogs.sap.com/2020/07/06/f4-help-in-custom-pre-conditions-for-flexible-workflow-manage-workf...

SAP S/4HANA on Premise – Adding custom new Pre-Conditions with F4 Value help in Flexible Workflow for Overall Release of Purchase Requisitions (2024)

FAQs

How to add condition in flexible workflow in SAP? ›

The general steps of implementing the BAdIs are listed as below:
  1. Open the Custom Logic app as an Administrator.
  2. Create an implementation of BAdI Providing additional conditions for scenarios. ...
  3. On the Filter tab, enter the following filter conditions:
Oct 31, 2022

What is flexible workflow for purchase requisition in SAP? ›

The flexible workflow for purchase requisitions allows you to define one-step or multi-step approval processes for purchase requisitions according to your requirements. Approvers can then approve or reject corresponding work items in the SAP Fiori app My Inbox.

Which preparation steps must be performed for an SAP S/4HANA conversion? ›

Important phases of SAP S/4HANA conversion journey
  1. Planning and system requirements.
  2. Maintenance planner.
  3. SAP readiness check and simplification item (SI) catalog.
  4. Cross-application and application-specific preparation activities.
  5. Custom-code analysis.

What is flexible workflow in SAP S/4HANA? ›

Flexible Workflow is a new concept introduced in SAP S/4HANA with the objective of simplifying workflow configuration. Documents in Sourcing and Procurement, such as purchase requisition, purchase order, request for quotation, etc., usually go through an approval process.

How do I add conditions to workflow? ›

Set conditions
  1. In the left pane, click Basic Settings.
  2. Click Add condition.
  3. Enter a condition.
  4. Enter additional conditions, if they are required.
  5. To verify that the conditions that you entered are configured correctly, complete the following steps: Click Test to open the Test workflow condition form.
Jun 6, 2024

How do I start a condition in workflow? ›

This means that the start of a workflow no longer depends only on whether a specific event is created, but also on the occurrence of additional conditions. A workflow is to be started when a notification of absence has been created and the creator of the notification of absence belongs to a specific group of people.

How do you automate purchase requisition? ›

To solve these problems, a well-defined and automated process can be implemented with a BPM tool such as Qflow. This tool offers several advantages, given that: Standardizes and organizes purchase requisition processes. Streamlines communication with purchasing and procurement.

What triggers purchase requisition in SAP? ›

Direct purchase requisition: An employee creates the requisition manually in the system. Indirect purchase requisition: The system triggers the requisition automatically. The trigger is a specific event, for example, if stock falls below a set threshold.

What does hana stand for in SAP? ›

SAP HANA (High-performance ANalytic Appliance) is a multi-model database that stores data in its memory instead of keeping it on a disk. The column-oriented in-memory database design allows you to run advanced analytics alongside high-speed transactions – in a single system. Why is this so important?

What is SAP's recommended methodology for an SAP S 4HANA implementation? ›

SAP Activate is the unique combination of SAP Best Practices, methodology, content, and tools that helps customers and partners deploy SAP S/4HANA. A methodology for each of the deployment modes (cloud, on premise, hybrid) is SAP ACTIVATE.

Which are the three deployment options of SAP S 4HANA? ›

Regarding the implementation of the solution, SAP offers three options: S/4HANA Cloud Essentials Edition, S/4HANA Cloud Extended Edition, or S/4HANA AnyPremise. In this blog, we compare the three deployment options.

What are the 3 layers in SAP workflow? ›

3 layers: presentation, application, database. SAP Logon and SAP GUI are software which can be classified as belonging to the presentation layer.

Can we have multiple steps in the flexible workflow? ›

We can create multiple steps for each document workflow with various starting conditions and different recipients. The steps are executed according to the order set in the Steps section of the workflow creator. To run the created workflow, after saving all changes, you need to activate the workflow.

Which advanced functionality has been embedded in SAP S 4HANA? ›

Advance ATP: As it is stated in the SAP Support portal, Advanced Available-to-Promise (aATP) is a business function in SAP S/4HANA that provides a response to order fulfillment requests from Sales and Production Planning.

How do I create a rule in SAP workflow? ›

To create a new workflow rule, select New from the workflow rules worklist.
  1. Enter Basic Data. Enter the Description to identify the rule in the worklist. ...
  2. Define Conditions (Optional) In the Define Conditions step, click Add Group to define a condition. ...
  3. Define Rule Actions (Required) ...
  4. Review and Activate the Workflow Rule.

How do I start a condition in SAP? ›

The start condition determines when the queue server triggers indexing of the documents collected in the queue. The queue server regularly checks whether this start condition has been reached.

How do I create a custom flexible workflow in SAP ABAP? ›

Create a flexible workflow scenario with the transaction SWDD_SCENARIO - Flexible Workflow: Scenario Editor using ABAP class as the lead object and starting a workflow by triggering an event. Activate the parameter sap. bc. bmt.

Top Articles
Redneck Brawl 6 highlights and results: The Best and The Wildest
Big Little Brawlers Cast: Meet the Real People In the New Micro Wrestling Show (Photos)
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Toyota Campers For Sale Craigslist
Unlocking the Enigmatic Tonicamille: A Journey from Small Town to Social Media Stardom
Ncaaf Reference
Globe Position Fault Litter Robot
Crusader Kings 3 Workshop
Robert Malone é o inventor da vacina mRNA e está certo sobre vacinação de crianças #boato
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Nfsd Web Portal
Selly Medaline
Latest Posts
Article information

Author: Delena Feil

Last Updated:

Views: 6002

Rating: 4.4 / 5 (45 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Delena Feil

Birthday: 1998-08-29

Address: 747 Lubowitz Run, Sidmouth, HI 90646-5543

Phone: +99513241752844

Job: Design Supervisor

Hobby: Digital arts, Lacemaking, Air sports, Running, Scouting, Shooting, Puzzles

Introduction: My name is Delena Feil, I am a clean, splendid, calm, fancy, jolly, bright, faithful person who loves writing and wants to share my knowledge and understanding with you.