Showing posts with label Integration of ALV. Show all posts
Showing posts with label Integration of ALV. Show all posts

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.

Wednesday, June 25, 2008

Using the ALV Views List Viewer in Web Dynpro for ABAP

The ALV component contains the following views, which you can use as required:

•TABLE
This is the central ALV view. To display the ALV output, you require this view.
The TABLE view is the container in which the ALV output is displayed. It is a fundamental part of the ALV component. You cannot, therefore, change the layout.

•SERVICE
This view contains the Settings dialog box with which the user can make changes to the settings for column display, sorting, filtering, and so on.
By default, the view is displayed above the ALV output when the user chooses the Settings hyperlink in the toolbar. You use this view when you want to display the dialog box elsewhere on the screen.

Inserting a TABLE View

You require the TABLE view if you want to display an ALV output in your application.

You can insert the TABLE view in various ways:

•You insert it directly into a window of your application.

In this case, you cannot display any another element on the screen except for the ALV output.

•You insert it into a cell of a view set in your application.

•You generate a UI element of the type ViewContainerUIElement in the position you want in one of the views. You then insert the TABLE ALV view into this UI element.

Objects of the ALV Configuration Model List Viewer in Web Dynpro, Integration of ALV

The following main areas are available for configuring your ALV output:

•Table settings

The data for the Table UI element includes the structure of the application data as well as the technical fields that determine the appearance or function of the ALV output. You can define, for example, whether the ALV output is to be displayed with a simple, two-dimensional table or as a hierarchy with a leading hierarchy column.

•Field settings

The fields describe the data that is used in the ALV output. The name of a field corresponds to the name of an attribute in the context node: All field objects are automatically generated from the specifications that you made in the context node. As a result, every attribute in the context node has a representative with the same name in the ALV configuration model.
By connecting the internal data table to the context node you fulfill all the prerequisites to start your application with ALV. You can sort the data with statements from your application, filter it, or perform applications. All these functions (ALV services) are essentially field object methods. You cannot, however, display the data yet. To do this, you need columns.

•Column settings

The column objects are visible elements that define the ALV output. The columns have the same names as the corresponding field objects and attributes in the context node. The column object contains settings as to whether and how the data for the field of the same name is displayed in the ALV output. If you do not want to display the values of the field, you can delete the corresponding column object.
You use the column settings to manage a list of all the column objects (the columns for the Table UI elements).

•Standard function settings

ALV provides a number of functions. The following list shows the most important of these standard ALV functions:

  • ALV services: Sorting, filtering, aggregating (calculations), as well as the option to make all the necessary settings for these services.
  • Settings you can provide for editable ALV output, such as inserting and deleting rows.
  • Exporting the ALV output to Microsoft Excel or generating a print version in PDF format.

All these standard functions are accessible using the relevant UI elements. You can hide or show these UI elements by using the standard function settings.

•Application-specific function settings

You can define as many functions as you want in your application and provide suitable UI elements to the user with which he or she can then run these functions.


As an application developer, you can configure all these areas. You can use a complete object model for object-oriented ABAP programming to do this. You can use it to change the ALV output, if necessary. There is an interface class for each of the areas listed here. They are implemented by the central class CL_SALV_WD_CONFIG_TABLE (see Class Diagram).

All the classes that are required for the configuration of the ALV output can be found in the system in the package SALV_WD_CONFIG.

Getting the ALV Configuration Model List Viewer in Web Dynpro for ABAP

To make the ALV configuration model available, you use, for example, a method from class IWCI_SALV_WD_TABLE in WDDOINIT. You choose one of the following methods:
...

● GET_MODEL

The system returns a complete ALV configuration model with all column objects and field objects.

This is the default variant. The method does not have any parameters.

● GET_MODEL_EXTENDED
The system returns all field objects (as above), but only returns column objects when required.
If, for example, you want to manage a large number of field objects but you only want to display a few columns, create the field objects first and later generate the column objects you require to display the content.

Parameter S_PARAM from method GET_MODEL_EXTENDED (type IF_SALV_WD_TABLE=>S_TYPE_PARAM_GET_MODEL) consists of the DEFAULT_COLUMNS field: This enables you to specify whether the column objects are to be generated or not.

You now have all the objects needed to configure the ALV output as required.

You can specify a new internal data table for the ALV output at a later stage. To do this, use method SET_DATA. However, by using this method you also automatically delete the entire ALV configuration model with all fields and column objects. To make the configuration model available again to the new data table, use method GET_MODEL or method GET_MODEL_EXTENDED.

Class Diagram List Viewer in Web Dynpro, Integration of ALV

The object model for the ALV configuration model consists of the following classes and interfaces:

This graphic is explained in the accompanying text This class diagram has been simplified. Some superclasses have been omitted. You can find the exact structures in the system in package SALV_WD_CONFIG.

Archive