SAP MESSAGE_PREPARE Function Module for Read T100 message and format message with parameters
MESSAGE_PREPARE is a standard message prepare SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Read T100 message and format message with parameters processing and below is the pattern details for this FM, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.
See here to view full function module documentation and code listing for message prepare FM, simply by entering the name MESSAGE_PREPARE into the relevant SAP transaction such as SE37 or SE38.
Function Group: SLG9
Program Name: SAPLSLG9
Main Program: SAPLSLG9
Appliation area:
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function MESSAGE_PREPARE pattern details
In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.CALL FUNCTION 'MESSAGE_PREPARE'"Read T100 message and format message with parameters.
EXPORTING
* LANGUAGE = ' ' "Language in which the message is read
MSG_ID = "Message ID
MSG_NO = "Message number
* MSG_VAR1 = ' ' "Message variable 1
* MSG_VAR2 = ' ' "Message variable 2
* MSG_VAR3 = ' ' "Message variable 3
* MSG_VAR4 = ' ' "Message variable 4
IMPORTING
MSG_TEXT = "Message text
EXCEPTIONS
FUNCTION_NOT_COMPLETED = 1 MESSAGE_NOT_FOUND = 2
IMPORTING Parameters details for MESSAGE_PREPARE
LANGUAGE - Language in which the message is read
Data type: T100-SPRSLDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
MSG_ID - Message ID
Data type: T100-ARBGBOptional: No
Call by Reference: No ( called with pass by value option)
MSG_NO - Message number
Data type: T100-MSGNROptional: No
Call by Reference: No ( called with pass by value option)
MSG_VAR1 - Message variable 1
Data type: BALM-MSGV1Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
MSG_VAR2 - Message variable 2
Data type: BALM-MSGV2Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
MSG_VAR3 - Message variable 3
Data type: BALM-MSGV3Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
MSG_VAR4 - Message variable 4
Data type: BALM-MSGV4Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for MESSAGE_PREPARE
MSG_TEXT - Message text
Data type:Optional: No
Call by Reference: Yes
EXCEPTIONS details
FUNCTION_NOT_COMPLETED - Formatting unsuccessful
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
MESSAGE_NOT_FOUND - Message not found
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for MESSAGE_PREPARE Function Module
The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the newer method of declaring data variables on the fly. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8), which i why i have stuck to the origianl for this example.| DATA: | ||||
| lv_language | TYPE T100-SPRSL, " SPACE | |||
| lv_msg_text | TYPE T100, " | |||
| lv_function_not_completed | TYPE T100, " | |||
| lv_msg_id | TYPE T100-ARBGB, " | |||
| lv_message_not_found | TYPE T100, " | |||
| lv_msg_no | TYPE T100-MSGNR, " | |||
| lv_msg_var1 | TYPE BALM-MSGV1, " SPACE | |||
| lv_msg_var2 | TYPE BALM-MSGV2, " SPACE | |||
| lv_msg_var3 | TYPE BALM-MSGV3, " SPACE | |||
| lv_msg_var4 | TYPE BALM-MSGV4. " SPACE |
|   CALL FUNCTION 'MESSAGE_PREPARE' "Read T100 message and format message with parameters |
| EXPORTING | ||
| LANGUAGE | = lv_language | |
| MSG_ID | = lv_msg_id | |
| MSG_NO | = lv_msg_no | |
| MSG_VAR1 | = lv_msg_var1 | |
| MSG_VAR2 | = lv_msg_var2 | |
| MSG_VAR3 | = lv_msg_var3 | |
| MSG_VAR4 | = lv_msg_var4 | |
| IMPORTING | ||
| MSG_TEXT | = lv_msg_text | |
| EXCEPTIONS | ||
| FUNCTION_NOT_COMPLETED = 1 | ||
| MESSAGE_NOT_FOUND = 2 | ||
| . " MESSAGE_PREPARE | ||
ABAP code using 7.40 inline data declarations to call FM MESSAGE_PREPARE
The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8.| "SELECT single SPRSL FROM T100 INTO @DATA(ld_language). | ||||
| DATA(ld_language) | = ' '. | |||
| "SELECT single ARBGB FROM T100 INTO @DATA(ld_msg_id). | ||||
| "SELECT single MSGNR FROM T100 INTO @DATA(ld_msg_no). | ||||
| "SELECT single MSGV1 FROM BALM INTO @DATA(ld_msg_var1). | ||||
| DATA(ld_msg_var1) | = ' '. | |||
| "SELECT single MSGV2 FROM BALM INTO @DATA(ld_msg_var2). | ||||
| DATA(ld_msg_var2) | = ' '. | |||
| "SELECT single MSGV3 FROM BALM INTO @DATA(ld_msg_var3). | ||||
| DATA(ld_msg_var3) | = ' '. | |||
| "SELECT single MSGV4 FROM BALM INTO @DATA(ld_msg_var4). | ||||
| DATA(ld_msg_var4) | = ' '. | |||
Search for further information about these or an SAP related objects