Acorel
To Acorel.nl
Acorel background

How to invalidate SAP C4C BADI code execution and raise messages

Vinaya Kumar Devara, 27 July 2022

Preface

Some SAP Cloud for Customer screens are built on BADI objects and in this case invalidating the further execution and throwing error/info and warning messages requires some special tweaking done in contrast to Extended BOs/Custom BOs. In this blog, I shall explain an approach how we could achieve that.

Development Setup

Here for the demo purpose, I have taken example BADIs from the Utilities functional area of SAP C4C. These BADIs can be part of any custom C4C solution in effect. And in the other way around this approach is also applicable for all other BADIs that C4C screens run upon. We need to first add a BADI relevant to the screen we are working upon into the solution and verify if the BADI “Returns” structure for example as below supports messaging sub-structure

With message structure

pic1

We can use the message structure to set the message type as E/I/W (Error/Info/Warning) as below and if we set this type to E the invalidation is triggered and the BADI execution exits hardly. In the below code execution we check if an instance has certain variable field enabled as true and if so we add the validation message to the result structure and that triggers the BADI exception.

pic2

Without message structure

Click on the <BADI>.enht file for example: UtilitiesP2PModify.enht and define messages as shown below

pic3

We can use the messages defined above to set the message type as E/I/W (Error/Info/Warning) as below and if we set this type to E the invalidation is triggered  and the BADI execution exits hardly. In the below code execution we check if an instance has certain variable field enabled as true and if so we raise the validation message and that triggers the BADI exception.

pic4

Execution Check

pic5

pic6

Conclusion

We achieved the invalidation of the SAP C4C BADI execution and raising messages.  It is also worth to verify SAP help documentation upfront on the BADI enhancements options to check how the BADI can be modified as per custom requirements.

For the above example BADIs documentation, you may refer the page: Utilities Contact Center Administrator Guide (sap.com) , sections utilities instalment plan and Promise to Pay

Vinaya Kumar Devara

Read all my blogs

Receive our weekly blog by email?
Subscribe here: