SAP Message class within ABAP reports



As you may already know using the ABAP “MESSAGE” statement allows you to display various types of message to the user, to let them know if processes have been successful or not and what they can to fix any issues. Often the same message is relevant to many different ABAP reports/programs.

Therefore instead of hard-coding or creating text symbols in each program, you can simply create them within a message class. These messages can then be referenced by any development object i.e. report, program, function module, workflow, web dynpro etc. 


What is a message Class? 

Message class is probably not the term that should have been used, I think message group would be a better name as a message class is essentially a group of individual messages which are referred by the class name and a number between 0 and 999. You can have as many messages classes as you want and obviously up to 1000 messages in each class. Rather than just creating one class for all your messages you would generally create a messages class to group related messages together. 

They act in a very similar way to functional groups and have no link to OO, which I think is what many people think of when you use the term class. 

ABAP code implementation 
In order to reference these messages within your ABAP report, you simply use the following syntax 

MESSAGE I999(zmymclass).

MESSAGE = ABAP syntax command
I = Message type
ZMYMCLASS = Name of your message Class
999 = Unique identifier within class 

An alternate method for ABAP reports 
Alternately you can add the class definition to the REPORT statement at the start of your code so that it is automatically referenced by all message statements. This means you would then only need to provide the number when displaying a message. The following code would achieve the same as above 

REPORT zmyreport MESSAGE-ID ZMYMCLASS. 
... 
MESSAGE I999.

 

I can’t really see a massive advantage of this method but just gives you another method of doing it and saves you having to refer to the class each time.

 

See here for a list of available SAP Standard Messages classes

About the Author se80