SlideShare a Scribd company logo
ALV Object Model – Simple 2D Table - The Basics
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2006 SAP AG 1
ALV Object Model – Simple 2D Table - The Basics
Applies to:
Netweaver 2004 and Netweaver 2004s
Summary
This tutorial is the first of the series, which deals with the ALV Object Model. In this tutorial, you will learn
how to create a simple two-dimensional table report using the ALV Object Model.
Author(s): Rich Heilman
Company: Yorktowne Cabinetry
Created on: 21 September 2006
Author Bio
Rich Heilman is an ABAP/J2EE Software Engineer/Analyst for Yorktowne Cabinetry, Inc. based in Red Lion,
Pennsylvania, USA. He has a total of nine years experience in the IT industry. He has spent the past five years
studying ABAP and Java.
ALV Object Model – Simple 2D Table - The Basics
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2006 SAP AG 2
Table of Contents
Applies to: ........................................................................................................................................ 1
Summary.......................................................................................................................................... 1
Author Bio ........................................................................................................................................ 1
Main Class – CL_SALV_TABLE...................................................................................................... 3
Functions – CL_SALV_FUNCTIONS .............................................................................................. 4
Display Settings – CL_SALV_DISPLAY_SETTINGS...................................................................... 4
Columns – CL_SALV_COLUMNS_TABLE and CL_SALV_COLUMN_TABLE.............................. 5
Sorts – CL_SALV_SORTS .............................................................................................................. 8
Aggregations – CL_SALV_AGGREGATIONS .............................................................................. 10
Filters – CL_SALV_FILTERS ........................................................................................................ 12
Layouts – CL_SALV_LAYOUT...................................................................................................... 14
Related Content............................................................................................................................. 15
Disclaimer and Liability Notice....................................................................................................... 16
ALV Object Model – Simple 2D Table - The Basics
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2006 SAP AG 3
Main Class – CL_SALV_TABLE
The main class used to create the simple 2D table is the class CL_SALV_TABLE. Create a reference
variable for this class. Create an internal table and fill this internal table with data as show below.
REPORT ZALVOM_DEMO1.
data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
start-of-selection.
select * into table ispfli from spfli.
Next we need to create the ALV object for the 2D table. The FACTORY method allows you to create the
ALV object in 3 ways. You can create the ALV Grid, as a classical list display, as a full screen grid, and
finally embedded into a screen container. For this example, we will be working with the full screen grid.
Create the call to the FACTORY method. We are importing the object reference into GR_TABLE and
passing the internal table ISPFLI.
cl_salv_table=>factory( importing r_salv_table = gr_table
changing t_table = ispfli ).
Next we need to display the grid, for this we use the DISPLAY method . Simply call it.
gr_table->display( ).
ALV Object Model – Simple 2D Table - The Basics
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2006 SAP AG 4
Functions – CL_SALV_FUNCTIONS
Next, add functions to the application toolbar. For this, use the CL_SALV_FUNCTIONS class. Create the
object reference variable and receive the object using the GET_FUNCTIONS method of the GR_TABLE
object. Call the method SET_ALL to force the ALV grid to show all standard functions.
report zalvom_demo1.
data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.
start-of-selection.
select * into table ispfli from spfli.
cl_salv_table=>factory( importing r_salv_table = gr_table
changing t_table = ispfli ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
gr_table->display( ).
The result is now you have the standard buttons on the application toolbar.
Display Settings – CL_SALV_DISPLAY_SETTINGS
Next, we can change some display settings using the class CL_SALV_DISPLAY_SETTINGS. Create the
object reference variable and receive the object using the GET_DISPLAY_SETTINGS method of the
GR_TABLE object. In this example, we are setting the “Striped Pattern” for the ALV Grid rows, and setting
the heading in the title bar.
report zalvom_demo1.
ALV Object Model – Simple 2D Table - The Basics
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2006 SAP AG 5
data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.
data: gr_display type ref to cl_salv_display_settings.
start-of-selection.
select * into table ispfli from spfli.
cl_salv_table=>factory( importing r_salv_table = gr_table
changing t_table = ispfli ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
gr_display = gr_table->get_display_settings( ).
gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
gr_display->set_list_header( 'This is the heading' ).
gr_table->display( ).
Columns – CL_SALV_COLUMNS_TABLE and CL_SALV_COLUMN_TABLE
Next, we can change some of the attributes of a specific column in the ALV grid. In this example we will
change the Heading Text of a column as well as the color of a column. Create the object reference variable
and receive the object using the GET_COLUMNS method of the GR_TABLE object. This will pass you the
object for all columns of the ALV grid. To access just one column, call the method GET_COLUMN from the
GR_COLUMNS object. In this example, we are accessing the CITYTO column and the CITYFROM column.
report zalvom_demo1.
data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.
ALV Object Model – Simple 2D Table - The Basics
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2006 SAP AG 6
data: gr_display type ref to cl_salv_display_settings.
data: gr_columns type ref to cl_salv_columns_table.
data: gr_column type ref to cl_salv_column_table.
data: color type lvc_s_colo.
start-of-selection.
select * into table ispfli from spfli.
cl_salv_table=>factory( importing r_salv_table = gr_table
changing t_table = ispfli ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
gr_display = gr_table->get_display_settings( ).
gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
gr_display->set_list_header( 'This is the heading' ).
gr_columns = gr_table->get_columns( ).
gr_column ?= gr_columns->get_column( 'CITYTO' ).
gr_column->set_long_text( 'This is long text' ).
gr_column->set_medium_text( 'This is med text' ).
gr_column->set_short_text( 'This is sh' ).
gr_column ?= gr_columns->get_column( 'CITYFROM' ).
color-col = '6'.
color-int = '1'.
color-inv = '0'.
gr_column->set_color( color ).
gr_table->display( ).
ALV Object Model – Simple 2D Table - The Basics
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2006 SAP AG 7
ALV Object Model – Simple 2D Table - The Basics
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2006 SAP AG 8
Sorts – CL_SALV_SORTS
Next, we can add some sorting to the ALV grid. Create the object reference variable and receive the object
using the GET_SORTS method of the GR_TABLE object. Next, add the sort by calling the ADD_SORT
method of the GR_SORTS object.
report zalvom_demo1.
data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.
data: gr_display type ref to cl_salv_display_settings.
data: gr_columns type ref to cl_salv_columns_table.
data: gr_column type ref to cl_salv_column_table.
data: gr_sorts type ref to cl_salv_sorts.
data: color type lvc_s_colo.
start-of-selection.
select * into table ispfli from spfli.
cl_salv_table=>factory( importing r_salv_table = gr_table
changing t_table = ispfli ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
gr_display = gr_table->get_display_settings( ).
gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
gr_display->set_list_header( 'This is the heading' ).
gr_columns = gr_table->get_columns( ).
gr_column ?= gr_columns->get_column( 'CITYTO' ).
gr_column->set_long_text( 'This is long text' ).
gr_column->set_medium_text( 'This is med text' ).
gr_column->set_short_text( 'This is sh' ).
gr_column ?= gr_columns->get_column( 'CITYFROM' ).
color-col = '6'.
color-int = '1'.
color-inv = '0'.
gr_column->set_color( color ).
gr_sorts = gr_table->get_sorts( ).
gr_sorts->add_sort 'CITYTO' ).
gr_table->display( ).
ALV Object Model – Simple 2D Table - The Basics
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2006 SAP AG 9
ALV Object Model – Simple 2D Table - The Basics
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2006 SAP AG 10
Aggregations – CL_SALV_AGGREGATIONS
Since we sorted by CITYTO, we can add an aggregation to subtotal the DISTANCE by CITYTO. Create the
object reference variable and receive the object using the GET_AGGREGATIONS method of the
GR_TABLE object. Next, add the aggregation by calling the ADD_AGGREGATION method of the
GR_SORTS object. We also need to modify the call to ADD_SORT to set the SUBTOTAL = ABAP_TRUE.
report zalvom_demo1.
data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.
data: gr_display type ref to cl_salv_display_settings.
data: gr_columns type ref to cl_salv_columns_table.
data: gr_column type ref to cl_salv_column_table.
data: gr_sorts type ref to cl_salv_sorts.
data: gr_agg type ref to cl_salv_aggregations.
data: color type lvc_s_colo.
start-of-selection.
select * into table ispfli from spfli.
cl_salv_table=>factory( importing r_salv_table = gr_table
changing t_table = ispfli ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
gr_display = gr_table->get_display_settings( ).
gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
gr_display->set_list_header( 'This is the heading' ).
gr_columns = gr_table->get_columns( ).
gr_column ?= gr_columns->get_column( 'CITYTO' ).
gr_column->set_long_text( 'This is long text' ).
gr_column->set_medium_text( 'This is med text' ).
gr_column->set_short_text( 'This is sh' ).
gr_column ?= gr_columns->get_column( 'CITYFROM' ).
color-col = '6'.
color-int = '1'.
color-inv = '0'.
gr_column->set_color( color ).
gr_sorts = gr_table->get_sorts( ).
gr_sorts->add_sort( columnname = 'CITYTO' subtotal = abap_true ).
gr_agg = gr_table->get_aggregations( ).
gr_agg->add_aggregation( 'DISTANCE' ).
ALV Object Model – Simple 2D Table - The Basics
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2006 SAP AG 11
gr_table->display( ).
ALV Object Model – Simple 2D Table - The Basics
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2006 SAP AG 12
Filters – CL_SALV_FILTERS
Using the CL_SALV_FILTERS class we can setup some filters for the data in our ALV GRID. Create the
object reference variable and receive the object using the GET_FILTERS method of the GR_TABLE object,
and then simply called the method ADD_FILTER with the parameters.
report zalvom_demo1.
data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.
data: gr_display type ref to cl_salv_display_settings.
data: gr_columns type ref to cl_salv_columns_table.
data: gr_column type ref to cl_salv_column_table.
data: gr_sorts type ref to cl_salv_sorts.
data: gr_agg type ref to cl_salv_aggregations.
data: gr_filter type ref to cl_salv_filters.
data: color type lvc_s_colo.
start-of-selection.
select * into table ispfli from spfli.
cl_salv_table=>factory( importing r_salv_table = gr_table
changing t_table = ispfli ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
gr_display = gr_table->get_display_settings( ).
gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
gr_display->set_list_header( 'This is the heading' ).
gr_columns = gr_table->get_columns( ).
gr_column ?= gr_columns->get_column( 'CITYTO' ).
gr_column->set_long_text( 'This is long text' ).
gr_column->set_medium_text( 'This is med text' ).
gr_column->set_short_text( 'This is sh' ).
gr_column ?= gr_columns->get_column( 'CITYFROM' ).
color-col = '6'.
color-int = '1'.
color-inv = '0'.
gr_column->set_color( color ).
gr_sorts = gr_table->get_sorts( ).
gr_sorts->add_sort( columnname = 'CITYTO' subtotal = abap_true ).
gr_agg = gr_table->get_aggregations( ).
gr_agg->add_aggregation( 'DISTANCE' ).
ALV Object Model – Simple 2D Table - The Basics
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2006 SAP AG 13
gr_filter = gr_table->get_filters( ).
gr_filter->add_filter( columnname = 'CARRID' low = 'LH' ).
gr_table->display( ).
ALV Object Model – Simple 2D Table - The Basics
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2006 SAP AG 14
Layouts – CL_SALV_LAYOUT
If you want to allow the user to manage layouts of the ALV grid, you must use the class CL_SALV_LAYOUT.
Create the object reference variable and receive the object using the GET_LAYOUT method of the
GR_TABLE object. Then simply call the method SET_KEY with the parameters and set the save restriction
using the SET_SAVE_RESTRICTION method.
report zalvom_demo1.
data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.
data: gr_display type ref to cl_salv_display_settings.
data: gr_columns type ref to cl_salv_columns_table.
data: gr_column type ref to cl_salv_column_table.
data: gr_sorts type ref to cl_salv_sorts.
data: gr_agg type ref to cl_salv_aggregations.
data: gr_filter type ref to cl_salv_filters.
data: gr_layout type ref to cl_salv_layout.
data: color type lvc_s_colo.
data: key type salv_s_layout_key.
start-of-selection.
select * into table ispfli from spfli.
cl_salv_table=>factory( importing r_salv_table = gr_table
changing t_table = ispfli ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
gr_display = gr_table->get_display_settings( ).
gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
gr_display->set_list_header( 'This is the heading' ).
gr_columns = gr_table->get_columns( ).
gr_column ?= gr_columns->get_column( 'CITYTO' ).
gr_column->set_long_text( 'This is long text' ).
gr_column->set_medium_text( 'This is med text' ).
gr_column->set_short_text( 'This is sh' ).
gr_column ?= gr_columns->get_column( 'CITYFROM' ).
color-col = '6'.
color-int = '1'.
color-inv = '0'.
gr_column->set_color( color ).
gr_sorts = gr_table->get_sorts( ).
gr_sorts->add_sort( columnname = 'CITYTO' subtotal = abap_true ).
gr_agg = gr_table->get_aggregations( ).
ALV Object Model – Simple 2D Table - The Basics
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2006 SAP AG 15
gr_agg->add_aggregation( 'DISTANCE' ).
gr_filter = gr_table->get_filters( ).
gr_filter->add_filter( columnname = 'CARRID' low = 'LH' ).
gr_layout = gr_table->get_layout( ).
key-report = sy-repid.
gr_layout->set_key( key ).
gr_layout->set_save_restriction( cl_salv_layout=>restrict_none ).
gr_table->display( ).
Related Content
• Help - ALV Object Model
• Utilizing the New ALV Object Model
• SDN ABAP Forum
ALV Object Model – Simple 2D Table - The Basics
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2006 SAP AG 16
Disclaimer and 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.

More Related Content

What's hot

Form personalization 395117_r12_updated1212
Form personalization 395117_r12_updated1212Form personalization 395117_r12_updated1212
Form personalization 395117_r12_updated1212
flower705
 
1. img mm projeto completo mbp
1. img mm projeto completo mbp1. img mm projeto completo mbp
1. img mm projeto completo mbp
Consultor SAP MM
 
funzionilogiche.pptx
funzionilogiche.pptxfunzionilogiche.pptx
funzionilogiche.pptx
Salvatore Cianciabella
 
Kspi Execute Plan Price Calculation
Kspi Execute Plan Price CalculationKspi Execute Plan Price Calculation
Kspi Execute Plan Price Calculation
whocanbe1
 
Sap controlling doc=venu+venu
Sap controlling doc=venu+venuSap controlling doc=venu+venu
Sap controlling doc=venu+venu
uvenu
 
SAP OPEN ITEM CLEARING PROCESS USEFUL FOR END USERS
SAP OPEN ITEM CLEARING PROCESS USEFUL FOR END USERSSAP OPEN ITEM CLEARING PROCESS USEFUL FOR END USERS
SAP OPEN ITEM CLEARING PROCESS USEFUL FOR END USERS
sapprofessional71
 
18 maintain split structure kks2
18 maintain split structure kks218 maintain split structure kks2
18 maintain split structure kks2
Trinath Gujari
 
Oracle OSN
Oracle OSNOracle OSN
Oracle OSN
Sam Elrashedy
 
Actualización de datos persona jurídica
Actualización de datos persona jurídicaActualización de datos persona jurídica
Actualización de datos persona jurídica
ElContadorPublico.com
 
Business Area in SAP FI
Business Area in SAP FIBusiness Area in SAP FI
Business Area in SAP FI
Alessio Ruffini
 
Report Registration Steps with effected tables in ORACLE Applications R12
Report Registration Steps with effected tables in ORACLE Applications R12Report Registration Steps with effected tables in ORACLE Applications R12
Report Registration Steps with effected tables in ORACLE Applications R12
Nagendra Reddy B K
 
Lsmw step by- step
Lsmw step  by- stepLsmw step  by- step
Lsmw step by- step
Capgemini
 
Kss4 Execute Plan Cost Splitting
Kss4 Execute Plan Cost SplittingKss4 Execute Plan Cost Splitting
Kss4 Execute Plan Cost Splitting
whocanbe1
 
Fico troubleshooting
Fico troubleshootingFico troubleshooting
Fico troubleshooting
vinayk_35919
 

What's hot (14)

Form personalization 395117_r12_updated1212
Form personalization 395117_r12_updated1212Form personalization 395117_r12_updated1212
Form personalization 395117_r12_updated1212
 
1. img mm projeto completo mbp
1. img mm projeto completo mbp1. img mm projeto completo mbp
1. img mm projeto completo mbp
 
funzionilogiche.pptx
funzionilogiche.pptxfunzionilogiche.pptx
funzionilogiche.pptx
 
Kspi Execute Plan Price Calculation
Kspi Execute Plan Price CalculationKspi Execute Plan Price Calculation
Kspi Execute Plan Price Calculation
 
Sap controlling doc=venu+venu
Sap controlling doc=venu+venuSap controlling doc=venu+venu
Sap controlling doc=venu+venu
 
SAP OPEN ITEM CLEARING PROCESS USEFUL FOR END USERS
SAP OPEN ITEM CLEARING PROCESS USEFUL FOR END USERSSAP OPEN ITEM CLEARING PROCESS USEFUL FOR END USERS
SAP OPEN ITEM CLEARING PROCESS USEFUL FOR END USERS
 
18 maintain split structure kks2
18 maintain split structure kks218 maintain split structure kks2
18 maintain split structure kks2
 
Oracle OSN
Oracle OSNOracle OSN
Oracle OSN
 
Actualización de datos persona jurídica
Actualización de datos persona jurídicaActualización de datos persona jurídica
Actualización de datos persona jurídica
 
Business Area in SAP FI
Business Area in SAP FIBusiness Area in SAP FI
Business Area in SAP FI
 
Report Registration Steps with effected tables in ORACLE Applications R12
Report Registration Steps with effected tables in ORACLE Applications R12Report Registration Steps with effected tables in ORACLE Applications R12
Report Registration Steps with effected tables in ORACLE Applications R12
 
Lsmw step by- step
Lsmw step  by- stepLsmw step  by- step
Lsmw step by- step
 
Kss4 Execute Plan Cost Splitting
Kss4 Execute Plan Cost SplittingKss4 Execute Plan Cost Splitting
Kss4 Execute Plan Cost Splitting
 
Fico troubleshooting
Fico troubleshootingFico troubleshooting
Fico troubleshooting
 

Similar to Alv object model simple 2 d table - the basics

Lecture15 abap on line
Lecture15 abap on lineLecture15 abap on line
Lecture15 abap on line
Milind Patil
 
Alv theory
Alv theoryAlv theory
Alv theory
Phani Kumar
 
Object oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAPObject oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAP
Noman Mohamed Hanif
 
An easy reference for alv grid control (1)
An easy reference for alv grid control (1)An easy reference for alv grid control (1)
An easy reference for alv grid control (1)
Faina Fridman
 
Integrating powl with web dynpro abap.
Integrating powl with web dynpro abap.Integrating powl with web dynpro abap.
Integrating powl with web dynpro abap.
Adesh Chauhan
 
Integrating powl with web dynpro abap.
Integrating powl with web dynpro abap.Integrating powl with web dynpro abap.
Integrating powl with web dynpro abap.
Adesh Chauhan
 
Scilab as a calculator
Scilab as a calculatorScilab as a calculator
Scilab as a calculator
Scilab
 
Jsf intro
Jsf introJsf intro
Jsf intro
vantinhkhuc
 
Abap 7.40
Abap 7.40Abap 7.40
OLAP Reporting In CR v2
OLAP Reporting In CR v2OLAP Reporting In CR v2
OLAP Reporting In CR v2
Mickey Wong
 
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...
Oleksandr Tarasenko
 
React table tutorial use filter (part 2)
React table tutorial use filter (part 2)React table tutorial use filter (part 2)
React table tutorial use filter (part 2)
Katy Slemon
 
Alv for web
Alv for webAlv for web
Alv for web
Kranthi Kumar
 
Applicative Functor - Part 3
Applicative Functor - Part 3Applicative Functor - Part 3
Applicative Functor - Part 3
Philip Schwarz
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
Learning & using new technology
Learning & using new technologyLearning & using new technology
Learning & using new technology
Michelle Crapo
 
Learning & using new technology
Learning & using new technologyLearning & using new technology
Learning & using new technology
Michelle Crapo
 
abap list viewer (alv)
abap list viewer (alv)abap list viewer (alv)
abap list viewer (alv)
Kranthi Kumar
 
Abap Questions
Abap QuestionsAbap Questions
Abap Questions
Kaustav Pyne
 
Abap
AbapAbap

Similar to Alv object model simple 2 d table - the basics (20)

Lecture15 abap on line
Lecture15 abap on lineLecture15 abap on line
Lecture15 abap on line
 
Alv theory
Alv theoryAlv theory
Alv theory
 
Object oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAPObject oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAP
 
An easy reference for alv grid control (1)
An easy reference for alv grid control (1)An easy reference for alv grid control (1)
An easy reference for alv grid control (1)
 
Integrating powl with web dynpro abap.
Integrating powl with web dynpro abap.Integrating powl with web dynpro abap.
Integrating powl with web dynpro abap.
 
Integrating powl with web dynpro abap.
Integrating powl with web dynpro abap.Integrating powl with web dynpro abap.
Integrating powl with web dynpro abap.
 
Scilab as a calculator
Scilab as a calculatorScilab as a calculator
Scilab as a calculator
 
Jsf intro
Jsf introJsf intro
Jsf intro
 
Abap 7.40
Abap 7.40Abap 7.40
Abap 7.40
 
OLAP Reporting In CR v2
OLAP Reporting In CR v2OLAP Reporting In CR v2
OLAP Reporting In CR v2
 
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...
 
React table tutorial use filter (part 2)
React table tutorial use filter (part 2)React table tutorial use filter (part 2)
React table tutorial use filter (part 2)
 
Alv for web
Alv for webAlv for web
Alv for web
 
Applicative Functor - Part 3
Applicative Functor - Part 3Applicative Functor - Part 3
Applicative Functor - Part 3
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
 
Learning & using new technology
Learning & using new technologyLearning & using new technology
Learning & using new technology
 
Learning & using new technology
Learning & using new technologyLearning & using new technology
Learning & using new technology
 
abap list viewer (alv)
abap list viewer (alv)abap list viewer (alv)
abap list viewer (alv)
 
Abap Questions
Abap QuestionsAbap Questions
Abap Questions
 
Abap
AbapAbap
Abap
 

More from Faina Fridman

294151805 end-to-end-o data-service-sapui5-application
294151805 end-to-end-o data-service-sapui5-application294151805 end-to-end-o data-service-sapui5-application
294151805 end-to-end-o data-service-sapui5-application
Faina Fridman
 
377776000 call-badi-from-report
377776000 call-badi-from-report377776000 call-badi-from-report
377776000 call-badi-from-report
Faina Fridman
 
Acro6 js guide
Acro6 js guideAcro6 js guide
Acro6 js guide
Faina Fridman
 
Bcsrvcommsx
BcsrvcommsxBcsrvcommsx
Bcsrvcommsx
Faina Fridman
 
Alv report-tutorial-www.sapexpert.co .uk-
Alv report-tutorial-www.sapexpert.co .uk-Alv report-tutorial-www.sapexpert.co .uk-
Alv report-tutorial-www.sapexpert.co .uk-
Faina Fridman
 
Bcsrvalv
BcsrvalvBcsrvalv
Bcsrvalv
Faina Fridman
 
Abap objects in action
Abap objects in actionAbap objects in action
Abap objects in action
Faina Fridman
 
Javascript beginner-handbook
Javascript beginner-handbookJavascript beginner-handbook
Javascript beginner-handbook
Faina Fridman
 
230394452 extending-extending-srm-web-dynpro-view srm-web-dynpro-view
230394452 extending-extending-srm-web-dynpro-view srm-web-dynpro-view230394452 extending-extending-srm-web-dynpro-view srm-web-dynpro-view
230394452 extending-extending-srm-web-dynpro-view srm-web-dynpro-view
Faina Fridman
 
R3 tosrm attach
R3 tosrm attachR3 tosrm attach
R3 tosrm attach
Faina Fridman
 

More from Faina Fridman (10)

294151805 end-to-end-o data-service-sapui5-application
294151805 end-to-end-o data-service-sapui5-application294151805 end-to-end-o data-service-sapui5-application
294151805 end-to-end-o data-service-sapui5-application
 
377776000 call-badi-from-report
377776000 call-badi-from-report377776000 call-badi-from-report
377776000 call-badi-from-report
 
Acro6 js guide
Acro6 js guideAcro6 js guide
Acro6 js guide
 
Bcsrvcommsx
BcsrvcommsxBcsrvcommsx
Bcsrvcommsx
 
Alv report-tutorial-www.sapexpert.co .uk-
Alv report-tutorial-www.sapexpert.co .uk-Alv report-tutorial-www.sapexpert.co .uk-
Alv report-tutorial-www.sapexpert.co .uk-
 
Bcsrvalv
BcsrvalvBcsrvalv
Bcsrvalv
 
Abap objects in action
Abap objects in actionAbap objects in action
Abap objects in action
 
Javascript beginner-handbook
Javascript beginner-handbookJavascript beginner-handbook
Javascript beginner-handbook
 
230394452 extending-extending-srm-web-dynpro-view srm-web-dynpro-view
230394452 extending-extending-srm-web-dynpro-view srm-web-dynpro-view230394452 extending-extending-srm-web-dynpro-view srm-web-dynpro-view
230394452 extending-extending-srm-web-dynpro-view srm-web-dynpro-view
 
R3 tosrm attach
R3 tosrm attachR3 tosrm attach
R3 tosrm attach
 

Recently uploaded

Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
Gerardo Pardo-Castellote
 

Recently uploaded (20)

Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
 

Alv object model simple 2 d table - the basics

  • 1. ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 1 ALV Object Model – Simple 2D Table - The Basics Applies to: Netweaver 2004 and Netweaver 2004s Summary This tutorial is the first of the series, which deals with the ALV Object Model. In this tutorial, you will learn how to create a simple two-dimensional table report using the ALV Object Model. Author(s): Rich Heilman Company: Yorktowne Cabinetry Created on: 21 September 2006 Author Bio Rich Heilman is an ABAP/J2EE Software Engineer/Analyst for Yorktowne Cabinetry, Inc. based in Red Lion, Pennsylvania, USA. He has a total of nine years experience in the IT industry. He has spent the past five years studying ABAP and Java.
  • 2. ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 2 Table of Contents Applies to: ........................................................................................................................................ 1 Summary.......................................................................................................................................... 1 Author Bio ........................................................................................................................................ 1 Main Class – CL_SALV_TABLE...................................................................................................... 3 Functions – CL_SALV_FUNCTIONS .............................................................................................. 4 Display Settings – CL_SALV_DISPLAY_SETTINGS...................................................................... 4 Columns – CL_SALV_COLUMNS_TABLE and CL_SALV_COLUMN_TABLE.............................. 5 Sorts – CL_SALV_SORTS .............................................................................................................. 8 Aggregations – CL_SALV_AGGREGATIONS .............................................................................. 10 Filters – CL_SALV_FILTERS ........................................................................................................ 12 Layouts – CL_SALV_LAYOUT...................................................................................................... 14 Related Content............................................................................................................................. 15 Disclaimer and Liability Notice....................................................................................................... 16
  • 3. ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 3 Main Class – CL_SALV_TABLE The main class used to create the simple 2D table is the class CL_SALV_TABLE. Create a reference variable for this class. Create an internal table and fill this internal table with data as show below. REPORT ZALVOM_DEMO1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. start-of-selection. select * into table ispfli from spfli. Next we need to create the ALV object for the 2D table. The FACTORY method allows you to create the ALV object in 3 ways. You can create the ALV Grid, as a classical list display, as a full screen grid, and finally embedded into a screen container. For this example, we will be working with the full screen grid. Create the call to the FACTORY method. We are importing the object reference into GR_TABLE and passing the internal table ISPFLI. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). Next we need to display the grid, for this we use the DISPLAY method . Simply call it. gr_table->display( ).
  • 4. ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 4 Functions – CL_SALV_FUNCTIONS Next, add functions to the application toolbar. For this, use the CL_SALV_FUNCTIONS class. Create the object reference variable and receive the object using the GET_FUNCTIONS method of the GR_TABLE object. Call the method SET_ALL to force the ALV grid to show all standard functions. report zalvom_demo1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions. start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_table->display( ). The result is now you have the standard buttons on the application toolbar. Display Settings – CL_SALV_DISPLAY_SETTINGS Next, we can change some display settings using the class CL_SALV_DISPLAY_SETTINGS. Create the object reference variable and receive the object using the GET_DISPLAY_SETTINGS method of the GR_TABLE object. In this example, we are setting the “Striped Pattern” for the ALV Grid rows, and setting the heading in the title bar. report zalvom_demo1.
  • 5. ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 5 data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions. data: gr_display type ref to cl_salv_display_settings. start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). gr_display->set_list_header( 'This is the heading' ). gr_table->display( ). Columns – CL_SALV_COLUMNS_TABLE and CL_SALV_COLUMN_TABLE Next, we can change some of the attributes of a specific column in the ALV grid. In this example we will change the Heading Text of a column as well as the color of a column. Create the object reference variable and receive the object using the GET_COLUMNS method of the GR_TABLE object. This will pass you the object for all columns of the ALV grid. To access just one column, call the method GET_COLUMN from the GR_COLUMNS object. In this example, we are accessing the CITYTO column and the CITYFROM column. report zalvom_demo1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions.
  • 6. ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 6 data: gr_display type ref to cl_salv_display_settings. data: gr_columns type ref to cl_salv_columns_table. data: gr_column type ref to cl_salv_column_table. data: color type lvc_s_colo. start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). gr_display->set_list_header( 'This is the heading' ). gr_columns = gr_table->get_columns( ). gr_column ?= gr_columns->get_column( 'CITYTO' ). gr_column->set_long_text( 'This is long text' ). gr_column->set_medium_text( 'This is med text' ). gr_column->set_short_text( 'This is sh' ). gr_column ?= gr_columns->get_column( 'CITYFROM' ). color-col = '6'. color-int = '1'. color-inv = '0'. gr_column->set_color( color ). gr_table->display( ).
  • 7. ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 7
  • 8. ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 8 Sorts – CL_SALV_SORTS Next, we can add some sorting to the ALV grid. Create the object reference variable and receive the object using the GET_SORTS method of the GR_TABLE object. Next, add the sort by calling the ADD_SORT method of the GR_SORTS object. report zalvom_demo1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions. data: gr_display type ref to cl_salv_display_settings. data: gr_columns type ref to cl_salv_columns_table. data: gr_column type ref to cl_salv_column_table. data: gr_sorts type ref to cl_salv_sorts. data: color type lvc_s_colo. start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). gr_display->set_list_header( 'This is the heading' ). gr_columns = gr_table->get_columns( ). gr_column ?= gr_columns->get_column( 'CITYTO' ). gr_column->set_long_text( 'This is long text' ). gr_column->set_medium_text( 'This is med text' ). gr_column->set_short_text( 'This is sh' ). gr_column ?= gr_columns->get_column( 'CITYFROM' ). color-col = '6'. color-int = '1'. color-inv = '0'. gr_column->set_color( color ). gr_sorts = gr_table->get_sorts( ). gr_sorts->add_sort 'CITYTO' ). gr_table->display( ).
  • 9. ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 9
  • 10. ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 10 Aggregations – CL_SALV_AGGREGATIONS Since we sorted by CITYTO, we can add an aggregation to subtotal the DISTANCE by CITYTO. Create the object reference variable and receive the object using the GET_AGGREGATIONS method of the GR_TABLE object. Next, add the aggregation by calling the ADD_AGGREGATION method of the GR_SORTS object. We also need to modify the call to ADD_SORT to set the SUBTOTAL = ABAP_TRUE. report zalvom_demo1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions. data: gr_display type ref to cl_salv_display_settings. data: gr_columns type ref to cl_salv_columns_table. data: gr_column type ref to cl_salv_column_table. data: gr_sorts type ref to cl_salv_sorts. data: gr_agg type ref to cl_salv_aggregations. data: color type lvc_s_colo. start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). gr_display->set_list_header( 'This is the heading' ). gr_columns = gr_table->get_columns( ). gr_column ?= gr_columns->get_column( 'CITYTO' ). gr_column->set_long_text( 'This is long text' ). gr_column->set_medium_text( 'This is med text' ). gr_column->set_short_text( 'This is sh' ). gr_column ?= gr_columns->get_column( 'CITYFROM' ). color-col = '6'. color-int = '1'. color-inv = '0'. gr_column->set_color( color ). gr_sorts = gr_table->get_sorts( ). gr_sorts->add_sort( columnname = 'CITYTO' subtotal = abap_true ). gr_agg = gr_table->get_aggregations( ). gr_agg->add_aggregation( 'DISTANCE' ).
  • 11. ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 11 gr_table->display( ).
  • 12. ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 12 Filters – CL_SALV_FILTERS Using the CL_SALV_FILTERS class we can setup some filters for the data in our ALV GRID. Create the object reference variable and receive the object using the GET_FILTERS method of the GR_TABLE object, and then simply called the method ADD_FILTER with the parameters. report zalvom_demo1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions. data: gr_display type ref to cl_salv_display_settings. data: gr_columns type ref to cl_salv_columns_table. data: gr_column type ref to cl_salv_column_table. data: gr_sorts type ref to cl_salv_sorts. data: gr_agg type ref to cl_salv_aggregations. data: gr_filter type ref to cl_salv_filters. data: color type lvc_s_colo. start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). gr_display->set_list_header( 'This is the heading' ). gr_columns = gr_table->get_columns( ). gr_column ?= gr_columns->get_column( 'CITYTO' ). gr_column->set_long_text( 'This is long text' ). gr_column->set_medium_text( 'This is med text' ). gr_column->set_short_text( 'This is sh' ). gr_column ?= gr_columns->get_column( 'CITYFROM' ). color-col = '6'. color-int = '1'. color-inv = '0'. gr_column->set_color( color ). gr_sorts = gr_table->get_sorts( ). gr_sorts->add_sort( columnname = 'CITYTO' subtotal = abap_true ). gr_agg = gr_table->get_aggregations( ). gr_agg->add_aggregation( 'DISTANCE' ).
  • 13. ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 13 gr_filter = gr_table->get_filters( ). gr_filter->add_filter( columnname = 'CARRID' low = 'LH' ). gr_table->display( ).
  • 14. ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 14 Layouts – CL_SALV_LAYOUT If you want to allow the user to manage layouts of the ALV grid, you must use the class CL_SALV_LAYOUT. Create the object reference variable and receive the object using the GET_LAYOUT method of the GR_TABLE object. Then simply call the method SET_KEY with the parameters and set the save restriction using the SET_SAVE_RESTRICTION method. report zalvom_demo1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions. data: gr_display type ref to cl_salv_display_settings. data: gr_columns type ref to cl_salv_columns_table. data: gr_column type ref to cl_salv_column_table. data: gr_sorts type ref to cl_salv_sorts. data: gr_agg type ref to cl_salv_aggregations. data: gr_filter type ref to cl_salv_filters. data: gr_layout type ref to cl_salv_layout. data: color type lvc_s_colo. data: key type salv_s_layout_key. start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). gr_display->set_list_header( 'This is the heading' ). gr_columns = gr_table->get_columns( ). gr_column ?= gr_columns->get_column( 'CITYTO' ). gr_column->set_long_text( 'This is long text' ). gr_column->set_medium_text( 'This is med text' ). gr_column->set_short_text( 'This is sh' ). gr_column ?= gr_columns->get_column( 'CITYFROM' ). color-col = '6'. color-int = '1'. color-inv = '0'. gr_column->set_color( color ). gr_sorts = gr_table->get_sorts( ). gr_sorts->add_sort( columnname = 'CITYTO' subtotal = abap_true ). gr_agg = gr_table->get_aggregations( ).
  • 15. ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 15 gr_agg->add_aggregation( 'DISTANCE' ). gr_filter = gr_table->get_filters( ). gr_filter->add_filter( columnname = 'CARRID' low = 'LH' ). gr_layout = gr_table->get_layout( ). key-report = sy-repid. gr_layout->set_key( key ). gr_layout->set_save_restriction( cl_salv_layout=>restrict_none ). gr_table->display( ). Related Content • Help - ALV Object Model • Utilizing the New ALV Object Model • SDN ABAP Forum
  • 16. ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 16 Disclaimer and 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.