ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 14.04.2021
Просмотров: 1554
Скачиваний: 2

An Easy Reference for ALV Grid Control
SDN Community Contribution
(This is not an official SAP document.)
Disclaimer & Liability Notice
This document may discuss sample coding or other information that does not include SAP official
interfaces and therefore is not supported by SAP. Changes made based on this information are not
supported and can be overwritten during an upgrade.
SAP will not be held liable for any damages caused by using or misusing the information, code or
methods suggested in this document, and anyone using these methods does so at his/her own risk.
SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content
of this technical article or code sample, including any liability resulting from incompatibility between the
content within this document and the materials and services offered by SAP. You agree that you will not
hold, or seek to hold, SAP responsible or liable with respect to the content of this document.
© 2005 SAP AG
1

An Easy Reference for ALV Grid Control
Applies To:
ALV Grid control can be used as of release 4.6C. Besides consider the following official note while
utilizing this control:
SAP does not guarantee that the methods, events and attributes of this class that are not
public will remain unchanged or will be available in future releases. This is why you should
not derive the class to access protected objects of the class. Using these objects makes it
more difficult to upgrade to subsequent releases.
Summary
Purpose of this tutorial is to provide an easy and quick reference which may be used as a guide while
coding to build lists using ALV Grid Control. Actually, there is easy-to-reach information about
implementing ALV Grid lists. However, it is generally required to find the information sought in a quicker
way. This tutorial handles this, being a condensed source which can be used as a “guide”. It will not deal
with the technical infrastructure on which ALV lays. Some of the tables are taken from the online SAP
Library which is the most trustable source about the topic. Shortly, this will be a booklet summarizing
major capabilities of the ALV Grid Control.
To get deep into the ALV Grid control, you can refer to the standard SAP course “
BC412 – ABAP
Dialog Programming Using EnjoySAP Controls
” and the book “
Controls Technology
”. Also you had better
inspect demo programs.
By
: Serdar
Şİ
M
Ş
EKLER
Company and Title
: Havelsan Inc., SAP Application Developer
Date
: 24 Oct 2004
Updated on 27 June 2005
Updated on 16 August 2005
Prerequisites
To use ALV Grid Control in a simple manner, it will be sufficient just having experience on dialog
programming. However, to make use of more capabilities, it is required some knowledge on object-
oriented perspective of ABAP programming. A general knowledge on control framework is supposed to
exist.
© 2005 SAP AG
2

An Easy Reference for ALV Grid Control
Table of Contents
NON-EVENT BASED ADDITIONAL FUNCTIONALITIES 23
© 2005 SAP AG
3

An Easy Reference for ALV Grid Control
Introduction
Here is the definition for ALV from SAPHelp:
“The ALV Grid control is a flexible tool for displaying lists. The tool provides common list operations as
generic functions and can be enhanced by self-defined options.”
The ALV Grid control is used to build non-hierarchical, interactive, and modern-design lists. As a
control, it is a component that is installed on the local PC.
The ALV Grid control provides typical list functions as sorting, filtering, summing, etc... while also
gives the opportunity to develop user functions where needed. It presents numerous interfaces like Excel
Inplace and Crystal Reports.
The wrapper class implemented to encapsulate ALV Grid functionality is “CL_GUI_ALV_GRID”.
There is another way to display lists with ALV utilizing “REUSE_ALV...” functions. However, that way is
not comprised in this tutorial.
Building Blocks
While preparing a list to be displayed via an ALV grid control, we have some basic components to
prepare. These are;
i. List
data: Obviously, this is the data in an internal table to be listed. Standard ALV functions except
sorting makes just read access to the list data. However, sorting changes state of the internal
table. The internal table holding list data may be of any flat type. Deep types are only allowed
when set for some functionalities of ALV Grid.
ii. Field
Catalog: We use another internal table to define specifications on how the fields of our list will
be displayed. This internal table is called the “field catalog”. The field catalog must comprise
some technical and additional information about display options for each column to be displayed.
There are three procedures to generate the field catalog as
“Automatic generation”, “Semi-
automatic generation”, and “Manual generation”
. The internal table for the field catalog must be
referenced to the dictionary type “
LVC_T_FCAT
”.
iii. Layout Structure: We fill a structure to specify general layout options for the grid. With this structure
we can set general display options, grid customizing, totals options, color adjustments etc... The
layout structure must be of type “
LVC_S_LAYO
”.
iv. Event Handler: We should define and implement an event handler class if we want to handle events
triggered by the ALV Grid instance. After creating ALV Grid instance, we must register an
instance of this event handler class to handle ALV Grid events.
v. Additional
Data: To trigger some additional features of ALV Grid we can have some additional data to
pass as parameters. For example, initial sorting criteria, buttons to be deactivated, etc...
General Scheme
Now, we can figure out a primitive scheme to prepare our ALV Grid. As a control object, ALV Grid
instance requires a container to be linked to the screen. Generally, an instance of the class
“
cl_gui_custom_container
” is used for this purpose. Instances of some other container classes such
as “
cl_gui_docking_container
”, “
cl_gui_dialogbox_container
” may also be used. In our
example we take a custom container. To create a custom container instance, we need a custom control
area on the screen.
Step
1
Æ
Add a custom control on the screen which will be related to the custom container. Let’s give
it the name ‘
CC_ALV
’.
© 2005 SAP AG
5
