Entering content frameObject documentation Class CL_BSP_MESSAGES Locate the document in its SAP Library structure

Overview

You can use class CL_BSP_MESSAGES in BSPs for outputting error and information messages.

You can flag each message with a condition that serves as a key for the message. The effect of this is that a message is only output in a BSP if the pertinent condition is fulfilled. This makes it easy to place input-specific messages directly beside the relevant input fields.

Each BSP has an instance of this class that contains the current messages of the class. The object is reset after every HTTP request/response cycle. The object is accessed from a BSP via the parameter page of the event handler as page->messages or via the self-reference me in the form of interface qualification me->if_bsp_page~messages.

Inheritance Hierarchy/Interface Composition

Implemented Interface

-

Superclass

-

Attributes

Attribute Name

Declaration Type

Description

co_severity_error

Constants

Error severity: error

co_severity_fatal_error

Constants

Error severity: Fatal error

co_severity_info

Constants

Error severity: Information

co_severity_success

Constants

Error severity: Confirmation of success

co_severity_warning

Constants

Error severity: Warning

Methods

Method add_message

Signature

method add_message
importing
condition type string
message type string optional
otr_alias type string optional
severity type i default co_severity_error
.

Description

This method inserts the message on the condition specified into the list of messages. If there is already a message with the condition, it is overwritten.

One of the two parameters message or otr_alias must be specified (exclusive or). If message is used, the message text is transferred directly, if otr_alias is used, the alias name of an OTR text is transferred. This makes it easy to address language-dependent messages from the OTR.

Parameters

CONDITION

Message condition

MESSAGE

Message text (if otr_alias-parameter is not used)

OTR_ALIAS

Alias name of an OTR text to be used as message text (if message parameter is not used)

SEVERITY

Message severity (see constants co_severity_...)

Return Values/Exceptions

-

Cross References

See also: assert, assert_message, assert_severity

Method assert

Signature

method assert
importing
condition type string
returning
index type i
.

Description

This method returns the message index (1..n) for the condition specified or 0 if there is no message for this condition.

Thus, you can use this method in BSPs in if statements if, for example, you want to insert HTML areas in the output on a message-dependent basis.

Example:

...
<% if page->messages->assert( 'invaliduser' ) <> 0. %>
<img src="stop.gif">
<%= page->messages->assert_message( 'invaliduser' ) %>
<% endif %>

Parameters

CONDITION

Message condition

Return Values/Exceptions

INDEX

=0: no message for condition

>0: Message index

Cross References

See also: assert_message, assert_severity

Method assert_message

Signature

method assert_message
importing
condition type string
returning
message type string
.

Description

This method returns the message for a specified condition. If there is no message for the condition, it returns an empty string.

Parameters

CONDITION

Message condition

Return Values/Exceptions

MESSAGE

Message

Cross References

See also: assert, assert_severity

Method assert_severity

Signature

method assert_severity
importing
condition type string
returning
severity type i
.

Description

This method returns the message severity (see constants co_severity_... ) for the specified condition, or 0 if there is no message for the condition.

Parameters

CONDITION

Message condition

Return Values/Exceptions

SEVERITY

=0: no message for condition

>0: Message severity (see constants co_severity_...)

Cross References

See also: assert, assert_message

Method get_message

Signature

method get_message
importing
index type I
exporting
severity type I
condition type string
message type string
.

Description

This method returns information about the message for the specified index (1..n). If there is no message for the index, in other words, if index > num_messages(), this is indicated by severity = 0 .

Parameters

INDEX

Message index (1..num_messages())

Return Values/Exceptions

message

Message text

condition

Message condition

severity

Message severity (see constants co_severity_...)

Cross References

See also: add_message, num_messages

Method num_messages

Signature

method num_messages
returning
count type I
.

Description

This method returns the number of messages that were defined using add_message().

Parameters

-

Return Values/Exceptions

count

Number of currently existing messages

Cross References

See also: add_message

 

 

Leaving content frame