SAP Knowledge Base Article - Public

3258553 - SAP S/4HANA Key User Extensibility powered by Embedded Steampunk: How to debug Procurement Cloud BAdI’s

Symptom

You have a BADI implementation created in your system and you don´t get the expected result of your custom Logic code .

EG : Enhancement sport MM_PUR_S4_PR , MM_PUR_S4_PO

Environment


Product version: SAP S/4HANA Cloud 2208
3SL

Resolution

Before the introduction of Embedded Steampunk it was not possible within SAP S/4HANA Cloud to debug any Key User coding, e.g. Custom Logic.
This has changed now with the general availability of Embedded Steampunk, which adds a new powerful option to the In App extensibility portfolio of SAP S/4HANA Cloud. E.g. ABAP Development Tools (ADT) as a powerful development environment and with that also the possibility to debug custom code.

 

Now let us assume for a moment that you created a Cloud BAdI implementation via the Key User tool “Custom Logic” with the implementation name “YY1_PR_ITEM"( client 100) or "ZIC_PR_ITEM" (created in client 080, using ADT environment). This custom logic is executed whenever a Key User Custom Field is calculated.
Within ADT we do now click on the “Open ABAP Development Object” button and as search term we enter the name of the Cloud BAdI implementation “YY1_PR_ITEM”.

We are then navigated to our Key User BAdI implementation. There we can set the breakpoint exactly at that position we are interested in.

When we now start the triggering application, e.g. in our SAP Fiori UI in the customizing tenant, the ADT debugger jumps in and stops at exactly the position we marked.

You can see bellow more details bellow , We hope you enjoy with the guide, 
 

How to set a Breakpoints at a Line in Code in ADT 

 

 
 
 
 
 
 
 

 

 
 
 
 

How to set a Breakpoints at a Line in Code in ADT 

 
 
 
 

Procedure I 

 

 
 

Setting Breakpoint from the Ruler in the Editor Using the Context Menu 

 

Position the cursor within the ruler (left bar) of the source editor at the line that contains the executable ABAP statement of your interest. 

 

Choose Toggle Breakpoint from the context menu. 

 

  

 

 
 
 
 

Procedure II 

 

 
 

Setting Breakpoint from the Ruler in the Editor Using Double-Click . 

 

Double-click within the ruler of the source editor at the line that contains the executable ABAP statement of your interest. 

 

 

 
 
 
 

Setting Breakpoint At Lines of Code 

 

 
 

Position the cursor on the ABAP statement at which you want to stop. 

 

Then choose the menu option Run - ABAP Breakpoints  Toggle Breakpoint. 

 

 
 
 
 

Results 

 

 
 

A breakpoint stays with the line of code at which you set it. If you change the code above the breakpoint, it slides along with the relocated code. 

 
 
 
 

Further Activities 

 

 
 

Toggle a breakpoint again to delete it. You can also deactivate breakpoints, without deleting them. 

 

You can display and manage breakpoints in the Breakpoints view in the Debug perspective. 

 

 

 

How to add Conditions to Breakpoints 

 

 
 
 
 
 
 
 

 

 
 
 
 

 

 
 
 
 

Context 

 

 
 

You have the option to specify a condition for an ABAP breakpoint. The condition is evaluated at runtime whenever the source code position of the related breakpoint is reached. If the condition is fulfilled (evaluates to true), the debugger will stop execution at the breakpoint. Otherwise, if the condition is not fulfilled, the debugger will not stop at the breakpoint. 

 

 
 
 
 

Procedure 

 

 
 

To add a condition to an existing ABAP breakpoint, proceed as follows: 

 

  1. Position the cursor in the ruler (left bar) of the source editor at the breakpoint position. 

  1. Open the context menu and choose Breakpoint Properties 

 

  1. Using properties dialog to add condition to a breakpoint 

  1. In the screen that appears, edit a condition in the corresponding entry field: 

 

 

Editing breakpoint condition 

Choose Apply to save the new breakpoint’s property. 

 

 
 
 
 

Results 

 

 
 

You have added a condition that is now active for the specified breakpoint. This is indicated by the new breakpoint decorator that is visible in the ruler of the source editor. 

 

Drag over the pointer to see the condition: 

 

 

 

Syntax for Breakpoint Conditions 

 

 
 
 
 
 
 
 

 

 
 
 
 

 

 
 
 
 

Context 

 

 
 

Breakpoint conditions have one or more operands. These can be: 

 

  1. Variables (including special debugger symbols) 

  1. Literals 

  1. Built-in debugger functions 

 

 
 
 
 

Syntax 

 

 
 

The condition syntax allowed in breakpoint conditions is basically a subset of what is allowed in ABAP logical expressions, such as an IF statement. 

 

You can specify elementary logical expressions (for example, SY-SUBRC = 0) and combine them using the keyword AND, OR. 

 

In addition, you can change the order of valuation by using brackets - as you are familiar with from logical expressions in ABAP. 

 

Similar to ABAP, you can also make use of short-circuit evaluation semantics, just like in the in the following example: 

 

oref is bound and oref->attr = 'abc' 

 

The second elementary logical expression oref->attr = 'abc' is evaluated only if the first expression oref is bound has been evaluated to true. 

 

 
 
 
 

Examples for Valid Conditions 

 

 
 
  1. sy-index > 5 

  1. sy-index = sy-tabix 

  1. lines( itab ) > 0 

  1. lines( itab ) <> sy-tabix 

  1. lines( itab ) < lines( itab2 ) 

  1. strlen( s ) >= sy-index 

  1. INEXACT_DF = 'X' 

  1. oref is bound and oref->attr = 'abc' 

  1. 'DEADBEEF' cs 'BEEF' and sy-fdpos = 4 

  1. a > b AND (c > b OR c > d) 

 

 

How to use Watchpoints in ADT 

 

 
 
 
 
 
 
 

 

 
 
 
 

 

 
 
 
 

Prerequisites 

 

 
 

You can use watchpoints for variables only during a running ABAP debug session. 

 

 
 
 
 

Context 

 

 
 

When debugging ABAP code, you can use watchpoints to track the value of individual ABAP variables. The ABAP Debugger stops as soon as the value of a watched variable has changed. Furthermore, you can specify conditions for watchpoints. The debugger then additionally checks whether this condition is fulfilled. More on this: Watchpoints 

 

 
 
 
 

Procedure 

 

 
 
  1. Setting Watchpoints for Currently Selected Field in the ABAP source code editor: 

  1. In the ABAP source code editor of the Debug perspective, position the cursor on the field in question. 

  1. Open the context menu and select the option Set Watchpoint. 

  1. Setting Watchpoints in the Variables view: 

  1. In the Variables view of the Debug perspective, select the node for the variable in question. 

  1. Open the context menu and select the option Set Watchpoint.