Moderate way of the Debugging for Technical Consultants & ABAP Learners– 'Art of Removing Errors':

 

Moderate way of the Debugging for Technical Consultants & ABAP Learners– 'Art of Removing Errors':

What is Debugging??? 

  • Identify Error.

  • Identify the Error Location.

  • Analyze Error.

  • Prove the Analysis.

  • Cover the Lateral Damage.

The debugging efficiently means not only removing the errors & it will help us to understand the flow of the program and also we can understand the business process or model of that particular requirement .

The purpose of this blog is to the give overview of the various debugging techniques available in SAP. The primary focus of the document is for the SAP ABAP consultants at moderate level & ABAP learners.




Introduction to Debugging

ABAP Debugger is used to execute and analyze the programs line by line. Using it we can check the flow logic of a program and display runtime values of the variables.

Currently, SAP offers two types of Debuggers

  • The Classic ABAP Debugger.
  • The New ABAP Debugger.
  • Recent release New Debugger is also called as the  ‘STANDARD DEBUGGER’

Switching between ‘Classic Debugger’ and ‘New Debugger’

You can switch btwn both the debugger & make any one your default debugger.. To do this, go to the ABAP Editor ( SE38 ) → Utilities → Settings

Now in user specific setting pop up box click on the ABAP Editor Tab and then click on Debugging.

Here you can select New Debugger radio button to make it your default debugger.

External (User) Debugging

External debuging is used when we want to analyze our program which is called by an external user through HTTP such as Web Dynpro ABAP, Web Dynpro JAVA, and BSP etc. To activate the external debugging, we have to set the external breakpoints, which can be set just like session breakpoints by keeping the cursor on the desired code line and clicking on the ‘ External Breakpoint ’ icon..

We can also set external user for whom the breakpoint is to be activated by going to  the ABAP Editor ( SE38 ) → Utilities → Settings, and in the ‘user specific setting’ pop up box click on the ABAP Editor Tab and then click on Debugging..

Here you can specify the username.

Watch point

Watch point can be used to break the execution of a program when values in a variable change.

This helps to go to the exact positions where the variable changes. And you can also specify conditions in watchpoint,& the execution of the program will break as soon as condition is fulfilled.

To create a watchpoint, click the Watchpoint button in New ABAP Debugger.

Now, in Create Watchpoint pop up enter the variable name for which you want to create Watchpoint.

 

For example, I will set an Watchpoint on the internal table itab1 to break when it is greater than 50 lines in content.

 

All the currently set Watchpoints are listed in the watch points tab of the Breakpoint tool. Here you can create/edit/delete/activate or inactivate the Watchpoint & in addition to information such as the variable name/scope/condition, you will find in the Watchpoint list a symbol for the 'old variable' for all watch points. This information will enable you to view value of the variable of the recently hit Watchpoint before it was changed. we will execute the above Watchpoint for illustration of this point.

 

Some limitations of the New ABAP debugger Screen Debugging are: 

When we try to set breakpoints in screen or dialog programs, you get  message stating that the debugging is not yet supported.

 

To get by this and debug your screen or dialog programs just switch back to  classical debugger..


ABAP Memory ID

In New debugger it is not possible to view the used ABAP memory ID’s & their content. But in the classical debugger you can view the ABAP memory ID's by going to the 

 Goto → System Areas → ABAP Memory.

In SAP Programming's there are two kinds of breakpoints.

Static Breakpoints:

These can be set by using statement BREAK POINT in ABAP code, these breakpoint are not user specific, these will trigger for every users. We need to delete these breakpoint manually.

Ex: breakpoint.  Ex2: break ADAGGUBATI.

Dynamic Breakpoints:

These breakpoint are user specific & these will trigger for specific user only. These breakpoint will be deleted automatically when you log off from SAP. These can be set in the ABAP editor. Dynamic breakpoint can be set in active ( activated ) source code only.

Dynamic breakpoints are of two types. External breakpoint - These are type of breakpoints, which will get activated even for Non SAP Applications, these breakpoints will be triggered from the SAP or from Non SAP example from Portal screen.

Set it through like Utilities –  Setting  –  breakpoints..

Session breakpoint 

This breakpoints will be activated for call only within SAP system & its active till the User session is on.

E.g., SE38

These breakpoint have different behaviors in different types of coding blocks for ex: Function Modules , Sub - routines etc.

In this we will discuss the behaviors of breakpoints in each:

When we put a breakpoint in some ABAP codes, control will stop at the specific place when executing ABAP program, then it is debugging mode. We can control the debugging using function keys F5/F6/F7 & F8 or using toolbar buttons in the debugging screen.

1Working with static breakpoint.

Go to the SE38 - create a program ZSAPN_DEBUGGING & add the below code and activate.

REPORT ZSAPN_DEBUGGING. 

SKIP. 

BREAK-POINT. “Static break-point

Save, activate and execute the program.

2. Working with Dynamic Breakpoint.

Go to tcode SE38, create a program ZSAPN_DEBUG & add below code,

REPORT ZSAPN_DEBUG.

DATA: IT_MARA TYPE TABLE OF MARA,
WA_MARA TYPE MARA.

PARAMETERS: P_MTART TYPE MARA-MTART.

SELCT * FROM MARA INTO  TABLE IT_MARA UP  TO 50 ROWS
WHERE MTART = P_MTART.

LOOP AT IT_MARA INTO WA_MARA.

WRITE: / WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MATKL, WA_MARA-MEINS, WA_MARA-SPART.

ENDLOOP.

Go to the program source code, put the cursor where you want to the set breakpoint and click on set or delete external breakpoint icon.

Control Buttons:

F5 – Step by Step.

F6 – Skip Function modules/routines/ class methods & executes that block directly without entering it & with statements acts as F5.

F7 – Returns from the Subroutine or Function module & go to the breakpoint.

F8 – Executes directly until next break point. No break points means directly execute program.

SY_SUBRC = 0 (atleast 1 line was read).

SY_SUBRC = 4 (no line were read).

SY_SUBRC = 8 (search keys not fully qualified).

Shortcuts for debugging options

  • Shift+f12 -> Go to statements.

The Magic of SHIFT + F12

You can use this key of combinations to bypass a specific line of code such as normal sy-subrc check or an authorizations check. To jump/bypass any line/lines of codes all we have to do is just put your cursor on the desired lines &then press the SHIFT + F12 key.

  • Shift+f8 -> continue to cursor.(Place cursor at the statement and it will execute & will go to that statements).

Click in breakpoint column whilst the key is depressed

  • SHIFT    => Set session breakpoint.
  • CTRL   => Set user Breakpoint.
  • SHIFT+CTRL => Go to statement.

Tools of the NEW ABAP Debugger

Tool of the New ABAP Debugger are optimized for the different debugging situation. we may have to deal with during solving an problem. Some tools you will recognize from the Classic ABAP Debugger & others are brand new. Before we look at a few of our tools & how to use them, lets first get comfortable with the tools menu & how the tools are organized.

If you want to add a new tools to the current desktop, you will get the pop-up window titled 'New Tool' where you can choose the appropriate tools based on your situation.


New ABAP Debugger – Tools are grouped into sections as shown below:


Standard Tools:

Source Code - Display current source code in back end editor. Please note that this is the old editor & I recommend you do not use this. There is another tool farther down the menu which we will use as the NEW Editor.

 

Call Stack - Displays current ABAP stack and screen stack.


Variable Fast Display - Displays variable value and type.

Breakpoints: Maintain breakpoints, watch points, and checkpoints.

Source Codes ( Edit Control ) -  Displays current source code in the NEW ABAP Front End Editor. This is the options we recommend you use to enlist all the valuable enhancements of the new editor.

Data Objects:

  1. Object: Display/change objects and classes.
  2. Table: Display/change internal tables.
  3. Structure: Display/change structures.
  4. Single Field: Display or change variables with the simple data types, such as C, N, D, T, STRING… etc.

Data Explorer - Displays very complex data structure in a tree like fashion.

It’s worth mentioning that if you double clicks on a variable displayed in any tool, you will launch the corresponding detail view described above that corresponds to its data types.


Special Tools:

  1. Web Dynpro - The structure of the content of current controllers, the properties of the UI element in the layout of the current views and the currently instantiated component usage.
  2. Loaded Program (Global Data) - Displays all currently loaded programs & their global variables.
  3. Memory Analysis - Displays integrated Memory Inspector tool ( S_MEMORY_INSPECTOR ).
  4. Screen Analysis -  Displays the screen attributes and the sub screen stack.
  5. Diff Tool -  Compare variable very quickly to the outline delta.
  6. System Area ( Internal ) -  Display system areas such as SMEM, ABAP Memory, Datasets, Screen Attributes…etc..

Finding field name in the internal table in the debugging using columns options

Click on the Internal table in the table contents, we will see the columns option and click on column configurations.

In Find icon we can give the column name and directly we can observe,

To find any field when we are dealing with the large data in the Internal Table while debugging

Select the category click on Find icon ( Ctrl+F )

For the Characters we should specify in single quotes,

Integers -1234.

 

Hope this Helps. Thank you everyone.

Comments

Popular posts from this blog

EVENTS IN INTERACTIVE REPORTS OF SAP ABAP

SAP ABAP Fresher Resume/ CV Writing Format..

CONCEPTS OF INNER JOIN AND OUTER JOIN in SAP ABAP