Showing posts with label Processing SAP System Messages. Show all posts
Showing posts with label Processing SAP System Messages. Show all posts

Creating a System Message Under Program Control

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.
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

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.

Creating and Sending System Messages

Prerequisites

You are in transaction SM02 (the 'System Messages' screen).

Procedure

Choose either This graphic is explained in the accompanying text or Goto ® Create from the menu.

A popup appears, in which you can make the following entries:

This graphic is explained in the accompanying text

  • Enter the text of the message at the top. The message text has a maximum length of 3 lines.
  • You can also specify the clients and servers to which the message is sent, in the Server and Client fields. If you enter nothing or * here, the message will be sent to all users logged on to this system (regardless of client and server).
  • If you enter a language in the Lang. field, only the users that are logged on in that language see the message.
  • Expires on specifies the day from which the message will no longer be displayed to users. The message will however remain in the SAP database and can be viewed until the Delete on date has passed. The default setting for the expiry date is the current day at 11:00 p.m., and the default setting for the delete date is one month later. This data can, however, be overwritten.

Result

You have created a system message. This will now be displayed to every user working in the system. Users receive all current system messages when they log on to the system.

This lasts until the expiration date of the message, or until it is deleted .

Leaving content frame