✒️ABAP / El debugger ABAP Por Alejandro Martinez

Selector Alummnos / Empresas

ABAP El debugger ABAP

ABAP El debugger ABAPSecrets of the ABAP Debugger: Advanced ABAP Debugging Techniques

https://blogs.sap.com/2018/01/22/secrets-of-the-abap-debugger-advanced-abap-debugging-techniques/

Debugging Techniques Debugging deep inside the Call Stack

Apart from debugging your own custom source code or the business-oriented code on the application level, it might be necessary from time to time to dive deeper into the call stack. Sometimes you can only spot bugs when debugging the asynchronously executed update tasks or system programs.

System Debugging

System programs are typically provided by SAP itself and you should not classify your own programs as such. System code is considered relatively technical and not containing any business logic. As a consequence, developers focusing on business logic commonly do not need/want to debug this. However, from time to time your debugging session might end up at a system program.

In order to dive into system code using the ABAP debugger you have to activate system debugging beforehand. Choose the menu entry System Debugging On/Off in the settings menu.

Activating system debugging allows you to access source code you are typically not able to see and, therefore, can help investigating issues. On the other hand, you need to deal with a growing call stack as all system programs are visible too. Usually the system code is executed in the background without your notice.

Update Debugging

Whenever you deal with transactions or reports that utilize asynchronous update tasks (e.g. to persist business data), you might encounter error messages occuring from the executed code inside the update task. Such errors appear usually in the SAP GUI telling you “Update was terminated”.

In order to examine what is going wrong, you can activate update debugging. If update debugging is turned on, the ABAP debugger opens once the update task is being executed and allows you to inspect the program flow.

Consider the change of a cost center as example. We open transaction KS02, select a demo cost center, and open its master data. Let us adjust the description. Before we click Save, we enter “/h” in the transaction code input field on the top left corner and press Return. The green success message “Debugging switched on” is displayed at the bottom.

After clicking Save, the debugger opens showing the PAI/PBO modules of the current ABAP program. In order to activate update debugging, we open the debugger settings following the menu path Settings -> Change Debugger Profile/Settings. In this dialog we activate Update Debugging and confirm.

Pressing F8 skips the current debugger session. The ABAP server continues processing the current ABAP program which prepares and hands over the update tasks to the update processing. Once they are executed, the debugger opens once again.

Coming back to the cost center change example, we end up inside the function module KOSTL_WRITE_DOCUMENT. According to its source code, it takes care calculating the change documents with regards to this cost center master data change.

In the most cases, multiple update tasks are coming into play for one business process (changing a cost center is relatively easy, though). Let us figure out how we can find all of them at runtime.

Looking at the call stack, we can see the form routine VB_V2_NORMAL.

Before we can navigate into this code, we have to activate system debugging (see chapter above).

Inside this form routine we can see that the internal table VBMOD_TABL contains all function modules to be processed.

Using update debugging you are able to spot bugs inside function modules executed in update task. Even if you do not encounter any bugs, it might be interesting to see what happens under the hood.

Influence the Program Behaviour at Runtime

When you are examining the flow of an ABAP program in the debugger and you aim to focus on a certain piece of it only, it may happen that the specific case you’re investigating only occurs under certain circumstances (e.g. certain variables having certain values). In such a case you have to invest time to modify everything so that the debugger reaches the piece of code you’re interested in.

Avoiding this effort (time is money) you can leverage the simple, but nevertheless very valuable, feature named Goto Statement.

Assuming the debugger is currently at line 32 in the given screenshot, you right-click on the line number where you want it to continue and choose Goto Statement. As a consquence, the lines in between are skipped, i.e. not executed, and the processing continues where you want.

Be aware that this feature can be abused: Users can skip intended and meaningful authorization checks and, therefore, conduct actions they are not allowed to do. Generally it is a recommended practice to turn this feature off (i.e. not authorizing anyone) in productive environments.

Make your Breakpoints more powerful

Breakpoints allow the developer to specify in which code line the debugger should stop.

Typically you choose one particular code (e.g. line x in program z) because you want to inspect the program flow around this code. Besides such dynamic breakpoints you can leverage special dynamic breakpoints and conditional breakpoints to make your debugging experience easier.

Special Dynamic Breakpoints

Assume we require to identify all authorization checks conducted during a program flow. We know that AUTHORITY-CHECK is the respective ABAP keyword. How do we solve this challenge?

Firstly, we could execute the ABAP program in the debugger and follow the program flow by hand. After browsing through all methods, function modules etc. we have noted down all authorization checks. Apparently this approach is time-consuming and also error prone as you never know if you have missed some piece of code deep in the call stack.

