Add a validation to a Custom Field via Developer Extensibility in SAP S/4HANA Cloud

With the introduction of Three System Landscape(3SL) in SAP S/4HANA Cloud, developers will now be able to create development projects via Eclipse IDE with the help of ABAP Development Tools (ADT)

In this blog, I will take you through a simple example of how to add a screen validation to a Custom field created via Key-User Extensibility using Developer Extensibility

Let’s take the example of the custom field ‘Enhancement 1’ which was created via Key-User Extensibility in the Development 100 system

Now, create a BAdI implementation to add a validation such that the Sales Order should not be saved if this field is empty.

As shown in the following screenshot, I have derived a new tree for Application Components.

By deriving this tree, it will be easier for me to search and identify the enhancement spot I am looking for.

Now that the enhancement spot, ES_SD_SLS_EXTEND, is identified, right click on the enhancement spot and click on ‘New BAdI Enhancement Implementation’ to create a new Enhancement Implementation.

Provide a Package name, Enhancement Implementation Name and Description and click on Next. The field ‘Enhancement Spot’ is automatically filled as the implementation is created by directly clicking on the Enhancement Spot

Provide an existing transport request or create a new transport request and click on Finish

This will create an Enhancement Implementation. Now add a BAdI implementation by clicking on ‘Add BAdI Implementation’ as shown below

Provide the BAdI definition name by clicking on the browse button and provide an implementation name and click on Add

Provide a class name and click on Implementing Class. This will create a new class dialog

Provide the package name and description and click on Next. Provide an existing transport request or create a new transport request and click on Finish

Save and Activate the class. Save and Activate the BAdI implementation once the class is activated

Add the following logic in the method check document

if salesdocument_extension-yy1_enhancementfield1_sdh IS INITIAL. append value #( messagetype = 'E' messagetext = `This custom field 'Enhancement Field' is empty` ) to messages.

Save and activate the class ZCL_FIELD_VALID.

As you can see, creating a BAdI implementation is much simpler now using Developer Extensibility.

Now, when I try to save the Sales Order with the Field ‘Enhancement Field’ as empty, I will get the following message.

The error message will be added to the log and can be seen as shown below

In addition to this, you can follow the blog SAP S/4HANA Key User Extensibility powered by Embedded Steampunk: How to debug Key User Extensibility extensions (e.g. Cloud BAdI’s) in client 100 to debug and test your code in the Development 100 system.

For more details on Developer Extensibility and how classic extension differs from developer extensibility, you can follow the blog Embedded Steampunk – Some more details for ABAP developers

Additionally, for queries on Developer Extensibility and language usage, you can follow the blog ABAP language Versions FAQ