Providing Data for ALV Display

Use

To provide the data that you want to display in the ALV display, you must connect the context node of your application (the one that contains the data for the table output) with the DATA context node of the ALV component. This takes place using External Context Mapping.

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 executed on the data by various mechanisms, and the changed ALV display 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.

Prerequisites

The following rules apply to the context node that contains the data for the ALV:

  • The node must only be used for displaying the ALV, that is:

    • No other view elements can be connected to attributes of this context node

    • No other ALV instance can be connected to this context node

  • The node must have cardinality 0..n.

  • The node must not contain any subnodes, that is, the ALV cannot function as master in a master detail scenario.

  • No dynamic attributes can be used, only static.

  • For each column of your internal data table, you create exactly one attribute of the same name and data type.

  • The data of the internal data table (which is connected to this context node) must also exist in flat structures. The easiest way to do this is to use an existing DDIC structure.

Procedure

  1. In Web Dynpro Explorer open Start of the navigation pathComponent Usages Next navigation step MY_ALV_COMP_USAGE Next navigation step INTERFACECONTROLLER_USAGEEnd of the navigation path

    Web Dynpro Explorer: Structure for Component Usages

    As you may have defined a particular component usage for several different ALV components, you must specify the exact ALV component usage that the data for your context node contains for context mapping.

  2. Click on controller usage, select your Component Controller, and confirm.

  3. Select the context node DATA of the INTERFACECONTROLLERs, open the context menu, and choose Defining External Mapping. Select the required context node of your Component Controller. The context node DATA is now displayed with a small arrow that symbolizes the mapping.

SET_DATA Method

Another options to transferring data to the ALV component is the SET_DATA method (reference type IF_WD_CONTEXT_NODE). In this way you can specify another structure for your ALV display at a later time. You specify the correct context node of your application as a parameter.