Secondly, as an advantageous approach you can leverage special dynamic breakpoints (that’s the official name according to the documentation). This feature let’s you create breakpoints at every instance of a certain e.g. statement, exception, or function module.

In order to define special dynamic breakpoints, choose Breakpoints -> Breakpoint At in the debugger menu. Choose Breakpoint at Statement with regards to our example. In the appearing pop-up we enter the name of the command.

As a consequence, the debugger creates breakpoints at every authorization check. By pressing F8 you can navigate from one occurrence to another.

Consider activating system debugging beforehand to really fetch all authorization checks (otherwise you miss them hidden in system code).

Conditional Breakpoints

Assume you are debugging some code containing a loop whereas you are interested in debugging a certain cycle (e.g. the fifth loop cycle). Making the debugger stop in this exact cycle is easy using conditional breakpoints.

Consider the following sample program.

REPORT zmd_cond_brkpnt_01. DATA lv_foo TYPE i VALUE 0. *for demonstration purposes; do not use static breakpoints in production BREAK-POINT. DO 50 TIMES. ADD 1 TO lv_foo. ENDDO. *for demonstration purposes; do not use static breakpoints in production BREAK-POINT.

The do loop runs 50 times whereas each loop cycle updates the variable lv_bar with the current value of lv_foo. When we set a breakpoint inside the loop, we stop there 50 times by pressing F8.

By introducing a conditional breakpoint we can define that the debugger shall only stop at this breakpoint in case a given condition is met.

We can define the condition using tab strip Break./Watchpoints.

Let’s say we want to stop when lv_foo gets 42 assigned.

After pressing F8 the debugger stops exactly at the respective loop cycle.

This simple example visualizes how to use conditional breakpoints. I found this feature to be quite useful a couple of times throughout my projects.

Classification of Breakpoints

In the official documentation we can find terms such as static breakpoints, special dynamic breakpoints, external breakpoints, debugger breakpoints. While investigating the meaning of these terms I found that they are addressing different properties of breakpoints, such as their life time or the way you create them.

Therefore, I was curious and have created a classification of breakpoint times according to the following categories:

  • Life Time
  • Way of Creation
  • Can be User-Agnostic
  • Processing Mode
  • Conditionally Considered
  • Activated
Life Time

Breakpoints exist for a certain time, that is once their life time has passed they are gone and cannot be used anymore. The possible life times are:

  • Lives during current debugging session: Debugger Breakpoint
  • Lives during all sessions of current user session: Session Breakpoint
  • Lives typically for two hours: External Breakpoint

Generally all breakpoints can be deleted manually, i.e. their life time can be shortened on purpose.

Way of Creation

There is several ways how to create a breakpoint:

  • Hard-wired statement in the code (such as BREAK-POINT): Static Breakpoint
  • Single line selected by hand: Dynamic Breakpoint
  • Lines selected by certain definition (such as at every instance of certain statement): Special Dynamic Breakpoint
Can be User-Agnostic

A breakpoint can be valid for a certain user name or not.

If so, the breakpoint is considered once the respective user executes the code line. This applies to all breakpoints unlike Static Breakpoints defined with BREAK-POINT.

If not, the debugger stops at every execution regardless of the current user. This applies to Static Breakpoints defined with BREAK-POINT.

Processing Mode

There is breakpoints that stop at dialog processing only, such as Debugger Breakpoints.

in contrast, e.g. External Breakpoints are used to debug processing of remote calls such as RFC or ICF processing.

Conditionally Considered

The consideration of a breakpoint may depend of a given condition expressed as logical condition. For instance, a variable has to have a defined value and, therefore, the debugger only stops if the condition is fulfilled. Such breakpoints are referred to as Conditional Breakpoints.

Activated

Apart from their existence breakpoints can be active or inactive.

In case you do not need a breakpoint being considered in your debugging session, you can deactivate it. You can turn it on again once you want to use it.

Discover changing Variables using Watchpoints

Watchpoints are quite useful whenever you are interested in the time point and the code at which a certain variable or an object attribute changes its value. Especially in very complex program flows with a deep call stack it may be hard to figure out value changes manually.

In order to create a watchpoint we navigate to the tab Break./Watchpoints, choose the tab Watchpoints and click the Create icon.

Considering the sample program about conditional breakpoints from above, we’re interested in spotting changes of the value of variable lv_foo.

In this dialog we can choose between inspecting variables of object attributes. We can also specify the respective ABAP program.

After creating this watchpoint and pressing F8 in our sample program, we get notified that the watchpoint has been reached.

Debugger Scripting

Debugger Scripting is a powerful mechanism to automate processes that occur often, are time-consuming and are conducted by hand.

