Thou shalt not use direct code in user-exits

images/thumbnail.jpg - Thumbnail

All code to be put in user-exits (BADIs, enhancements, SMOD, etc.) should be encapsulated. It’s common for an user-exit to include multiple independent parts. Each of these parts should be encapsulated in its own method. Even if it is only one line; This should apply to both new implementations and changes to existing code; A change to existing code should always be seen as an opportunity to organize existing code into methods, since it will have to be tested again anyway;

Deleting packages that do not want to be deleted

images/thumbnail.jpg - Thumbnail

When you try to delete a package where you have created objects that have meanwhile been deleted, and the package looks empty in SE80, when you try to delete it, it won’t work because it says the package still contains objects.

For some silly reason, SE80 does not show every type of object associated with packages. In addition, when an object is deleted, its entry is often times not deleted correctly. SAP is full of shortcomings. But it’s what we have, and it’s what brings us the bacon, so let’s not say too many bad things about it.

Abapinho has the solution for you.

Thou shalt not implement in classical processing blocks

images/thumbnail.jpg - Thumbnail

Official ABAP Programming Guidelines (page 34): [When a classical processing block is required], you should immediately delegate the execution to a suitable method (see Rule 6.37, No Implementations in Function Modules and Subroutines, and Rule 6.44, No Implementations in Dialog Modules and Event Blocks).

0 is Private, 1 is Protected, 2 is Public

images/thumbnail.jpg - Thumbnail

Simple tip to speed up entering data in (some) fields.

Thou shalt use ABAP OO whenever possible

images/thumbnail.jpg - Thumbnail

All new developments should be implemented using ABAP Objects unless still impossible (RFC, IN UPDATE TASK, screens, etc). Existing developments, when rewritten, should also be converted to OO, if it proves to be realistic. Official ABAP Programming Guidelines (page 32) rule 3.1: Use ABAP Objects whenever possible for new and further developments. Classical processing blocks may be newly created in exceptional cases only. pdf/why-abap-objects.pdf https://scn.sap.com/people/thomas.jung/blog/2007/12/19/update-your-abap-development-skills-to-sap-netweaver-70 https://wiki.

Read the texts of a program

images/thumbnail.jpg - Thumbnail

An easy way of programmatically accessing the texts of any program: DATA: t_textos TYPE TABLE OF textpool. READ TEXTPOOL sy-repid INTO t_textos LANGUAGE sy-langu STATE 'A’. Now, you have all of the texts available in the internal table T_TEXTOS. As if this were not enough, you can also change the texts programmatically with the following commands: INSERT TEXTPOOL sy-repid FROM t_textos LANGUAGE sy-langu. DELETE TEXTPOOL PROGRAM LANGUAGE 'E’. According to SAP, these last two commands are for internal use only.

SELECT within SELECT

images/thumbnail.jpg - Thumbnail

ABAP programmers don’t explore the possibilities of SQL, probably for historical reasons. There are many who instead of using INNER JOINs still think it’s faster to do several SELECTs for internal tables and then process the data in ABAP. But the truth is that even if there are exceptions, the rule is: the lower the number of accesses to the database, the better the performance. And it makes sense because, after all, they were written explicitly for this; relational databases are much more adept at processing relational data than an ABAP program.

There are of course things that, due to their complexity, cannot be done with a simple INNER JOIN. Nevertheless, some of these things can be done in a single SELECT.

Get information on a remote system by RFC

images/thumbnail.jpg - Thumbnail

Here’s a cool mini-function to obtain some details of a remote system accessible by RFC: RFC_SYSTEM_INFO I cannot give any example here because it would reveal very important secret information about my client which would certainly be used by the baddies to perform industrial espionage. But it is easy to test in SE37. Thanks to kingofthebigmacs for the photo. Greetings from Abapinho.

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.

Class with loads of methods to deal with dates

images/thumbnail.jpg - Thumbnail

There are countless standard functions to make calculations with dates. There are too many of them, they are redundant and, in many cases, they are obscure or impossible to understand. I’ve been meaning to insert an article here with a list of the most useful ones. But now it’s no longer necessary.

How to debug a job

images/thumbnail.jpg - Thumbnail

Here’s a simple way to start debugging a job: Go to transaction SM37; Click on the job you want to debug; type JDBG in the command line (without /) and press ENTER; 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.

Use a password manager in your life

images/thumbnail.jpg - Thumbnail

And there you go, if you read the title you know the hint.

Now, here are some hints about the hint:

I'm 5 years old!

Hello, my name is Abapinho and I’m 5 years old. I’m still growing up. Thank you to everyone who visited me during my short life and a special thank you to all those who participated with tips, ideas and posts. Greetings from me, Abapinho.

Abapinho's best practices

images/thumbnail.jpg - Thumbnail

Recently, I have compiled a set of personal best practices. I decided to share them here by creating a new category (which will soon appear on the menu to the left) into which they will be grouped. The original idea was to make a PDF file but, since they are constantly being reviewed and expanded, this was largely impractical. As such, they will be published one by one. The goal is for these practices to be visible in their entirety as a user-friendly, accessible reference.