Skip to Content
Author's profile photo Yogesh Patil

How to… Better DECISION in Process Chain by using custom Formulas

Link to Content’s target Space :

Applies to:

SAP BW NetWeaver 2004s (BW7.0 or greater). For more information, visit the Business Intelligence homepage.

1. Business Scenario:

The business scenario for this document is that a customer has a need to use ‘Decision’ in Process chain based on Parameter set in custom table or based on output from different conditions and consistently uses the same in other Process chain decisions. In this example, Process chain takes decision based on entry maintained in TVARVC table. Instead of changing process chain, process chain executes steps based on TVARVC table entries maintained by Business or administrator.

2. Background Information:

Custom formulas are introduced into the ‘Decision Between Multiple Alternatives’ process type library of the Formula Builder by means of BAdi (Business Add-In) RSAR_CONNECTOR. The step by step solution that follows will demonstrate how to achieve this.

You can view the definition of the BAdi in transaction SE19 with BAdi name RSAR_CONNECTOR.

3. Pre-requisites

There are no prerequisites for this How-To-Guide, however the following reading material will help if you are not familiar with ABAP Classes and Method:

Reference 1 – ABAP Business Development and Service Provisioning

Reference 2 – Creating, Editing, and Deleting Enhancement Implementations

4. Step-By-Step Procedure

The guide starts you off by creating a BAdi implementation. This implementation will generate a class which we will use to store our custom functions (implemented as methods) in. When the custom methods are written and activated, we can then reference them in our BAdi implementation. Once linked, we will have them available in the Process Type ‘Decision’ in Process chain maintenance.

For this example, we will use TVARVC table entry which will decide what process flow/steps executed in Process chain.

4.1 Create Implementation for BAdi RSAR_CONNECTOR.

    • Go to t-code SE19 -> Create Implementation -> Classic BAdi. Give BAdi Name as ‘RSAR_CONNECTOR’ and click on ‘Create Impl’ button.
    • Provide name of Implementation and click ‘OK’

Implementation Name.JPG

    • This will take you to the definition of the implementation. Provide suitable description to the Implementation.

Implementation Name-02.JPG

    • Press the activate button on the toolbar in order to activate your implementation and its underlying objects.

     Remember the name of the implementing class you can see in the screenshot (ZCL_IM_DEMO_CUSTOM_FUNC), we will use this later to store our methods.

4.2 Create custom methods i.e. custom formula

    • Go to transaction SE24 in order to edit Class ZCL_IM_DEMO_CUSTOM_FUNC. Alternatively, instead of using the class generated from creating the implementation, you could implement your own class with methods.


    • Press ‘Change’ button. On the ‘Methods’ tab you can implement as many custom methods as you wish. In the below screenshot, 1 custom method is visible: C_DEMO_FUNC.


    • C_DEMO_FUNC is given name to method. Choose Level as ‘Static Method’, Visibility as ‘Public’ and give suitable Description.
    • Once your method has a name and attributes, proceed to defining its parameters by pressing the ‘Parameters’ button.
    • Maintain Importing and Exporting Parameter as shown below. Remember that, you can have importing, exporting or returning parameter, no changing parameter allowed. Most important thing is, you can have only one Exporting parameter.


    • Once you maintained Parameters, click on ‘Methods’.
    • Double-click on the Method name (C_DEMO_FUNC) to view method code.
    • Enter code between the sections “METHOD <method name>. ENDMETHOD.” Remember to use your parameters exactly as you have named them on the parameter definition screen for your method. In the screenshot, you will see that we pass the ‘I_RULE_NAME’ to ‘where-clause of SELECT statement performed on TVARVC table to return ‘E_STATUS’.


    • Activate your method.