Assume that you want to skip authorization checks by manipulating the sy-subrc value.

Disclaimer: Only do so if it is harmless, that is you must not abuse this feature. Tell you admin if you are authorized to use it and you are working in a field with sensitive data or processes.

You can open the tab Script in the debugger and there you will find a local class implementation. Besides the methods prologue, init and end you can add you own logic in the method script. On the left-hand side you can decide when the script shall be triggered. For instance, et every debug step or after once a watchpoint is


 

Escanear / Compartir

 

 


Sobre el autor

Publicación académica de Alejandro Luis Martinez, en su ámbito de estudios para la Carrera Consultor ABAP Nivel Inicial.

SAP Senior


Alejandro Luis Martinez

Profesión: Licenciado en Sistemas - Argentina - Legajo: EK90T

✒️Autor de: 2 Publicaciones Académicas

🎓Egresado de los módulos:

Disponibilidad Laboral: FullTime

Certificación Académica de Alejandro Martinez

✒️+Comunidad Académica CVOSOFT

Continúe aprendiendo sobre el tema "El debugger ABAP" de la mano de nuestros alumnos.

SAP Expert


1. Definición y Utilidad El Debugger ABAP (o depurador) es una herramienta esencial para el análisis y solución de problemas. Permite ejecutar programas paso a paso para verificar la lógica, inspeccionar el contenido de las variables, tablas internas y objetos de memoria en tiempo de ejecución,. Es fundamental para detectar errores y comprender el flujo del programa. 2. Versiones del Debugger Existen dos versiones: el Debugger Clásico y el Nuevo Debugger. Se recomienda utilizar el nuevo debido a sus mejoras. Configuración: Se puede cambiar la versión desde el editor ABAP (SE38) yendo al menú Utilidades > Opciones > Editor ABAP > Debugging y seleccionando "F.debugging...

Acceder a esta publicación

Creado y Compartido por: Gabriel José Luces González

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Senior

El debugger ABAP 1| El debugger ABAP Cuando programamos en ABAP, un programa solo va funcionar tal como deseamos que funcione si y solo si el código ABAP que forma parte del programa ha sido escrito a la perfección, es decir exactamente tal como se lo necesita. Si existe alguna diferencia o error en el código ABAP entonces el programa va producir resultados diferentes a los esperados, lo que dentro del ámbito de la programación solemos llamar como errores. Ahora bien, en ocasiones detectar esos errores es bastante fácil, lo podemos hacer a simple vista, mirando el código y en otra ocasiones es bastante más complejo y va a requerir que ejecutemos varias veces el programa en cuestión,...

Acceder a esta publicación

Creado y Compartido por: Felipe De Jesus Arrona Rodriguez

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Master


Uso del debugger ABAP Importancia del debugger ABAP El correcto funcionamiento de un programa ABAP depende de que el código esté bien escrito y libre de errores. El debugger ABAP es fundamental para encontrar y corregir errores, permitiendo analizar la lógica y los valores de las variables en tiempo de ejecución. Saber usar el debugger es tan importante como saber programar en ABAP, ya que gran parte del trabajo consiste en depuración tanto de desarrollos propios como ajenos. Tipos de debuggers y configuración Existen dos versiones de debugger: el clásico y el nuevo debugger; el nuevo incorpora muchas mejoras y es el recomendado. Para activar el nuevo debugger en la transacción...

Acceder a esta publicación

Creado y Compartido por: Juan Ignacio Romero

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Senior

Cuando programamos en ABAP, un programa solo va a funcionar tal como deseamos que funcione si y solo el código de ABAP que forma parte del programa ha sido escrito a la perfección, tal cual como se necesitaba. El debugger de ABAP Es una de las herramientas más poderosas que se tiene de SAP para el análisis y la solución de problemas. Se utiliza para ejecutar paso a paso y durante el proceso se puede verificar la lógica, inspeccionar el contenido de las variables de programa, las tablas internas , las variables del sistema, las áreas de memoria, entre otras opciones. Existen dos versiones de debugger: El debugger clásico: que es es la primera versión o funcionalidad de...

Acceder a esta publicación

Creado y Compartido por: Mara Fadua Romero Hernandez

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Junior

1 | El debugger ABAP Cuando programamos en ABAR un programa solo va a funcionar tal como deseamos que funcione si y solo si el código ABAP que forma parte del programa ha sido escrito a la perfección, es decir exactamente tal como se lo necesita. Si existe alguna diferencia o error en el código ABAP entonces el programa va a producir resultados diferentes a los esperados, lo que dentro del ámbito de la programación solemos llamar como errores. Ahora bien, en ocasiones detectar esos errores es bastante fácil, lo podemos hacer a simple vista, mirando el código y en otras ocasiones es bastante más complejo y va a requerir que ejecutemos varias veces el programa en cuestión, probablemente...

