Skip to content

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

DEMAND

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Obsolete Syntax

DEMAND val1 = f1 val2 = f2 ...
       FROM CONTEXT context_ref
       [MESSAGES INTO itab].

Addition

... MESSAGES INTO itab

Effect

This statement assigns the values of derived fields val1 val2 ... of a context instance to data objects f1 f2 .... For context_ref, you have to specify a data object that points to a context instance (see CONTEXTS). For val1 val2 ..., you can specify the names of fields derived for the corresponding context. For f1 f2 ..., you have to specify data objects whose data type conforms with the corresponding context field (val1 val2 ...).

If the context instance contains valid values derived for the current key, these are assigned directly. Otherwise, the system searches the cross-transaction buffer of the context to find the corresponding data record, which is then transferred to the context instance and from there to data objects f1 f2 .... Only if no corresponding data is found here are the values in the modules of the context derived and placed in the buffer, the context instance, and data objects f1 f2 ....

If some values required cannot be derived because not enough key fields are known, processing is stopped, the values derived are initialized, and the module sends the message defined in the context for this purpose.

System Fields

sy-subrc Meaning
0 The MESSAGES addition is not specified or the internal table specified after MESSAGES is empty
Not equal to 0 The internal table specified after MESSAGES contains messages.


Note

You can use the structured type context_t_con generated with CONTEXTS to create suitable fields.

Addition

... MESSAGES INTO itab

Effect

The MESSAGES addition is used for handling messages that may be sent by the modules of a context. If the MESSAGES addition is not specified, each message is sent according to its definition in the context, as described under Messages. If the MESSAGES addition is specified, the messages are not sent; instead, for each message, a row is attached to internal table itab, which must be specified after INTO. The row type of the internal table must refer to the SYMSG structure in the ABAP Dictionary. Columns msgty, msgid, msgno, and msgv1 to msgv4 then contain the message type, message class, message number, and content of any placeholders. Internal table itab is initialized at the start of the DEMAND statement.


Example

An instance of the demo_travel context is generated, the key fields are populated, and the values derived are requested.

CONTEXTS demo_travel. 

PARAMETERS: p_carrid TYPE context_t_demo_travel-carrid, 
           p_connid TYPE context_t_demo_travel-connid. 

DATA: context_ref TYPE context_demo_travel, 
      fields TYPE context_t_demo_travel. 

SUPPLY carrid = p_carrid 
       connid = p_connid 
       TO CONTEXT context_ref. 

DEMAND cityfrom = fields-cityfrom 
       cityto   = fields-cityto 
       fltime   = fields-fltime 
       FROM CONTEXT context_ref. 

WRITE: / fields-cityfrom, fields-cityto, fields-fltime.