DEMAND

DEMAND - Request information from a context

syntax diagram

Additions:

...MESSAGES INTO itab

Effect

DEMAND triggers the calculation of the values p1 ... pn. The context checks whether the desired information already exists. If so, it performs the necessary steps to retrieve the information, notes the new values in the buffer and finally transports all the values to the fields f1,...,fn. If any of the values cannot be calculated, the DEMAND statement sets the relevant fields to the initial value (CLEAR).
You can find the names of the available fields in the Context Builder.

REPORT demo_supply_demand. 
TABLES   sbook. 
CONTEXTS demo_travel. 
DATA:	 my_travel	TYPE context_demo_travel, 
		apfrom	 TYPE context_t_demo_travel-name_from, 
		apto		 TYPE context_t_demo_travel-name_to, 
		geo_distance TYPE i, 
		carrier	LIKE scarr-carrname. 
 
SELECT * FROM sbook UP TO 10 ROWS. 
  SUPPLY carrid = sbook-carrid 
		 connid = sbook-connid 
			 TO CONTEXT my_travel. 
  DEMAND 
		 distance   = geo_distance 
		 name_from  = apfrom 
		 name_to	= apto 
		 carrname   = carrier 
			FROM CONTEXT my_travel. 
 
  FORMAT COLOR col_key. 
  WRITE: / sbook-carrid, sbook-connid, 
		 sbook-fldate, sbook-bookid, '|'. 
  FORMAT COLOR col_normal. 
  WRITE:   geo_distance, apfrom, apto, carrier, '|'. 
ENDSELECT. 

Effect

MESSAGES INTO specifies an internal table itab with the structure SYMSG. If error messages, warnings or information messages occur within the context processing, the user gets no output. Instead, the message is flagged in the specified internal table itab and the processing resumes.
The messages table is deleted before the actual context processing.

The return code SY-SUBRC specifies whether messages were inserted into the messages table:

Example

TABLES: SPFLI, SCARR. 
CONTEXTS: TRAVEL. 
DATA:	 MY_TRAVEL TYPE CONTEXT_TRAVEL, 
		APFROM	LIKE SAIRPORT-NAME, 
		APTO	LIKE SAIRPORT-NAME, 
		MSGTAB	LIKE SYMSG OCCURS 4. 
DEMAND 
	 DISTANCE   = SPFLI-DISTANCE 
	 NAME_FROM  = APFROM 
	 NAME_TO	= APTO 
	 CARRNAME   = SCARR-CARRNAME 
								 FROM CONTEXT MY_TRAVEL 
								 MESSAGES INTO MSGTAB.


Around 100 msn for all buffered fields of a context module.

Related

CONTEXTS, SUPPLY