Category > Tips & tricks
Supported by
Supported by Inetum

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:

The SAPGui history does not work even when active?

images/thumbnail.jpg - Thumbnail
Has it ever happened to you that SAPGui does not store a history of values that you input to various fields even though the History option is actived in the settings?

SE80 has favourites

images/thumbnail.jpg - Thumbnail
The SE80 transaction contains everything. It seems like those village grocery stores crammed with junk where you can buy toothpaste, bread, shoes, perfume and rice in bulk. I like these grocery stores. But to go there you need to know where you are going, otherwise you’ll walk from pillar to post. But this is what it’s like in these grocery stores but in SE80…. there are favourites. Yes indeed there are.

If a stranger offers you values, this is Input

images/thumbnail.jpg - Thumbnail
In a report, the values are normally requested from the user at the first selection screen before the program is run. But what if you want to interactively ask for more values in the middle of running the program?

Selection screen with tabs

images/thumbnail.jpg - Thumbnail
The selection screens of ABAP programs have several features that, although complex and easy to use, are generally ignored. Here, I will show you how easy it is to create tabs to better organise the parameters of a program. This time though, and uncommonly, I’ll spare you the verbal onslaught. It’s a practical class.

Debugging while in modal dialogue boxes

images/thumbnail.jpg - Thumbnail
There are times when you can’t do /H to launch debugger. The most common one is when a pop-up window is open. However there is a simple, if Heath-Robinson, way to do it:

What does a message say?

images/thumbnail.jpg - Thumbnail
Do you want to obtain the text from a message when you only know the ID and the number, but you don’t know how? Find out here: DATA text TYPE string. MESSAGE ID '00' TYPE 'E' NUMBER '163' WITH '123' INTO text. That’s all it is. Now inside the text variable, you find the following text: “Client 123 does not exist in the system” Thanks to Peteris B for the photo.

Be lazy when you write in ABAPese

images/thumbnail.jpg - Thumbnail
To find out which professions attract the laziest people, I googled the following: Profession Results “médico preguiçoso (lazy doctor)"| 2,140,000 “advogado preguiçoso (lazy lawyer)"| 1,430,000 “gestor preguiçoso (lazy business administrator)"| 1,020,000 “engenheiro preguiçoso (lazy engineer)"| 647,000 “político preguiçoso (lazy politician)"| 602,000 “economista preguiçoso (lazy economist)"| 284,000 “pedreiro preguiçoso (lazy builder)"| 91,200 As this conclusively proves, engineers are not lazy enough as they are beaten by lawyers and doctors. This must change. And this tip will help. But not without making the following difference clear: lazy is not work-shy. I am talking here about noble laziness, the behaviour of those who like doing things but with the least possible effort. Lazy slobs are not included here. SAP is something that evolves slowly, and it launched a new editor a few years ago that is full of capabilities many of which, while handy, are barely used. One of them is called ‘Code templates’ which I will now demonstrate:

Multiple choice ALV in a modal dialogue box

images/thumbnail.jpg - Thumbnail
Do you know how to present an ALV with a list of records in a dialogue box allowing multiple choice? I didn’t. But I do now. Let me explain how.

<!--:pt-->Pasta temporária do SAP Gui<!--:-->

images/thumbnail.jpg - Thumbnail
Sometimes a program wants to save a file locally on the user&rsquo;s computer via the SAP Gui. In these cases it is usual that one of the fields of the selection screen is the location of the folder on the local disk. This is a way of initialising this field with the temporary folder of the SAP Gui: PARAMETERS: p_path TYPE string. AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path. CALL METHOD cl_gui_frontend_services=&gt;directory_browse EXPORTING initial_folder = p_path CHANGING selected_folder = p_path.

Partial Analyses in SE30

images/thumbnail.jpg - Thumbnail
Obviously you already know the SE30 transaction (run time analysis) and obviously you use it often to analyse standard programs and to discover tables, functions, BADIs and similar contained within them. But if you are like me, then you have a love-hate relationship with this transaction – on the one hand you love it because it enables you to see the guts of a program without having to debug it, yet on the other hand you hate it because normally the list of guts tends to have thousands of lines and becomes unmanageable.

Multilingual programs that know what they are talking about

images/thumbnail.jpg - Thumbnail
SAP is multilingual. But ABAP not always. ABAP does have some ability to learn and speak a few languages, but sometimes the programmers do not let it. A lot of programmers whack literal texts directly into the program, leaving it forever unable to communicate in multiple languages. I can think of two reasons for shackling a program to just one language: Laziness, the main reason for doing things badly;

Fair thee well DESCRIBE TABLE. And good riddance.

images/thumbnail.jpg - Thumbnail
For twelve long years When I wanted to count The lines of an itab I did what everyone does: DESCRIBE TABLE itab LINES linhas. Until the other day When (my eyes didn’t deceive me) I saw something so new, You wouldn’t believe me: LINES( itab ). It gives the same outcome And does away with declaring The damn variable. So instead of: DATA: linhas TYPE i. DESCRIBE TABLE itabl LINES linhas.

The drag queen message

images/thumbnail.jpg - Thumbnail
The AT SELECTION-SCREEN modules of a report can throw error messages and send you back to the selection screen. But once you get past the START-OF-SELECTION, if you get an error message, the program ends. The solution to getting an error and returning to the selection screen, is to disguise the message: START-OF-SELECTION. IF condicao_desejada. MESSAGE S208(00) with &#39;Erro!&#39; DISPLAY LIKE &#39;E&#39;. EXIT. ENDIF. WRITE &#39;Olá, eu sou o resto do programa&#39;.

The round-about routes of VALUE CHECK

images/thumbnail.jpg - Thumbnail
Have you ever come up against something in ABAP that seems to be one thing but is in fact another? The documentation says it is this and everything seems to indicate that it is, but after all it isn’t. You&rsquo;ve probably needed to, when setting a parameter in the report selection screen, check the possibilities of what the user can input to the available values in the data type of that parameter, right?