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.
   ENDLOOP.
ENDLOOP.

Did you know that for big tables this can take ages because LOOP WHERE makes a sequential reading of itab2 for each entry in itab1?

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.
  lv_valor = sy-index * 10.
  lv_texto(3) = lv_valor.
  CONCATENATE lv_texto '%!' INTO lv_texto.
  CONCATENATE 'Time remaining' lv_texto INTO lv_texto SEPARATED BY space.

  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
    EXPORTING
      percentage = lv_valor
      text       = lv_texto.

ENDDO.

You see that the timer bar is filling up. Unfortunately the WAIT UP TO N SECONDS command is limited to whole numbers, so I don’t know how you can do a faster count. But it’s better than nothing.

<!--: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. Mantém-te do lado do bem se fazes favor.

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-->Como encavalitar tabelas<!--:-->

images/thumbnail.jpg - Thumbnail

Às vezes temos de criar uma tabela Z. Às vezes temos até de criar várias tabelas Z. Às vezes estas tabelas estão relacionadas de alguma forma. Como quando uma contém dados de cabeçalho e a outra dados de item, por exemplo. Ora se estão relacionadas pode dar jeito que sejam editadas em conjunto. É para isso que servem os Clusters de Visão (view cluster).

<!--: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. Eis uma dúzia:

<!--: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. Logo enviou uma águia, mais seguro dos alados portentos. Quando o guerreiro viu que da parte de Zeus viera a ave, acalmou-se e viu que seus pés lhe traziam uma mensagem.