Friday, August 15, 2008

Providing the Data List Viewer in Web Dynpro, Integration of ALV

To provide the data you want to display in the ALV output, perform the following three steps:

Internal data table

You provide an internal data table.

Context nodes

You provide a suitable context node and attributes in the context of your application.

Transferring data to the ALV component

You provide this context node for the ALV component.

Internal Data Table

The data of the internal data table must be available in flat structures. This is the only prerequisite. The easiest way to do this is to use an existing DDIC structure.

Context Nodes

The ALV component requires a context node that can contain the data of the internal data table. This context node has the following properties:

It has the cardinality 0..n.

It only contains attributes and no subnodes: For each column of your internal data table, you create exactly one attribute of the same name and data type.

All the attributes are static, not dynamic.

If the internal data table is based on a DDIC structure, the easiest way to generate the attributes of the context node is to use this DDIC structure.

To transfer the data of the internal data table into the application context node, connect the data table to this node. To do this, use method BIND_TABLE, for example in the SUPPLY method of your controller.

Transferring Data to the ALV Component

In the previous step, you created the entire structure of the ALV output in the context node. Now you must transfer this to the ALV component. You can do this in the following ways:

Using external context mapping

Using method SET_DATA

Since you may have defined a different component usage for various different components (or different ALV components), for context mapping, you must specify the exact ALV component usage that is to contain the data of your context node.

External Context Mapping

The ALV component contains a separate context node known as DATA that must contain the structure and data of the ALV output to be able to display the required output. The easiest way to transfer the data to the DATA context node is to use external context mapping.

SET_DATA Method

You can transfer the data of your context node to the ALV component as well by using the SET_DATA method (reference type IF_WD_CONTEXT_NODE). You can do this, for example, in the WDDOINIT method. For more information, see SET_DATA. You specify the correct context node of your application as a parameter.

You also use method SET_DATA if you want to specify another structure for your ALV output at a later date or time.

Method SET_DATA always deletes any ALV configuration model that may exist. If you want to configure the ALV output, you must get the ALV configuration model again once the SET_DATA method has been run.

Using the Data in the ALV Component

In the context of the ALV component, context node DATA only contains a reference to the corresponding context node of your application. This in turn is a reference to the internal data table.

By default, the ALV component works with your reference to the data: Filters, calculations, and other standard ALV functions are carried out on the data by various mechanisms, and the changed ALV output is then shown on the screen.

Important Exception: Sorting

Here ALV has to use the entire dataset so that the data records can be arranged in the new order. For this purpose, the ALV component temporarily takes control of the internal data table and invalidates the corresponding context node of your application during this time. This ensures that the application cannot access the context node while the ALV component is editing the internal data table.

Once the internal data table has been resorted, ALV rebuilds the context node, releases it again for the application, and displays the data accordingly.


This ensures that the internal data table is never copied. This is important because large volumes of data would considerably impact performance and memory space.

When you are planning your application, note the following side-effects of this mechanism:

When the context node is invalidated, information about current selections, and in particular the lead selection, is lost.

If your application has created subnodes for the context node, (master-detail scenario), these subnodes are lost as soon as the ALV component invalidates the context node. If the application then tries to access the subnodes, a runtime error occurs.

No comments: