Show TOC

/IWBEP/IF_MESSAGE_CONTAINERLocate this document in the navigation structure

Use

The interface IWBEP/IF_MESSAGE_CONTAINER is used to add error details to the inner error section of the OData error response. See also http://www.odata.org/media/30002/OData%20Atom%20Format.html#themetadata:errorelementInformation published on non-SAP site.

The format for the inner error section of the OData error response is as follows:

<innererror>
  <transactionid>123</transactionid>
..<errordetails>
    <errordetail>
      <message>Street must not be empty</message>
      <propertyref>Address/Street</propertyref>
      <severity>error</severity>
    </errordetail>
    ... 
  </errordetails>
<innererror> 

Each entry of the message container will be mapped to an error detail entry of the inner error and will also be logged in the SAP Gateway framework.

HTTP Header SAP-Messages

If a request is successful, warnings and success messages can be returned to the consumer in the HTTP header SAP-Messages.

All messages that are added to the message container with the flag IV_ADD_TO_RESPONSE_HEADER = ABAP_TRUE are added to the HTTP header SAP-Messages if the request does not end in an error.

Example of how to add a message to the header SAP-Messages:

lo_message_container->add_message(
         iv_msg_type                = /iwbep/cl_cos_logger=>warning
         iv_msg_id                  = /iwbep/cx_tea_business=>team_id_out_of_range-msgid
         iv_msg_number              = /iwbep/cx_tea_business=>team_id_out_of_range-msgno 
         iv_add_to_response_header  = abap_true 
     ).
 

For more information, see Map Message Container to Message Protocol Format.

Instantiation

DATA lo_message_container TYPE REF TO /iwbep/if_message_container. 


  " get message container object
  lo_message_container = me->/iwbep/if_mgw_core_srv_runtime~mo_context->get_message_container( ).  

Constants

Table 1: Constants

Constant

Description

Value Set

GCS_MESSAGE_TYPE

Message types

abort, error, warning, success, info, termination

GCS_LEADING_MSG_SEARCH_OPTION

Method to determine the leading message

none, first, last

CS_SEVERITY

Severity of message

info, warning, error

Methods

Method ADD_ERRROR_DETAIL

The method parameter IS_ERROR_DETAIL is a structure containing fields for message text, severity, code, and property reference:

  • Code is a (custom) message code that a client can translate into a client-specific message text.

  • Severity is the severity of the message.

  • Property reference is the XPATH expression that points to the corresponding property for this message.

Method ADD_MESSAGE_FROM_EXCEPTION

Parameter

Description

Default Value

IO_EXCEPTION

Use this parameter to put your exception into the container

 

IV_ERROR_CATEGORY

Error category

/IWBEP/IF_MESSAGE_CONTAINER=>GCS_ERROR_CATEGORY-PROCESSING

IV_IS_LEADING_MESSAGE

The leading message will be displayed in the message section of the OData error response

ABAP_FALSE

IV_ENTITY_TYPE

Entity type

 

IT_KEY_TAB

Entity key as key-value table

 

IV_ADD_TO_RESPONSE_HEADER

Flag for adding the message to the response header.

If this parameter is set to ABAP_TRUE then the messages are reset in the response header.

ABAP_FALSE

Method ADD_MESSAGE_FROM_BAPI

Parameter

Description

Default Value

IT_BAPI_MESSAGES

Provide a table of BAPIRET2 messages

 

IV_ERROR_CATEGORY

Error category

/IWBEP/IF_MESSAGE_CONTAINER=>GCS_ERROR_CATEGORY-PROCESSING

IV_DETERMINE_LEADING_MSG

A leading message con optionally be determined by choosing the first or last error message in the table

/IWBEP/IF_MESSAGE_CONTAINER=>GCS_LEADING_MSG_SEARCH_OPTION-NONE

IV_ENTITY_TYPE

Entity type

 

IT_KEY_TAB

Entity key as key-value table

 

IV_ADD_TO_RESPONSE_HEADER

Flag for adding the message to the response header.

If this parameter is set to ABAP_TRUE then the messages are reset in the response header.

ABAP_FALSE

Method ADD_MESSAGE

Parameter

Description

Default Value

IV_MSG_TYPE

Message type

 

IV_MSG_ID

Message class

 

IV_MSG_NUMBER

Message number

 

IV_MSG_TEXT

Text of the message

 

IV_MSG_V1

Message variable

 

IV_MSG_V2

Message variable

 

IV_MSG_V3

Message variable

 

IV_MSG_V4

Message variable

 

IV_ERROR_CATEGORY

Error category

/IWBEP/IF_MESSAGE_CONTAINER=>GCS_ERROR_CATEGORY-PROCESSING

IV_IS_LEADING_MESSAGE

Set if the message shall be the new leading message of the container

 

IV_ENTITY_TYPE

Entity type

 

IT_KEY_TAB

Entity key as key-value table

 

IV_ADD_TO_RESPONSE_HEADER

Flag for adding the message to the response header.

If this parameter is set to ABAP_TRUE then the messages are reset in the response header.

ABAP_FALSE

Methode ADD_MESSAGES_FROM_LOG

Parameter

Description

Default Value

IT_LOG_MESSAGES

Table of log messages

 

IV_ERROR_CATEGORY

OBSOLETE

/IWBEP/IF_MESSAGE_CONTAINER=>GCS_ERROR_CATEGORY-PROCESSING

IV_ENTITY_TYPE

Entity type

 

IT_KEY_TAB

Entity key as key-value table

 

Method ADD_MESSAGE_TEXT_ONLY

Parameter

Description

Default Value

IV_MSG_TYPE

Message type

 

IV_MSG_TEXT

Text of the message

 

IV_ERROR_CATEGORY

OBSOLETE

/IWBEP/IF_MESSAGE_CONTAINER=>GCS_ERROR_CATEGORY-PROCESSING

IV_IS_LEADING_MESSAGE

Specify whether the message shall be the new leading message

 

IV_ENTITY_TYPE

Entity type

 

IT_KEY_TAB

Entity key as key-value table

 

IV_ADD_TO_RESPONSE_HEADER

Flag for adding (or not adding) the message to the response header

ABAP_FALSE

Method ADD_MESSAGES_FROM_CONTAINER

Note that this method is obsolete.

Parameter

Description

Default Value

IO_MESSAGE_CONTAINER

Reference to message container to be added

 

IV_ADD_TO_RESPONSE_HEADER

Flag for adding the message to the response header.

If this parameter is set to ABAP_TRUE then the messages are reset in the response header.

ABAP_FALSE

Method GET_MESSAGES

Parameter

Description

Default Value

IV_PROVIDE_TEXT

If set the text of the messages is inserted into the container structure

 

RT_MESSAGES

Table of messages

 

Method GET_LEADING_MESSAGE_TEXT

Parameter

Description

Default Value

RV_MESSAGE_TEXT

Text of the leading message

 

Method GET_WORST_MESSAGE_TYPE

Parameter

Description

Default Value

RV_MESSAGE_TEXT

Worst message type inside the container

 

Method GET_HAS_LEADING_MESSAGE

Parameter

Description

Default Value

RV_HAS_LEADING_MESSAGE

Is set if the container contains a leading message