MESSAGE statement has more to it then meets the eye... A message is an important way to inform the en user in a uniform way that should be understood and carried by all developers.
The syntax of the message statement, which has a strong relation to messages as held on
SE93 and table
T100. Hence the message is a re-usable object that can be referred to from your report/program.
MESSAGE I999 WITH 'Parameter 1' param2.
999 is the number, "I" indicates that it's an information message and
WITH indicates which variables have to be completed in the message. Messages always reside under a message class. A report using the message class ZZ:
REPORT ZUMIRACLE LINE-SIZE 80 MESSAGE-ID 'ZZ'.
When it is necessary to reproduce a message from another message class than indicated in the report heading
MESSAGE-ID, the following addition can be linked to the message number:
MESSAGE I123(ZZ) WITH 'Parameter 1' Param2.
"ZZ" is the message class that should contain message number 123 and this will override the default message class specified in the report heading.
Many messages don't really deserve a place in the re-usable
SE93setup. If it's just a bit of information you need to portray, consider this simplified syntax:
MESSAGE 'Your message is sweet and simple' TYPE 'I'.
Message into a message variabele
This bit of coding is picked up directly from the help texts. Message credentials are used to place the message into a variabele, which is ready to be output in some sort of error logging (often
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno INTO DATA(mtext) WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
Using a BDC session ? BDC messages can be picked up with the
MESSAGES INTO option. An easy-to-copy example for this:
data: lt_messages type STANDARD TABLE OF BDCMSGCOLL, lw_message type BDCMSGCOLL, lv_message_str type c length 90. * call transaction 'PA30' using lt_bdcdata mode 'N' * MESSAGES INTO lt_messages. loop at lt_messages into lw_message. MESSAGE ID lw_message-msgid TYPE lw_message-msgtyp NUMBER lw_message-msgnr INTO lv_message_str WITH lw_message-msgv1 lw_message-msgv2 lw_message-msgv3 lw_message-msgv4. write: / lv_message_str. endloop.