SAP Knowledge Base Article - Public

2767845 - How to define new Procurement Pre-conditions in Manage Workflow Apps.

Symptom

You want to use the new Custom Pre-Condition:  New BADI available in 1902 S4HC.

 You can define  new pre-conditions in Manage workflow app.You can use the Custom Fields and Logic app to create a BAdI implementation and publish the custom logic.

Environment

SAP S/4HANA Cloud

Reproducing the Issue

SAP has delivered a set or pre-conditions and step conditions. Customers can additionally define their own pre-condition / step condition using the custom BADI. New conditions can be defined using custom BADI SWF_WORKFLOW_CONDITION_DEF.      Once this BADI is implemented, then those pre-condition / step condition will be visible in the Manage Workflows app for the respective filter criteria.

The defined pre-condition / step condition needs to be evaluated against the newly created BO. That will be done using the custom BADI SWF_WORKFLOW_CONDITION_EVAL.

Both  BADI’s needs to be implemented in order to define and evaluate new custom pre-condition / step condition

Filter Conditions would be the scenario ID. The following are soem of the scenario ID’s  that can be used:

  1. WS00800157 - Release of Purchase Requisition Header Level
  2. WS00800173 - Release of Purchase Requisition Item Level
  3. WS02000434 - Release of Central PR Header Level
  4. WS02000438 - Release of Central PR Item Level
  5. WS02000458-  Release of Purchase Requisition for header level using the APP Manage Workflow for Purchase Requisitions – New
  6. WS02000471-  Release of Purchase Requisition for item level using the APP Manage Workflow for Purchase Requisitions – New
  7. WS00800251-  Workflow for blocked invoices
  8. WS00800303 - Workflow for parked invoices as complete
  9. WS00800238 - Workflow for Purchase Orders

 

You can find  2 new BADIS in the Flexible Workflow Framework:

BADi - SWF_WORKFLOW_CONDITION_DEF,  Method  : GET_CONDITIONS

Use : to define additional conditions for scenarios

BADi - SWF_WORKFLOW_CONDITION_EVAL,  Method  : EVALUATE_CONDITION

Use : to evaluate the additional conditions defined

 

Resolution

Check the following technical documentation and sample code for the BADIS:

 

BADi - SWF_WORKFLOW_CONDITION_DEF,  Method  : GET_CONDITIONS

Use : to define additional conditions for scenarios

Parameters :

  • 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

 

Sample code for adding additional condition delivery date at both step and workflow level:-

       ct_condition = VALUE #(

            ( id = 1 subject = 'BADI: Delivery Date is equal to'(006)     type = if_swf_flex_ifs_condition_def=>cs_condtype-start_step ) ).

    ct_parameter = VALUE #(

      ( id = 1 name = 'BADI: Delivery Date'(006)          xsd_type = if_swf_flex_ifs_condition_def=>cs_xstype-date   mandatory = abap_true )

).

 

BADi - SWF_WORKFLOW_CONDITION_EVAL,  Method  : EVALUATE_CONDITION

Use : to evaluate the additional conditions defined

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

 

Sample code for evaluating additional condition – Delivery date:-

data:

        lv_dlv_date type sydatum.

 

    IF ( is_condition-condition_id > 1 ).

      RAISE EXCEPTION TYPE cx_ble_runtime_error

        EXPORTING

          previous = NEW cx_swf_flex_lra( textid = cx_swf_flex_lra=>condition_not_supported ).

    ENDIF.

 

    cv_is_true = abap_false.

*

    IF is_sap_object_node_type-sont_key_part_2 IS INITIAL.

        SELECT  * INTO TABLE @DATA(lt_purchaserequisition)

          FROM i_purchaserequisition_api01

           WHERE purchaserequisition = @is_sap_object_node_type-sont_key_part_1.

    ELSE.

        SELECT  * INTO TABLE @lt_purchaserequisition

          FROM i_purchaserequisition_api01

           WHERE purchaserequisition = @is_sap_object_node_type-sont_key_part_1

             AND purchaserequisitionitem = @is_sap_object_node_type-sont_key_part_2.

    ENDIF.

 

    IF sy-subrc <> 0.

      RAISE EXCEPTION TYPE cx_ble_runtime_error

        EXPORTING

          previous = NEW cx_swf_flex_lra( textid = cx_swf_flex_lra=>object_instance_not_found ).

    ENDIF.

 

    READ TABLE it_parameter_value INTO ls_param_value

      WITH KEY name = 'BADI: Delivery Date'.

    if sy-subrc EQ 0.

      REPLACE ALL OCCURRENCES OF '-' in ls_param_value-value WITH '' IN CHARACTER MODE.

      lv_dlv_date = ls_param_value-value.

    endif.

 

    CASE is_condition-condition_id.

     WHEN 1.

        IF lv_dlv_date = lt_purchaserequisition[ 1 ]-deliverydate.

            cv_is_true = abap_true.

        Endif.

    ENDCASE.

 

Keywords

withdraw, badi, flexible, workflow, approve, my inbox , KBA , MM-FIO-PUR-REL , Fiori UI for Purchasing Approval , MM-PUR-REQ , Purchase Requisitions , How To

Product

SAP S/4HANA Cloud all versions