DEMAND

Short Reference

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 the data objects f1 f2 .... For context_ref, you must specify a data objects that points to a context instance (see CONTEXTS). For val1 val2 ..., you can specify the names of derived fields of the corresponding context. For f1 f2 ..., you must specify data objects whose data type conforms with the corresponding context field val1 val2 ....

If the context instance contains valid derived values for the current key, these are assigned directly. Otherwise, the cross-transaction buffer of the context is searched for the corresponding data record, which is then transferred to the context instance and from there to the 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 the data objects f1 f2 ....

If not all required values can be derived since not enough key fields are known, processing is stopped, the derived values are initialized, and the module sends the message specified 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
Unequal to 0 The internal table specified after MESSAGES contains messages.

Note

The structured type context_t_con, created with CONTEXTS, can be used 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 the internal table itab, which is specified after INTO. The row type of the internal table must refer to the structure SYMSG in the ABAP Dictionary. The columns msgty, msgid, msgno, and msgv1 to msgv4 contain the message type, message class, message number, and content of any placeholders. The internal table itab is initialized at the start of the DEMAND statement.

Example

In this example, an instance of the context demo_travel is created, the key fields are supplied, and the derived values 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.