Category > Tips & tricks
Supported by
Supported by Inetum

Taking a nap

images/thumbnail.jpg - Thumbnail

Whatever the case, it is necessary to put a program to sleep. And, as with almost everything else, there are several ways to do this, some better than others. The most standard way to do this in ABAP is as follows: WAIT UP TO 10 SECONDS. The advantage of WAIT UP TO N SECONDS is that the process is freed up during these 10 seconds, thereby making it available for those who want it.

Different versions of the same story

images/thumbnail.jpg - Thumbnail

Everyone knows that the SAP versions are a big mess. The lords of Heidelberg who play around with the names they give their things are either an impulsive bunch, are making fun of us, or they must always be in uproar. Here is a little table to help to unravel them: Ano | UI | Edition | Version | Version | BASIS | WebAS | ECC | NetWeaver —|—|—|—|—|—|—|—|— | Terminal

Global macros

images/thumbnail.jpg - Thumbnail

In a previous article we talked about macros, a relatively obscure and little used feature that can be both useful as well as create a huge mess. But these aren’t the only ABAP macros. There are others that are even more obscure and with even greater potential to mix up a system: the global macros. I don’t know if I should tell you this, as it’s so strange… But, I don’t think it’s a good idea to hide it… Therefore, I’ll tell all.

Start on the right footing

images/thumbnail.jpg - Thumbnail

Normally when you log on to SAP the SAP menu appears. But you can use the function module NAVIGATION_SET_START_TCODE to pre-set an initial transaction. Anyway, it’s better to know it’s there than not to know it’s there, and even better than knowing that it’s not there. Who knows – it could be good for some users. There’s also the function module NAVIGATION_GET_START_TCODE to see what is pre-set. Greetings from Abapinho.

Not even David Copperfield would do better

images/thumbnail.jpg - Thumbnail

Sometimes we want to access a transaction and we don’t have permission. That’s annoying. Luckily there’s the function module ALINK_CALL_TRANSACTION which makes things better. But use it with care or someone will get angry. Welcome to the dark side of Abapinho. If they say it was me that said it, I deny everything. Update: this function module will also do the trick: CALL_TRANSACTION_FROM_TABLE. New update: if all the above fail try this other function module: RS_HDSYS_CALL_TC_VARIANT (clearing flag AUTHORITY_CHECK).

ABAP Ninja

images/thumbnail.jpg - Thumbnail

One of the major new features in ERP 6.0 is the Enhancement Framework, a kind of “landlord’s friend” that allows you to hammer on all the SAP walls without chipping the paintwork. Unfortunately there’s still very little documentation about this and it’s always difficult to find the right Enhancement Point for the hammering you want. The a ABAP Ninja site tries to help. It’s an Enhancement search engine. They say they have more than 13,000 Enhancement Points waiting to be found.

St. Isidore of Seville

images/thumbnail.jpg - Thumbnail

Don’t know who to pray to in moments of desperation? Now you can relax. Programmers have a saint – St. Isidore of Seville. A very learned and intelligent gentleman who lived in Spain in the 6th and 7th centuries and, to quote Wikipedia, “wrote about mathematics, astronomy, medicine, human anatomy, zoology, geography, meteorology, geology, mineralogy, botany and agriculture. He added nothing innovative or original, carried out no experiment, made no new observations or reinterpretations and discovered nothing, but his influence on the Middle Ages and the Renaissance was great”.

LOOP FROM INDEX

images/thumbnail.jpg - Thumbnail

It’s very easy to get tied up in knots where performance is concerned when you’re working with internal tables – especially when they’re getting really big. In fact these problems often only arise after a few months, when the tables tend to grow as time goes by. For example, when you’re looping two tables, one of headers and another of entries, do you do this? LOOP AT itab1 ASSIGNING <fs1>. LOOP AT itab2 ASSGNING <fs2> WHERE field1 = <fs1>-field1.

Progress indicator