4.3 Integrate custom methods into your implementation

    • Go back to transaction SE19, and in the ‘Edit Implementation’ section, change the radio button to ‘Classic BAdi’ and enter BAdi name ‘ZDEMO_CUSTOM_FUNC’.
    • Click on ‘Change’ button.
    • Press “CTRL+F4” to deactivate your implementation.
    • Double-click on the ‘GET’ method on the ‘Interface’ tab in order to incorporate your custom methods as formulas
        • Note:
          • The ‘GET’ method allows us to do two things:

            • Firstly we get to create new categories for custom formulas (optional)

            • Secondly we get to assign custom formulas to those new groupings or alternatively to the default grouping.

    • Initially the method will be empty.
    • Write below code –



     CASE I_KEY.

          WHEN ‘CUSTOM’.

               CLEAR: L_FUNCTION.

                 L_FUNCTIONCLASS      = ‘ZCL_IM_DEMO_CUSTOM_FUNC’.

                 L_FUNCTIONMETHOD     = ‘C_DEMO_FUNC’.

                 L_FUNCTIONTECH_NAME  = ‘C_DEMO_FUNC’.

                 L_FUNCTIONDESCRIPTN  = ‘Demo Rule’.




    • Here-
      • When I_KEY is populated as ‘CUSTOM’, it is referring to a category name for customer use in which you want to place your custom formulas. In this section appending to c_operands creates a new function within that category.
      • CLASS – this is class you defined above where the formula method is implemented
      • METHOD- The method which you have defined in your class to define your formula.
      • TECH_NAME- Give technical name to your Function. This should always start with C_ and should be in CAPITAL letters.
      • DESCRIPTN- Give description to your function.
      • The TECH_NAME and DESCRIPTN will appear in Formula Builder of the Decision process maintenance screen.
      • ‘CUSTOM’ is predefined category provided to user to categorize their custom defined functions in Formula Builder.
    • Activate the GET method using the activate button on the toolbar.
    • Go back one screen and activate your implementation.

4.3 View in Formula Builder of DECISION of the process chain

    • Go to Maintenance screen of the Process Type ‘ Decision’ in Process Chain.


    • Click on ‘Create’


    • Give Long Description
    • In right hand side, in ALL Function drop down, you will see – ‘User Defined Functions’.
      • Note: If no single custom function created before, you will not have this option available. As soon as you create your first function, it will start displaying this category. This category is nothing but ‘CUSTOM’


    • Select ‘User-Defined Function’, it will show you your created function as below-


    • According to your definition, use it in ‘Formula Builder’.


      • Where-
        • C_DEMO_FUNC is your custom function
        • ‘TEST_RULE’ = Exporting parameter to the function
        • Output of the function is compared  with right hand side string.

Important Note: This Function will be reusable. This can be viewed in Transformation Formula Builder as well.

This is how you can use your custom function to take better decision in Process chain.

Hope this guide will help you.

Assigned tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      excellent example ! was looking for such a feature this since a while ....

      have followed your example, and it works 🙂

      many thanks !

      Author's profile photo Yogesh Patil
      Yogesh Patil
      Blog Post Author

      Hey Marc... I am glad it helped you. 🙂



      Author's profile photo Benedict Venmani Felix
      Benedict Venmani Felix

      'Like' for the content.....'Double Like' for the presentation

      A good example for a well presented document 🙂

      Author's profile photo Yogesh Patil
      Yogesh Patil
      Blog Post Author

      I "liked" your comment. 😉

      Thank you

      Author's profile photo Gopi R
      Gopi R

      Excellent Work ! 🙂

      Very useful document for ABAP learner


      Gopi R

      Author's profile photo Yogesh Patil
      Yogesh Patil
      Blog Post Author

      Thank you Gopi..! 🙂 Please rate the document..!

      Author's profile photo Venu Gopal
      Venu Gopal

      Hi Yogesh,

      Very nice presentation of the concept...


      Venu Gopal

      Author's profile photo Daniel Klein
      Daniel Klein

      'TEST_RULE' = Exporting parameter to the function

      caused a bit confusion in my opinion.

      I would change the explanation to

      'TEST_RULE' = Importing parameter of your custom function

      Author's profile photo Yogesh Patil
      Yogesh Patil
      Blog Post Author

      I hope this document helped you.  If you look at SAP's Function module or Class/Methods, the passing values are export parameters and return values are import parameters.

      Here,  C_DEMO_FUNC accepts 'Test_Rule' as a input and returns value based on input string 'Test_Rule'. So in SAP's definition, it is export parameter.

      I hope this will satisfy your query 🙂

      Author's profile photo Daniel Klein
      Daniel Klein

      yes, it helped, many thanks!

      Oh, i see, function in terms of "formula editor function". So you are right. x)

      Author's profile photo Former Member
      Former Member

      very helpful. thanks 

      Author's profile photo Diogo Oliveira
      Diogo Oliveira


      Thanks for the document, it's really well explained.

      I've followed each step, my implementation is active, the class is active, everything seems to be OK, but still I cannot see the "Custom" category in the formula builder.

      I've placed a breakpoint in the GET method and when I start the formula builder, I can actually see that I_KEY is never populated with 'CUSTOM'.

      Any idea why and how to solve this?