Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Obsolete Language Elements →  Obsolete Processing of External Data →  Contexts (Obsolete) 

Contexts, Message Handling

This example demonstrates how messages can be handled in contexts.

Other versions: 7.31 | 7.40 | 7.54

Source Code

REPORT  demo_context_message.

DATA: c_from TYPE spfli-cityfrom,
      c_to   TYPE spfli-cityto.

CONTEXTS docu_test1.

DATA: context_inst TYPE context_docu_test1.

DATA: itab TYPE TABLE OF symsg,
      line LIKE LINE OF itab.

SUPPLY carrid = 'XX'
       connid = '400'
       TO CONTEXT context_inst.


DEMAND cityfrom = c_from
       cityto   = c_to
       FROM CONTEXT context_inst MESSAGES INTO itab.

IF sy-subrc NE 0.
  line = itab[ 1 ].
  MESSAGE ID line-msgid TYPE 'I' NUMBER line-msgno
          WITH line-msgv1 line-msgv2 DISPLAY LIKE line-msgty.
ENDIF.

DEMAND cityfrom = c_from
       cityto   = c_to
       FROM CONTEXT context_inst.

Description

First, the message is handled in the program using the addition MESSAGES INTO of the statement DEMAND. The message is then available for further processing in the internal table itab. In the second DEMAND statement, the message is handled by the system and the program cancels with an error message.