Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Obsolete Language Elements →  Obsolete Processing of External Data →  Obsolete Contexts 

Contexts, message handling

The example illustrates 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.
  READ TABLE itab INTO line INDEX 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 handling is executed in the program which is achieved via the additon MESSAGES INTO of the statement DEMAND. The message is then available for further processing in the internal table itab. At the second DEMAND statement, the message handling is carried out by the system and the program cancels with an error message.