Skip to Content
Technical Articles
Author's profile photo Keshav Saxena

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

 

Introduction

  • 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.

 

Scenario

  • 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.

 

Steps

  • 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.

 

Implement BADI

  • 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

Save.

NOTE – Ignore the errors here. These errors are because the class does not exist till now.

Proceed ahead.

  • Click on “Implementing Class” hyperlink in the above screen shot and give the required details to create the class:

Save.

  • 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.

ENDIF.

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’.

ENDIF.

*       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’.

ENDIF.

ENDIF.

ENDIF.

ENDLOOP.

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:

 

Summary

  • 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.

 

Useful References

Assigned Tags

      4 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Thanks for sharing!

      This post is titled "How to use Embedded Steampunk..." but there doesn't seem to be any difference compared to how we've done BADI implementation for years before... Did I miss anything?

      The first steps are rather confusing and I'm not sure what is their purpose (it would be great if you could explain why you're doing something vs just listing the steps).

      Step 1 is to create a software component. Why? What does it do? I can see it has to be entered to create a package in the next step but why do you need to create a custom component? Is this some kind of specific Embedded Steampunk requirement? I guess not but this is not clear at all.

      Step 2 is create a package of Structure type. Again, why? I'm sure every ABAPer already knows what package is and most of us know what it does / how it works. We can find the boilerplate "create a package" steps in hundreds of posts and tutorials. But why specifically "structure" in this case?

      I've not used this option before, so I looked it up in Help (question mark button). It says: "Structure package as the root container of a new package hierarchy". Hm... Unless you specifically want to create a hierarchy, I'd just go with default option of "Development". I feel that using structure type is irrelevant in this example and it just creates confusion.

      Then there goes Software Component. I've created packages many times and it's not been the thing so far, so I was curious if this was also something specific to Embedded Steampunk. But I think this is just one of those cases where SE80 is still better than ADT. 🙂 When I create a package there, this field (which I think is meaningless for SAP customers anyway) defaults to HOME:

      This seems to be the correct value for custom development, so there should be no need to create any custom components in Step 1. I've never paid any attention to this field though and haven't heard of any memos issued on its importance going forward. Thomas Fiedler can this field default to HOME in ADT too? Or do customers need to start caring about this? I'm confused...

      The rest of the steps are the same ones we used to do in SE18/SE19 transactions, just done in ADT. I won't comment on the code but please use "format as code" option, so that it's easier to read.

      And last but not least the 1,000,000 USD question: how did you find this BADI? When I go to API Hub (I refuse to use its new name because it's ridiculous 🙂 ) and search for "product", this BADI is not at the top of the list. Here is what the search result looks like:

      Since there only 2 pages with results, then it's not difficult to scroll manually and read. But I assume number of BADIs should increase, so searching by "product" will turn into a challenge. Any pointers how to get better search results? This is the page where the screenshot comes from, enter "product" in search field.

      It's good to know that we can use the same BADI skills going forward. I feel it'd be useful if the post pointed out if there was anything specific to Cloud or Embedded Steampunk.

      Thank you.

      Author's profile photo Thomas Fiedler
      Thomas Fiedler

      Hi,

      The recommendation is to use a software component which is classified as "ABAP for Cloud development".

      Please find more about this approach it in the ABAP Cloud Extensibility Guide:

      https://www.sap.com/documents/2022/10/52e0cd9b-497e-0010-bca6-c68f7e60039b.html

      Chapter 5.

      Regards,

      Thomas.

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Thanks for the reference!

      I typed a long comment in response with quotes and all but, ufortunately, it just poof disappeared when I clicked Submit button. 🙁  Below is a shorter version.

      Based on what I've read in that document, the software component basically enforces ABAP Cloud model. But other than that, I don't really see this being relevant for SAP customers. (This is also not explained in Help I'm seeing in ADT, btw.)

      Would it make sense to just create a generic ABAP Cloud equivalent of HOME? If every customer has to go and create exactly same custom component, then it's not very productive.

      Author's profile photo Thomas Fiedler
      Thomas Fiedler

      Hi Jelena,

      this is exactly what we want to do next. Some kind of pre-configuration of Software component ABAP_CLOUD (or similar) and ATC setup to make the start of ABAP Cloud a bit more easy for the customers.

      Regards,

      Thomas.