Friday, August 15, 2008

Integration of ALV in ApplicationList Viewer in Web Dynpro for ABAP

Purpose

If you want to use an ALV output in your application, you have to follow various steps, depending on the required result. The following variants outline the most important ways in which you can call ALV:

Simple call without ALV configuration model

You only display an ALV output. You do not want to make any changes.

Simple call with ALV configuration model

You want to change the standard output using your application. To do this, you require the ALV configuration model.

ALV output in external view without ALV configuration model

ALV output is just one of many elements in a view. You do not want to change the ALV output. You do not need the ALV configuration model.

ALV output in external view with ALV configuration model

ALV output is just one of many elements in a view. You want to change the standard output using your application. To do this, you require the ALV configuration model.

Most of the steps listed below are the same as those you follow with the Web Dynpro components. Some of them, however, are tailored specifically for use with ALV.

Prerequisites

You must proceed as follows (ALV-independent) for all the variants listed above:

You generate a Web Dynpro component for your application and save it as active.

You generate a context node with the cardinality 0..n. The structure of the attributes in this context node (name and data type) and the structure of the internal data table that you connect to this context node in the next step are the same.

You connect your internal data table to the context node (for example, using the supply method). To do this, you use method BIND_TABLE from interface IF_WD_CONTEXT_NODE.

Process Flow

When the prerequisites listed above are fulfilled, the process then taken depends on the required result.

Simple Call Without ALV Configuration Model

...

1. You define a component usage for the ALV component SALV_WD_TABLE in your application component. In doing so, you specify a name for the component usage (for example, MY_ALV).

2. Using external context mapping, you provide the DATA context node in the ALV interface controller with your application data.

3. You embed the TABLE view of ALV component SALV_WD_TABLE into a window of your component.

Simple Call with ALV Configuration Model

...

1. You define a component usage for ALV component SALV_WD_TABLE in your application component. In doing so, you specify a name for the component usage (for example, MY_ALV).

You also define this component usage in your component controller. Since you need the ALV configuration model for your changes, select the With Controller Access variant (component interface).

2. You embed the TABLE view of ALV component SALV_WD_TABLE into a window of your component.

3. Using external context mapping, you provide the DATA context node in the ALV interface controller with your application data.

4. To configure the ALV output, you must follow two additional steps:

You instantiate the used ALV component in a method of the component controller (for example, WDDOINIT).

You receive the ALV configuration model and with it the object model, field objects, and column objects.

You can find a description of all the classes and methods of the ALV configuration model in the system in package SALV_WD_CONFIG.

ALV Output in External View Without ALV Configuration Model

...

...

1. You decide whether you require the context node in the component controller or in the view context of your application view. If necessary, you generate an appropriate context node in your view and map the context node from the component controller to it.

2. In your application component, you define a component usage for ALV component SALV_WD_TABLE. In doing so, you specify a name for the component usage (for example, MY_ALV).

You also define the usage of this component in the properties for your view. Since you do not need the ALV configuration model, choose the Without Controller Access variant (no component interface).

3. Using external context mapping, you provide the DATA context node in the ALV interface controller with your application data.

4. You generate the UI element ViewContainerUIElement at the required position in the layout of your view.

5. You have already embedded your view in the window of your application. The name of the UI element ViewContainerUIElement that you prepared in the previous step for the ALV output is displayed beneath this view. Under this entry, you then embed the TABLE view for the SALV_WD_TABLE ALV component.

ALV Output in External View with ALV Configuration Model

...

...

1. You decide whether you require the context node in the component controller or in the view context of your application view. If necessary, you generate an appropriate context node in your view and map the context node from the component controller to it.

2. In your application component, you define a component usage for ALV component SALV_WD_TABLE. In doing so, you specify a name for the component usage (for example, MY_ALV).

You also define the usage of this component in the properties for your view. Since you need the object model for your changes, choose the With Controller Access variant (component interface).

3. Using external context mapping, you provide the DATA context node in the ALV interface controller with your application data.

4. You generate the UI element ViewContainerUIElement at the required position in the layout of your view.

5. You have already embedded your view in the window of your application. The name of the UI element ViewContainerUIElement that you prepared in the previous step for the ALV output is displayed beneath this view. Under this entry, you then embed the TABLE view for the SALV_WD_TABLE ALV component.

6. To configure the ALV output, you must follow two additional steps:

You instantiate the used ALV component in a method of your view (for example, WDDOINIT).

You receive the ALV configuration model and with it the object model, field objects, and column objects.

You can find a description of all the classes and methods of the ALV configuration model in the system in package SALV_WD_CONFIG.

Defining the Component Usage List Viewer in Web Dynpro, Integration of ALV

To use an ALV output in your application, use the component SALV_WD_TABLE. You can integrate this ALV component as an external component into your Web Dynpro component. To do this, you define the component usage.

If you want to display multiple different ALV outputs, distinguish between these outputs by using unique names for the respective usage variants of the component.

How you define the component usage depends upon how you want to use the ALV component.

· If the ALV output is the only element on the screen, you define the component usage of the ALV component only in the component of your application (the top node in the hierarchy of the component, as it is displayed in the Component Editor).

This is the simplest case. You cannot configure the ALV output before it is displayed.

· If the ALV output is the only element on the screen (as above), but you want to make changes to the appearance, function, or run-time behavior, specify the usage of the component in the properties of the component controller for your application. Choose the variant with controller access.

· If, however, you want to insert the ALV output into a complex layout in a view of your application, define the component usage in the properties of the view (and not the component controller) in which the ALV output is to be displayed.

Depending on whether you want to use the standard display of the ALV output, or whether you want to change it, choose either the without controller access or the with controller access version respectively.

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.

Web Dynpro ABAP Integration

Web Dynpro ABAP provides functions for integration in and with various technologies:

● Portal Integration

● Adobe Integration

● Office integration

● BI integration

● FileUpload and FileDownload - File Export

● SAP List Viewer Integration

● CAF Guided Procedures Integration

In View Designer Category Integration is provided for relevant UI elements.