Entering content frameProcedure documentation Creating a System Message Under Program Control Locate the document in its SAP Library structure

It can sometimes be useful to issue (create) system messages under program control 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 R/3 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.

* Messages have the same format as the dialog transaction --
* a maximum of 3 lines each with a maximum of 60 characters. Only the first line
* must contain a message.
emtext = "Bitte abmelden. Backup in 2 minutes.

* Enter the expiration time as shown. Use 12- or 24-hour format as * set in the user master record under which the program will run.

* If only time is specified, today’s date is assumed.

* Always specify a time.
exp_time = '230000'.

CALL FUNCTION 'SM02_ADD_MESSAGE'

EXPORTING

MESSAGE = emtext " 1. Zeile der Nachricht

MESSAGE2 = " 3. Zeile

MESSAGE3 = " 3. Zeile

SERVERNAME = " Server

EXPIRATION_DATE = SY-DATUM " Verfallsdsatum mit

EXPIRATION_TIME = '230000' " Zeit

DELETE_DATE = ' ' " Löschdatum mit

DELETE_TIME = '230000' " Zeit

CLIENT = ' ' " Mandant

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.

 

 

 

 

 

 

Leaving content frame