Debugging an infinite loop already in execution

images/thumbnail.jpg - Thumbnail

Imagine you have a program executing an infinite cycle or, at least, a cycle with 70x7 iterations. It is neverending, and you want to know what’s going on there.

In the past you had to go to SM50, select the process and choose from the menu “Administration | Program | Debug”.

But now there is a much easier way.

Request Based Debugging

images/thumbnail.jpg - Thumbnail

If you look up the UNAME system variable in debug within a RFC call you may think it kind of odd to find a username that is not your own. What happens is that the system adopts a specific username for remote calls and a new session is started. A new session implies a new execution context and, hence, all our strategically placed breakpoints will no longer be recognised.

This problem can hinder a simple debug forcing us to run through the code looking for THAT remote call to THAT particular system.

SAP has a solution.

How to debug a job

images/thumbnail.jpg - Thumbnail

Here’s a simple way to start debugging a job:

  1. Go to transaction SM37;

  2. Click on the job you want to debug;

  3. type JDBG in the command line (without /) and press ENTER;

  4. and… bang! you’re now debugging the job.

Thank you Ricardo Monteiro for the tip. And thank you Ingolf for the photo.

Greetings from Abapinho

Shortcut for time travelling

images/thumbnail.jpg - Thumbnail

Some months ago I showed how to transform the debugger into a time machine.

Today’s tip is simple but useful: there is a keyboard shortcut which makes it even simple to travel in time:

shift + F12

Just place the cursor in the line you want to travel to and then… shift+F12.

Thank you Maxsuel Maia for the tip.

Greetings from Abapinho.

Close the frozen window

images/thumbnail.jpg - Thumbnail

How many times have you been left with a “hanging” window when you end a debug?

Hold on… but not yet

images/thumbnail.jpg - Thumbnail

You are doing a LOOP AT in a 1000-line table, and you know that you want line 853. Until recently, you had two options: either hit F8 852 times, running the risk of hitting it 853 times and having to start all over again, or create a watchpoint with the condition SY-TABIX = 852 or something close, and pray that it worked.

Now you have a third option.

/HS Command

images/thumbnail.jpg - Thumbnail

Most functionals, and even the hardcore functionals, knows that in order to start debugging an ABAP program, we use the /H command. But few programmers, even the hardcode programmers, will know the purpose of the /HS command.

Jump The Wall

images/thumbnail.jpg - Thumbnail

Turn down the music. Close the door. Look around. Is anyone looking at you? Are you being watched? Are there any security cameras? If not, we can go on.

Oh time turn back

images/thumbnail.jpg - Thumbnail

“Oh time turn back Give me everything I have lost Take pity and give me the life The life I have already lived Oh time turn backward Kill off my futile hopes Look how even the sun itself Returns every morning” – António Mourão

Hey Tony, right away. I will show you how you can turn back time.

Create test variants within functions from the debugger

images/thumbnail.jpg - Thumbnail

Imagine that you are debugging a transaction, you enter into a function and find something interesting. So interesting that you have to debug it several times. The conventional way is to start the debug of the transaction again from the beginning. How tedious.

But there is a more direct route. When you are debugging a function you can create test data for this function directly from the debugger, using the values with which the function had been called at that time. For instance: