Thou shalt not COMMIT in user-exits

images/thumbnail.jpg - Thumbnail

Never do COMMITs inside user-exits. Also, make sure any external routine you call from there doesn’t do any COMMIT either.

Automatic model just using CTRL-SPACE

images/thumbnail.jpg - Thumbnail

Of course you already know the “Model” button in the ABAP editor that allows you to automatically add models for function modules, calls for methods and others.

The new editor has now grown a bit (it’s now only 10 years behind Eclipse instead of 20) and it allows you to automatically complete some commands through the CTRL-SPACE shortcut.

Thou shalt consider using SM34 clusters

images/thumbnail.jpg - Thumbnail

If a development requires more than one customising table consider grouping their maintenance views under a cluster. This way it will be more intuitive to maintain them. This makes even more sense if one depends on the other since in the cluster definition these relations can be explicitly defined.

Example: Como encavalitar tabelas (portuguese)

Thou shalt not SELECT *

images/thumbnail.jpg - Thumbnail

Always try to select only the fields you’ll need. Selecting others is a waste of resources. Exception made for the use of FM *_SINGLE_READ because, even though these do select all fields, since they cache the data, they are still faster when used multiple times for the same key. If you just want to check if a record exists, select just one field, if possible the one you’re using as criteria to avoid declaring an extra variable. Example: SELECT KUNNR INTO V_KUNNR FROM KNA1 WHERE KUNNR = V_KUNNR. https://abapinho.com/en/2010/11/select-todos-os-campos/ (portuguese)

Thou shalt use a constants table

images/thumbnail.jpg - Thumbnail

Whenever you feel a constant value can change and you can’t add it as a user parameter, store it in ZCONSTS. This table should never be used directly. Instead, a class like ZCL_CONSTS should be created to properly access it, like shown in this article: https://abapinho.com/en/2009/06/constantes/ (portuguese only)

Resist the temptation of using T900 or similar tables for this purpose. It’s true that a lot of people do it. But it’s ugly, durty and besides these tables don’t even have an adequate key because they were not designed with this in mind.

Unlocking objects in a transport request

images/thumbnail.jpg - Thumbnail

When you touch an object and add it to a transport request, it becomes locked there by default. In a transport request you can also lock objects which are not yet locked in another order. But, once locked, how to unlock them?

Thou shalt build up and adopt toolkits with common tools

images/thumbnail.jpg - Thumbnail

Code which is used very often should be made available centrally, if possible under a single package (ex: ZTOOLS) so that it’s easily identified.

  • There is a lot of code already available on the Internet to accomplish several common functions (ex: ABAP2XLSX). Adopt it;

  • For your most common tasks, develop your own tools which you can reuse and add them to the central library;

  • Advertise the existence of that library among your colleagues to avoid that they waste time come up with duplicate code wasting;

Put it between parentheses

images/thumbnail.jpg - Thumbnail

Sweet little trick: when in SE38 you need to surround a word or expression with () or [] or ‘’, just select it and press ( or [ or ’ and it immediately becomes (it) or [it] or ‘it’.

Thank you Sérgio Fraga for the tip.

Thou shalt not REPLACE ‘.’ with ‘,’ just like that

images/thumbnail.jpg - Thumbnail

If you need to adapt the content of a file with amounts, always take into consideration the user settings (USR01-DSCFM). If you need to convert a string to a number use FM MOVE_CHAR_TO_NUM. If you need to convert a number to a string use WRITE curr TO str [CURRENCY waers].

Thou shalt use command TABLES only when unavoidable

images/thumbnail.jpg - Thumbnail

Using SELECT-OPTIONS is one of the very few reasons for using TABLES. For all other cases, explicitly declare a local variable for the equivalent structure. TABLES basically creates obscure global variables which increase ambiguity in the code. And global variables should be avoided anyway.