ABAP Quick - Where-Used list messages
When working with BAPIs and messages, it usually comes to a loss of searchability in the use of messages because they are firmly created in structures.
Table of contents
For what does you actually need the proof of use of messages? You probably can even think of that as a developer if you were looking for a mistake and wanted to understand the surrounding code of the message. When was the message generated provides in many cases the context of the data and the checks that led to these messages. At this point you can usually already derive the error and correct it.
But what if you can not understand the generation of the message? Either you know the call point of the message or start searching in the source code. But you can also make it easier for yourself by including pseudo-calls of use for the messages.
Where-Used list
The where-used list works using the keyword MESSAGE and the number, that is, if the message is generated in a BAPI and the normal BAPI structures are used, then the where-used list does not work because only the number and the message class do not work as a literal fpr the search function.
Pseudo calls
However, the integration of a message can cause some problems because it interrupts the program flow. In this context, you will find pseudo-calls to messages in SAP source code more often, but it will never call this messages. If you stumble over such a call for the first time, it may seem strange why just a piece of code that has not been run is at this point.
But that is exactly the meaning of this piece of source code, it has only one meaning at this point and that is the proper function of the where-used list.
Implement messages
So what does an integration of the intended use of a message look like? Today, we suggest three methods that you can easily use for your own.
Classic use
The classic variant is also used by SAP in many older reports and relies on the shuttering in an IF statement, which is never called. Normally, the message is displayed without parameters and in one line. Disadvantage here is e.g. that there are several statements on one line, which could be contrary to your development conventions.
" Classic variant
IF 0 = 1. MESSAGE S011(F5). ENDIF.
Inline Declaration
The IF-statement is omitted with this method and the message is saved in a variable in the coding. Visual processing does not take place because the INTO addition is used when calling. Disadvantage is the declaration of a new variable, even if one has, for example, several meditations in a row. Then you should consider whether you declare the variable in the data part or use a different name each time, which again defines many local variables.
" Inline Declaration
MESSAGE s012(F5) INTO DATA(ld_msg).
System variable
If you do not want to rely on an inline declaration and do not want to create a local variable, you can also use a system parameter to take over the contents of the variable. This has the advantage that you do not have to pay attention to the defined variables.
" System variable
MESSAGE s013(F5) INTO sy-prtxt.
Conclusion
The where-used list can be helpful to yourself or other developers in many situations. It is superfluous code at first, but it will simplify your work, especially in error analysis. So if you want to do you and your colleagues a favor, then just use one of the tips shown.