images/thumbnail.jpg - Thumbnail

You know those progress bars that show how long it will take for a process to end? The ones that sometimes go back to the beginning when they reach the end and leave you frustrated and confused and wondering what use they are anyway? Here’s how you can use them in an ABAP program. DATA: lv_texto TYPE char40, lv_valor type i. DO 10 TIMES. WAIT UP TO 1 SECONDS. CLEAR lv_texto.

<!--:pt-->Executa um comando no teu computador<!--:-->

images/thumbnail.jpg - Thumbnail

Imagina que queres executar um programa no teu PC a partir de um programa ABAP. Não sei porque carga de água quererás tu fazer isto mas ok, se queres mesmo fazer, é assim: DATA: i_returncode TYPE i. CALL FUNCTION 'GUI_EXEC' EXPORTING command = 'Notepad.exe' parameter = 'eu_sou_um_texto.txt' IMPORTING returncode = i_returncode. É provável que dê para fazer coisas boas com isto. Mas está à vista a grande javardice que se pode fazer por isso pensa bem antes de começares para aí a escangalhar os computadores dos utilizadores todos.

SAT – The new execution analysis tool

images/thumbnail.jpg - Thumbnail

Since I was small I have been using the SE30 transaction for two different things: To analyze a (normally standard) program I don’t know in order to find out what functions it uses, what BADIs it offers, etc; To analyze a program of mine to search for performance problems. The simple truth is that the SE30 transaction is a total mess. It’s extremely limited and inflexible and it’s useless for any more complex analysis.

<!--:pt-->As estruturas PRE-a-porter<!--:-->

images/thumbnail.jpg - Thumbnail

Quantas vezes não é necessária uma pequena estrutura para guardar, por exemplo, uma lista que relacione materiais e centros. Mas perder tempo a inventar a roda é sempre de evitar. No reino do MM há uma pequena família de estruturas que uso amiúde: são elas as PRE*, uma série de estruturas que vai desde a PRE01 à PRE50, com uns saltos pelo meio. Embora sejam, na sua maioria, específicas demais para servirem algum propósito, há algumas úteis.

<!--:pt-->A Ressurreição de um programa<!--:-->

images/thumbnail.jpg - Thumbnail

Batendo impetuoso com seus braços no peito, o famoso guerreiro gritava desesperado: “Oh meu Zeus! Apaguei um grande programa , um programa precioso, feito de bronze, forjado por vós deuses no próprio Olimpo. Que será de mim quando isto for descoberto! Oh, ignomínia! Oh, funesto infortúnio! Zeus pai, não te enfureças com tal revés, Se és mesmo meu pai, acode-me ao invés.” Assim falou; e Zeus compadeceu-se dele que chorava, garantindo que seu programa se salvaria e não pereceria.

<!--:pt-->Imprimir para PDF local<!--:-->

images/thumbnail.jpg - Thumbnail

Receita rápida: Manda-se imprimir o que se quer, dizendo ao SAP para guardar a ordem de impressão no spool e não a imprimir imediatamente. Reserva-se o número da ordem de impressão num recipiente à parte. A seguir, corre-se o programa RSTXPDFT4 , junta-se-lhe o número da ordem de impressão, mistura-se bem e executa-se o dito. Por fim escolhe-se onde, no computador local, se quer desenformar o ficheiro PDF com o conteúdo da ordem de impressão.

<!--:pt-->Depuração telepática<!--:-->

images/thumbnail.jpg - Thumbnail

Imagine o seguinte cenário: um utilizador (ou utilizadora) está sentado no escritório dele, a correr uma transacção ou não sei o quê. Tem um problema e chama um programador (ou programadora) para o (ou a) ajudar a entender o que se passa. Normalmente o programador (ou programadora) teria de se deslocar lá, à sala do senhor utilizador (ou senhora utilizadora) e das duas uma: fazer debug no computador dele (ou dela) ou aprender como recriar o problema e depois fazer debug no seu computador.