This is a test message to test the length of the message box.
Login
ABAP Quick Where-used list
Created by Software-Heroes

ABAP Quick - Where-Used list messages

591

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.

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.


Included topics:
QuickWhere-Used listMessages
Comments (0)



And further ...

Are you satisfied with the content of the article? We post new content in the ABAP area every Friday and irregularly in all other areas. Take a look at our tools and apps, we provide them free of charge.


ABAP Quick - CLEAR right

Category - ABAP

Delete correctly? In this article we want to take a look at when it makes sense to delete and how you can do it effectively.

05/12/2023

ABAP Quick - Performance chained statements

Category - ABAP

Let's take a look at the performance when creating chained statements with DATA and FIELD-SYMBOL. Which variant will be ahead in terms of performance?

04/28/2023

ABAP - ALV still relevant in 2022?

Category - ABAP

Today the joking question, do we still need reports that generate ALV outputs in 2022? In this article, we want to look into this question.

07/01/2022

ABAP in Change

Category - ABAP

The programming language ABAP has been changing for years and is being modernized in various concepts. In this article, we'll look at it in detail.

06/24/2022

ABAP Quick - Clean Core

Category - ABAP

In this article something about Clean Core, what does it mean for the developer, what are the requirements and what do you have to pay attention to.

06/17/2022