ABAPMESSAGE_OPTIONS - MESSAGE OPTIONS
PERFORM Short Reference CL_GUI_FRONTEND_SERVICES - Frontend ServicesThis documentation is copyright by SAP AG.
MESSAGE - message_options
Syntax
... { {[DISPLAY LIKE dtype] [RAISING exception]}
| [INTO text] }
[WITH dobj1 ... dobj4].
Additions
1. ... DISPLAY LIKE dtype
2. ... RAISING exception
3. ... INTO text
4. ... WITH dobj1 ... dobj4
Effect
These additions change the type of display, raise anon-class-based exception in function modules or methods, assign the text of themessage to a data object, and replace the placeholders in short and long texts of messages.
Addition 1
... DISPLAY LIKE dtype
Effect
When you use this addition, the icon of the message type specified in dtype is displayed instead of the associated icon. A character-likedata object is expected for dtype. This data object must contain one of the values "A", "E", "I", "S", or "W" in uppercase letters.
The message short text is still displayed as a dialog box for messages that are displayed this way bydefault. Messages of type "E" or "W" (except those for PBO and LOAD-OF-PROGRAM) are displayedas dialog boxes if dtype contains "A" or "I". Messages of type "S" are always displayed in thestatus bar, regardless of the dtype. The latter also applies to messages of type "I" for PBO and LOAD-OF-PROGRAM. Messages of type "X" always trigger a runtime error.
Notes
The use of this addition influences the type of display only and not the behavior determined by the message type.
- Specifying "X" for dtype is not recommended since no icon is assigned to this message type.
Addition 2
... RAISING exception
Effect
With this addition, the MESSAGE statement raises either anon-class-basedexception or sends a message. This addition is only of use when processing methods and function modules in which the non-class-based exception is defined. Furthermore, the addition must not be used in the sameprocessing block as statement RAISE EXCEPTION for raising class-based exceptions.
If the MESSAGE statement is executed with addition RAISING during the processing of a method or a function module whose caller assigns a return value to the exceptionexception with addition EXCEPTIONS of statement CALL, it has the same effect asstatement RAISE.If no return value is assigned to the exception exception, addition RAISING is ignored and the message is processed in accordance with itsmessage type.
The system fields of statement MESSAGE are populated in both cases and are available in the callingprogram once an exception raised with MESSAGE ...RAISING has been handled. This is especially true if a function module was called by means of a Remote Function Call(RFC).
Note
- Using MESSAGE ... RAISING in cases in which non-class-based exceptions must still be used ispreferable to using the RAISE statement because it offers the option of providing additional text information with an exception.
- You can assign a return value to messages that are sent in function modules without addition RAISINGusing the predefined exception error_message.
- If a procedure is exited by raising an exception, the content of the formal parameters for which thepass by value is defined is not assigned to the respective actual parameters.
Example
When the method is first called, an information message is sent. When it is called next, an exception is raised instead and is handled after the call by evaluating sy-subrc.
CLASS c1 DEFINITION.
PUBLIC SECTION.
CLASS-METHODS m1 EXCEPTIONS exc1.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
METHOD m1.
MESSAGE 'Message in a Method' TYPE 'I' RAISING exc1.
ENDMETHOD.
ENDCLASS.
...
c1=>m1( ).
c1=>m1( EXCEPTIONS exc1 = 4 ).
IF sy-subrc = 4.
...
ENDIF.
Addition 3
... INTO text
Effect
With this addition, you assign the short text of the message to variable text. Themessagetype plays no role. The program flow is not interrupted and message processing does not take place. For text, a character-like data object is expected.
Addition INTO cannot be specified when a user-defined text is output.
Example
The short text of a message sent in a function module is stored in data object mtext by meansof the relevant system fields when the exception error_message is handled.
DATA mtext TYPE string.
CALL FUNCTION ... EXCEPTIONS error_message = 4.
IF sy-subrc = 4.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
INTO mtext
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Addition 4
... WITH dobj1 ... dobj4
Effect
This addition replaces the placeholders "&1" to "&4" and "&" of the short text and "&V1&" to "&V4&"of the long text of the message with the prepared content of data objects dobj1, ... , dobj4. You can specify up to four data objects(dobj1 to dobj4). They can have the same data type as a source field of the WRITETO statement and they are formatted with output length 50 in accordance with the relevantpredefined formats.The position of a data object determines which placeholder will be replaced. The formatted content ofthe first data object replaces the placeholders "&1", the first placeholder "&", and "&V1&", the placeholderof the second data object replaces "&2", the second "&", and "&V2&", and so on. Furthermore, the formattedcontent of data objects dobj1, ..., dobj4 is assigned in sequence to the system fields sy-msgv1 to sy-msgv4.
If you specify fewer data objects than placeholders, superfluous placeholders are not displayed in theshort text and the associated system fields sy-msgv1 to sy-msgv4 are initialized. If a data object specified cannot be assigned to a placeholder, it is ignored.
Addition WITH cannot be specified when a user-definedtext or an object reference oref is output.
Notes
If a short text contains placeholders of both forms "&i" and "&", the content of a data object canreplace two placeholders. The data object at the i-th position not only replaces "&i" but also the i-thplaceholder "&". We recommend that you use only one of the two forms for placeholders in a short text.If a short text is to be translated into other languages, only the numbered placeholder "&i" since the structure of the sentence may change.
- For downward compatibility reasons, the character "$" is handled in the same way as "&" in short texts. The same is true of "$i". Therefore, "$$" must be specified if "$" is to be output.
- In long texts, the placeholders "&V1&" to "&V4&" must be saved as such in the database. If you are usingthe graphical PC editor, you cannot enter these directly. Instead,you have to copy them by choosing Insert → Symbols → Text Symbols.
Example
If the short text of the message specified in table T100 contains the value "& & & &", the text "This is not America" is output as aninformationmessage. If the short text was defined as "&4 &1 &3 &2", "America This not is" is output.
MESSAGE i010 WITH 'This' 'is' 'not' 'America'.
Vendor Master (General Section) CL_GUI_FRONTEND_SERVICES - Frontend Services
This documentation is copyright by SAP AG.
Length: 11790 Date: 20120523 Time: 001227 triton ( 309 ms )






