Show TOC

Procedure documentationCreating a System Message Under Program Control Locate this document in the navigation structure

 

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.

Syntax Syntax

  1. 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    
    
End of the code.

Note Note

  • As you can see in the example program, messages have the same format as in the dialog transaction: A maximum of three lines each with a maximum of 60 characters. Only the first line has to be filled.

  • 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 enter a time.

End of the note.

Result

Each time your program runs, the message you specify is issued to all users.