»  ABAP Development
 Picture

Using the ALV to Display Data in Table Form

By: LANCE Hayworth
Date Added : December 19, 2009 Views : 497
Rate Author : Current : 2.33 /5
Rate this Article : Current : 2.04 /5



Using the ALV to Display Data

The SAP List Viewer is used in many standard reports and reporting tools (such as SAP Query). ABAP programmers can install it in their own programs.

ALV is typically used as an abbreviation; it goes back to the old name (ABAP List Viewer).

The ALV has a number of interactive standard functions that list users frequently use (such as Print). As a developer, you have the option of hiding, adjusting or extending those standard functions.

The ALV Object Model (ALV OM), which was introduced for SAP NetWeaver 2004, offers three output forms for non-hierarchical lists: full screen, embedded in a container (filling only a part of a subscreen container), or the classic ABAP list. The ALV is always embedded in a container in the ALV Grid Control version (introduced for SAP R/3 4.6).

The screen layout of the container ALV is composed of three areas:

• The application toolbar is displayed in the header area. The calling program can hide individual functions, or even the entire application toolbar.
• The calling program can display a single-line list header under the application toolbar.
• Below the header is the area that displays list data (known as the data area).

The data area itself has a structure of its own.

The data is passed from the calling program as a table.

If the data table contains more rows and columns than can be displayed in the control area, horizontal and vertical scroll bars appear automatically.

Columns can be divided into lead columns and non-lead columns. Lead columns have a different color from non-lead columns. They also have a fixed position and therefore remain unchanged when the user scrolls horizontally through the list. Furthermore, you can make any column in your data table a lead column from the calling program.

You can select (depending on the implementation in the program): Cells and groups of cells, whole rows, whole columns, or whole rows and columns. If Line Selection is configured from the calling program, the system automatically displays a column (the first column in the data area) with pushbuttons that allow the user to select whole lines.

If a column is used as a sort criterion, a small red triangle will indicate that.

Columns that are totaled for have a sigma sign (Ó) in their header.

The following functions can be offered as standard in the application toolbar, so that you do not need to implement them yourself:

• Details: Displays the data for the selected row in a modal dialog box.
• Sort ascending/descending: Displays the list content sorted by the selected column or columns. Users can specify as many columns as they want, and the order in which they are to used for sorting, in a dialog box.
• Search: Users can specify search terms and search order (columns or rows).
• Set filter: Restricts the dataset display based on any filter criteria the user chooses.
• Total: Users can choose to display the total, arithmetic mean, maximum value, or minimum value for the numeric columns they selected.
• Subtotal: Displays subtotals for a data group (which the user defines by selecting a non-numeric column).
• Print: Opens the standard print dialog box.
• Views: Output List displays a print preview.
• Export: Allows users to open other installed applications with the data.
• Layout: Allows users to set up other display variants temporarily in a single dialog box, along with the standard functions already described.
• Graphic: Opens a graphic editor with the data from the list. Users can choose other processing options by double-clicking.

Functions of the left mouse button:

• You select columns by left-clicking the column header. You select several columns by holding down the control key on the keyboard at the same time. Click the column header again to deselect it.
• You select a line by clicking it.
• You move selected columns by holding down the left mouse button and dragging the column to the required position (drag & drop).
• You change the column width by holding down the left mouse button and dragging a column margin in the header line to the required position (Drag&Drop).

The mouse pointer changes according to the function you choose.

Important functions of the right mouse button (context menu) when you click a column header:

• You can hide selected columns for a clearer layout. By choosing Show, you can choose to show the required columns again in a dialog box.
• If you choose the Optimum Width function, the system will adjust all of the columns displayed to their optimum width.
• You can define a selected column as the last fixed column: When you scroll across, only columns to the right of the selected column are scrolled through. This is particularly useful when you have a wide list in which not all columns can be displayed on the screen at once. It means that you can still see the most important columns all the time.

To generate subtotals in the ALV:

1. Select the column or columns for which you want to create totals.
2. Click the pushbutton that has the sigma symbol. This makes the pushbutton for subtotals visible.
3. If you do not require complex subtotals, select the columns for which you want to create subtotals. They must be non-numerical columns. Then when you create subtotals, the list is sorted in ascending order according to the fields in the columns you selected and subtotals are created for all the columns you selected.
4. You can then create the subtotals by clicking the corresponding pushbutton.
5. For more complex subtotals, leave out step three. When you click the subtotals pushbutton, a dialog box appears in which the columns that you want to use for sorting are shown on the left and the rest of the columns are shown on the right. You move columns from one side to the other by double-clicking them, for example. On the left-hand side, you can determine for each column in the ALV whether you want to sort in ascending or descending order and whether you want to create subtotals. Moreover, you can influence the sort hierarchy by using the pushbuttons with the arrows (top-left) to move sort criteria up or down.

Post Article Comments

Name : 
EmailAddress : 
URL : 
Comments :