Acceder a esta publicación

Creado y Compartido por: Gustavo Jose Rondon Hernandez / Disponibilidad Laboral: FullTime + Carta Presentación

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Expert



El Debugger ABAP: Concepto, Funcionamiento y Buenas Prácticas El Debugger ABAP es una herramienta fundamental dentro del entorno de desarrollo SAP que permite a los programadores analizar y depurar programas ABAP en tiempo de ejecución. Su objetivo principal es ayudar a los desarrolladores a entender el flujo del programa, revisar el contenido de las variables, analizar condiciones lógicas y detectar errores en el código que podrían no ser evidentes durante la ejecución normal. ¿Qué es el Debugger en ABAP? El Debugger ABAP es una interfaz de diagnóstico integrada en SAP NetWeaver, diseñada para interrumpir la ejecución de un programa y permitir la inspección...

Acceder a esta publicación

Creado y Compartido por: David Ibarra / Disponibilidad Laboral: FullTime + Carta Presentación

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Expert


El debugger ABAP 1 El debugger ABAP Es una herramienta esencial para los programadores en SAP, ya que permite analizar la ejecución de un programa paso a paso, observar el contenido de variables, estructuras y tablas internas, y detectar errores lógicos. Tipos de Debugger: Clásico Nuevo Debugger: es el recomendado por SAP, más moderno y potente, y se configura desde el menú de opciones de SAP GUI. Funcionalidades principales: Breakpoints (puntos de interrupción): Estáticos: con la sentencia BREAK-POINT. Dinámicos: creados manualmente durante la ejecución. Watchpoints:...

Acceder a esta publicación

Creado y Compartido por: Geovanny Martínez Campoverde

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Master

1. ¿Qué es el Debugger ABAP? Definición: Herramienta para analizar programas ABAP ejecutándose paso a paso. Propósito: Detectar errores en la lógica del código. Inspeccionar valores de variables, tablas internas, áreas de memoria. Modificar valores durante la ejecución para probar escenarios. Importancia: ≈ 70% del tiempo de un programador ABAP se dedica a depurar. Esencial para entender programas existentes o corregir errores. Sin el debugger, depurar sería como "buscar...

Acceder a esta publicación

Creado y Compartido por: Oscar Aravena Muller / Disponibilidad Laboral: FullTime

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Senior

El debugger ABAP Cuando programamos en ABAP, un programa solo va a funcionar tal como deseamos que funcione si y solo si el código ABAP que forma parte del programa ha sido escrito a la perfección, es decir exactamente tal como se lo necesita. Si existe alguna diferencia o error en el código ABAP entonces el programa va a producir resultados diferentes a los esperados, lo que dentro del ámbito de la programación solemos llamar como errores. <<El debugger ABAP es una de las herramientas más poderosas que tiene SAP para análisis y la solución de problemas. Se utiliza para ejecutar programas paso a paso y durante el proceso se puede verificar la lógica, inspeccionar el contenido...

Acceder a esta publicación

Creado y Compartido por: Yeny Gisela Yanes Bautista

*** CVOSOFT - Nuestros Alumnos - Nuestro Mayor Orgullo como Academia ***

SAP Junior

Debugger: Con la herramienta de debug en SAP se pueden analizar los programas paso a paso, inspeccionando el contenido de las variables, las tablas internas, las variables del sistema, las áreas de memoria... Breakpoints: Un Breakpoint es un punto de interrupción dentro del código del programa, de tal forma qeu cuando la ejecución del mismo llegue a ese punto, el procesamiento se detiene y entonces se puede analizar lo que pasa justo en ese punto, antes de ejecutar la línea de código donde situamos el breakpoint. Se pueden colocar tantos breakpoints como queramos, normalmente interesa colocarlos en los puntos críticos donde creemos que se produce el error en cuestión. Tipos de breakpoint:...

Acceder a esta publicación

Creado y Compartido por: Miguel Angel Campo Velasco

 


 

👌Genial!, estos fueron los últimos artículos sobre más de 99.000 publicaciones académicas abiertas, libres y gratuitas compartidas con la comunidad, para acceder a ellas le dejamos el enlace a CVOPEN ACADEMY.

🔎Buscador de Publicaciones:


🔎Googlear en CVOSOFT:
Googlear: "ABAP - El debugger ABAP"

 


 

No sea Juan... Solo podrá llegar alto si realiza su formación con los mejores!