Creating a System Message Under Program Control
Use
It can sometimes be useful to issue (create) system messages from an ABAP program rather than interactively. For example, you can issue warning messages from a background job before starting a database backup or other action that causes the system to pause.
Procedure
To issue a message under program control, you need to create a program that calls the function module shown below. When the program runs (for example, as a job step in a background job), the message that you specify is displayed immediately as a system message. The message expires and is no longer displayed at the time that you specify.
data: emtext like TEMSG-EMTEXT.
data: exp_time like TEMSG-TIMDEL.
emtext = "Bitte abmelden. Backup in 2 Minuten.
exp_time = '230000'.
CALL FUNCTION 'SM02_ADD_MESSAGE'
EXPORTING
MESSAGE = emtext " 1. line of the message
MESSAGE2 = " 2. line
MESSAGE3 = " 3. line
SERVERNAME = " Server
EXPIRATION_DATE = SY-DATUM " Expiration date with
EXPIRATION_TIME = '230000' " time
DELETE_DATE = ' ' " Deletion date with
DELETE_TIME = '230000' " time
CLIENT = ' ' " Client
IMPORTING
MESSAGE_ID =
EXCEPTIONS
EMPTY_MESSAGE = 1
SERVER_NOT_AVAILABLE = 2
CLIENT_NOT_AVAILABLE = 3
NOT_AUTHORIZED = 4
OTHERS = 5
Result
Each time your program runs, the message you specify is issued to all users.