"
Supported by

Best practices
Consider converting WRITE reports into ALVs

ashtanga15

Reports still writing directly to the screen are very hard to maintain whenever changes to the layout are required. On such occasions, review the code and, if the effort involved is not too big, consider converting it to ALV. Always involve the functional people in this decision.

(Português) Curso online grátis de depuração

logo

Sorry, this entry is only available in Português. For the sake of viewer convenience, the content is shown below in the alternative language. You may click the link to switch the active language.

O Pedro Lima (responsável pelo OnSAP) fez um curso online grátis a ensinar os rudimentos da depuração em ABAP. Espreitem pois está bem feito e porque estas iniciativas merecem todo o nosso apoio. Tenho a certeza de que o Pedro fará mais cursos se vir que há público interessado.

Aqui

Nota: o curso é em inglês.

O Abapinho saúda-vos

No more english translations

uk_flag

Sadly, Abapinho will not be able to continue posting the English translation of the Portuguese posts. I am sorry to all the readers who don’t speak Portuguese.

Abapinho’s main goal has always been to publish ABAP content written in Portuguese. But the possibility of also publishing them in English was a great asset because it allowed us to reach a much wider audience. We were able to do it for several years because the translations were sponsored. Unfortunately, at least for now, this will no longer be possible. For this I ask your understanding.

Greetings from Abapinho.

(Português) CALL FUNCTION com DESTINATION ‘NONE’ cria nova LUW

elvis_boca

Sorry, this entry is only available in Português. For the sake of viewer convenience, the content is shown below in the alternative language. You may click the link to switch the active language.

Sabias que quando invocas uma função com a opção DESTINATION ‘NONE’ estás a iniciar uma nova LUW?

Isto pode parecer apenas uma curiosidade, mas há um caso em que pode fazer toda a diferença: sabes aqueles módulos de função que ao serem chamados uma segunda vez têm um comportamento diferente da primeira vez? Isto acontece porque eles hão-de ter alterado alguma variável global ao grupo de funções. Ora se iniciares uma nova LUW quando chamares a função, o seu grupo de funções é automaticamente inicializado e assim garantes que o comportamento da função é o esperado.

Há um exemplo disto na nota OSS 770626.

Obrigado Artur Moreira pela dica.

Quanto à foto, decidi que os dentes do Elvis são uma boa forma de representar LUWs.

O Abapinho saúda-vos.

(Português) Debug de um job

bug_em_ecra

Sorry, this entry is only available in Português. For the sake of viewer convenience, the content is shown below in the alternative language. You may click the link to switch the active language.

Para fazeres debug a um programa que faça parte de um job faz o seguinte:

Ler o resto do artigo! »

Converting an exception into an exception

estafetas

If you’re still not using exception classes, then you’re making a mistake. Cause they are very healthy for your code. They’re not only good nutrients for the system, they also make it lean and less vulnerable to diseases.

There are cases where you still need to deal with the old exceptions. For example, when a function module is invoked.

In this article I am presenting a suggestion that seems a little complex, but it works very well if you need to integrate the old exceptions with exception class in a simple way. And though it is sophisticated, you only need to do it once. Once it’s done, it’s easy to use.

Ler o resto do artigo! »

(Português) Novo livro “UI5 para desenvolvedores SAP/ABAP”

abap101

Sorry, this entry is only available in Português. For the sake of viewer convenience, the content is shown below in the alternative language. You may click the link to switch the active language.

O Flávio Pagoti, do blog ABAP101 publicou um livro em português sobre SAPUI5/OPENUI5.

Aqui está o artigo do ABAP101 a anunciar o livro. Lá encontras um link para o comprar. Custa $9,99.

A minha principal motivação quando decidi criar o Abapinho foi exactamente combater a gritante falta de conteúdos técnicos de qualidade escritos em português. Hoje as coisas estão um pouco melhores, em particular no mundo do ABAP onde há vários blogs de óptima qualidade. É fantástico que surjam publicações em português nesta área, ainda por cima de um assunto tão novo e inovador como este. Desejo-lhe muito sucesso.

