In this blog article, I’ll walk you through each step of using the Custom Function interface to add customer-defined functions to the Manage Substitution/Validation Rules app’s code in order to customise it to your company’s needs. I’ll give you an example of how the process is put into practise so you can see it better.

Note : that only the SAP S/4HANA Cloud with a 3-system landscape offers developer extensibility. See System Landscapes in SAP S/4HANA Cloud for further details on system landscapes.

Content Overview

  • Business Background
  • Example Business Scenario
  • Step-by-Step Procedure
    1. Create a Custom Field
    2. Set up and Install Local ABAP Development Tools (ADT)
    3. Develop a Custom Function using Demo Implementation
    4. Create Custom Rule in Manage Substitution/Validation Rules App
    5. Derive Field Value
  • Wrap Up

Business Background

Generally speaking, you may display, edit, and create substitution and validation rules for particular business contexts and events using the Manage Substitution/Validation Rules app. These rules can be applied in the applicable business processes to verify, derive, or replace values entered into the pertinent fields at the time of entry.

For example, the quality of the data you enter when you record papers or other pertinent information in Finance is crucial to ensuring accurate legal and management reporting. To prevent costs and efforts associated with inaccuracies in reports and subsequent decision-making, incorrect data should be identified as early as swiftly as possible.

The substitution of values in financial papers is also necessary for other business procedures. Based on the particular context of a transaction, field values are either derived or updated.

Example Business Scenario

The use of market segmentation in margin analysis allows you to report on the profitability of each unique enterprise sector (market segment) with clarity. Customers, products, or sales organisations are just a few examples of the various market segments. The qualities of your market segments can be substituted for field values thanks to SAP.

Analyzing the profitability of a market segment according to the weekday of the posting dates is a business situation in which it may be useful to expand the Manage Substitution/Validation Rules app’s code.

In the Custom Fields app, the administrator in your firm first creates a custom field called “YY1 WEEKDAY” for the business context Accounting: Market Segment. This is insufficient, though, as there is no built-in way to automatically determine the weekday that falls on the posting date of a business transaction. Using the Post General Journal Entries tool, the G/L accountant would have to manually add the weekday to the journal entry.

Consequently, this is where the new Custom Function interface is useful. Let’s look at how the Manage Substitution/Validation Rules app can be expanded to include the weekday’s automated derivation.

Keep in mind that this is merely an example of a custom function that is intended to show how to calculate a value inside of a substitution or validation rule. Any functional logic may be wrapped in such a function in place of the weekday calculation, making it accessible inside the Manage Substitution/Validation Rules app.

Step-by-Step Procedure

Note: All screenshots in this blog post were obtained from a test system for SAP S/4HANA Cloud and are based on the UI that SAP provides as standard. Depending on the version of your programmes or your configuration choices, interfaces could vary slightly.

    1. Create a Custom Field (Administrator)

    • Launch your SAP Fiori launchpad.


    • Using the Custom Fields app, create and publish a Weekday field in the business context Accounting: Market Segment.

    • Optionally, check that the new field is available in the Post General Journal Entries app. (Role: G/L Accountant).
    • Choose Assign Profitability Segment in Line Item section.

Note: If the field isn’t visible, enable the corresponding UI for your field in the Custom Fields app above and Publish the custom field again.

   2.Set up and install ABAP Development Tools (Developer)

    1. Download and install ABAP Development Tools (ADT) from
    2. Follow the installation procedure or check out this interactive tutorial:
    3. Create an ABAP cloud project with ADT to connect to the ABAP system. See Connect to the ABAP System.
    4. Create an ABAP package. See Creating ABAP Packages.

Now that you’ve installed and set up your ADT environment, you can start enhancing the existing code in the Manage Substitution/Validation Rules app by implementing the Custom Function interface.

Tip: To familiarize yourself further with the development in ADT, see ABAP Development User Guide.

   1.Develop a Custom Function using Demo Implementation (Developer)

      • Open the interface by choosing Navigate > Open ABAP Development Object from the menu bar or use the keyboard combination Ctrl+Shift+A. Then, enter the name of the interface in the search bar: IF_FIN_RE_CUSTOM_FUNCTION.Note: The interface and the class contain thorough inline documentation, which should support you in implementing your custom function.

      • For this purpose, use the demo implementation in class CL_SUBVAL_WEEKDAY.

      • Duplicate the class and adapt the name of the class to your own name space.

      • Choose Next to create your own new class that defines a new function within the Manage Substitution/Validation Rules app.

      • Select a transport request to transfer your changes.
      • Replace all other places in the coding with the new name

      • Remove the method IF_FIN_RE_CUSTOM_FUNCTION~is_disabled.
        Note: The demo implementation is hidden by default. This is why this step is necessary.

      • Activate the class.
        As soon as this is done, the function will be available in the Manage Substitution/Validation Rules app.

   2.Create a Custom Rule in Manage Substitution/Validation Rules app (Configuration Expert)

  • Launch your SAP Fiori launchpad and open the Manage Substitution/Validation Rules app.
  • Create a new substitution rule for the Market Segment business context.

  • Add a Rule Name and a Description to your substitution rule.

  • In the Substitution section, choose the value help for the Target Field. Now, the YY1_WEEKDAY appears in the list.

  • As the Substitution Type choose Substitute with Field / Function.

  • Choose the value help for the Source Field. Then, choose the custom-defined function that was just implemented by your developer from the list.

  • In the pop up, choose Field Value as the input parameter based on which the weekday is calculated.

  • Choose the DocumentDate as the field from the value help.
  • Save your changes.
  • Save the changes made to the substitution rule and activate it.

   3.Derive Field Value (G/L Accountant)

  • Go to the Post General Journal Entries app.
  • Choose Assign to Profitability Segment.
  • In the pop up that appears choose Derive and the current weekday is derived

Wrap Up

Your journey to adding custom code to the Manage Substitution/Validation Rules app was walked you through in this blog post. Weekday class serves as a straightforward illustration of how a computation is wrapped in a function and then incorporated into the app.

In addition to basic methods like CONCATENATE and SUBSTRING, the programme also gives configuration experts the ability to incorporate preexisting functionality into substitution or validation criteria.

More process descriptions are there any you’d want to read? Following that, add your thoughts and comments to the space provided below this post.

Use the tag FIN Finance when posting a question in the SAP Community’s Q&A to receive responses to your queries.