alv overview amaderforum

14
ABAP List Viewer (ALV)

Upload: zlatil

Post on 13-Apr-2015

12 views

Category:

Documents


1 download

DESCRIPTION

SAP tutorial for ALV

TRANSCRIPT

Page 1: ALV Overview Amaderforum

ABAP List Viewer(ALV)

Page 2: ALV Overview Amaderforum

In this section, we will…

• Explain the concept of ALV Reports• The Data Declaration for ALV Reports• Database Selection, Event Handling and

Form Handling in ALV reports• Different Function Modules for displaying ALV

reports

Page 3: ALV Overview Amaderforum

ALV can be performed using two ways:

1. Using Function Modules2. Using Classes and Objects – Discussion on this is out of scope of this session

Page 4: ALV Overview Amaderforum

Steps involved in creating a simple ALV report :

1. Define field catalogue internal table which is of typeslis_t_fieldcat_alv. This table contains the field attributes.

2. Define Layout structure which is of type slis_layout_alv

3. Define Events internal table which is of type slis_alv_event. This internal table contains all the possible events of ALV.

4. Populating these tables into the Function Moduleas parameters. These Function Modules are used in displaying the output data.

5. All the definitions of internal tables, structures, and constants are declared in type-pool called SLIS

Page 5: ALV Overview Amaderforum

1. Define field catalogue internal table which is of typeslis_t_fieldcat_alv

Eg :t_ls_fieldcat type slis_t_fieldcat_alv

t_ls_fieldcat-tabname = ‘t_spfli’.t_ls_fieldcat-fieldname = ‘scarr’ .t_ls_fieldcat-ref_tabname = par_reftabname.t_ls_fieldcat-ref_fieldname = par_ref_fieldname.t_ls_fieldcat-seltext_m = par_seltext.t_ls_fieldcat-input = par_input.t_ls_fieldcat-outputlen = ‘30’.t_ls_fieldcat-do_sum = ‘X’.APPEND t_ls_fieldcat.

Page 6: ALV Overview Amaderforum

Eg :par_ls_layout-zebra = ‘X’.par_ls_layout-no_colhead = ‘X’.par_ls_layout-no_hotspot = ‘X’.

2. Defining Layout structure which is of typeslis_layout_alv

Page 7: ALV Overview Amaderforum

3. Define Events internal table which is of typeslis_alv_event

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'EXPORTING

I_LIST_TYPE = 0IMPORTING

ET_EVENTS = E03_LT_EVENTS.

Page 8: ALV Overview Amaderforum

4. Important Function Modules

Reuse_alv_list_display - This is the Function Module which prints the data.Reuse_alv_fieldcatalog_merge - This Function Module is used to populate a fieldcatalog which is essential to display the data in ALV.Reuse_alv_events_get - Returns table of possible events for a list type.Reuse_alv_commentary_write - This is used in the Top-of-page event to print the headings and other comments for the list.

Page 9: ALV Overview Amaderforum

Reuse_alv_grid_display - A new function in 4.6 version, to display the results in grid rather than as a list.Reuse_alv_hierseq_list_display - To display Hierarchical Sequential display of reports

Important Function Modules

Page 10: ALV Overview Amaderforum

Calling Function REUSE_ALV_LIST_DISPLAY

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'EXPORTING

I_CALLBACK_PROGRAM = G_REPIDI_STRUCTURE_NAME = 'SFLIGHT'IS_LAYOUT = GS_LAYOUTIT_FIELDCAT = GT_FIELDCAT[ ]IT_SPECIAL_GROUPS = GT_SP_GROUP[ ]I_SAVE = G_SAVEIS_VARIANT = G_VARIANTIT_EVENTS = GT_EVENTS[ ]

* IMPORTING* E_EXIT_CAUSED_BY_CALLER =

TABLEST_OUTTAB = GT_SFLIGHT.

Page 11: ALV Overview Amaderforum

Calling Function REUSE_ALV_EVENTS_GET

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'EXPORTING

I_LIST_TYPE = 0IMPORTING

ET_EVENTS = E03_LT_EVENTS.

Page 12: ALV Overview Amaderforum

Calling Function REUSE_ALV_COMMENTARY_WRITE

refresh GT_LIST_TOP_OF_PAGE.Move ‘H’ to GT_LIST_TOP_OF_PAGE-typ.Move ‘Materials Display’ to GT_LIST_TOP_OF_PAGE-info.Append GT_LIST_TOP_OF_PAGE.

FORM TOP_OF_PAGE.CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTINGIT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.

ENDFORM.

Page 13: ALV Overview Amaderforum

Calling Function REUSE_ALV_GRID_DISPLAY

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'EXPORTING

I_CALLBACK_PROGRAM = G_REPIDI_STRUCTURE_NAME = 'SFLIGHT'IS_LAYOUT = GS_LAYOUTIT_FIELDCAT = GT_FIELDCAT[ ]IT_SPECIAL_GROUPS = GT_SP_GROUP[ ]I_SAVE = G_SAVEIS_VARIANT = G_VARIANTIT_EVENTS = GT_EVENTS[ ]

* IMPORTING* E_EXIT_CAUSED_BY_CALLER =

TABLEST_OUTTAB = GT_SFLIGHT.

Page 14: ALV Overview Amaderforum

Calling Function REUSE_ALV_HIERSEQ_LIST_DISPLAY

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'EXPORTING

I_CALLBACK_PROGRAM = G_REPIDIS_LAYOUT = GS_LAYOUTIT_FIELDCAT = GT_FIELDCAT[ ]IT_SPECIAL_GROUPS = GT_SP_GROUP[ ]I_SAVE = G_SAVE

IS_VARIANT = G_VARIANTIT_EVENTS = GT_EVENTS[ ]I_TABNAME_HEADER = G_TABNAME_HEADER

I_TABNAME_ITEM = G_TABNAME_ITEMIS_KEYINFO = GS_KEYINFO

TABLEST_OUTTAB_HEADER = GT_SCARRT_OUTTAB_ITEM = GT_SPFLI.