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 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. * Hour format, as in user master record, under which the program * is running. * Always specify a time. CALL FUNCTION 'SM02_ADD_MESSAGE' EXPORTING MESSAGE = emtext " 1. message line MESSAGE2 = " 3. 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 |
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 either 12 or 24
* Hour format, as in user master record, under which the program
* is running.
* 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. message line
MESSAGE2 = " 3. 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.
No comments:
Post a Comment