Você está na página 1de 2

How to…

Use Messages in SADL Applications


Document version: V1 - 2015-01-23

Definitions
Messages are objects of type if_t100_message. You can reuse any existing t100 message.
Messages are collected by message handlers which implement the interface if_sadl_message_handler
(used by consumers) and the additional methods in class cl_sadl_frwk_message_handler (used by
frameworks implementing the transactional SADL interfaces).

Each message has an associated severity level, which takes one of the values defined in
if_sadl_message_handler=>co_severity.

CONSTANTS:
BEGIN OF co_severity,
error TYPE ty_severity VALUE if_sadl_types=>co_sadl_error_severity-error,
warning TYPE ty_severity VALUE if_sadl_types=>co_sadl_error_severity-warning,
information TYPE ty_severity VALUE if_sadl_types=>co_sadl_error_severity-information,
END OF co_severity .

Each SADL Runtime (instance) has an own message handler. This message handler is initialized when
needed. You can retrieve the message handler corresponding to a runtime with the method
if_sadl_entity_transactional~get_message_handler.

METHODS get_message_handler RETURNING VALUE(ro_message_handler) TYPE REF TO


if_sadl_message_handler.

Evaluate Messages
Consumers use the if_sadl_message_handler interface, which has the methods:

"! Get multiple messages to the message handler


"! @parameter iv_severity | Severity of the messages. If not specified, all messages are
returned. Takes a value specified in if_sadl_message_handler=>co_severity
"! @parameter et_messages | Table of message of type t100 and their severity.
METHODS get_messages IMPORTING iv_severity TYPE ty_severity OPTIONAL
EXPORTING et_messages TYPE tt_messages.

"! Informs whether there are any messages with the severity of type error
METHODS has_errors RETURNING VALUE(rv_has_errors) TYPE abap_bool.

"! Clears all messages from the message handler


METHODS clear.

The message handler collects all messages added, until it is explicitly cleared using the method
if_sadl_message_handler~clear.
Generate Messages
Frameworks use the cl_sadl_frwk_message_handler casting for the message handler. This class
implements the if_sadl_message_handler interface, and in addition provides the methods for adding
messages:

"! Adds a single message to the message handler


"! @parameter is_message | Message of type t100 and its severity. The severity of the
message takes one of the values specified in if_sadl_message_handler=>co_severity
METHODS add_message IMPORTING is_message TYPE if_sadl_message_handler~ty_message.

"! Adds multiple messages to the message handler


"! @parameter it_messages | Table of message of type t100 and their severity. The severity
of the message. Takes one of the values specified in if_sadl_message_handler=>co_severity
METHODS add_messages IMPORTING it_messages TYPE if_sadl_message_handler~tt_messages.

Provided they inherit their implementation from the cl_sadl_entity_transactional class, they can reuse
the message handler instance created in the super class.

mo_message_handler = CAST cl_sadl_frwk_message_handler(


if_sadl_entity_transactional~get_message_handler( ) ).

They can also replace the message handler by their own message handler, which needs to implement the
if_sadl_message_handler interface.

Rules for Message Generation


Messages are intended for human users, frameworks need only to evaluate the “failed” entries.

Technical errors result in “failed” tabix entries. In addition, the frameworks may and should generate a
message. Messages can also be added for information and warnings.

The SADL-level runtime aggregates the messages from the frameworks runtimes corresponding to the
entities participating in the SADL.

Você também pode gostar