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

705

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 in Practice - Test Driven Development

Category - ABAP

How does TDD actually work in practice and are there simple examples for learning in ABAP? In this exercise we will look at the practical part.

09/24/2024

ABAP in Practice - Merge data sets

Category - ABAP

How do we merge two different data sets in ABAP, especially with regard to Modern ABAP? A practical task for this topic.

09/17/2024

ABAP in Practice - Modern ABAP

Category - ABAP

In this small task we look at existing classic ABAP source code and try to optimize it according to Modern ABAP.

08/27/2024

ABAP Quick - Performance Data Filtering

Category - ABAP

Which statement do you use in ABAP to filter internal tables and is it performant? Read more in this article.

08/13/2024

ABAP in Practice - Type Conversion

Category - ABAP

How would you perform this type conversion in ABAP? A practical example and a suggested solution.

07/16/2024