Supported by
Supported by Inetum

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.

Presenting the EGSAP_TECH app

images/thumbnail.jpg - Thumbnail

Do you know about the EGSAP_TECH app? It’s a SAP knowledge bank.

Here is a description in the words of its own creators:

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.

Chained exceptions

images/thumbnail.jpg - Thumbnail

Today I will teach you how to chain exceptions. It’s a very practical solution to a complicated, not so obvious problem. Let’s start by describing the problem. Imagine you are in the application BANANA. The application is quite complex. It has three modules: BANANA1, BANANA2 and BANANA3. Each one has its exception class ZCX_BANANA1, ZCX_BANANA2 and ZCX_BANANA3. Since the application is in fact well designed, all the exception classes inherit from the same ZCX_BANANA.

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,

Thou shalt use exception classes

images/thumbnail.jpg - Thumbnail

In classes, consider using exceptions classes over the old ones. These have great advantages and, once understood, are simple and allow for simpler code. https://zevolving.com/2011/12/class-based-exception/

Thou shalt use readily translatable explicit literals in programs

images/thumbnail.jpg - Thumbnail

In reports, instead of WRITE TEXT-001, use WRITE ‘bla bla bla’(001). This way a default text will always be there and besides the readability of the program is improved. https://abapinho.com/en/2011/11/programas-poliglotas/

Thou shalt use SALV instead of the old ALV functions

images/thumbnail.jpg - Thumbnail

SALV classes are more versatile and more recent than the old function modules. So, for new ALVs always use SALV. The only exception is editable ALVs which SALV classes are still very incapable of doing. https://scn.sap.com/docs/DOC-10365 https://scn.sap.com/docs/DOC-10366

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.

Communication by event between programmes

images/thumbnail.jpg - Thumbnail

In Greek mythology, the gods’ most commonly used means of communication with mortals was rape. They would rape for no reason whatsoever.

The closest thing we have to rape in ABAP is the command “SUBMIT”, which is also the most common way of communicating between two programmes.

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?

INNER JOIN vs FOR ALL ENTRIES vs artificial RANGES

images/thumbnail.jpg - Thumbnail

Since data operations are much more optimized in the database server than in ABAP, it is always better to use the first as much as possible. FOR ALL ENTRIES should only be used when INNER JOIN doesn’t give us what we need or is not possible (like with BSEG for example). Artificial ranges are also a possible alternative to FOR ALL ENTRIES but be careful not to reach the SQL parser limit.