Show TOC

Class CL_BSP_MESSAGESLocate this document in the navigation structure

Use

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 interfaces -
Super Class -
Attributes

Attribute Name

Declaration Type

Description

co_severity_error

Constant

Severity of the Message: Error

co_severity_fatal_error

Constant

Severity of the Message: Fatal error

co_severity_info

Constant

Severity of the Message: Information

co_severity_success

Constant

Severity of the Message: Confirmation of success

co_severity_warning

Constant

Severity of the Message: 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.

Parameter 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

For more information, see: 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 %>
... 
                           
Parameter

CONDITION

Message condition

Return Values/Exceptions

INDEX

>0: Message index

=0: No message for condition

Cross References

For more information, see: 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.

Parameter CONDITION

Message condition

Return Values/Exceptions MESSAGE

Message

Cross References

For more information, see: 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.

Parameter CONDITION

Message condition

Return Values/Exceptions SEVERITY

=0: No message for condition

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

Cross References

For more information, see: 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.

Parameter INDEX

Message index (1..num_messages())

Return Values/Exceptions message

Message text

condition

Message condition

severity

Message severity (see constants co_severity_...)

Cross References

For more information, see: add_message, num_messages

Method num_message
Signature
method num_messages
  returning
    count type I
  .
                           
Description

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

Parameter

-

-
Return Values/Exceptions count

Number of messages that currently exist

Cross References

For more information, see: add_message