Requirement 2 – Upload Excel Data and display in ALV using CL_GUI_ALV_GRID

Authored by

Requirement: 2

Upload an excel file from presentation server and display those records in an ALV using cl_gui_alv_grid

To display excel sheet data in ALV grid,

  1. 1. Data deceleration’s for ALV, Custom Container, Fieldcatlog and Internal Table.
  2. 2. Create Screen.
  3. 3. Insert Custom Container UI Element on to the screen.
  4. 4. Create modules and add logic.
  5. 5. Display ALV.

Step1:  Excel Structure that is to be uploaded.

Step2: Program to upload excel.

There are many function modules in SAP ABAP to upload an excel file from presentation server to database.

Here we are using FM – ‘TEXT_CONVERT_XLS_TO_SAP’

Go to SE24,

  • Create a class which will have methods to Upload Excel and F4 help for file name.
  • Define a structure for the internal table that holds records from the excel sheet.




Go to SE38,

Data Declarations:

  • Data declarations for ALV grid, Custom Container, Fieldcatalog and internal tables.

Define Parameters on Selection Screen to enter file name

Populate internal table with excel sheet records:

Create Screen to insert Custom Container UI element.

When double clicked, below popup is raised

Screen Painter is opened, provide short description and click on Layout.

In Layout, Custom Container UI Element is inserted which displays the ALV Grid.

Why do we use Custom Container UI Element to display ALV Grid?

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.

Double click on Custom Container UI Element, and provide it a name.

Go to Flow Logic, uncomment the PBO and PAI modules.

Double click on the modules to create it.

Modules can either be created in Include or Master Program.

In this example, we create the modules in Master Program.

At PBO of the screen we will deal with building a fieldcatalog and creating an ALV Grid instance.

To enable Back, Exit and Cancel buttons, double click on SET PF-STATUS ‘ALV_GUI’.

It navigates to the below screen. Expand function keys and provide texts for Back, Exit and Cancel buttons, save and activate.


Enter the excel filename or navigate using F4 help that is configured.

Excel Sheet Structure,

The ALV Grid display,