!--a11y-->
Dynamic Context
Manipulation 
You can manipulate the context of a controller in different ways at runtime.
To support the dynamic programming
of contexts and view layouts, the Web Dynpro framework offers a number of
methods in the service class
CL_WD_DYNAMIC_TOOL.
This class contains the most frequently used methods in a predefined form. However, you can also implement yourself all the methods for dynamic context manipulation implemented in this class within the Web Dynpro framework.
To get an overview of how this class is used, have a look at the example component DEMODYNAMIC in the SWDP_DEMO package, which was delivered together with your system.
Adding a node to a context at runtime may be necessary for a variety of reasons. In highly generically programmed components, the number of required nodes may not be known at design time. Even if the number is known, the structure of the node may become known only at runtime. In such a case, the node is also created and typed dynamically.
For this purpose, the service class CL_WD_DYNAMIC_TOOL contains the method
CREATE_NODEINFO_FROM_STRUCT. To this method, you pass a number of parameters, such as information on the parent node or the name of the structure the new node shall have. For a complete list of the parameters, their meanings and possible values, see the reference documentation for this service class. Use method CREATE_NODEINFO_FROM_STRUCT to create the new node info, from which the relevant node will then be generated.
If you delete the node info, then all
instances of the related node are automatically deleted as well.
In contrast to statically created context
nodes, the length of the name of a dynamically created node is not limited.
The method CREATE_NODEINFO_FROM_STRUCT expects a known structure to be passed, which means that the node created in such a way automatically has a fixed set of attributes in accordance with the selected structure. However, you can always add individual attributes to this structure (see below). Basically, you could also dynamically create an empty node and fill it with attributes afterwards. However, the service class CL_WD_DYNAMIC_TOOL does not provide a prepared method for this.
The dynamic bind of a UI element to a context node is programmed at the UI element (see chapter Dynamic Layout Manipulation).
It can make sense to add or remove parameters to or from a context node, depending on the parameters evaluated at runtime. If you created a context node with a DDIC structure at design time, you can create additional attributes only dynamically. In generic applications it may happen that the type of an attribute is not yet known at design time; in this case, you will also create and type this attribute dynamically.
For this purpose, the interface IF_WD_CONTEXT_NODE_INFO contains the method ADD_ATTRIBUTE.
A UI element can be bound to a dynamically created context node. The UI element may access fixed values of context attributes. In this case, it is necessary to determine fixed values for the attributes. For more information, see Fixed Values of Attributes.