SAP Messages

Using SAP messages with your ABAP programs

As you may already know using the ABAP "MESSAGE" statement allows you to display various types of information message to the user, to let them know if process 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 symbol in each 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?
I think message group would be a better name as a message class is essentially a group of individual messages which are reference by 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 function 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 you reports 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 

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


I can't really see a massive advantage of this method but just gives you another method of doing it.

See here for list of available SAP Standard Messages classes