Recently I had the chance to implement a BADI in SAP S/4HANA Cloud. Never been on an SAP S/4HANA Cloud system, so I searched the SAP community first.
I found a great blog by
akshay_kumar and got amazing help from
esmee :
https://blogs.sap.com/2020/05/28/power-of-business-add-ins-in-sap-s-4hana-cloud/
https://s4hanacloud.community.sap/blogs/show/l136xd9svBNl0sg4CPjrwK?_lightbox=true
So, after I found the information I started developing in the fancy ABAP web editor with it's restricted syntax. The first problem I was facing: where is my SE12 to browse through the table entries to check which database tables I need?? Of course, SE12 does not exist! So, my first tip is to use the FIORI App "Custom CDS Views":
Here you can create a new Custom CDS Views based on existing Views. This was extremly helpful to get an overview about columns, associations etc. (Yes, you have to have a basic understanding of CDS and the new VDM data model:
https://help.sap.com/viewer/0f69f8fb28ac4bf48d2b57b9637e81fa/2011.500/en-US/7139c1648de84c0bbd763758... )
I used the app to view the table contents, here's a screenshot of what that looks like for the CDS view I_EngagementProject:
You can even publish those views as an OData service, then you're able to see all data (the Custom CDS view only gives you a data preview; If there's a lot of data, you're not able to see it all) and use all OData functions. But for my usecase the "Data Preview" was enough.
So, after I got a good overview and a plan of which CDS views I will need, I wrote the coding in ABAP. But very soon I faced my next challenge: How can I actually test my coding? Yes, there is the integrated test capabilitay in the BADI editor (and it is very useful), but in my case there weren't enough export parameters that I could use to see what I actually selected in my variables. After a while of "blind coding", I was again looking for help but I couldn't find any.
I was even reaching out to
rohit.khan but he told me that this is a common struggle for customers. Finally, I browsed through the app "Released ABAP Artifacts" and a class caught my eye:
CL_BLE_TRACE_WRITER
So, I checked this class and I found some interesting methods:
WRITE_INFO_MESSAGE
WRITE_WARNING_MESSAGE
And with this information I was able to log my values in my coding:
So, now you can activate the log, execute the BADI (even in test mode) and see your log:
Call the App "Custom Logic Tracing":
Start the Trace, finish it after execution and then show the content and THAT'S IT!
I hope it'll help your first steps in SAP S/4HANA Cloud Development be a little bit easier! I hope SAP will provide more help to make developments easier in future. A logging functionality in test mode would be great. But I think with these tools in place we can write ABAP code comfortably and fast.