Se prezas a tua carreira como ABAPer aconselho-te a começares a dar atenção a estas novas tecnologias e abordagens. Aqui tens uma oportunidade não só de o fazer como de apoiares a criação de conteúdos técnicos em português.

O Abapinho saúda-vos.

Teach ABAP to juggle

linhas_paralelas

What can be done when a night is not enough to complete the daily processes?

Ler o resto do artigo! »

Best practices
Thou shalt modularize, modularize, modularize

ashtanga02

Historically ABAP programs tend to grow very loooong. All programming best practices teach us there is not a single advantage in this approach.
If any routine, be it a program, a method, a function or anything else, becomes longer than 200-300 lines, question it and seriously consider refactoring it into several sub-routines.
This has the added advantage of potentially increasing code reuse. But the greatest advantage is encapsulation, isolating variables in their local context, instead of having all of them together, resulting in safer and more readable code.
The Official ABAP Programming Guidelines book advises this in its chapter 2.2 KISS (pages 32-34).
http://help.sap.com/abapdocu_731/en/abenencapsulation_guidl.htm

Best practices
Thou shalt reuse, thou shalt not rewrite

ashtanga03

If the same piece of code is repeated at least once, question yourself why and try to avoid it by creating a reusable routine.
If there is more than one SELECT for the same table in a program, make sure you can’t merge them into a single one. Sometimes a smart use of RANGEs to unify parameters can avoid the need for multiple SELECTs.
If the same code is used in 2 different programs, don’t repeat the code. Instead, create a class for it which can be shared by both and move the reused code to the common class.
http://abapinho.com/en/2012/06/mais-ranges-menos-selects/

Best practices
Thou shalt avoid global variables

ashtanga04

The more global variables a program has, the most obscure it becomes. Please avoid them. This is a basic rule of good programming and should always be followed. Even if several variables have to be passed by parameter, it takes slightly more effort but yields a much more readable and safer code.
Exceptions can be made for simple reports which run around a single internal table, which can be declared globally without compromising clarity.

How to ask if the line exists without seeming fashioned

carris

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?

Ler o resto do artigo! »

Stop the functions module’s error messages

silencio

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.
 
Ler o resto do artigo! »

Text search in a WebDynpro

seti

SAP doesn’t know how to do things right the first time. The WebDynpros are a good example of this. It doesn’t even let you do a text search. It’s sad.

Fortunately Sérgio Fraga has found a way, though it’s rather laboured:

Ler o resto do artigo! »

It’s my birthday!

6velas

I’m 6 years old!

(Thank you Caleb Prichard for the photo)

Best practices
Thou shalt always use a predefined structure with ALV

ashtanga13

It is common to find an ALV data structure explicitly defined in the code. If this is done, the field catalog has to be manually constructed. If a predefined structure (from DDIC or declared as a TYPE) is used instead, the field catalog can be automatically built. This approach is always better and results in less code, even if the field catalog needs to be adjusted here and there.
http://abapinho.com/en/2011/12/automatizar-catalogo-alv/

Best practices
Thou shalt use TRANSPORTING NO FIELDS

ashtanga06

Many times we do READ TABLE itbl or LOOP AT itbl just to do a CHECK SY-SUBRC = 0. In these cases, the actual data read is not needed. For these cases always use TRANSPORTING NO FIELDS. This way is faster and avoids having to declare a target structure.

Debugging an infinite loop already in execution

cobra-infinita

Imagine you have a program executing an infinite cycle or, at least, a cycle with 70×7 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.

Ler o resto do artigo! »

How many includes is a class made of?

sapateira

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.
Ler o resto do artigo! »

Unreleasing a released transport order

mulher-policia

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.
Ler o resto do artigo! »


About Abapinho
Abapinho runs on WordPress
Articles (RSS) e Comments (RSS).