Ansicht
Dokumentation

ABAPRAISE_EXCEPTION_MESSAGE - RAISE EXCEPTION MESSAGE

ABAPRAISE_EXCEPTION_MESSAGE - RAISE EXCEPTION MESSAGE

RFUMSV00 - Advance Return for Tax on Sales/Purchases   Addresses (Business Address Services)  
This documentation is copyright by SAP AG.
SAP E-Book

RAISE EXCEPTION, message

Short Reference



... ${ MESSAGE tn(id)
            $| ${ ID mid TYPE mtype NUMBER num $}
              $[WITH dobj1 ... dobj4$] $}
  $| ${ USING MESSAGE $} ...


Variants:

1. ... MESSAGE msg ...

2. ... USING MESSAGE ...

Effect

The addition MESSAGE of the statement RAISE EXCEPTION and of the addition THROW in a conditional expression passes the specification of a message to the exception object.

Variant 1

... MESSAGE msg ...


Effect

The addition tn(id) or ID mid TYPE mtype NUMBER num is used to specify the message type, the message class, and the message number of a message msg for the table T100, statically or dynamically like in the statement MESSAGE. Also like in MESSAGE, the optional addition WITH can be used to provide the placeholders of a message with content. The exception class of the raised exception must implement one of the system interfaces for messages:

The addition MESSAGE fills the attributes of these interfaces with values. This assignment takes place after the instance constructor is executed. This overwrites any values that were assigned to these attributes when the exception object was constructed.

The attributes of the system interfaces are used to link the exception object to the message specified after MESSAGE. Using an object reference, the object can be used directly in the variant MESSAGE oref of the MESSAGE statement and the message texts can be read using the interface methods.

If the addition MESSAGE is used, the input parameter TEXTID of the constructor of the exception class must not be filled. This parameter is only intended for specifying a predefined exception text.

Notes

  • The position behind MESSAGE is contained in the where-used list for the message specified.

Using IF_T100_DYN_MSG

The full functionality of the addition MESSAGE is available only if the system interface IF_T100_DYN_MSG is implemented in the used exception class. This interface includes the system interface IF_T100_MESSAGE requested by the syntax check. If an exception class is used with the system interface IF_T100_DYN_MSG, the addition MESSAGE fills its attributes as follows after the instance constructor is executed:

  • The message type specified after MESSAGE is assigned to the attribute MSGTY of the interface IF_T100_DYN_MSG.
  • The components of the structured attribute T100KEY of the component interface IF_T100_MESSAGE are filled as follows:
  • MSGID is assigned the message class specified after MESSAGE.

  • MSGNO is assigned the message number specified after MESSAGE.

  • ATTR1 to ATTR4 are assigned the names IF_T100_DYN_MSG~MSGV1 to IF_T100_DYN_MSG~MSGV4 of the interface attributes for the placeholders of the message. If the addition WITH is not specified, ATTR1 to ATTR4 remain initial.

  • The attributes MSGV1 to MSGV4 of the interface IF_T100_DYN_MSG are assigned the texts specified using WITH.

Notes

  • If IF_T100_DYN_MSG is used, the addition MESSAGE assigns the correct values to all required attributes of the exception class to link them to the message. More specifically, the attributes for the placeholders of the message are mapped to the structure T100KEY of the interface IF_T100_MESSAGE automatically.
  • In exception classes with the interface IF_T100_DYN_MSG, MESSAGE used together with the EXPORTING addition can produce unexpected results in the placeholder texts if the addition WITH is not specified. Implicit assignments of the input parameters specified after EXPORTING to the components ATTR1 to ATTR4 are intended for exception classes with the interface IF_T100_MESSAGE where WITH cannot be specified (see the executable example). Implicit assignments of the names of the input parameters or of initial values can be prevented by specifying WITH with a dummy value space.

Example

Raising of the exception CX_DEMO_DYN_T100 that implements the interface IF_T100_DYN_MSG. The addition MESSAGE is used to pass the properties of a message that determines the exception text.

Using IF_T100_MESSAGE

If only the system interface IF_T100_MESSAGE is implemented, the addition WITH must not be used and only a restricted set of functions is available. When an exception class is used that implements only the system interface IF_T100_MESSAGE, the addition MESSAGE fills its attributes as follows after the instance constructor is executed:

  • The specification of a message type has no effect.
  • The components of the structured attribute T100KEY of the component interface IF_T100_MESSAGE are filled as follows:
  • MSGID is assigned the message class specified after MESSAGE.

  • MSGNO is assigned the message number specified after MESSAGE.

  • ATTR1 to ATTR4 are assigned the names of the first four input parameters of the instance constructors specified after EXPORTING that can be converted to a character-like target field, in the specified order. Components that cannot be assigned input parameters are initialized.

Notes

  • It is recommended that the system interface IF_T100_DYN_MSG is used for exceptions raised using the addition MESSAGE.
  • The use of the addition MESSAGE for an exception class with IF_T100_MESSAGE is intended for cases where existing exception classes that cannot be switched to IF_T100_DYN_MSG must be used.
  • The addition MESSAGE is suitable for existing exception classes with IF_T100_MESSAGE that already have a generic exception text without semantic meaning. Previously, structures of the type SCX_T100KEY, filled in the program, had to be passed to such exceptions.
  • The use of the addition MESSAGE is not recommended for an exception class with IF_T100_MESSAGE whose exception texts all have a fixed semantic meaning.

System Interface IF_T100_MESSAGE for Exception with Message

Variant 2

... USING MESSAGE ...


Effect

This variant is a short form of the preceding variant of the MESSAGE addition. It can be used if the exception class of the raised exception implements the system interface IF_T100_DYN_MSG, and has the following effect:

... MESSAGE ID     sy-msgid
            TYPE   sy-msgty
            NUMBER sy-msgno
            WITH   sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 ...

The addition USING MESSAGE implicitly passes the specification of the message that is stored during the execution of the statement in the system fields sy-msgid, sy-msgty sy-msgno, and sy-msgv1 to sy-msgv4 to the exception class.

Note

The short form is particularly suitable for converting classic exceptions that were raised in function modules or methods with the statement MESSAGE RAISING, or messages that were caught with error_message, into class-based exceptions.

Example

Raising of the exception CX_DEMO_DYN_T100 that implements the interface IF_T100_DYN_MSG. The addition USING MESSAGE implicitly passes the properties of a status message that was previously output with the statement MESSAGE.






ABAP Short Reference   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.

Length: 13564 Date: 20240426 Time: 041924     sap01-206 ( 237 ms )