Tag > estilo
Supported by
Supported by Inetum

Create RANGEs in DDIC without getting all wound up

images/thumbnail.jpg - Thumbnail

I am using RANGEs more and more. I use them at breakfast, lunch, and dinner and outside meal times. It’s like soy sauce. A few spoonfuls and everything is instantly tastier.

Benefits of LIKE LINE OF

images/thumbnail.jpg - Thumbnail

Let’s start by assuming that you have some dignity and so you don’t use internal tables with HEADER LINE anymore ;)

Given this, let’s suppose you declare an internal table:

INSERT and APPEND with ASSIGNING FIELD-SYMBOL

images/thumbnail.jpg - Thumbnail

The harsh truth, at all costs, is that structures are out of date. Nowadays FIELD-SYMBOLS are in.

When you make a LOOP to an internal table of course that you also use ASSIGNING FIELD-SYMBOL instead of INTO Structure,correct?

But what was screwing everything over was APPEND and INSERT. I did not know how to use a structure to add records

If you still don't use ABAP Objects you're chicken

images/thumbnail.jpg - Thumbnail

SAP has a book called Official ABAP Programming Guidelines which describes rules and best practices on how to program in ABAP. In there you can read: Page 42: Rule 3.1: Use ABAP Objects whenever possible for new and further developments. Classic processing blocks may be newly created in exceptional cases only. Page 45: Within such a [classic] processing block, however, you should immediately delegate the execution to a suitable method (see Rule 6.

More RANGEs, less SELECTs

images/thumbnail.jpg - Thumbnail

The dictionary has the following entry for “style”: “set of formal aspects and expressive resources that characterise a text.”

It is preferable to read a text with style than one without. If ABAP were a language, a program in ABAP would be a text. When it comes to style, there are programs that seem to have been written by the feet, while there are others that one would swear the quill that wrote them was guided by the pure hand of an eighteenth century lady plagued by the troubles of love. Fortunately, I think it’s not possible to write programs in ABAP as tacky as the last sentence.

The “style” label is used here in Abapinho to identify articles that talk about just that: style. These articles try to find ways to improve the style of ABAP programs. This is one of Abapinho’s favourite labels, as you can see here. And what you are reading is another of those articles.

Moving on.

Gregarious constants

images/thumbnail.jpg - Thumbnail

If you are one of those who insert the values directly in code instead of using constants, then read no more and go and stand over there in the corner on punishment for 1 hour to learn not to be lazy. If you’ve come back from punishment or you usually use constants, then please continue reading.

Search object attributes in an internal table

images/thumbnail.jpg - Thumbnail

There are increasingly more objects in ABAP, gradually less fear of them and, lo and behold, more and more people are writing and using them. It is normal and desirable, if objects begin to appear everywhere, to start to stuff them into internal tables. I also stored a load of objects in tables a while back, unfortunately I did not know at that time what I am going to teach you here. It could have come in handy.

So, what exactly am I going to teach you here?

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.

Automating the ALV field catalogue

images/thumbnail.jpg - Thumbnail

Sometimes I ask myself what percentage of the world’s ABAP code is unnecessary. A paradigmatic example of how time can be wasted writing code which is of no use to anyone and only creates problems is the ALV’s all-too-common field description definition sitting directly in ABAP.

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 'Erro!' DISPLAY LIKE 'E'. EXIT. ENDIF. WRITE 'Olá, eu sou o resto do programa'.

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’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?

Stand up, all victims of oppression

images/thumbnail.jpg - Thumbnail

Classes. They have always existed among people. But there are still few who take them into consideration in ABAP. While being a supporter of classes in society can result in pedantry, the only class struggle in ABAP is that some fight for them to be used more. There are two types of classes: global and local. The global ones are created in the SE24 transaction. Local classes, which by the way I find myself using more and more, are done declaratively in SE38.

SPLIT INTO TABLE

images/thumbnail.jpg - Thumbnail

I’m going to show you a creative way of filling out an internal table with constants that I learned in a standard program. Imagine you want to create an internal table with the following kinds of financial documents: AB AF CH DG DZ EX F3 F4. The more conventional way would be this: DATA: t_blart TYPE STANDARD TABLE OF blart, wa_blart LIKE LINE OF t_blart. wa_blart = 'AB'. APPEND wa_blart TO t_blart.

Unparameterisable parameters

images/thumbnail.jpg - Thumbnail

Every now and then you get a client who asks a programmer to create a write-protected parameter on the program selection screen. It’s a bit dumb given that the whole idea of parameters is that they are parameterisable. But there you go, it takes all sorts. Clients have so much imagination that SAP should create a cinema module, SAP CI, especially so they can screen all the films they carry around in their heads.