SAP MESSAGE_STORE Function Module for Store transferred message or output directly
MESSAGE_STORE is a standard message store SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Store transferred message or output directly 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 store FM, simply by entering the name MESSAGE_STORE into the relevant SAP transaction such as SE37 or SE38.
Function Group: SMSG
Program Name: SAPLSMSG
Main Program: SAPLSMSG
Appliation area:
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function MESSAGE_STORE 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_STORE'"Store transferred message or output directly.
EXPORTING
ARBGB = "Message ID
* EXCEPTION_IF_NOT_ACTIVE = 'X' "X = exception not_active is initialized if
MSGTY = "Type of message (I, S, W, E, A)
* MSGV1 = ' ' "First variable parameter of message
* MSGV2 = ' ' "Second variable parameter of message
* MSGV3 = ' ' "Third variable parameter of message
* MSGV4 = ' ' "Fourth variable parameter of message
TXTNR = "Message Number
* ZEILE = ' ' "Reference line (if it exists)
IMPORTING
ACT_SEVERITY = "Level of current message
MAX_SEVERITY = "Maximum level of severity
EXCEPTIONS
MESSAGE_TYPE_NOT_VALID = 1 NOT_ACTIVE = 2
IMPORTING Parameters details for MESSAGE_STORE
ARBGB - Message ID
Data type: SMESG-ARBGBOptional: No
Call by Reference: No ( called with pass by value option)
EXCEPTION_IF_NOT_ACTIVE - X = exception not_active is initialized if
Data type:Default: 'X'
Optional: Yes
Call by Reference: No ( called with pass by value option)
MSGTY - Type of message (I, S, W, E, A)
Data type: SMESG-MSGTYOptional: No
Call by Reference: No ( called with pass by value option)
MSGV1 - First variable parameter of message
Data type:Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
MSGV2 - Second variable parameter of message
Data type:Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
MSGV3 - Third variable parameter of message
Data type:Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
MSGV4 - Fourth variable parameter of message
Data type:Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
TXTNR - Message Number
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
ZEILE - Reference line (if it exists)
Data type:Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for MESSAGE_STORE
ACT_SEVERITY - Level of current message
Data type: SY-SUBRCOptional: No
Call by Reference: No ( called with pass by value option)
MAX_SEVERITY - Maximum level of severity
Data type: SY-SUBRCOptional: No
Call by Reference: No ( called with pass by value option)
EXCEPTIONS details
MESSAGE_TYPE_NOT_VALID - Type of message not I, S, W, E or A
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
NOT_ACTIVE - Collection of messages not activated
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for MESSAGE_STORE 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_arbgb | TYPE SMESG-ARBGB, " | |||
| lv_act_severity | TYPE SY-SUBRC, " | |||
| lv_message_type_not_valid | TYPE SY, " | |||
| lv_not_active | TYPE SY, " | |||
| lv_max_severity | TYPE SY-SUBRC, " | |||
| lv_exception_if_not_active | TYPE SY, " 'X' | |||
| lv_msgty | TYPE SMESG-MSGTY, " | |||
| lv_msgv1 | TYPE SMESG, " SPACE | |||
| lv_msgv2 | TYPE SMESG, " SPACE | |||
| lv_msgv3 | TYPE SMESG, " SPACE | |||
| lv_msgv4 | TYPE SMESG, " SPACE | |||
| lv_txtnr | TYPE SMESG, " | |||
| lv_zeile | TYPE SMESG. " SPACE |
|   CALL FUNCTION 'MESSAGE_STORE' "Store transferred message or output directly |
| EXPORTING | ||
| ARBGB | = lv_arbgb | |
| EXCEPTION_IF_NOT_ACTIVE | = lv_exception_if_not_active | |
| MSGTY | = lv_msgty | |
| MSGV1 | = lv_msgv1 | |
| MSGV2 | = lv_msgv2 | |
| MSGV3 | = lv_msgv3 | |
| MSGV4 | = lv_msgv4 | |
| TXTNR | = lv_txtnr | |
| ZEILE | = lv_zeile | |
| IMPORTING | ||
| ACT_SEVERITY | = lv_act_severity | |
| MAX_SEVERITY | = lv_max_severity | |
| EXCEPTIONS | ||
| MESSAGE_TYPE_NOT_VALID = 1 | ||
| NOT_ACTIVE = 2 | ||
| . " MESSAGE_STORE | ||
ABAP code using 7.40 inline data declarations to call FM MESSAGE_STORE
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 ARBGB FROM SMESG INTO @DATA(ld_arbgb). | ||||
| "SELECT single SUBRC FROM SY INTO @DATA(ld_act_severity). | ||||
| "SELECT single SUBRC FROM SY INTO @DATA(ld_max_severity). | ||||
| DATA(ld_exception_if_not_active) | = 'X'. | |||
| "SELECT single MSGTY FROM SMESG INTO @DATA(ld_msgty). | ||||
| DATA(ld_msgv1) | = ' '. | |||
| DATA(ld_msgv2) | = ' '. | |||
| DATA(ld_msgv3) | = ' '. | |||
| DATA(ld_msgv4) | = ' '. | |||
| DATA(ld_zeile) | = ' '. | |||
Search for further information about these or an SAP related objects