In the SAP Netweaver 2004, SAP Introduced a new Object Oriented ALV List family class, called CL_SALV, in this post we will focus on the CL_SALV_TABLE class, I will demonstrate how to create ALV Grid in ABAP Dynpro Screen using CL_SALV_TABLE. I assumed you’ve known about ALV Grid.

Step 1 Create ABAP Screen

You need to create one ABAP Dynpro ( Screen ) and put one custom control on the screen and input the required name of custom control.


Step 2 Get Coding.

Write the code on the PBO screen and declare all important variable on your ABAP Program as below.

You need to declare two required reference variable to CL_GUI_CUSTOM_CONTAINER and CL_SALV_TABLE class. because in this program you will create ALV Grid using CL_SALV_TABLE and display in the ABAP Screen container.

Two reference variable LO_AGGRS is used to display aggregation on ALV Grid and LR_LAYOUT to customizing ALV Grid layout.

First you need to instantiating object CALV_CONST_POST, then input Container Name with your custom control name on the ABAP Screen ( in this sample My custom control name is : ALV_CONS_POST, and to create ALV is simple you only need to call static method factory and completed all of the mandatory Exporting, Importing and Changing of this method. ( r_container for Container Control, r_salv_table for CL_SALV_TABLE object and t_table is internal table containing your data that you want to show into ALV Grid ).

Call method get_aggregations to display total on your certain column as you business requirement.

create one macro to add sum function on your column easily.

And you just use this macro to add which one of your columns have sum function.

In this sample we only want to show sum function on two columns ( ZPRIDIS and ZIDC ).

Create one subroutine to build and customize ALV Grid Columns, in this subroutine contain routine to set _currency, set_long_text  and set_color.

The result :


Incoming search terms: