Category > Tips & tricks
Supported by
Supported by Inetum

[:pt]Debug de um job[:]

images/thumbnail.jpg - Thumbnail
[:pt]Para fazeres debug a um programa que faça parte de um job faz o seguinte:

How to ask if the line exists without seeming fashioned

images/thumbnail.jpg - Thumbnail
Long ago, you used the expression “groovy, man”. Later came “great, man”. Then there was “cool”. Today you say “awesome”. It’s important not to get confused and not make a fool of yourself. And how do you ask an internal table if a line exists exists?

Stop the functions module's error messages

images/thumbnail.jpg - Thumbnail
There are standard functions that trigger messages where they shouldn’t. And they shouldn’t because we want to use these functions in non-interactive programs and then, instead of returning the error, an error message is triggered and ruins the whole process. However, being aware of this problem, SAP has provided a quite elegant (but not well documented) way of solving this problem.

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.

How many includes is a class made of?

images/thumbnail.jpg - Thumbnail
No matter how many times things go around in ABAP, everything ends up in SE38. Even the methods of the ABAP classes are saved in includes. Sometimes, when there is a dump, it says the problem is, for example, here: CL_MESSAGE_HELPER=============CM001.

Unreleasing a released transport order

images/thumbnail.jpg - Thumbnail
You’ve released a transport order because you thought everything was ready. However, one more minor modification was still missing. So now you will have to create a new order and transport both of them. What a drag. Don’t worry.

SELECT-OPTIONS default behavior

images/thumbnail.jpg - Thumbnail
Abapinho received a letter. Mr. Abapinho, Everybody knows how to set default values in select options using the DEFAULT keyword. What some people may not know is that one can also set the default option, sign and even if allows for intervals or just fixed values.

Ignore function module exceptions

images/thumbnail.jpg - Thumbnail
When calling a function module which returns exceptions you normally give them sequential numbers like this: CALL FUNCTION 'GO_BUT_PLEASE_COME_BACK' EXPORTING ali = 'To the moon' EXCEPTIONS NOT_FOUND = 1 GOT_LOST = 2 OTHERS = 3. But Code Inspector may be configured to report a warning if afterwards you are not careful to add an IF or a CASE to look at SY-SUBRC,

Let's concatenate

images/thumbnail.jpg - Thumbnail
We start with two variables: DATA word1 TYPE string. DATA word2 TYPE string. DATA: phrase TYPE string. word1 = ‘this’. word2 = ‘that’. And we want to concatenate them adding the word “plus” between them and, of course, separate them by space.

Write in multiple lines at the same time

images/thumbnail.jpg - Thumbnail
The ABAP editor has many curious functionalities. You can even write in multiple lines at the same time.

Where is the boolean?

images/thumbnail.jpg - Thumbnail
It’s not. But they - the people who make and remake the ABAP itself - are trying to mend this unfortunate situation. Look at this new functionality:

LOOP AT tbl ASSIGNING <line> CASTING

images/thumbnail.jpg - Thumbnail
Did you know that you can do a LOOP on an internal table of one type into a structure of a different type?

Block indent

images/thumbnail.jpg - Thumbnail
To indent a block of lines do the following:

Clearing the buffers of an SAP session

images/thumbnail.jpg - Thumbnail
I keep learning new transaction commands. Today I learned some which solve a problem which, although rarely, has happened to me in the past. Did this happen to you? You make a change to a text of a data element you’re using in a table to be edited through SM30. But when you go and edit that table in SM30 the old text is still there. You activate objects, close windows, open windows, no matter what you do, the new text is not shown.

Automatic model just using CTRL-SPACE

images/thumbnail.jpg - Thumbnail
Of course you already know the “Model” button in the ABAP editor that allows you to automatically add models for function modules, calls for methods and others. The new editor has now grown a bit (it’s now only 10 years behind Eclipse instead of 20) and it allows you to automatically complete some commands through the CTRL-SPACE shortcut.