How to use Embedded Steampunk in Private Cloud – Step by Step Cloud BADI Implementation via Developer Extensibility
How to use Embedded Steampunk in Private Cloud – Step by Step cloud BADI Implementation via Developer Extensibility
- With the SAP S/4 HANA 2022 release, Embedded Steampunk (Developer Extensibility) is now available in S/4HANA Cloud, Private Edition as well.
- This means that now we can have ABAP cloud development model used in PCE, similar to Public Cloud and BTP (ONE common ABAP cloud development model available in all these environments).
- This will help in achieving clean core principle which in turn will help to reduce upgrade efforts for the business.
- In this blog, we will see one similar step by step example where we will get BADI implemented via developer extensibility.
- The requirement is to have some user defined validation on the material creation via FIORI app – Manage Product Master Data (F1602)
- To narrow down the requirement, for this example, we will place the validation check on the Division field. Material will not be allowed to be created (or saved) without Division information populated and error message will be displayed.
- Find the available cloud BADI for the requirement.
- Create Cloud Project
- Implement BADI
- Test the BADI Implementation
Find the available cloud BADI
All available cloud BADIs can be found on SAP Business Accelerator Hub. Following is the navigation path:
Business Accelerator Hub -> S/4 Hana Cloud -> Developer Extensibility -> Business Add-Ins.
Here we can find all the relevant BADIs available for different scenarios. For our scenario we will be using BADI – BD_CMD_PROD_DATA_API_CHECK_2.
This BADI is ‘Released’ for developer extensibility and hence can be used.
Create Cloud Project
Developer extensibility is a cloud-ready, upgrade-stable, custom ABAP development model. By using ADT, we can write our custom ABAP code and extensions using set of released objects and APIs for the ABAP platform.
The important steps to set up developer extensibility include:
1. Create Software Component
If we want to use the developer extensibility in parallel to classical extensibility, we need to create a separate software component. For this use report RSMAINTAIN_SWCOMPONENTS and create a separate s/w component saving in workbench TR.
Execute this report in transaction SE38:
Click on Insert Software Component Version:
Give the component Name, Description. Select ABAP Language Version as ‘ABAP for Cloud’.
Save it to a workbench TR. Release the TR.
2. Create Structure Package
This step is to create the development package where the custom developments with ABAP language version as ABAP for Cloud Development will be stored. This will be done in ADT selecting ABAP language as ‘ABAP for Cloud Dev.’ assigning the above created software component.
- Login into Eclipse ADT S/4 system
- In the Project explorer, Click New and select ABAP Project
- Select the package type as ‘Structure’
- Click on next and assign the Software Component created in the previous step (via report RSMAINTAIN_SWCOMPONENTS).
- Save it to the TR.
Following these two steps, we have the system setup ready to start with our actual development.
- Create a development package inside the above created main cloud project (ZDEMO_CLOUD_DEV in our case).
Save assigning it to a workbench TR.
NOTE – Till now it is a one-time step. We can save multiple BADI Implementations or different ABAP Cloud based objects in one package. Based on project requirement, we can have multiple projects/packages created.
- Create Enhancement Implementation in the created development project.
Enhancement Spot details can be found on BADI details page of SAP Business Accelerator Hub (api.sap.com). Screen shot of this is there on the top of this document.
Save it to the workbench TR.
- Add BADI Implementation to the created Enhancement Implementation:
- Give description and Implementing Class Name
NOTE – Ignore the errors here. These errors are because the class does not exist till now.
- Click on “Implementing Class” hyperlink in the above screen shot and give the required details to create the class:
- Place the below code in method CHECK_DATA of above created class:
DATA:ls_message LIKE LINE OF ct_message.
LOOP AT it_data ASSIGNING FIELD-SYMBOL(<ls_data>).
IF sy-subrc = 0.
IF <ls_data>-product-division IS INITIAL. ” Dummy Check
ls_message-product = <ls_data>-product-product.
ls_message-msgty = ‘E’.
ls_message-msgid = ‘MG’.
ls_message-msgno = ‘899’.
ls_message-msgv1 = ‘Please enter a valid value for division’.
APPEND ls_message TO ct_message.
IF <ls_data>-product-ischemicalcompliancerelevant IS INITIAL.
READ TABLE ct_product_upd ASSIGNING FIELD-SYMBOL(<ls_product_upd>) WITH TABLE KEY product = <ls_data>-product-product.
IF sy-subrc = 0.
<ls_product_upd>-ischemicalcompliancerelevant = ‘Y’.
* mark the x flag
READ TABLE ct_product_upd_x ASSIGNING FIELD-SYMBOL(<fs>) WITH TABLE KEY product = <ls_data>-product-product.
IF sy-subrc = 0.
<fs>-ischemicalcompliancerelevant = ‘X’.
Note – The code can also be referenced from the Sample Class provided from SAP in the BADI description (in api.sap.com)
- Save and activate the class.
- After activating the class. Go back to the BADI Implementation page (where errors were showing up earlier).
Activate this BADI implantation. Errors will now go.
Also, make sure the Runtime Behaviour of our implementation is set to Active.
Our BADI is implemented now and ready to test.
Test the BADI Implementation
- Open FIORI app – Manage Product Master Data.
Open it for any existing Material and save it without populating Division details. Or create a new material without Division.
On saving without Division, error message will be shown:
- We saw an example of implementing Cloud BADI in S/4 2022 PCE system.
- Similar functionality can be achieved using Classical approach as well. But we should try to explore the possible cloud extensibility approach, if available.
- This will help to have core clean as much as possible, which in turn will reduce upgrade efforts.
- There are limitations on writing code and not all the functionalities can be achieved with the current model in place. Eventually it will grow, but the target is to keep aligned with the suggested best practices and standards.
- Explore ‘ABAP for Cloud Development’. This will help us to understand what all code/functionality we can write in our cloud ready development objects – link.