Contexts are obsolete and should not be used. Contexts were introduced in Release 4.0 for high-performance access to frequently required data. Since the introduction of ABAP Objects for Release 4.5, contexts have not been developed further. Since Release 6.40, contexts can be replaced by shared objects .
Once you have supplied a context instance with key values, you can query its dependent values. You do this using the DEMAND statement:
Syntax
DEMAND val 1 = f 1 ... val n = f n FROM CONTEXT inst [MESSAGES INTO itab].
This statement fills the fields f 1 … f n with the derived values val 1 … val n from the context instance inst. The fields of the context are contained in the fields table.
In doing this, the system carries out the following steps:
REPORT rsgcon01.
DATA: c_from TYPE spfli-cityfrom, c_to TYPE spfli-cityto, c_time TYPE spfli-fltime.
CONTEXTS demo_travel.
DATA: demo_travel_inst1 TYPE context_demo_travel, demo_travel_inst2 TYPE context_demo_travel.
SUPPLY carrid = 'LH' connid = '400' TO CONTEXT demo_travel_inst1.
SUPPLY carrid = 'AA' connid = '017' TO CONTEXT demo_travel_inst2.
DEMAND cityfrom = c_from cityto = c_to fltime = c_time FROM CONTEXT demo_travel_inst1.
WRITE: / c_from, c_to, c_time.
DEMAND cityfrom = c_from cityto = c_to fltime = c_time FROM CONTEXT demo_travel_inst2.
WRITE: / c_from, c_to, c_time.
This program creates two instances of context demo_travel, supplies them both with key values and reads three dependent values from each of them.