Start of Content Area

Background documentation Context at Design Time and Runtime  Locate the document in its SAP Library structure

Once the main structure of a context and the properties of the individual nodes and attributes have been designed at design time, the context is filled with data at runtime.

Term: Element

The cardinality property of a context node is used at design time to determine the number of elements a node can have at runtime. If a node has a cardinality of a maximum of 1, this means that each attribute/child node is available once only at runtime. There is only a single value for each attribute. This corresponds to the type definition of a structure in ABAP Objects.

This graphic is explained in the accompanying text

In contrast, a node with maximum cardinality n can have multiple elements at runtime. In ABAP objects, this case corresponds to the type definition of an internal table.

This graphic is explained in the accompanying text

At runtime, an element represents a single instance of a context node. The corresponding situation in ABAP objects programming language is the instantiation of a variable or object.

The root node of a context is only instantiated once.

Static and Dynamic Attributes

All attributes of a context node created at design time are called static attributes. Web Dynpro framework enables application developers to add additional attributes to a context node at runtime. Attributes that are generated dynamically at runtime are called dynamic attributes. The explicit differentiation between these two attribute variants is significant for programming runtime behavior.

Sequence of Elements

If a runtime context node contains multiple elements, these elements are subject to a defined sequence. This sequence is important since it enables access to specific elements during context programming. The elements of a node filled from an internal table adopt the sequence of the rows in that table. Elements that are only generated at runtime (see Writing Data to New Context Elements) are appended to the end of the sequence, unless explicitly programmed to behave otherwise.

Context Nodes on the Basis of Existing Structure

You can use existing structures for the declaration of a context. For instance, you can link the attribute set of a node to an ABAP Dictionary structure. This causes all required attributes to be generated and placed into the context node. All attributes have the correct typing. In addition, existing additional data such as help texts or column headers can be adopted from the Dictionary. Note the following points:

Caution 

If you have assigned an ABAP Dictionary structure to a context node, you cannot add any attributes that do not belong to the structure in question to the node.

When creating this kind of context node, you have the choice of selecting individual attributes from the structure for your context. However, your selection is only for the purposes of obtaining a clear overview. In fact, the runtime context of the node always contains all attributes of the Dictionary structure. This is particularly important for memory and performance considerations.

Design Time View at Runtime

For various reasons, information from the design time view is also required or processed at runtime. For example, this includes information on whether or not the context node is of the type singleton. This information is called the metadata of a node.

Each context node also references an object of the type IF_WD_CONTEXT_NODE_INFOsapurl_link_0001_0001_0001. This represents the metadata of the context node. The corresponding methods can then be used to read or set the individual pieces of metadata information for the context node.

Example: Reading the singleton Property of a Node

 

method EXAMPLE .  

 

data: l_snode_11    type ref to IF_WD_CONTEXT_NODE,

      l_node_info                type ref to IF_WD_CONTEXT_NODE_INFO,

      l_singleton                type abap_bool.

. . . . . . . . . 

l_node            = wd_context->get_child_node( wd_this->wdctx_node_1 ).

l_node_info       = l_node->get_node_info( ).

l_singleton       = l_node_info->is_singleton( ).

. . . . . . . . .

endmethod.

 

 

 

 

End of Content Area