Show TOC Start of Content Area

Background documentation Recursion Nodes   Locate the document in its SAP Library structure

The recursion node is a special type of node used when a node hierarchy with a recursive structure needs to be created. This is needed when, for instance, the depth of the node hierarchy is not known until runtime. Using a recursion node, you can declare that a particular node structure be replicated as a child of itself. A good example here is if your context needs to hold information in the same structure as a file system, containing directories and subdirectories.

A simplistic file system can be represented by the structure shown in the following figure.

This graphic is explained in the accompanying text

At runtime, the Directory node will hold a collection of file names in its attribute FileName. The node SubDirectory is a recursion node whose repeatedNode property points up to the node Directory.

Note

The cardinality of the Directory node must be set to 0..n.

A recursion node is really a dummy node that acts simply as a design time placeholder. The repeatedNode property is then used to determine which node instance will occupy that location in the context hierarchy at runtime.

Caution

You cannot nominate a recursive node to act as the data source in a context mapping relationship. Recursive node structures are restricted to the scope of a single controller.

At design time, it is necessary to write some coding that will create an instance of the recursion node. Then at runtime, an instance of the node named in the repeatedNode property is created and inserted into the node hierarchy at the location of the recursion node.

Caution

The root node of a context cannot be used for a recursion.

If the particular element in the node collection of Directory node represents a file, then the SubDirectory instance in that element will remain null. However, if you wish to create a subdirectory, then the value held in attribute FileName will be the name of the subdirectory, and the recursion node SubDirectory will hold an instance of node Directory.

After two instances of the recursion node SubDirectory have been created, the context structure shown in the figure above will look like this:

This graphic is explained in the accompanying text

Note

This is the only situation in which you are permitted to create multiple node instances in the context with non-unique names.

End of Content Area