You are on page 1of 29

ALV Object Model

Ali Mohammed NCDOT - BSIP

Reporting using ALV GRID in 4.6C

The New Object Model ECC 6.0

Classes ABAP Objects


1.

2.

3.

4.

5. 6.

ABAP Objects provides an advanced level of encapsulation that improves maintainability and stability of programs. ABAP Objects allows you to instantiate multiple instances of a single class. ABAP Objects greatly enhances code reuse through inheritance a key feature of OO . ABAP Objects is the only way to use new ABAP technology Web Dynpro ABAP etc. Explicit Event handling . Better Interfaces . Reference article on ABAP OO - http://www.sapdb.info/wpcontent/uploads/2008/09/why-abap-objects.pdf

ABAP Class Transaction SE24

Programming with Class / Methods


In SE38 ABAP Editor

CL_SALV_TABLE

Two Dimensional data display in ALV_GRID form . Object orientation (OO), or to be more precise, object-oriented programming . No screens to define , no field catalogs to create no PBO and PAI modules , standard menu bar can be used. More functionality for application development. Extremely fast delivery to users. A way to get used to what ABAP programming is trending towards. Only Available in ECC 6.0 and above .

Main Classes in SALV - GRID

Main Class Functions Display Settings Columns

Sorts Aggregations Filters Layouts Events

CL_SALV_TABLE CL_SALV_FUNCTIONS CL_SALV_DISPLAY_SETTINGS CL_SALV_COLUMNS_TABLE and CL_SALV_COLUMN_TABLE CL_SALV_SORTS CL_SALV_AGGREGATIONS CL_SALV_FILTERS CL_SALV_LAYOUT CL_SALV_EVENTS_TABLE

CL_SALV_TABLE Main class for ALV_GRID


data: gr_table type ref to cl_salv_table. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = itab ). gr_table->display( ).

CL_SALV_FUNCTIONS - (Adds functions to toolbar)


data: gr_functions type ref to cl_salv_functions. gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ).

CL_SALV_DISPLAY_SETTINGS
data: gr_display type ref to cl_salv_display_settings. 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' ) .

Columns CL_SALV_COLUMNS_TABLE and CL_SALV_COLUMN_TABLE (make column settings old field catalog )
data: gr_columns type ref to cl_salv_columns_table. data: gr_column type ref to cl_salv_column_table. 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 ).

Columns CL_SALV_COLUMNS_TABLE CL_SALV_COLUMN_TABLE

and

CL_SALV_SORTS - ( sort data by defined column)


data: gr_sorts type ref to cl_salv_sorts. gr_sorts = gr_table->get_sorts( ). gr_sorts->add_sort( columnname = 'CITYTO' ).

CL_SALV_AGGREGATIONS ( do sum for field )


data: gr_agg type ref to cl_salv_aggregations. gr_sorts->add_sort( columnname = 'CITYTO' subtotal = abap_true). gr_agg = gr_table->get_aggregations( ). gr_agg->add_aggregation( 'DISTANCE' ).

CL_SALV_LAYOUT - ( Manage / Save layout)


data: gr_layout type ref to cl_salv_layout. 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 ).

class lcl_handle_events definition deferred. HOT SPOT EVENT data: gr_events type ref to lcl_handle_events. CLASS lcl_handle_events DEFINITION. PUBLIC SECTION. METHODS on_single_click FOR EVENT link_click OF cl_salv_events_table IMPORTING row column. ENDCLASS. "lcl_handle_events DEFINITION CLASS lcl_handle_events IMPLEMENTATION. METHOD on_single_click. PERFORM call_transaction USING row column . ENDMETHOD. "on_single_click ENDCLASS. "lcl_handle_events IMPLEMENTATION gr_column ?= gr_columns->get_column( 'EBELN' ). gr_column->set_cell_type( if_salv_c_cell_type=>hotspot ). data: lr_events type ref to cl_salv_events_table. lr_events = gr_table->get_event( ). create object gr_events. set handler gr_events->on_single_click for lr_events.

HOT SPOT EVENT

Resources

SE80 package SALV_OBJECTS ( SAP Demo Programs ) Test Programs (DEV ECC) - Z_BC_CL_SALV_TABLE1 Z_BC_CL_SALV_TABLE_FUNCTIONS Z_BC_CL_SALV_TABLE_LAYOUT https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/eac1fa0b0e01-0010-0990-8530de4908a6 - ALV Object Model The Basics https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/cda3992d -0e01-0010-90b2-c4e1f899ac01 - ALV Object Model Event Handling http://help.sap.com/saphelp_nw04/helpdata/en/5e/88d440e14f8431e10000 000a1550b0/frameset.htm - SAP Help - ALV Object Model https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/acdefb130701-0010-f1a2-8eeefa7d3780 - Utilizing the New ALV Object Model https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f6556c740e01-0010-aa99-b96b4316fed9 - FI report using the ALV OM https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5dc3e690 -0201-0010-1ebf-b85b3bed962d - SAP List Viewer The New

Programming Model in SAP NetWeaver04

Creating the Top of List ( Header ) Class CL_SALV_FORM_LAYOUT_GRID

Form layout for top_of_list


Objects for layouting

Grid layout (CL_SALV_FORM_LAYOUT_GRID)


Columns Rows Span of Rows and Columns Alignment (left justified, right justified)

Flow layout (CL_SALV_FORM_LAYOUT_FLOW)


Sequence of elements Alignment (left justified, right justified)

Nested layout of Grid and Flows possible (e.g. Grid in Grid, Flow in Grid)

Pseudo code for form layout


Create a Grid CL_SALV_FORM_LAYOUT_GRID)

Create Header Information (CL_SALV_FORM_HEADER_INFO)

Add row (CL_SALV_FORM_LAYOUT_GRID) and Create Grid in cell (2,1) (CL_SALV_FORM_LAYOUT_GRID)

Create label in cell (2,1)(CL_SALV_FORM_LABEL) and Create text in cel(2,2)(CL_SALV_FORM_TEXT)

Create a Flow layout (CL_SALV_FORM_LAYOUT_FLOW)

Create label in flow (CL_SALV_FORM_LABEL) and Create text in flow (CL_SALV_FORM_TEXT)

Create Action Information (CL_SALV_FORM_ACTION_INFO)

Set Top/End of List/Page (CL_SALV_TABLE)

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4d40e790-02010010-c695-e7ce17ff5908 - How to use ALV Form Elements for Events Test Program ( DEV ECC ) - Z_BC_CL_SALV_TABLE_LAYOUT

ALV Object Model Hierarchical Sequential List

Main Class - CL_SALV_HIERSEQ_TABLE

Hierarchical Sequential List Other Classes


Functions CL_SALV_FUNCTIONS (adds functions to toolbar) Columns CL_SALV_COLUMNS_HIERSEQ (column settings ) Levels CL_SALV_HIERSEQ_LEVEL (expand or collapse default ) Sorts CL_SALV_SORTS (sort data ) References: SE80 package SALV_OBJECTS ( SAP Demo Programs ) https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b0f03986 -046c-2910-a5aa-e5364e96ea2c - ALV Object Model Hierarchical Sequential List

ALV Object Model ALV Tree

Main Class CL_SALV_TREE

ALV Object Model ALV Tree

Reference Programs SE80 package SALV_OBJECTS ( SAP Demo Programs ) Test Program (DEV ECC) -> Z_BC_CL_SALV_TREE

You might also like