Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Reg ALV

Former Member
0 Likes
2,239

Hi Friends,

Can any one plz post some simple examples regarding ALV EVENTS.

Regards,

Lakshmi

Hi Friends,

Can any one plz post some simple examples regarding ALV EVENTS.

Regards,

Lakshmi

8 REPLIES 8
Read only

Former Member
0 Likes
1,385

ALV EVENTS:

ABAP List Viewer (ALV):

The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).

This helps us to implement all the features mentioned very effectively.

Using ALV, We can have three types of reports:

1. Simple Report

2. Block Report

3. Hierarchical Sequential Report

There are some function modules which will enable to produce the above reports without much effort.

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

1. SIMPLE REPORT.

The important function modules are:

A. Reuse_alv_list_display

B. Reuse_alv_fieldcatalog_merge

C. Reuse_alv_events_get

D. Reuse_alv_commentary_write

E. Reuse_alv_grid_display

A. REUSE_ALV_LIST_DISPLAY

This is the function module which prints the data.

The important parameters are :

I. Export :

i. I_callback_program : report id

ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status

iii. I_callback_user_command : routine where the function codes are handled

iv. I_structure name : name of the dictionary table

v. Is_layout : structure to set the layout of the report

vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE

vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.

II. Tables :

i. t_outtab : internal table with the data to be output

B. REUSE_ALV_FIELDCATALOG_MERGE:

This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.

The important Parameters are:

I. Export:

i. I_program_name : report id

ii. I_internal_tabname : the internal output table

iii. I_inclname : include or the report name where all the dynamic forms are handled.

II Changing

ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is

declared in the type pool SLIS.

C. REUSE_ALV_EVENTS_GET:

Returns table of possible events for a list type

Parameters :

I. Import:

Et_Events: The event table is returned with all possible CALLBACK events

for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.

II. Export:

I_List_type:

0 = simple list REUSE_ALV_LIST_DISPLAY

1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY

2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND

3 = hierarchical-sequential block list

REUSE_ALV_BLOCK_LIST_HS_APPEND

D. REUSE_ALV_COMMENTARY_WRITE:

This is used in the Top-of-page event to print the headings and other comments for the list.

Parameters :

I. it_list_commentary : internal table with the headings of the type slis_t_listheader.

This internal table has three fields :

Typ : ‘H’ – header, ‘S’ – selection , ‘A’ - action

Key : only when typ is ‘S’.

Info : the text to be printed

E. REUSE_ALV_GRID_DISPLAY:

A new function in 4.6 version, to display the results in grid rather than as a preview.

Parameters : same as reuse_alv_list_display

This is an example for simple list.

2. BLOCK REPORT

This is used to have multiple lists continuously.

The important functions used in this report are:

A. REUSE_ALV_BLOCK_LIST_INIT

B. REUSE_ALV_BLOCK_LIST_APPEND

C. REUSE_ALV_BLOCK_LIST_HS_APPEND

D. REUSE_ALV_BLOCK_LIST_DISPLAY

A. REUSE_ALV_BLOCK_LIST_INIT

This function module is used to set the default gui status etc.

Parameters:

I. I_CALLBACK_PROGRAM

II. I_CALLBACK_PF_STATUS_SET

III. I_CALLBACK_USER_COMMAND

B. REUSE_ALV_BLOCK_LIST_APPEND

This function module adds the data to the block.

Repeat this function for all the different blocks to be displayed one after the other.

Parameters :

Export :

I. is_layout : layout settings for block

II. it_fieldcat : field catalog

III. i_tabname : internal table name with output data

IV. it_events : internal table with all possible events

Tables :

i. t_outtab : internal table with output data.

C. REUSE_ALV_BLOCK_LIST_HS_APPEND

This function module is used for hierarchical sequential blocks.

D. REUSE_ALV_BLOCK_LIST_DISPLAY

This function module display the list with data appended by the above function.

Parameters : All the parameters are optional.

Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.

3. Hierarchical Reports:

Hierarchical sequential list output.

The function module is

A. REUSE_ALV_HIERSEQ_LIST_DISPLAY

Parameters:

I. Export:

i. I_CALLBACK_PROGRAM

ii. I_CALLBACK_PF_STATUS_SET

iii. I_CALLBACK_USER_COMMAND

iv. IS_LAYOUT

v. IT_FIELDCAT

vi. IT_EVENTS

vii. i_tabname_header : Name of the internal table in the program containing the

output data of the highest hierarchy level.

viii. i_tabname_item : Name of the internal table in the program containing the

output data of the lowest hierarchy level.

ix. is_keyinfo : This structure contains the header and item table field

names which link the two tables (shared key).

II. Tables

i. t_outtab_header : Header table with data to be output

ii. t_outtab_item : Name of the internal table in the program containing the

output data of the lowest hierarchy level.

slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using ‘REUSE_ALV_FIELDCATALOG_MERGE’.

Important Attributes :

A. col_pos : position of the column

B. fieldname : internal fieldname

C. tabname : internal table name

D. ref_fieldname : fieldname (dictionary)

E. ref_tabname : table (dictionary)

F. key(1) : column with key-color

G. icon(1) : icon

H. symbol(1) : symbol

I. checkbox(1) : checkbox

J. just(1) : (R)ight (L)eft (C)ent.

K. do_sum(1) : sum up

L. no_out(1) : (O)blig.(X)no out

M. outputlen : output length

N. seltext_l : long key word

O. seltext_m : middle key word

P. seltext_s : short key word

Q. reptext_ddic : heading (ddic)

R. ddictxt(1) : (S)hort (M)iddle (L)ong

S. datatype : datatype

T. hotspot(1) : hotspot

Reward points if useful

Read only

0 Likes
1,385

Hi Lakshmi ,

Need your help in printing of a report.

I have to display a alv report in a format like suppose a user selects march month and year 2008

then the report should give an output in the form like

1 2 3 4.................... 31

1st half p p a p.....................

2nd half p a p p ..................... by this what i mean is, this report will show the status of the an employee. for the complete month his 1st half and 2nd half presence in the office. now the problem that im facing is like for each time like for the date 1 we have to fill the two entries ie for the firat half and for the 2nd half attandence. So is there any way by which i can have the field catalog like in the 1st row complete dates of the whole month is stored and then we even have the heading as 1st half and 2nd half.

please help me out. in case you are not able to understand my problem do let me know.

Read only

Former Member
0 Likes
1,385

REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.

Parameters :

I. it_list_commentary : internal table with the headings of the type slis_t_listheader.

This internal table has three fields :

Typ : ‘H’ – header, ‘S’ – selection , ‘A’ - action

Key : only when typ is ‘S’.

Info : the text to be printed

REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.

The important parameters are :

I. Export :

i. I_callback_program : report id

ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status

iii. I_callback_user_command : routine where the function codes are handled

iv. I_structure name : name of the dictionary table

v. Is_layout : structure to set the layout of the report

vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE

vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.

II. Tables :

i. t_outtab : internal table with the data to be output

REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.

Parameters : same as reuse_alv_list_display

REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.

The Important Parameters are :

I. Export :

i. I_program_name : report id

ii. I_internal_tabname : the internal output table

iii. I_inclname : include or the report name where all the dynamic forms are handled.

II Changing

ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is

declared in the type pool SLIS.

REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type

Parameters :

I. Import :

Et_Events : The event table is returned with all possible CALLBACK events

for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.

II. Export :

I_List_type :

0 = simple list REUSE_ALV_LIST_DISPLAY

1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY

2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND

3 = hierarchical-sequential block list

REUSE_ALV_BLOCK_LIST_HS_APPEND

REUSE_ALV_HIERSEQ_LIST_DISPLAY

Parameters:

I. Export:

i. I_CALLBACK_PROGRAM

ii. I_CALLBACK_PF_STATUS_SET

iii. I_CALLBACK_USER_COMMAND

iv. IS_LAYOUT

v. IT_FIELDCAT

vi. IT_EVENTS

vii. i_tabname_header : Name of the internal table in the program containing the

output data of the highest hierarchy level.

viii. i_tabname_item : Name of the internal table in the program containing the

output data of the lowest hierarchy level.

ix. is_keyinfo : This structure contains the header and item table field

names which link the two tables (shared key).

II. Tables

i. t_outtab_header : Header table with data to be output

ii. t_outtab_item : Name of the internal table in the program containing the

output data of the lowest hierarchy level.

slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using ‘REUSE_ALV_FIELDCATALOG_MERGE’.

Important Attributes :

A. col_pos : position of the column

B. fieldname : internal fieldname

C. tabname : internal table name

D. ref_fieldname : fieldname (dictionary)

E. ref_tabname : table (dictionary)

F. key(1) : column with key-color

G. icon(1) : icon

H. symbol(1) : symbol

I. checkbox(1) : checkbox

J. just(1) : (R)ight (L)eft (C)ent.

K. do_sum(1) : sum up

L. no_out(1) : (O)blig.(X)no out

M. outputlen : output length

N. seltext_l : long key word

O. seltext_m : middle key word

P. seltext_s : short key word

Q. reptext_ddic : heading (ddic)

R. ddictxt(1) : (S)hort (M)iddle (L)ong

S. datatype : datatype

T. hotspot(1) : hotspot

REUSE_ALV_COMMENTARY_WRITE List body comment block output

REUSE_ALV_EVENTS_GET Returns table of possible events for a list type

REUSE_ALV_EVENT_NAMES_GET Returns table of constant names of possible events for a list type

REUSE_ALV_FIELDCATALOG_MERGE Create field catalog from dictionary structure or internal table

REUSE_ALV_HIERSEQ_LIST_DISPLAY Hierarchical sequential list output

REUSE_ALV_LIST_DISPLAY Output a simple list (single line or several lines)

REUSE_ALV_GRID_DISPLAY Output a simple list (single line or several lines)

REUSE_ALV_LIST_LAYOUT_INFO_GET Read current ALV list information

REUSE_ALV_LIST_LAYOUT_INFO_SET Set current ALV list information

REUSE_ALV_POPUP_TO_SELECT List in dialog box to choose one or more entries (or display only)

We can use ABAP ALV LIST and GRID function modules to display Normal LIST and Hiearchical LISTS .

All the definitions TYPES and STRUCTURES and CONSTANTS are defined

in the TYPE-POOL 'SLIS' ,so it should be declared first.

TYPE-POOLS : 'SLIS' .

To display ALV LISTS the function module used are :

REUSE_ALV_LIST_DISPLAY "For Normal LIST

REUSE_ALV_HIERARCHICAL_LIST_DISPLAY "For Hierarchical LIST

To display ALV GRID the function module used are :

REUSE_ALV_GRID_DISPLAY . "For GRID display

The most important component of the ALV is the FIELDCATALOG which is of

TYPE SLIS_T_FIEDLCAT_ALV

or of

TYPE STANDARD TABLE OF SLIS_FIELDCAT_ALV .

The line items of the field catalog are of

TYPE SLIS_FIELDCAT_ALV .

FIELDCATALOG

To prepare field catalog certain fields are essential .There are various other fields allowing for vaarious possibilities and display options.

TABNAME

FIELDNAME

REF_TABNAME

SELTECT_M

e.g.

DATA: WS_FCAT TYPE SLIS_FIELDCAT_ALV . "LINE ITEM OF FCAT

DATA: IN_FCAT TYPE SLIS_T_FIELDCAT_ALV.

WS_FCAT-TABNAME = 'MARA'.

WS_FCAT-FIELDNAME = 'MATNR'.

WS_FCAT-SELTEXT_M = 'Material Number'.

APPEND WS_FCAT TO IN_FCAT .

CLEAR WS_FCAT.

WS_FCAT-TABNAME = 'MAKT'.

WS_FCAT-FIELDNAME = 'MAKTX'.

WS_FCAT-SELTEXT_M = 'Material Description'.

APPEND WS_FCAT TO IN_FCAT .

This will create fieldcatalog with two columns for displaying material and material description .

RESUSE_ALV_LIST_DISPLAY.

The following FM is used to display the data in the internal table in the form of ALV

LIST. The Event table is only required if event handling is being done.

CALL FUNCTION 'RESUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = W_REPID "of TYPE SY-REPID and

" value SY-REPID

IS_LAYOUT = W_LAYOUT "of TYPE SLIS_LAYOUT_ALV

IT_FIELDCAT = IN_FCAT "of TYPE SLIS_T_FIELDCAT_ALV

I_SAVE = W_SAVE "of TYPE C ,values A ,U ,' '

IT_EVENTS = IN_EVENTS " of TYPE SLIS_T_EVENT

TABLES

T_OUTTAB = IN_DATA "internal table conatining data

"corresponding to IN_FCAT

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

IF SY-SUBRC NE 0.

MESSAGE ENNN .

ENDIF.

REUSE_ALV_EVENTS_GET.

This FM is used to get the default event table of the ALV LIST DISPLAY.

The IN_EVENTS internal table is of TYPE SLIS_T_EVENT. This table contains

all the events wrapped up in the ALV LIST or ALV GRID and consistsof two fields

NAME and FORM .The NAME corresponds to names of the events like TOP_OF_PAGE and END_OF_PAGE ,USER_COMMAND and FORM will contain the name of the FORM ROUTINE that will be called dynamically through callback mechanism when the particular event will fire and is initial for all events bt default and has to be filled for

events for which handling is required.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = IN_EVENTS[].

e.g.

DATA: W_EVENT TYPE SLSI_ALV_EVENT "LINE ITEM OF EVENT TABLE

DATA: IN_EVENTS TYPE SLSI_T_EVENT . "Internal table containing events

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = IN_EVENTS[].

RTEAD TABLE IN_EVENTS WITH KEY NAME = 'TOP_OG_PAGE'

INTO W_EVENT.

IF SY-SUBRC EQ 0.

MOVE 'F3000_TOP_OF_PAGE' TO W_EVENT -FORM.

MODIFY IN_EVENTS FROM W_EVENT INDEX SY-TABIX.

ENDIF.

Here the FORM ROUTINE 'F3000_TOP_OF_PAGE' is being set up for the

event TOP_OF_PAGE which will fire when the ALV LIST will be displayed ,This form

will be called dynamically by th ALV LIST display during top_of_page event and for this the modified Events internal table has to be passed to the FM 'REUSE_ALV_LIST_DISPLAY' in the exporting parameter IT_EVENTS. Failing this the form '3000_TOP_OF_PAGE' will not be called . This event is used for placing heading information like Current date and time and the name of the report.

Regards,

Read only

Former Member
0 Likes
1,385

HI

TYPE-POOLS : slis.

TYPES : BEGIN OF st_ekko,

ebeln TYPE ekko-ebeln, "Purchasing Document Number

bstyp TYPE ekko-bstyp, "Purchasing Document Category

bsart TYPE ekko-bsart, "Purchasing Document Type

aedat TYPE ekko-aedat, "record created on

ernam TYPE ekko-ernam, "Person who Created the Object

check(1),

END OF st_ekko.

TYPES : BEGIN OF st_ekpo,

ebeln TYPE ekko-ebeln,

ebelp TYPE ekpo-ebelp, "Item Number of Purchasing Document

ematn TYPE ekpo-ematn, "Material number

matkl TYPE ekpo-matkl, "Material group

netpr TYPE ekpo-netpr, "Net price in purchasing document

END OF st_ekpo.

TYPES : BEGIN OF st_ebeln,

ebeln TYPE ekpo-ebeln,

END OF st_ebeln.

TYPES : BEGIN OF st_eine,

ebeln TYPE ekko-ebeln,

ekorg TYPE eine-ekorg,

ekgrp TYPE eine-ekgrp,

END OF st_eine.

TYPES : BEGIN OF st_check,

check(1),

END OF st_check.

DATA : it_ekpo TYPE STANDARD TABLE OF st_ekpo,

it_ekko TYPE STANDARD TABLE OF st_ekko,

wa_ekko LIKE LINE OF it_ekko,

it_fieldcat TYPE slis_t_fieldcat_alv,

wa_fieldcat LIKE LINE OF it_fieldcat,

wa_layout TYPE slis_layout_alv,

it_events TYPE slis_t_event,

st_event LIKE LINE OF it_events,

it_listheadr TYPE slis_t_listheader ,

wa_listheadr LIKE LINE OF it_listheadr,

st_printparams TYPE slis_print_alv,

it_sortinfo TYPE slis_t_sortinfo_alv,

wa_sortinfo LIKE LINE OF it_sortinfo,

it_ekposortinfo TYPE slis_t_sortinfo_alv,

wa_ekposortinfo LIKE LINE OF it_ekposortinfo,

it_filter TYPE slis_t_filter_alv,

it_ebeln TYPE STANDARD TABLE OF st_ebeln,

it_eine TYPE STANDARD TABLE OF st_eine,

wa_eine TYPE st_eine,

it_popup TYPE STANDARD TABLE OF st_eine,

wa_popup TYPE st_eine,

it_check TYPE STANDARD TABLE OF st_check,

wa_check TYPE st_check.

DATA : v_ebeln TYPE ekko-ebeln.

----


  • SELECTION-SCREEN

----


SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE tit.

SELECT-OPTIONS: so_ebeln FOR v_ebeln OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b.

----


  • INITIALIZATION

----


INITIALIZATION.

tit = text-000.

----


  • AT SELECTION-SCREEN ON

----


AT SELECTION-SCREEN ON so_ebeln.

PERFORM validate_ebeln.

----


  • START-OF-SELECTION

----


START-OF-SELECTION.

PERFORM get_ekko_data.

PERFORM get_eine_data.

----


  • END-OF-SELECTION

----


END-OF-SELECTION.

PERFORM populate_fieldcat1.

PERFORM populate_layout.

PERFORM get_eventlist.

PERFORM get_ekkosortinfo.

PERFORM ekkodisplay_onalv.

&----


*& Form POPULATE_FIELDCAT1

&----


FORM populate_fieldcat1.

wa_fieldcat-fieldname = 'EBELN'.

wa_fieldcat-seltext_l = text-004.

wa_fieldcat-no_zero = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'BSTYP'.

wa_fieldcat-seltext_l = text-005.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'BSART'.

wa_fieldcat-seltext_l = text-006.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'AEDAT'.

wa_fieldcat-seltext_l = text-007.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'ERNAM'.

wa_fieldcat-seltext_l = text-008.

APPEND wa_fieldcat TO it_fieldcat.

ENDFORM. "POPULATE_FIELDCAT1

&----


*& Form populate_fieldcat2

&----


FORM populate_fieldcat2 .

CLEAR wa_fieldcat.

CLEAR it_fieldcat.

REFRESH it_fieldcat.

wa_fieldcat-fieldname = 'EBELN'.

wa_fieldcat-seltext_l = text-004.

wa_fieldcat-hotspot = 'X'.

  • wa_fieldcat-no_zero = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'EBELP'.

wa_fieldcat-seltext_l = text-009.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'EMATN'.

wa_fieldcat-seltext_l = text-010.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'MATKL'.

wa_fieldcat-seltext_l = text-011.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'NETPR'.

wa_fieldcat-seltext_l = text-012.

wa_fieldcat-datatype = 'CURR'. "Obligatory to perform SUM

wa_fieldcat-do_sum = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

ENDFORM. "populate_fieldcat2

&----


*& Form GET_EVENTLIST

&----


FORM get_eventlist.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = it_events[]

EXCEPTIONS

list_type_wrong = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

READ TABLE it_events WITH KEY name = slis_ev_pf_status_set INTO st_event.

IF sy-subrc EQ 0.

st_event-form = 'SET_PF_STATUS1'.

APPEND st_event TO it_events.

CLEAR st_event.

ENDIF.

READ TABLE it_events WITH KEY name = slis_ev_end_of_page INTO st_event.

IF sy-subrc EQ 0.

st_event-form = 'END_OF_PAGE'.

APPEND st_event TO it_events.

CLEAR st_event.

ENDIF.

ENDFORM. "GET_EVENTLIST

&----


*& Form ekpodisplay_onalv

&----


FORM ekpodisplay_onalv .

IF it_ekpo[] IS INITIAL.

MESSAGE 'NO DATA FOUND' TYPE 'I'.

ELSE.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_callback_pf_status_set = 'SET_PF_STATUS'

i_callback_user_command = 'AT_USER_COMMAND1'

i_callback_top_of_page = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME = I_STRUCTURE_NAME

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE = I_GRID_TITLE

  • I_GRID_SETTINGS = I_GRID_SETTINGS

is_layout = wa_layout

it_fieldcat = it_fieldcat

  • IT_EXCLUDING = IT_EXCLUDING

  • IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS

it_sort = it_ekposortinfo[]

  • IT_FILTER = IT_FILTER

  • IS_SEL_HIDE = IS_SEL_HIDE

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT = IS_VARIANT

  • it_events = it_events

  • IT_EVENT_EXIT = IT_EVENT_EXIT

  • IS_PRINT = IS_PRINT

  • IS_REPREP_ID = IS_REPREP_ID

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS = IT_ALV_GRAPHICS

  • IT_HYPERLINK = IT_HYPERLINK

  • IT_ADD_FIELDCAT = IT_ADD_FIELDCAT

  • IT_EXCEPT_QINFO = IT_EXCEPT_QINFO

  • IR_SALV_FULLSCREEN_ADAPTER = IR_SALV_FULLSCREEN_ADAPTER

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER

  • ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER

TABLES

t_outtab = it_ekpo

EXCEPTIONS

program_error = 1

OTHERS = 2 .

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDIF.

ENDFORM. "ekpodisplay_onalv

&----


*& Form SET_PF_STATUS1

&----


FORM set_pf_status1 USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'MENU' excluding rt_extab. "Copy from SALV .

ENDFORM. "SET_PF_STATUS1

&----


*& Form SET_PF_STATUS

&----


FORM set_pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'STANDARD' excluding rt_extab. "Copy from SALV .

ENDFORM. "SET_PF_STATUS

&----


*& Form AT_user_command

&----


FORM at_user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN '&IC1'.

IF rs_selfield-fieldname EQ 'EBELN'.

READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.

SELECT ebeln ebelp ematn matkl netpr

FROM ekpo

INTO TABLE it_ekpo

WHERE ebeln EQ wa_ekko-ebeln.

PERFORM populate_fieldcat2.

PERFORM populate_layout2.

PERFORM get_ekposortinfo.

PERFORM ekpodisplay_onalv.

ELSE.

MESSAGE i020(z50871msg) WITH text-013.

ENDIF.

WHEN 'SE16'.

CALL TRANSACTION 'SE16'.

WHEN 'SE37'.

CALL TRANSACTION 'SE37'.

WHEN 'DISP'.

PERFORM get_popupdata.

PERFORM get_popupfcat.

PERFORM display_popup.

ENDCASE.

ENDFORM. "AT_user_command

&----


*& Form TOP_OF_PAGE

&----


FORM top_of_page.

REFRESH it_listheadr.

wa_listheadr-typ = 'H'.

wa_listheadr-info = text-001.

APPEND wa_listheadr TO it_listheadr.

CLEAR wa_listheadr.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_listheadr[]

i_logo = 'ENJOYSAP_LOGO'. "From OAER transaction

ENDFORM. "TOP_OF_PAGE

&----


*& Form build_print_params

&----


FORM build_print_params.

st_printparams-reserve_lines = '3'. "Lines reserved for footer

st_printparams-no_coverpage = 'X'.

ENDFORM. "build_print_params

&----


*& Form end_of_page

&----


FORM end_of_page.

REFRESH it_listheadr.

wa_listheadr-typ = 'H'.

wa_listheadr-info = sy-pagno.

APPEND wa_listheadr TO it_listheadr.

CLEAR wa_listheadr.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_listheadr[].

ENDFORM. "end_of_page

&----


*& Form GET_EKPOSORTINFO

&----


FORM get_ekposortinfo.

wa_ekposortinfo-up = 'X'.

wa_ekposortinfo-spos = 1.

wa_ekposortinfo-fieldname = 'EBELP'.

wa_ekposortinfo-tabname = 'EKPO'.

APPEND wa_ekposortinfo TO it_ekposortinfo.

CLEAR wa_ekposortinfo.

wa_ekposortinfo-up = 'X'.

wa_ekposortinfo-spos = 2.

wa_ekposortinfo-fieldname = 'EMATN'.

wa_ekposortinfo-tabname = 'EKPO'.

APPEND wa_ekposortinfo TO it_ekposortinfo.

CLEAR wa_ekposortinfo.

ENDFORM. "GET_EKPOSORTINFO

*

&----


*& Form POPULATE_LAYOUT

&----


FORM populate_layout.

wa_layout-colwidth_optimize = 'X'. "column width

wa_layout-zebra = 'X'.

  • wa_layout-no_hline = 'X'.

  • wa_layout-no_vline = 'X'.

  • wa_layout-cell_merge = 'X'.

wa_layout-box_fieldname = 'CHECK'.

wa_layout-box_tabname = 'IT_EKKO'.

wa_layout-window_titlebar = 'PURCHASE ORDER HEADER DETAILS'.

ENDFORM. "POPULATE_LAYOUT

&----


*& Form get_EKKOsortinfo

&----


FORM get_ekkosortinfo.

wa_sortinfo-up = 'X'.

wa_sortinfo-spos = 1.

wa_sortinfo-fieldname = 'EBELN'.

wa_sortinfo-tabname = 'EKKO'.

APPEND wa_sortinfo TO it_sortinfo.

CLEAR wa_sortinfo.

wa_sortinfo-up = 'X'.

wa_sortinfo-spos = 2.

wa_sortinfo-fieldname = 'BSTYP'.

wa_sortinfo-tabname = 'EKKO'.

APPEND wa_sortinfo TO it_sortinfo.

CLEAR wa_sortinfo.

wa_sortinfo-up = 'X'.

wa_sortinfo-spos = 3.

wa_sortinfo-fieldname = 'AEDAT'.

wa_sortinfo-tabname = 'EKKO'.

APPEND wa_sortinfo TO it_sortinfo.

CLEAR wa_sortinfo.

ENDFORM. "get_EKKOsortinfo

&----


*& Form EKKODISPLAY_ONALV

&----


FORM ekkodisplay_onalv.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_callback_pf_status_set = 'SET_PF_STATUS1'

i_callback_user_command = 'AT_USER_COMMAND'

is_layout = wa_layout

it_fieldcat = it_fieldcat

it_sort = it_sortinfo[]

it_filter = it_filter

it_events = it_events[]

TABLES

t_outtab = it_ekko[]

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDFORM. "EKKODISPLAY_ONALV

&----


*& Form validate_ebeln

&----


FORM validate_ebeln.

SELECT ebeln

FROM ekpo

INTO TABLE it_ebeln

WHERE ebeln IN so_ebeln.

IF sy-subrc NE 0.

MESSAGE e020(z50871msg) WITH text-014.

ENDIF.

ENDFORM. "validate_ebeln

&----


*& Form populate_layout2

&----


FORM populate_layout2 .

CLEAR wa_layout.

wa_layout-colwidth_optimize = 'X'. "column width

  • wa_layout-zebra = 'X'.

  • wa_layout-no_hline = 'X'.

  • wa_layout-no_vline = 'X'.

  • wa_layout-cell_merge = 'X'.

wa_layout-window_titlebar = 'PURCHASE ORDER DETAILS SECOND SCREEN'.

ENDFORM. " populate_layout2

&----


*& Form GET_POPUPDATA

&----


FORM get_popupdata .

LOOP AT it_ekko INTO wa_ekko WHERE check = 'X'.

READ TABLE it_eine INTO wa_eine WITH KEY ebeln = wa_ekko-ebeln.

IF sy-subrc NE 0.

MESSAGE i020(z50871msg) WITH text-015 wa_ekko-ebeln .

ELSE.

wa_popup-ebeln = wa_eine-ebeln.

wa_popup-ekorg = wa_eine-ekorg.

wa_popup-ekgrp = wa_eine-ekgrp.

APPEND wa_popup TO it_popup.

ENDIF.

ENDLOOP.

ENDFORM. " GET_POPUPDATA

&----


*& Form GET_POPUPFCAT

&----


FORM get_popupfcat .

CLEAR wa_fieldcat.

REFRESH it_fieldcat.

wa_fieldcat-fieldname = 'EBELN'.

wa_fieldcat-seltext_l = text-004.

wa_fieldcat-hotspot = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'EKORG'.

wa_fieldcat-seltext_l = text-016.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'EKGRP'.

wa_fieldcat-seltext_l = text-017.

APPEND wa_fieldcat TO it_fieldcat.

ENDFORM. " GET_POPUPFCAT

&----


*& Form DISPLAY_POPUP

&----


FORM display_popup .

LOOP AT it_ekko INTO wa_ekko WHERE check EQ 'X'.

wa_check-check = wa_ekko-check.

APPEND wa_check TO it_check.

ENDLOOP.

IF it_check[] IS INITIAL.

MESSAGE i020(z50871msg) WITH text-018.

ENDIF.

IF NOT it_popup[] IS INITIAL.

CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'

EXPORTING

i_title = text-003

i_allow_no_selection = 'X'

i_scroll_to_sel_line = 'X'

i_tabname = 'IT_POPUP'

it_fieldcat = it_fieldcat

i_callback_program = sy-repid

TABLES

t_outtab = it_popup

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDIF.

REFRESH it_check.

REFRESH it_popup.

ENDFORM. " DISPLAY_POPUP

&----


*& Form get_ekko_data

&----


FORM get_ekko_data .

SELECT ebeln bstyp bsart aedat ernam

FROM ekko

INTO CORRESPONDING FIELDS OF TABLE it_ekko

WHERE ebeln IN so_ebeln.

IF sy-subrc NE 0.

MESSAGE e020(z50871msg) WITH text-019.

ENDIF.

ENDFORM. " get_ekko_data

&----


*& Form get_eine_data

&----


FORM get_eine_data .

SELECT ebeln ekorg ekgrp

FROM eine

INTO TABLE it_eine

WHERE ebeln IN so_ebeln.

ENDFORM. " get_eine_data

&----


*& Form at_user_command1

&----


FORM at_user_command1 USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN 'SE16'.

CALL TRANSACTION 'SE16'.

WHEN 'SE37'.

CALL TRANSACTION 'SE37'.

ENDCASE.

ENDFORM. "at_user_command1

Read only

Former Member
0 Likes
1,385

Hi

A list of possible events is populated into an event table (I_EVENTS) when this table is passed to the function module REUSE_ALV_EVENT_NAMES_GET. The return table from this function module contains all the possible events.

The function module contains following import and export parameters.

IMPORTING PARAMETERS: I_LIST_TYPE

This parameter has possible values from 0-4.

The parameter I_LIST_TYPE is of TYPE SLIS_LIST_TYPE and is DEFAULT 0 .

EXPORTING PARAMETERS: I_EVENTS table.

This table is of TYPE SLIS_T_EVENT and returns to the program the name of all the possible events.

The table structure contains the fields:

I_EVENTS-NAME: Name of the Callback event.

I_EVENTS-FORM: Name of the form routine that should be called in the calling program at the event.

Only events with a form routine name are processed.

The I_EVENTS table returns with the following possible constants:

1. Slis_ev_item_data_expand TYPE slis_formname VALUE 'ITEM_DATA_EXPAND'.

Only relevant for hierarchical-sequential lists using the layout parameter IS_LAYOUT-EXPAND_FIELDNAME of the structure IS_LAYOUT. Exit for passing item entries (ITEM table) for a header record that was expanded interactively by the user.

2. Slis_ev_reprep_sel_modify TYPE slis_formname VALUE 'REPREP_SEL_MODIFY'.

RS_SELFIELD-TABINDEX contains the header table index for which the item entries are to be put in the global item output table (T_OUTTAB_SLAVE). The Callback is only called if ALV has no items for a header that is to be expanded.

RFLG_ALL is passed with 'X' if the user shows all items. The application must ensure that entries are not repeated in the item table.

RS_SELFIELD is initial in this case.

3. Slis_ev_caller_exit_at_start TYPE slis_formname VALUE 'CALLER_EXIT'.

Is called at the beginning of the function module to make special settings. It is not usually used.

4. Slis_ev_user_command TYPE slis_formname VALUE 'USER_COMMAND'.

As this is a frequently-used Callback event, the form routine can also be passed directly in the interface by passing the user command in the IMPORTING parameter I_CALLBACK_USER_COMMAND.

5. Slis_ev_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.

Equivalent to the list processing TOP-OF-PAGE event.

6. Slis_ev_top_of_coverpage TYPE slis_formname VALUE 'TOP_OF_COVERPAGE'.

The selection information and list status are output together (if they exist) on a separate page by default

7. Slis_ev_end_of_coverpage TYPE slis_formname VALUE 'END_OF_COVERPAGE'.

Analogously to TOP_OF_COVERPAGE the user can add other information

to the information output by ALV (selection information, list status) at this event.

8. Slis_ev_foreign_top_of_page TYPE slis_formname VALUE ‘FOREIGN_TOP_OF_PAGE'.

The Top-of-page event is always processed in ALV and is only passed to the caller via the Callback mechanism. This is still the case if the caller, e.g. by a user action, processes a branch list which was not formatted by ALV (e.g. a popup with additional information about the list record selected and displayed by ALV).

In this case, top-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event top-of-page still occurs in ALV. When ALV notices a top-of-page which was not caused by an ALV output, the form routine in FOREIGN_TOP_OF_PAGE is called.

9. Slis_ev_foreign_end_of_page TYPE slis_formname VALUE 'FOREIGN_END_OF_PAGE'.

The event end-of-page is always processed in ALV and only passed to the caller via callback. This is still the case, e.g. when the caller processes a details list which was not formatted by ALV (e.g. a popup with further information about selected list records which were displayed by ALV).

In this case, end-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event end-of-page still occurs in ALV. When ALV notices an end-of-page that was not caused by an ALV output, the form routine in FOREIGN_END_OF_PAGE is called.

10. Slis_ev_pf_status_set TYPE slis_formname VALUE 'PF_STATUS_SET'.

If a user list status is to be set, it must be done in the form routine assigned to this event. The ALV function codes, which must not be active, are in the Parameter RT_EXTAB. This table must be passed with the SET PF-STATUS command (with inactive user function codes as well, if necessary).

The STANDARD status of the function group SALV should be used as a template for a user-specific status. As this is a frequently used Callback event, its form routine can also be passed directly in the interface in the IMPORTING parameter I_CALLBACK_PF_STATUS_SET.

11. Slis_ev_list_modify TYPE slis_formname VALUE 'LIST_MODIFY'.

LIST_MODIFY USING R_TABNAME TYPE SLIS_TABNAME

R_INDEX LIKE SY-TABIX

R_INDEX_ITEM LIKE SY-TABIX

R_INDEX_SUM LIKE SY-TABIX.

12. Slis_ev_top_of_list TYPE slis_formname VALUE 'TOP_OF_LIST'.

Information output at the start of the list

13. Slis_ev_end_of_page TYPE slis_formname VALUE 'END_OF_PAGE'.

Information output at the end of a page. This is only called for printing.

14. Slis_ev_end_of_list TYPE slis_formname VALUE 'END_OF_LIST'.

Information output at the end of the list

15. Slis_ev_after_line_output TYPE slis_formname VALUE 'AFTER_LINE_OUTPUT'.

Output information after each output line. Should only be used in justified cases because it costs a lot of performance.

16. Slis_ev_before_line_output TYPE slis_formname VALUE 'BEFORE_LINE_OUTPUT'.

Output information before each output line. Should only be used in justified cases because it costs a lot of performance.

17. Slis_ev_subtotal_text TYPE slis_formname VALUE 'SUBTOTAL_TEXT'.

This event table (I_EVENTS) is now checked with the desired constants. If the desired constant is found, then the corresponding field for the FORM NAME is populated with the name of the routine containing the corresponding event.

Sample code :

FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',

FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE', FORMNAME_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.

DATA: L_I_EVENT TYPE SLIS_ALV_EVENT.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = I_EVENTS.

READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE

INTO L_I_EVENT.

IF SY-SUBRC = 0.

MOVE FORMNAME_TOP_OF_PAGE TO L_I_EVENT-FORM.

APPEND L_I_EVENT TO I_EVENTS.

ENDIF.

READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE

INTO L_I_EVENT.

IF SY-SUBRC = 0.

MOVE FORMNAME_END_OF_PAGE TO L_I_EVENT-FORM.

APPEND L_I_EVENT TO I_EVENTS.

ENDIF.

CLEAR L_I_EVENT.

READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_USER_COMMAND

INTO L_I_EVENT.

IF SY-SUBRC = 0.

MOVE FORMNAME_USER_COMMAND TO L_I_EVENT-FORM.

APPEND L_I_EVENT TO I_EVENTS.

ENDIF.

Events in alv and their FM The main events in alv and their FM and why we use these:

1. SLIS_PRINT_ALV.

2. SLIS_T_LISTHEADER.

3. SLIS_T_EVENT.

4. SLIS_T_SORTINFO_ALV.

5. SLIS_T_LAYOUT_ALV.

6. SLIS_T_FIELDCAT_ALV.

and in classic reports what is the sequence of events: === Events are

At selection-screen output.

Initialization.

At selection-screen on field

At selection-screen on end of field

At selection-screen on Radiobutton Group R1. (If you have any radio buttons)

At selection-screen on block b1. (If you have any blocks)

Start-of-selection.

Get node. (if the data is retreived from a logical database)

Get node late. (if the data is retreived from a logical database)

Top-of-page. (if the write statement is in the end-of-selection event or we can say that before the first write statement)

end-of-selection.

and fuction modules are

LISTHEADER - Is used to print the header information in the ALV List. Name, Date, Time, ALV Name and other details are called as Header information. EVENT - Basically this is the FM to handle Event's. When the user needs to do some event operation like when double clicking the a particular field we need to perform some operation. These events are captured by this FM. LAYOUT - This FM is used to define the layout of the List. There are many options available in this FM to define the Layout style. FIELDCAT - These are used to populate the List header. We can change them according to our req.

User-defined Text Output Event

Application

print_end_of_list

Define output text to be printed at the end of the entire list

print_top_of_list

Define output text to be printed at the beginning of the entire list

print_end_of_page

Define output text to be printed at the end of each page

print_top_of_page

Define output text to be printed at the beginning of each page

subtotal_text

Define self-defined subtotals texts

Mouse-controlled Actions in the Grid Control Event

Application

button_click

Query a click on a pushbutton in the ALV Grid Control

double_click

Query a double-click on a cell of the ALV Grid control

hotspot_click

Query a hotspot click on columns defined for this purpose in advance

onDrag

Collect information when elements of the ALV Grid Control are dragged

onDrop

Process information when elements of the ALV Grid Control are dropped

onDropComplete

Perform final actions after successful Drag&Drop

onDropGetFlavor

Distinguish between options for Drag&Drop behavior

Processing of Self-defined and Standard Functions Event

Application

before_user_command

Query self-defined and standard function codes

user_command

Query self-defined function codes

after_user_command

Query self-defined and standard function codes

Definition of Self-defined Functions Event

Application

toolbar

Change, delete or add GUI elements in the toolbar

menu_button

Define menus for menu buttons in the toolbar

context_menu_request

Change context menu

onf1

Define self-defined F1 help

All of these can be found under type group SLIS.

Events

SLIS_EV_ITEM_DATA_EXPAND TYPE SLIS_FORMNAME VALUE 'ITEM_DATA_EXPAND',

SLIS_EV_REPREP_SEL_MODIFY TYPE SLIS_FORMNAME VALUE 'REPREP_SEL_MODIFY', SLIS_EV_CALLER_EXIT_AT_START TYPE SLIS_FORMNAME VALUE 'CALLER_EXIT',

SLIS_EV_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND',

SLIS_EV_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',

SLIS_EV_DATA_CHANGED TYPE SLIS_FORMNAME VALUE 'DATA_CHANGED',

SLIS_EV_TOP_OF_COVERPAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_COVERPAGE',

SLIS_EV_END_OF_COVERPAGE TYPE SLIS_FORMNAME VALUE 'END_OF_COVERPAGE',

SLIS_EV_FOREIGN_TOP_OF_PAGE TYPE SLIS_FORMNAME

VALUE 'FOREIGN_TOP_OF_PAGE', SLIS_EV_FOREIGN_END_OF_PAGE TYPE SLIS_FORMNAME

VALUE 'FOREIGN_END_OF_PAGE',

SLIS_EV_PF_STATUS_SET TYPE SLIS_FORMNAME VALUE 'PF_STATUS_SET',

SLIS_EV_LIST_MODIFY TYPE SLIS_FORMNAME VALUE 'LIST_MODIFY',

SLIS_EV_TOP_OF_LIST TYPE SLIS_FORMNAME VALUE 'TOP_OF_LIST',

SLIS_EV_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE',

SLIS_EV_END_OF_LIST TYPE SLIS_FORMNAME VALUE 'END_OF_LIST',

SLIS_EV_AFTER_LINE_OUTPUT TYPE SLIS_FORMNAME VALUE 'AFTER_LINE_OUTPUT', SLIS_EV_BEFORE_LINE_OUTPUT TYPE SLIS_FORMNAME VALUE 'BEFORE_LINE_OUTPUT',

SLIS_EV_SUBTOTAL_TEXT TYPE SLIS_FORMNAME VALUE 'SUBTOTAL_TEXT'.

For more information check the following link:

http://www.sapbrainsonline.com/TUTORIALS/TECHNICAL/ALV_tutorial.html

http://www.sap-img.com/abap-function.htm

http://beingkedar.googlepages.com/objectorientedalv

see these links

http://www.sapdev.co.uk/reporting/alv/alvgrid_events.htm

http://www.sapdev.co.uk/reporting/alv/alvgrid_endlist.htm

http://www.sapdev.co.uk/reporting/alv/alvgrid_rephead.htm

http://www.sapdev.co.uk/reporting/alv/alvgrid_pfstatus.htm

Please look into this program it may help full to you

ALV Grid display with Lights

This sample code can be used to display Lights in an ALV Grid output. The code can be modified as per the requirements so that, the color of the light can be varied depending on the conditions specified.

Sample Code

Program Name: zzz_light_alv



************************************************************************
REPORT zzz_light_alv NO STANDARD PAGE HEADING.


The Data Declarations 
INCLUDE zzz_light_alv_data.

PARAMETERS p_layout LIKE disvariant-variant.

************************************************************************

START-OF-SELECTION 
************************************************************************
START-OF-SELECTION.
*Fetching data for the report
PERFORM f1003_display_data.

************************************************************************

END-OF-SELECTION 
************************************************************************
END-OF-SELECTION.

CALL SCREEN 9001.

************************************************************************

TOP-OF-PAGE. 
************************************************************************
TOP-OF-PAGE.

*Data Selection
INCLUDE zzz_light_alv_forms.
*PBO & PAI Modules
INCLUDE zzz_light_alv_screen.


Create an include : zzz_light_alv_data




--------------------------------------------------------------------------------

INCLUDE ZZZ_LIGHT_ALV_DATA *

--------------------------------------------------------------------------------

This include has all the data declaration defined 
************************************************************************

************************************************************************

************************************************************************

Table Declarations: 
************************************************************************
TABLES: mara. " General Material Data.

************************************************************************

Types: 
************************************************************************
TYPES : BEGIN OF ty_data,
light TYPE ZLIGHT_STRUC-light, " Light
matnr TYPE mara-matnr , " Material number
msgty TYPE ZLIGHT_STRUC-msgty, " Message type
END OF ty_data.

************************************************************************

Internal Tables: 
************************************************************************
DATA: i_exclude TYPE ui_functions, " Function button table definitions
i_fieldcat TYPE lvc_t_fcat, " Field catalogue
i_output TYPE STANDARD TABLE OF ZLIGHT_STRUC,
i_groups TYPE lvc_t_sgrp,

************************************************************************

Work Areas: 
************************************************************************
w_variant TYPE disvariant, " Enable variant saving
w_layout TYPE lvc_s_layo, " Define the layout structure
w_output TYPE ZLIGHT_STRUC.

************************************************************************

Constants Declaration 
************************************************************************
CONSTANTS: c_a TYPE c VALUE 'A'. "All Layouts

***********************************************************************

Object Declarations 
************************************************************************
DATA : o_alvgrid TYPE REF TO cl_gui_alv_grid,
o_dockingcontainer TYPE REF TO cl_gui_docking_container.

*Create an include: ZZZ_LIGHT_ALV_FORMS



--------------------------------------------------------------------------------

INCLUDE ZZZ_LIGHT_ALV_FORMS *



--------------------------------------------------------------------------------

*
************************************************************************

&---------------------------------------------------------------------
*& Form f1002_value_request
&---------------------------------------------------------------------

Get the values for the layout.



--------------------------------------------------------------------------------
FORM f1002_value_request.

DATA: lv_exit TYPE c,
lw_variant LIKE w_variant.

w_variant-report = sy-repid.

Invoke function to provide drop down entries 
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = w_variant
i_save = c_a
IMPORTING
e_exit = lv_exit
es_variant = lw_variant
EXCEPTIONS
not_found = 1
program_error = 2
OTHERS = 3.
IF sy-subrc IS INITIAL.
IF lv_exit IS INITIAL.
p_layout = lw_variant-variant.
ENDIF.
ELSE.

MESSAGE i037. "No layouts found 
ENDIF.

ENDFORM. " f1002_value_request

&---------------------------------------------------------------------
*& Form f1003_display_data
&---------------------------------------------------------------------

Display Data



--------------------------------------------------------------------------------
FORM f1003_display_data.

You can put your conditions here. Based upon the conditions you can 
display the lights as Red, Yellow or Green 

w_output-light = '1'. “ Red
w_output-matnr = '000123456'.
w_output-msgty = '1'.
APPEND w_output TO i_output.

w_output-light = '2'. “ Yellow
w_output-matnr = '000123457'.
w_output-msgty = '1'.
APPEND w_output TO i_output.

w_output-light = '3'. “ Green
w_output-matnr = '000123458'.
w_output-msgty = '1'.
APPEND w_output TO i_output.

ENDFORM. " f1003_display_data

&---------------------------------------------------------------------
*& Form f9000_objects_create
&---------------------------------------------------------------------

This form creates the objects that we later reference.



--------------------------------------------------------------------------------
FORM f9000_objects_create.

Check to see if we are runnng on online 
IF cl_gui_alv_grid=>offline( ) IS INITIAL.

CREATE OBJECT o_dockingcontainer
EXPORTING
ratio = '95'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.

IF sy-subrc NE 0.

MESSAGE i001 WITH text-e01. 
LEAVE LIST-PROCESSING.
ENDIF.

ENDIF.

CREATE OBJECT o_alvgrid
EXPORTING
i_parent = o_dockingcontainer.

ENDFORM. " f9000_objects_create

&---------------------------------------------------------------------
*& Form f9100_exclude_functions
&---------------------------------------------------------------------

This form exclude buttons from the toolbar.



--------------------------------------------------------------------------------

-->P_IEXCLUDE text 
-->P_1150 text

--------------------------------------------------------------------------------
FORM f9100_exclude_functions USING pexclude LIKE i_exclude
value(pfunction).

DATA: l_exclude TYPE ui_func.

l_exclude = pfunction.
APPEND l_exclude TO pexclude.

ENDFORM. " f9100_exclude_functions

&---------------------------------------------------------------------
*& Form f9200_build_field_cat
&---------------------------------------------------------------------

Building the field catalogue

--------------------------------------------------------------------------------

-->P_I_FIELDCAT[] - Internal table having the fields of the ALV 
structure 
-->P_structure - ALV structure to be displayed in the output

--------------------------------------------------------------------------------
FORM f9200_build_field_cat TABLES p_fieldcat STRUCTURE lvc_s_fcat
USING value(p_structure).

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = p_structure
CHANGING
ct_fieldcat = p_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc 0.

MESSAGE i277. 
LEAVE LIST-PROCESSING.
ENDIF.

ENDFORM. " f9200_build_field_cat

&---------------------------------------------------------------------
*& Form f9400_layout
&---------------------------------------------------------------------

This form sets how the grid will look. 
The title, alternate colouring on lines, if the column widths are 
optimised for the data contents and the display variant if_used.

--------------------------------------------------------------------------------

-->P_SY_TITLE - Title bar text 
-->P_0015 - Alternating line color (striped) 
-->P_0016 - Selection mode 
-->P_0017 - Optimize column width 
-->P_P_DISVAR - Report name

--------------------------------------------------------------------------------
FORM f9400_layout USING value(ptitle)
value(pzebra)
value(pmode)
value(pwidth)
value(pvariant).

w_layout-grid_title = ptitle.
w_layout-zebra = pzebra.
w_layout-sel_mode = pmode.
w_layout-cwidth_opt = pwidth.
w_variant-handle = pvariant.
w_variant-report = sy-repid.
w_layout-excp_fname = 'LIGHT'. " To display Light

ENDFORM. " f9400_layout

&---------------------------------------------------------------------
*& Form f9500_display_data
&---------------------------------------------------------------------

Display the output data

--------------------------------------------------------------------------------

-->P_IOUTPUT - Output table to be displayed in the ALV 
-->P_groups - Field groups 
-->P_exclude - Excluded toolbar standard functions 
-->P_fieldcat - Field catalog 
-->P_layout - Layout

--------------------------------------------------------------------------------
FORM f9500_display_data TABLES p_output
p_groups
p_exclude
p_fieldcat
USING value(p_layout).

CALL METHOD o_alvgrid->set_table_for_first_display
EXPORTING
is_variant = w_variant
i_save = c_a
is_layout = p_layout
it_special_groups = p_groups[]
it_toolbar_excluding = p_exclude[]
CHANGING
it_outtab = p_output[]
it_fieldcatalog = p_fieldcat[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.

IF sy-subrc 0.

MESSAGE i278. 
LEAVE LIST-PROCESSING.
ENDIF.

ENDFORM. " f9500_display_data

&---------------------------------------------------------------------
*& Form f9600_free_objects
&---------------------------------------------------------------------

This form handles the freeing of the following objects 
ALV Docking Container

--------------------------------------------------------------------------------

-->P_O_ALVGRID - Object to be freed 
-->P_0020 - Type of the object 
-->P_0021 - Object text

--------------------------------------------------------------------------------
FORM f9600_free_objects USING pobject
value(ptype)
value(ptext).

DATA: l_objectalv TYPE REF TO cl_gui_alv_grid.

Need to type the field symbol or it does not work 

CASE ptype.
WHEN 'ALV'.

l_objectalv = pobject.

IF NOT ( l_objectalv IS INITIAL ).
CALL METHOD l_objectalv->free
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
CLEAR: pobject, l_objectalv.
PERFORM f9700_error_handle USING ptext.

ENDIF.
WHEN 'DOCKING'.
DATA: lobjectdock TYPE REF TO cl_gui_docking_container.
lobjectdock = pobject.

IF NOT ( lobjectdock IS INITIAL ).
CALL METHOD lobjectdock->free
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
CLEAR: pobject, lobjectdock.
PERFORM f9700_error_handle USING ptext.

ENDIF.
WHEN 'CONTAINER'.
DATA: lobjectcontainer TYPE REF TO cl_gui_container.
lobjectcontainer = pobject.

IF NOT ( lobjectcontainer IS INITIAL ).
CALL METHOD lobjectcontainer->free
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
CLEAR: pobject, lobjectcontainer.
PERFORM f9700_error_handle USING ptext.

ENDIF.
WHEN OTHERS.
sy-subrc = 1.
PERFORM f9700_error_handle USING
text-e04.
ENDCASE.

ENDFORM. " f9600_free_objects

&---------------------------------------------------------------------
*& Form f9700_error_handle
&---------------------------------------------------------------------

This form is used to handle errors

--------------------------------------------------------------------------------

-->P_PTEXT - Text holding the messsage to be displayed as 
information

--------------------------------------------------------------------------------
FORM f9700_error_handle USING value(ptext).

IF sy-subrc NE 0.

Add your handling, for example 
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = text-e03
txt2 = sy-subrc
txt1 = ptext.
ENDIF.

ENDFORM. " f9700_error_handle

Create a screen: 9001. 

Create an include: ZZZ_LIGHT_ALV_SCREEN




--------------------------------------------------------------------------------

INCLUDE ZZZ_LIGHT_ALV_SCREEN *

--------------------------------------------------------------------------------

This include contains PAO and PBO details 
************************************************************************************************************************************************
&---------------------------------------------------------------------
*& Module STATUS_9001 OUTPUT
&---------------------------------------------------------------------

This is used for PBO details

--------------------------------------------------------------------------------
MODULE status_9001 OUTPUT.

IF o_dockingcontainer IS INITIAL.

SET PF-STATUS 'ZSTATUS'.
SET TITLEBAR 'ZTITLE'.

*Create Objects
PERFORM f9000_objects_create.

*Build field catalog
PERFORM f9200_build_field_cat TABLES i_fieldcat
USING 'ZLIGHT_STRUC'.

*Layout
PERFORM f9400_layout USING sy-title 'X' 'X' 'X' p_layout.

*Display data
PERFORM f9500_display_data TABLES i_output
i_groups
i_exclude
i_fieldcat
USING w_layout.

ENDIF.

ENDMODULE. " STATUS_9001 OUTPUT
*&---------------------------------------------------------------------
*& Module USER_COMMAND_9001 INPUT
*&---------------------------------------------------------------------

This is used for PAI details 
*----------------------------------------------------------------------
MODULE user_command_9001 INPUT.

CASE sy-ucomm.

WHEN 'EXIT' OR 'CANC'.
PERFORM f9600_free_objects:
USING o_alvgrid 'ALV' text-e02,
USING o_dockingcontainer 'DOCKING'
text-e01.
LEAVE PROGRAM.

WHEN 'BACK'.
PERFORM f9600_free_objects:
USING o_alvgrid 'ALV' text-e02,
USING o_dockingcontainer 'DOCKING'
text-e01.
SET SCREEN '0'.
LEAVE SCREEN.

WHEN OTHERS.

ENDCASE.

ENDMODULE. " USER_COMMAND_9001 INPUT

Create a structure: ZLIGHT_STRUC

Components:
LIGHT
MATNR
MSGTY

Check this link also...

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_events.htm

Regards,

Chandru

Read only

Former Member
0 Likes
1,385

Check this code. This code doesn't contain OOP Concept


REPORT ZALV1.
*******************TABLE DECLARATION************************************

TABLES : VBAP. " tables declaration

******************TYPE POOLS********************************************

TYPE-POOLS : SLIS. " slis type pool

******************INTERNAL TABLE DECLARATION****************************

DATA : BEGIN OF IT_VBAP OCCURS 0,
" internal table for sales document item
VBELN LIKE VBAP-VBELN, " sales document
POSNR LIKE VBAP-POSNR, " document item
ERNAM LIKE VBAP-ERNAM,
" name of the person who created the object
ERDAT LIKE VBAP-ERDAT, " date on which the record was created
MATNR LIKE VBAP-MATNR. " material number
DATA : END OF IT_VBAP.

DATA : BEGIN OF IT_MARA OCCURS 0, " general material data
MATNR LIKE MARA-MATNR, " material number
ERNAM LIKE MARA-ERNAM,
" name of the person who created the object
MATKL LIKE MARA-MATKL, " material group
MEINS LIKE MARA-MEINS, " base unit of measure
PSTAT LIKE MARA-PSTAT. " maintainence status
DATA : END OF IT_MARA.

******************VARIABLE
*DECLARATION***********************************

DATA : REPID LIKE SY-REPID. " program name

DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
" field catalog table for vbap
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

DATA : IT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV,
" field catalog table for mara
WA_FIELDCAT1 TYPE SLIS_FIELDCAT_ALV.

DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.

DATA: GT_XEVENTS TYPE SLIS_T_EVENT.
DATA: GT_YEVENTS TYPE SLIS_T_EVENT. " events table

DATA : XS_EVENT TYPE SLIS_ALV_EVENT. " events type

DATA : GT_PRINT TYPE SLIS_PRINT_ALV. " print table

*******************MULTIPLE SELECT INPUT
*PARAMETERS***********************

SELECT-OPTIONS : S_VBELN FOR VBAP-VBELN.
" multiple selection for sales document

*******************INITIALIZATION***************************************
***

INITIALIZATION.

REPID = SY-REPID.

*******************START OF
*SELECTION*************************************

START-OF-SELECTION.

PERFORM POP_VBAP.
" populating the table with document item data

PERFORM POP_MARA.
" populating the table with general material data

PERFORM FIELD_CAT.
" mapping the fields for the field catalog

PERFORM EVENTS. " using the events

PERFORM BLOCK_LIST.
" displaying the data in blocked list

*<---------------------------------------------------------------------
*& Form field_cat
*&---------------------------------------------------------------------

*text
*----------------------------------------------------------------------
*
*--> p1 text
*<-- p2 text
*----------------------------------------------------------------------
FORM FIELD_CAT .

WA_FIELDCAT-FIELDNAME = 'VBELN'.
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-SELTEXT_L = 'SALES DOC'.
WA_FIELDCAT-COL_POS = 1.
WA_FIELDCAT-OUTPUTLEN = 10.

APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.

WA_FIELDCAT-FIELDNAME = 'POSNR'.
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-SELTEXT_L = 'DOC ITEM'.
WA_FIELDCAT-COL_POS = 2.
WA_FIELDCAT-OUTPUTLEN = 6.

APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.

WA_FIELDCAT-FIELDNAME = 'ERNAM'.
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-SELTEXT_L = 'NAME'.
WA_FIELDCAT-COL_POS = 3.
WA_FIELDCAT-OUTPUTLEN = 12.

APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.

WA_FIELDCAT-FIELDNAME = 'ERDAT'.
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-SELTEXT_L = 'DATE'.
WA_FIELDCAT-COL_POS = 4.
WA_FIELDCAT-OUTPUTLEN = 8.

APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.

WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-SELTEXT_L = 'MAT NO'.
WA_FIELDCAT-COL_POS = 5.
WA_FIELDCAT-OUTPUTLEN = 18.

APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.

WA_FIELDCAT1-FIELDNAME = 'MATNR'.
WA_FIELDCAT1-TABNAME = 'IT_MARA'.
WA_FIELDCAT1-SELTEXT_L = 'MAT NO'.
WA_FIELDCAT1-COL_POS = 1.
WA_FIELDCAT1-OUTPUTLEN = 18.

APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
CLEAR WA_FIELDCAT1.

WA_FIELDCAT1-FIELDNAME = 'ERNAM'.
WA_FIELDCAT1-TABNAME = 'IT_MARA'.
WA_FIELDCAT1-SELTEXT_L = 'NAME'.
WA_FIELDCAT1-COL_POS = 2.
WA_FIELDCAT1-OUTPUTLEN = 12.

APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
CLEAR WA_FIELDCAT1.

WA_FIELDCAT1-FIELDNAME = 'MATKL'.
WA_FIELDCAT1-TABNAME = 'IT_MARA'.
WA_FIELDCAT1-SELTEXT_L = 'MAT DESC'.
WA_FIELDCAT1-COL_POS = 3.
WA_FIELDCAT1-OUTPUTLEN = 9.

APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
CLEAR WA_FIELDCAT1.

WA_FIELDCAT1-FIELDNAME = 'MEINS'.
WA_FIELDCAT1-TABNAME = 'IT_MARA'.
WA_FIELDCAT1-SELTEXT_L = 'UNITS'.
WA_FIELDCAT1-COL_POS = 4.
WA_FIELDCAT1-OUTPUTLEN = 3.

APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
CLEAR WA_FIELDCAT1.

WA_FIELDCAT1-FIELDNAME = 'PSTAT'.
WA_FIELDCAT1-TABNAME = 'IT_MARA'.
WA_FIELDCAT1-SELTEXT_L = 'STATUS'.
WA_FIELDCAT1-COL_POS = 5.
WA_FIELDCAT1-OUTPUTLEN = 15.

APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
CLEAR WA_FIELDCAT1.




ENDFORM. " field_cat
*&---------------------------------------------------------------------
**& Form events
*&---------------------------------------------------------------------
*
*
*text
*----------------------------------------------------------------------
*
*--> p1 text
*<-- p2 text
*----------------------------------------------------------------------
FORM EVENTS .
CLEAR XS_EVENT.
XS_EVENT-NAME = SLIS_EV_END_OF_PAGE.
XS_EVENT-FORM = 'XEND_OF_PAGE'.
APPEND XS_EVENT TO GT_XEVENTS.
CLEAR XS_EVENT.
XS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.
XS_EVENT-FORM = 'XTOP_OF_PAGE'.
APPEND XS_EVENT TO GT_XEVENTS.
CLEAR XS_EVENT.
XS_EVENT-NAME = SLIS_EV_TOP_OF_LIST.
XS_EVENT-FORM = 'XTOP_OF_LIST'.
APPEND XS_EVENT TO GT_XEVENTS.
CLEAR XS_EVENT.
XS_EVENT-NAME = SLIS_EV_END_OF_LIST.
XS_EVENT-FORM = 'XEND_OF_LIST'.
APPEND XS_EVENT TO GT_XEVENTS.
CLEAR XS_EVENT.

CLEAR XS_EVENT.
XS_EVENT-NAME = SLIS_EV_END_OF_PAGE.
XS_EVENT-FORM = 'YEND_OF_PAGE'.
APPEND XS_EVENT TO GT_YEVENTS.
CLEAR XS_EVENT.
XS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.
XS_EVENT-FORM = 'YTOP_OF_PAGE'.
APPEND XS_EVENT TO GT_YEVENTS.
CLEAR XS_EVENT.
XS_EVENT-NAME = SLIS_EV_TOP_OF_LIST.
XS_EVENT-FORM = 'YTOP_OF_LIST'.
APPEND XS_EVENT TO GT_YEVENTS.
CLEAR XS_EVENT.
XS_EVENT-NAME = SLIS_EV_END_OF_LIST.
XS_EVENT-FORM = 'YEND_OF_LIST'.
APPEND XS_EVENT TO GT_YEVENTS.
ENDFORM. " events

*&--------------------------------------------------------------------
**& Form XTOP_OF_PAGE
*&--------------------------------------------------------------------
*
*
*text
*---------------------------------------------------------------------
FORM XTOP_OF_PAGE.

BREAK-POINT.
WRITE: / 'X_TOP_OF_PAGE'.
ENDFORM. "XTOP_OF_PAGE
*---------------------------------------------------------------------
*
*FORM XTOP_OF_LIST *
*---------------------------------------------------------------------
*
*........ *
*---------------------------------------------------------------------
FORM XTOP_OF_LIST.

BREAK-POINT.
WRITE: / 'X_TOP_OF_LIST'.
ENDFORM. "XTOP_OF_LIST
*---------------------------------------------------------------------
*
*FORM XEND_OF_PAGE *
*---------------------------------------------------------------------
*
*........ *
*---------------------------------------------------------------------
FORM XEND_OF_PAGE.

BREAK-POINT.
WRITE: / 'X_END_OF_PAGE'.
ENDFORM. "XEND_OF_PAGE
*---------------------------------------------------------------------
*
*FORM XEND_OF_LIST *
*---------------------------------------------------------------------
*
*........ *
*---------------------------------------------------------------------
FORM XEND_OF_LIST.

BREAK-POINT.
WRITE: / 'X_END_OF_LIST'.
ENDFORM. "XEND_OF_LIST
*

FORM YTOP_OF_PAGE.


BREAK-POINT.
WRITE: / 'Y_TOP_OF_PAGE'.
ENDFORM. "YTOP_OF_PAGE
*---------------------------------------------------------------------
*
*FORM YTOP_OF_LIST *
*---------------------------------------------------------------------
*
*........ *
*---------------------------------------------------------------------
FORM YTOP_OF_LIST.

BREAK-POINT.
WRITE: / 'Y_TOP_OF_LIST'.
ENDFORM. "YTOP_OF_LIST
*---------------------------------------------------------------------
*
*FORM YEND_OF_PAGE *
*---------------------------------------------------------------------
*
*........ *
*---------------------------------------------------------------------
FORM YEND_OF_PAGE.

BREAK-POINT.
WRITE: / 'Y_END_OF_PAGE'.
ENDFORM. "YEND_OF_PAGE
*---------------------------------------------------------------------
*
*FORM YEND_OF_LIST *
*---------------------------------------------------------------------
*
*........ *
*---------------------------------------------------------------------
FORM YEND_OF_LIST.

BREAK-POINT.
WRITE: / 'Y_END_OF_LIST'.
ENDFORM. "YEND_OF_LIST
*
*&---------------------------------------------------------------------
**& Form POP_VBAP
*&---------------------------------------------------------------------
*
*text
*----------------------------------------------------------------------
*
*--> p1 text
*<-- p2 text
*----------------------------------------------------------------------
FORM POP_VBAP .

SELECT VBELN
POSNR
ERNAM
ERDAT
MATNR
FROM VBAP
INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
WHERE VBELN IN S_VBELN.

ENDFORM. " POP_VBAP
*&---------------------------------------------------------------------
**& Form POP_MARA
*&---------------------------------------------------------------------
*
*text
*----------------------------------------------------------------------
*
*--> p1 text
*<-- p2 text
*----------------------------------------------------------------------
FORM POP_MARA .

LOOP AT IT_VBAP.

SELECT SINGLE MATNR
ERNAM
MATKL
MEINS
PSTAT
FROM MARA
INTO CORRESPONDING FIELDS OF IT_MARA
WHERE MATNR = IT_VBAP-MATNR.
APPEND IT_MARA.
ENDLOOP.

ENDFORM. " POP_MARA
*&---------------------------------------------------------------------
**& Form BLOCK_LIST
*&---------------------------------------------------------------------
*
*text
*----------------------------------------------------------------------
*
*--> p1 text
*<-- p2 text
*----------------------------------------------------------------------
FORM BLOCK_LIST .
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
I_CALLBACK_PROGRAM = REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'user_command'.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
I_TABNAME = 'IT_VBAP'
IT_EVENTS = GT_XEVENTS


*IT_SORT =
I_TEXT = ' '
TABLES
T_OUTTAB = IT_VBAP

EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3
.
*IF SY-SUBRC 0.
*
*MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT1
I_TABNAME = 'IT_MARA'
IT_EVENTS = GT_YEVENTS

*IT_SORT =
I_TEXT = ' '
TABLES
T_OUTTAB = IT_MARA

EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3
.
*IF SY-SUBRC 0.
*
*MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
EXPORTING

I_INTERFACE_CHECK = ' '
IS_PRINT = GT_PRINT

I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
*IMPORTING
*E_EXIT_CAUSED_BY_CALLER =
*ES_EXIT_CAUSED_BY_USER =
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
*IF SY-SUBRC 0.
*
*MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
ENDFORM. " BLOCK_LIST

Regards,

Chandru

Read only

Former Member
0 Likes
1,385

Here is some more information

The main events in alv and their FM and why we use these:

1. SLIS_PRINT_ALV.

2. SLIS_T_LISTHEADER.

3. SLIS_T_EVENT.

4. SLIS_T_SORTINFO_ALV.

5. SLIS_T_LAYOUT_ALV.

6. SLIS_T_FIELDCAT_ALV.

and in classic reports what is the sequence of events: === Events are

At selection-screen output.

Initialization.

At selection-screen on field

At selection-screen on end of field

At selection-screen on Radiobutton Group R1. (If you have any radio buttons)

At selection-screen on block b1. (If you have any blocks)

Start-of-selection.

Get node. (if the data is retreived from a logical database)

Get node late. (if the data is retreived from a logical database)

Top-of-page. (if the write statement is in the end-of-selection event or we can say that before the first write statement)

end-of-selection.

and fuction modules are

LISTHEADER - Is used to print the header information in the ALV List. Name, Date, Time, ALV Name and other details are called as Header information. EVENT - Basically this is the FM to handle Event's. When the user needs to do some event operation like when double clicking the a particular field we need to perform some operation. These events are captured by this FM. LAYOUT - This FM is used to define the layout of the List. There are many options available in this FM to define the Layout style. FIELDCAT - These are used to populate the List header. We can change them according to our req.

User-defined Text Output Event

Application

print_end_of_list

Define output text to be printed at the end of the entire list

print_top_of_list

Define output text to be printed at the beginning of the entire list

print_end_of_page

Define output text to be printed at the end of each page

print_top_of_page

Define output text to be printed at the beginning of each page

subtotal_text

Define self-defined subtotals texts

Mouse-controlled Actions in the Grid Control Event

Application

button_click

Query a click on a pushbutton in the ALV Grid Control

double_click

Query a double-click on a cell of the ALV Grid control

hotspot_click

Query a hotspot click on columns defined for this purpose in advance

onDrag

Collect information when elements of the ALV Grid Control are dragged

onDrop

Process information when elements of the ALV Grid Control are dropped

onDropComplete

Perform final actions after successful Drag&Drop

onDropGetFlavor

Distinguish between options for Drag&Drop behavior

Processing of Self-defined and Standard Functions Event

Application

before_user_command

Query self-defined and standard function codes

user_command

Query self-defined function codes

after_user_command

Query self-defined and standard function codes

Definition of Self-defined Functions Event

Application

toolbar

Change, delete or add GUI elements in the toolbar

menu_button

Define menus for menu buttons in the toolbar

context_menu_request

Change context menu

onf1

Define self-defined F1 help

All of these can be found under type group SLIS.

Events

SLIS_EV_ITEM_DATA_EXPAND TYPE SLIS_FORMNAME VALUE 'ITEM_DATA_EXPAND',

SLIS_EV_REPREP_SEL_MODIFY TYPE SLIS_FORMNAME VALUE 'REPREP_SEL_MODIFY', SLIS_EV_CALLER_EXIT_AT_START TYPE SLIS_FORMNAME VALUE 'CALLER_EXIT',

SLIS_EV_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND',

SLIS_EV_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',

SLIS_EV_DATA_CHANGED TYPE SLIS_FORMNAME VALUE 'DATA_CHANGED',

SLIS_EV_TOP_OF_COVERPAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_COVERPAGE',

SLIS_EV_END_OF_COVERPAGE TYPE SLIS_FORMNAME VALUE 'END_OF_COVERPAGE',

SLIS_EV_FOREIGN_TOP_OF_PAGE TYPE SLIS_FORMNAME

VALUE 'FOREIGN_TOP_OF_PAGE', SLIS_EV_FOREIGN_END_OF_PAGE TYPE SLIS_FORMNAME

VALUE 'FOREIGN_END_OF_PAGE',

SLIS_EV_PF_STATUS_SET TYPE SLIS_FORMNAME VALUE 'PF_STATUS_SET',

SLIS_EV_LIST_MODIFY TYPE SLIS_FORMNAME VALUE 'LIST_MODIFY',

SLIS_EV_TOP_OF_LIST TYPE SLIS_FORMNAME VALUE 'TOP_OF_LIST',

SLIS_EV_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE',

SLIS_EV_END_OF_LIST TYPE SLIS_FORMNAME VALUE 'END_OF_LIST',

SLIS_EV_AFTER_LINE_OUTPUT TYPE SLIS_FORMNAME VALUE 'AFTER_LINE_OUTPUT', SLIS_EV_BEFORE_LINE_OUTPUT TYPE SLIS_FORMNAME VALUE 'BEFORE_LINE_OUTPUT',

SLIS_EV_SUBTOTAL_TEXT TYPE SLIS_FORMNAME VALUE 'SUBTOTAL_TEXT'.

SLIS_EV_ITEM_DATA_EXPAND

SLIS_EV_REPREP_SEL_MODIFY

SLIS_EV_CALLER_EXIT_AT_START

SLIS_EV_USER_COMMAND

SLIS_EV_TOP_OF_PAGE

SLIS_EV_TOP_OF_COVERPAGE

SLIS_EV_END_OF_COVERPAGE

SLIS_EV_FOREIGN_TOP_OF_PAGE

SLIS_EV_FOREIGN_END_OF_PAGE

SLIS_EV_PF_STATUS_SET

SLIS_EV_LIST_MODIFY

SLIS_EV_TOP_OF_LIST

SLIS_EV_END_OF_PAGE

SLIS_EV_END_OF_LIST

SLIS_EV_AFTER_LINE_OUTPUT

SLIS_EV_BEFORE_LINE_OUTPUT

SLIS_EV_SUBTOTAL_TEXT

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_events.htm

If you want to perform anything in ALV then you have to use Events.

Suppose you want to display header(Top-of-page) then you need to use specific events.

Events in ALV are as follows,

CALLER_EXIT

USER_COMMAND

TOP_OF_PAGE

TOP_OF_COVERPAGE

END_OF_COVERPAGE

FOREIGN_TOP_OF_PAGE

FOREIGN_END_OF_PAGE

PF_STATUS_SET

LIST_MODIFY

TOP_OF_LIST

END_OF_PAGE

END_OF_LIST

AFTER_LINE_OUTPUT

BEFORE_LINE_OUTPUT

REPREP_SEL_MODIFY

SUBTOTAL_TEXT

GROUPLEVEL_CHANGE

Here are the event handlers for ALV

CLASS lcl_event_handler DEFINITION .

PUBLIC SECTION .

METHODS:

To add new functional buttons to the ALV toolbar

handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid

IMPORTING e_object e_interactive ,

To implement user commands

handle_user_command

FOR EVENT user_command OF cl_gui_alv_grid

IMPORTING e_ucomm ,

Hotspot click control

handle_hotspot_click

FOR EVENT hotspot_click OF cl_gui_alv_grid

IMPORTING e_row_id e_column_id es_row_no ,

Double-click control

handle_double_click

FOR EVENT double_click OF cl_gui_alv_grid

IMPORTING e_row e_column ,

To be triggered before user commands

handle_before_user_command

FOR EVENT before_user_command OF cl_gui_alv_grid

IMPORTING e_ucomm ,

To be triggered after user commands

handle_after_user_command

FOR EVENT context_menu_request OF cl_gui_alv_grid

IMPORTING e_object

Controlling data changes when ALV Grid is editable

handle_data_changed

FOR EVENT data_changed OF cl_gui_alv_grid

IMPORTING er_data_changed ,

To be triggered after data changing is finished

handle_data_changed_finished

FOR EVENT data_changed_finished OF cl_gui_alv_grid

IMPORTING e_modified ,

To control menu buttons

handle_menu_button

FOR EVENT menu_button OF cl_gui_alv_grid

IMPORTING e_oject e_ucomm ,

To control button clicks

handle_button_click

FOR EVENT button_click OF cl_gui_alv_grid

IMPORTING e_oject e_ucomm .

PRIVATE ENDCLASS.

SECTION.

CLASS lcl_event_handler IMPLEMENTATION .

Handle Toolbar

METHOD handle_toolbar.

PERFORM handle_toolbar USING e_object e_interactive .

ENDMETHOD .

Handle Hotspot Click

METHOD handle_hotspot_click .

PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no .

ENDMETHOD .

Handle Double Click

METHOD handle_double_click .

PERFORM handle_double_click USING e_row e_column es_row_no .

ENDMETHOD .

Handle User Command

METHOD handle_user_command .

PERFORM handle_user_command USING e_ucomm .

ENDMETHOD.

Handle After User Command

METHOD handle_context_menu_request .

PERFORM handle_context_menu_request USING e_object .

ENDMETHOD.

Handle Before User Command

METHOD handle_before_user_command .

PERFORM handle_before_user_command USING e_ucomm .

ENDMETHOD .

Handle Data Changed

METHOD handle_data_changed .

PERFORM handle_data_changed USING er_data_changed .

ENDMETHOD.

Handle Data Changed Finished

METHOD handle_data_changed_finished .

PERFORM handle_data_changed_finished USING e_modified .

ENDMETHOD .

Handle Menu Buttons

METHOD handle_menu_button .

PERFORM handle_menu_button USING e_object e_ucomm .

ENDMETHOD .

Handle Button Click

METHOD handle_button_click .

PERFORM handle_button_click USING e_object e_ucomm .

ENDMETHOD .

ENDCLASS .

IF U REQUIRE A DETAILED EXPLANATION DO REPLY.

Also Check these links

Simple ALV report

http://www.sapgenie.com/abap/controls/alvgrid.htm

http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox

ALV

1. Please give me general info on ALV.

http://www.sapfans.com/forums/viewtopic.php?t=58286

http://www.sapfans.com/forums/viewtopic.php?t=76490

http://www.sapfans.com/forums/viewtopic.php?t=20591

http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.

2. How do I program double click in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=11601

http://www.sapfans.com/forums/viewtopic.php?t=23010

3. How do I add subtotals (I have problem to add them)...

http://www.sapfans.com/forums/viewtopic.php?t=20386

http://www.sapfans.com/forums/viewtopic.php?t=85191

http://www.sapfans.com/forums/viewtopic.php?t=88401

http://www.sapfans.com/forums/viewtopic.php?t=17335

4. How to add list heading like top-of-page in ABAP lists?

http://www.sapfans.com/forums/viewtopic.php?t=58775

http://www.sapfans.com/forums/viewtopic.php?t=60550

http://www.sapfans.com/forums/viewtopic.php?t=16629

5. How to print page number / total number of pages X/XX in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)

6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.

http://www.sapfans.com/forums/viewtopic.php?t=64320

http://www.sapfans.com/forums/viewtopic.php?t=44477

7. How can I set the cell color in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=52107

8. How do I print a logo/graphics in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=81149

http://www.sapfans.com/forums/viewtopic.php?t=35498

http://www.sapfans.com/forums/viewtopic.php?t=5013

9. How do I create and use input-enabled fields in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=84933

http://www.sapfans.com/forums/viewtopic.php?t=69878

10. How can I use ALV for reports that are going to be run in background?

http://www.sapfans.com/forums/viewtopic.php?t=83243

http://www.sapfans.com/forums/viewtopic.php?t=19224

11. How can I display an icon in ALV? (Common requirement is traffic light icon).

http://www.sapfans.com/forums/viewtopic.php?t=79424

http://www.sapfans.com/forums/viewtopic.php?t=24512

12. How can I display a checkbox in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=88376

http://www.sapfans.com/forums/viewtopic.php?t=40968

http://www.sapfans.com/forums/viewtopic.php?t=6919

follwing is list of events :

Only events with a form routine name are processed.

The I_EVENTS table returns with the following possible constants:

1. Slis_ev_item_data_expand TYPE slis_formname VALUE 'ITEM_DATA_EXPAND'.

Only relevant for hierarchical-sequential lists using the layout parameter IS_LAYOUT-EXPAND_FIELDNAME of the structure IS_LAYOUT. Exit for passing item entries (ITEM table) for a header record that was expanded interactively by the user.

2. Slis_ev_reprep_sel_modify TYPE slis_formname VALUE 'REPREP_SEL_MODIFY'.

RS_SELFIELD-TABINDEX contains the header table index for which the item entries are to be put in the global item output table (T_OUTTAB_SLAVE). The Callback is only called if ALV has no items for a header that is to be expanded.

RFLG_ALL is passed with 'X' if the user shows all items. The application must ensure that entries are not repeated in the item table.

RS_SELFIELD is initial in this case.

3. Slis_ev_caller_exit_at_start TYPE slis_formname VALUE 'CALLER_EXIT'.

Is called at the beginning of the function module to make special settings. It is not usually used.

4. Slis_ev_user_command TYPE slis_formname VALUE 'USER_COMMAND'.

As this is a frequently-used Callback event, the form routine can also be passed directly in the interface by passing the user command in the IMPORTING parameter I_CALLBACK_USER_COMMAND.

5. Slis_ev_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.

Equivalent to the list processing TOP-OF-PAGE event.

6. Slis_ev_top_of_coverpage TYPE slis_formname VALUE 'TOP_OF_COVERPAGE'.

The selection information and list status are output together (if they exist) on a separate page by default

7. Slis_ev_end_of_coverpage TYPE slis_formname VALUE 'END_OF_COVERPAGE'.

Analogously to TOP_OF_COVERPAGE the user can add other information

to the information output by ALV (selection information, list status) at this event.

8. Slis_ev_foreign_top_of_page TYPE slis_formname VALUE ‘FOREIGN_TOP_OF_PAGE'.

The Top-of-page event is always processed in ALV and is only passed to the caller via the Callback mechanism. This is still the case if the caller, e.g. by a user action, processes a branch list which was not formatted by ALV (e.g. a popup with additional information about the list record selected and displayed by ALV).

In this case, top-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event top-of-page still occurs in ALV. When ALV notices a top-of-page which was not caused by an ALV output, the form routine in FOREIGN_TOP_OF_PAGE is called.

9. Slis_ev_foreign_end_of_page TYPE slis_formname VALUE 'FOREIGN_END_OF_PAGE'.

The event end-of-page is always processed in ALV and only passed to the caller via callback. This is still the case, e.g. when the caller processes a details list which was not formatted by ALV (e.g. a popup with further information about selected list records which were displayed by ALV).

In this case, end-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event end-of-page still occurs in ALV. When ALV notices an end-of-page that was not caused by an ALV output, the form routine in FOREIGN_END_OF_PAGE is called.

10. Slis_ev_pf_status_set TYPE slis_formname VALUE 'PF_STATUS_SET'.

If a user list status is to be set, it must be done in the form routine assigned to this event. The ALV function codes, which must not be active, are in the Parameter RT_EXTAB. This table must be passed with the SET PF-STATUS command (with inactive user function codes as well, if necessary).

The STANDARD status of the function group SALV should be used as a template for a user-specific status. As this is a frequently used Callback event, its form routine can also be passed directly in the interface in the IMPORTING parameter I_CALLBACK_PF_STATUS_SET.

11. Slis_ev_list_modify TYPE slis_formname VALUE 'LIST_MODIFY'.

LIST_MODIFY USING R_TABNAME TYPE SLIS_TABNAME

R_INDEX LIKE SY-TABIX

R_INDEX_ITEM LIKE SY-TABIX

R_INDEX_SUM LIKE SY-TABIX.

12. Slis_ev_top_of_list TYPE slis_formname VALUE 'TOP_OF_LIST'.

Information output at the start of the list

13. Slis_ev_end_of_page TYPE slis_formname VALUE 'END_OF_PAGE'.

Information output at the end of a page. This is only called for printing.

14. Slis_ev_end_of_list TYPE slis_formname VALUE 'END_OF_LIST'.

Information output at the end of the list

15. Slis_ev_after_line_output TYPE slis_formname VALUE 'AFTER_LINE_OUTPUT'.

Output information after each output line. Should only be used in justified cases because it costs a lot of performance.

16. Slis_ev_before_line_output TYPE slis_formname VALUE 'BEFORE_LINE_OUTPUT'.

Output information before each output line. Should only be used in justified cases because it costs a lot of performance.

17. Slis_ev_subtotal_text TYPE slis_formname VALUE 'SUBTOTAL_TEXT'.

This event table (I_EVENTS) is now checked with the desired constants. If the desired constant is found, then the corresponding field for the FORM NAME is populated with the name of the routine containing the corresponding event.

plz reward points if helpful..

Regards,

Chandru

Read only

Former Member
0 Likes
1,385

Hi Lakshmi,

The aims of this part is to present the main technical functionalities of ALV.

The function ‘Abap List Viewer’ report information with the function “REUSE_ALV_LIST_DISPLAY”, after initialisation of:

• Field for output table

• Format of layout

• Events like ‘Top of page’

• Printing

• Display variant

1.1. Function “REUSE_ALV_LIST_DISPLAY”

1.1.1. Functionality

This module outputs an internal table with any structure as a formatted one-line or multiple-line list.

1.1.2. Principle:

• Pass an internal table with the set of output information

• Pass a structure with general list layout details

• Pass a field catalogue as an internal table

The field catalogue describes the fields to be output in the list.

1.1.3. Notes

• All actions on the list refer directly to the internal output table, e.g. sorting the list also sorts the passed internal output table (passed by reference).

• An important consideration for the use of the tools and certain generic functions (totals, subtotals) is the expected amount of data to be displayed.

The application must take this consideration into account.

2. “REUSE_ALV_LIST_DISPLAY” MAIN PARAMETERS

2.1. I_INTERFACE_CHECK

Interface consistency check log output

2.1.1. Description

To avoid overloading list output with interface consistency checks, they are only made in an extra call mode.

If this parameter is 'X', the consistency of the interface is checked when the function module is called, and an error log is output.

This parameter should only be set for development test purposes (e.g. in debugging).

The interface check can also be made on the results list by entering the function code &SOS.

2.1.2. Default

SPACE

2.2. I_CALLBACK_PROGRAM

Name of the calling program

2.2.1. Description

Program which calls the function module and contains the exit routines. It must be a Report, Function group, Module pool or Form routine pool (not an Include).

Note: Never pass SY-REPID directly in the interface. If the desired program name is in SY-REPID, it must be assigned to an intermediate variable which is then passed to the interface.

2.3. I_CALLBACK_PF_STATUS_ST

Set EXIT rountine to status

2.3.1. Description

Passing an EXIT routine tells the ALV that the caller wants to set his or her own user status. In this case, the default ALV status is not set. The form routine interface must be defined as follows:

FORM set_pf_status USING rt_extab TYPE slis_t_extab

The table RT_EXTAB contains those function codes that are hidden on the standard interface.

If the caller wants to use his or her own interface (to offer other functions on the list or transfer existing functionality, for example), it is recommended that he or she copy the standard status STANDARD from function group SALV and make the appropriate changes. Standard ALV function codes always begin with '&'.

Please consult the documentation on the I_CALLBACK_USER_COMMAND parameter as well.

If, however, the user chooses to use his or her own interface that contains the standard interface's function codes, the function codes from the excluding table passed must also be taken into consideration. This means that the user status should always be set as follows:

SET PF-STATUS usrstatus EXCLUDING rt_extab.

Excluding table rt_extab can be appended to include those application functions that are to be deactivated. The system calls this routine whenever the standard interface is set using SET PF-STATUS.

2.3.2. Default

If no exit routine is entered, then the ALV sets a status that corresponds to the STANDARD status of function group SALV.

2.4. I_CALLBACK_USER_COMMAND

EXIT routine for command handling

2.4.1. Description

Passing an EXIT routine tells ALV that the application wants to react to certain function codes itself. These are general function codes which ALV does not recognize (not ALV standard functions) and which were defined and set by an application status.

See also the documentation of the parameter I_CALLBACK_PF_STATUS_SET.

The interface of the specified form routine must be defined as follows:

FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.

The parameter R_UCOMM contains the function code called.

The structure RS_SELFIELD contains the following information:

• tabname : internal output table name

• tabindex : internal output table index

• fieldname: field name of cursor position

• sel_tab_field: cell name of cursor position (internal ALV table name field

• endsum : cursor is on the final total row

• sumindex : if >0, the cursor is on a subtotal row

• value : field value on the list

• refresh : (exporting) list is to be refreshed

• col_stable:(exporting) keep column positions in refresh

• row_stable:(exporting) keep row positions in refresh

• exit :(exporting) leave list (and ALV)

• before_action: jump before performing standard action

• after_action : jump after performing standard action, before creating list

• ignore_multi : internal use

The exit routine always runs when a function code occurs which ALV does not recognize, or a jump before or after a standard function code is defined by the interface parameter IT_EVENT_EXIT.

See also the documentation of the parameter IT_EVENT_EXIT.

The function code and current cursor position information are passed to the calling program via the exit routine.

If several lines are selected by marking checkboxes, the output table checkbox field contains the current status of the checkbox in the list.

2.5. I_STRUCTURE_NAME

Internal output table structure name

2.5.1. Description

If the internal output table is defined via an ABAP/4 Dictionary structure (INCLUDE STRUCTURE struct or LIKE struct), the field catalog can be built-up automatically by passing the structure name.

The field catalog is internally built up for this structure as follows:

• All fields are in the list (NO_OUT = SPACE) except fields of data type CLNT.

• The key fields of the Dictionary structure are also key fields in the field catalog.

• Dictionary references to unit fields are copied if the reference fields are in the structure.

• If a field catalog is also passed as parameter, the structure information is combined with this field catalog.

For further information about the automatic build-up of the field catalog, see the documentation of the function module REUSE_ALV_FIELDCATALOG_MERGE.

2.6. IS_LAYOUT

List layout specifications

2.6.1. Description

Output list description structure.

The parameters are described under the following headers:

• Display options

• Exceptions

• Totals

• Interaction

• Detail screen

• Display variants (only for hierarchical-sequential lists)

• Color

• Other

Note the section 'Default'.

Display options

• colwidth_optimize

value set: SPACE, 'X' 'X' = optimzes the column width so that all contents are displayed completely.

• no_colhead

value set: SPACE, 'X' 'X' = column headers are not output

• zebra

value set: SPACE, 'X' 'X' = striped pattern (e.g. for wide lists)

• no_vline (not relevant for: hierarchical-sequential lists and multiple-line lists.)

value set: SPACE, 'X' 'X'= columns separated by SPACE

• no_min_linesize (not relevant for block lists)

value set: SPACE, 'X' X' = line size depends on list width

' ' = line size is set to 80 or MIN_LINESIZE (if > 0) .

• min_linesize

value set: 0, 10 – 250 minimum width of the list (to change default of 80)

If the list is wider, the format uses the list width (maximum 250 or MAX_LINESIZE (if > 0)).

prerequisite: no_min_linesize = ' '.

• max_linesize

value set: 0, 80 – 1020 maximum list width (to change the default of 250)

interactively-definable maximum list width setting.

Caution: wide lists are difficult to read and to print.

Exceptions

• lights_fieldname

value set: SPACE, internal output table field name

internal output table field containing the codes of exceptions to be output.

Output table field code:

'1' = red traffic light

'2' = yellow traffic light

'3' = green traffic light

• lights_tabname (Only relevant for hierarchichal-sequential lists.)

value set: SPACE, internal output table name

Name of the internal output table which contains the field in the parameter LIGHTS_FIELDNAME. If LIGHTS_FIELDNAME is not empty, this field must also be filled for hierarchical-sequential lists.

• lights_rollname

value set: SPACE, data element name

The documentation of this data element is displayed when you call F1 help for an exception column.

• lights_condense

value set: SPACE, 'X' 'X' = the 'maximum' exception of the items in the subtotal is output at subtotal level.

Ex.: if a list record is output with 'red traffic light', each subtotal which includes this record is also output with 'red traffic light'.

Totals

• no_sumchoice

value set: SPACE, 'X' 'X' = fields which are to be summed, passed by the calling program (FIELDCAT-DO_SUM = 'X'). The user should not be able to change this value interactively.

• no_totalline

value set: SPACE, 'X' 'X' = no total record is to be output. Subtotals can still be calculated and output. The fields in the subtotals are flagged DO_SUM = 'X' in the field list.

• no_subchoice

value set: SPACE, 'X' 'X' = value whose change triggers subtotals, provided by the calling program. The user should not be able to change this value interactively.

See also the documentation of the IMPORTING parameter IT_SORT.

• no_subtotals

value set: SPACE, 'X' 'X' = no subtotals.

• totals_only

value set: SPACE, 'X' 'X' = only total records are output.

an interactive breakdown of simple and hierarchical-sequential lists is possible. prerequisite: the IMPORTING parameter IT_SORT contains the sort criteria and subtotal flags.

See also the documentation of the IMPORTING parameter IT_SORT.

• totals_text

value set: SPACE, string(max.60) ' ' = the first column in the total record contains an appropriate number of ''s to indicate the total by default. If the first column is wide enough, the string 'Total' is output after the asterisks. 'string' = the string passed is output after the total indicated by '', if the column is wide enough.

• subtotals_text

value set: SPACE, string(max.60) ' ' = in the first column of subtotal records, the subtotal is indicated by an appropriate number of '*' by default. If the first column is not a subtotal criterion, the string 'Total' is output after the asterisks, if the column is wide enough.

'string' = the string passed is output after the subtotal indicated by '*', if the column is wide enough and the first column is not a subtotal criterion.

If it is a subtotal criterion, its value is repeated after the total, if the column is wide enough.

• numc_sum

value set: SPACE, 'X' ' ' = by default NUMC fields cannot be totalled

'X' = NUMC fields can be totalled. If this flag is set, the total can be controlled via the FIELDCAT-NO_SUM parameter per NUMC column.

Interaction

• box_fieldname

value set: SPACE, internal output table field name

if the list has checkboxes at the start of records (for selecting several records), this parameter contains the internal output table field name indicated by the checkbox selection column.

The field is a checkbox at the start of list records without a list header.

• box_tabname

value set: SPACE, internal output table name

Only relevant for hierarchical-sequential lists. Name of the internal output table which contains the field in the parameter BOX_FIELDNAME. If BOX_FIELDNAME is not empty, this field must also be filled for hierarchical-sequential lists.

• no_input

value set: SPACE, 'X'

'X' = all ready-for-input fields in a list are displayed as not ready-for-input.

(record selection checkboxes and fields which can be made ready-for-input via the field list parameter FIELDCAT-INPUT = 'X')

• expand_fieldname

value set: SPACE, internal header table field name

Only relevant for hierarchical-sequential lists

if hierarchical-sequential list items are to be expandable and collapsable, the internal header table must contain an additional CHAR(1) field which contains the expansion status of the header entry.

The name of this field must be assigned to the parameter IS_LAYOUT-EXPAND_FIELDNAME.

The initial value of the field in the header table is that the items are not displayed and the folder symbol SYM_PLUS_FOLDER appears in the list before the header entry.

If the field contains 'X' for a header entry, the items for this header appear, and the folder symbol SYM_MINUS_FOLDER appears on the list before the header entry.

The user can show or hide the items by clicking on the folder symbol (hotspot).

If the items for a header entry are only to be read by the calling program and passed to ALV when a header has been expanded interactively, this can be controlled via the CALLBACK event 'ITEM_DATA_EXPAND'.

See also the documentation of the parameter IT_EVENTS.

• f2code

value set: SPACE, function code

meaning in the ALV standard interface: To assign an ALV standard function code to double-click (F2), assign the function code to this parameter.

Ex.: to assign the ALV standard function 'Detail' ('&ETA') to F2.

=> LAYOUT-F2CODE = '&ETA'

Effect in 'user interface':

Case 1: the ALV standard function code for F2 '&IC1' is left in the copied application interface, but F2 is to have a function which is not under F2 in the interface (ALV standard function or application function). Pass this function codeto ALV in the parameter F2CODE.

Case 2: The ALV standard function code for F2 '&IC1' was deleted from the application interface and replaced by another function code (ALV standard function or application function). Pass this function code to ALV in the parameter F2CODE. This is the prerequisite for column selection in this case.

• confirmation_prompt

value set: SPACE, 'X' 'X' = if one of the functions 'Back(F03)', 'Exit(F15)' or 'Cancel(F12)' occurs, a confirmation prompt appears.

• key_hotspot

value set: SPACE, 'X' The columns defined in the field catalog as key fields

(FIELDCAT-KEY = 'X') are output as hotspots, i.e. clicking on a key column (highlighted in color in the list) calls the function under F2.

• reprep

value set: SPACE, 'X' 'X' = activate Report/Report interface:

prerequisite: application system (=> Report RKKBRSTI exists).

List module is a possible sender in the Report/Report interface logic (poss. initialization of the interface...). The calling report/module pool... of type RT=Report in I_CALLBACK_PROGRAM is passed to the Report/Report interface as sender report. If the sender report is assigned to receiver reports in the table TRSTI, the function code BEBx is active (x = function code class).

Example: If Report Writer report group 7KOI with function code class '3' (SAP setting) is assigned as a receiver for the sender RKTFGS15, this receiver report group is called by function code 'BEB3' via the Re/Re interface. The report restrictions and the key information of the selected records are passed to the Re/Re interface as selection criteria.

For further information about the Report/Report interface see the documentation of the function group 'RSTI'.

• group_buttons Not relevant for block lists (output of several lists consecutively)

value set: SPACE, 'X'

Prerequisite:

Group output fields via FIELDCAT-SP_GROUP in the field list, and pass the group name to the list module in the interface parameter IT_SPECIAL_GROUPS.

Further information: See the documentation of the IMPORTING parameter IT_SPECIAL_GROUPS. and the field catalog parameter FIELDCAT-SP_GROUP of the IMPORTING parameter IT_FIELDCAT.

' ' = if the prerequisite is fulfilled, but the parameter is not set, the function code '&OL0' calls the display variant popup in which you can show the visible fields in the field list by their groups. All fields in the field list are visible by default. The user can go to the group views in the popup.

The fields can be classified into any number of logical groups (1:n).

'X' = a maximum of five logical groups can be formed. The display variant popup for each of these groups can be called by its own function in the interface. The fields in the field list belong to this group. The ALV standard interface contains pushbuttons for the first three groups (the first three entries in the internal table IT_SPECIAL_GROUPS). The group text passed in IT_SPECIAL_GROUPS is displayed as pushbutton text. The display variant popup for the fourth and fifth groups can be called via the right-hand mouse key function selection. When the display variant popup for a field group is called, that group is selected, but the user can change the group view in the popup. The function codes &OLx (x=1,2,3,4,5) call the display variant popups for the respective group.

There are pushbuttons for the function codes &OL1, &OL2 and &OL3 in the ALV standard interface (function group KKBL status STANDARD). The functions &OL4 and &OL5 only have function keys.

A group 'All fields' is added by the System when grouping logic is used (= the above prerequisite is satisfied), regardless of the setting of this parameter.

• no_keyfix Not relevant for block lists (output of several lists consecutively)

value set: SPACE, 'X'

' ' = the key columns defined in the field catalog by FIELDCAT-KEY = 'X' are fixed in the list output. These columns do not scroll horizontally. The item table key columns are fixed in hierarchical-sequential lists. The header table key fields are not considered here.

'X' = key columns not fixed. The user can change these general settings interactively.

To fix a column by default which is not a key column, set the parameter to 'X' and control it via the field list. See the documentation of the field list parameter FIELDCAT-FIX_COLUMN of the IMPORTING parameter IT_FIELDCAT.

• get_selinfos

value set: SPACE, 'X'

If the calling program is a report with an ABAP/4 selection screen, setting this parameter makes ALV read the selection screen again. If the selections are read successfully, a pushbutton, via which the user can call a popup which lists the report selections in a simple form, becomes active on the results list output by ALV. The contents of this popup are printed, if the interface IS_PRINT structure parameter NO_PRINT_SELINFOS is not set. You can ensure that they are printed on a separate page by setting the parameter IS_PRINT-NO_COVERPAGE.

For more information about printed output, see the documentation of the parameter IS_PRINT.

• group_change_edit

value set: SPACE, 'X'

'X' = the user can enter a format option for each sort criterion in the sort/subtotal popup, for the list format when this value changes (e.g. new page or undeline).

For further information about sorting see the documentation of the parameter IT_SORT.

Detail screen

• detail_popup

value set: SPACE, 'X' ' ' = list record detail display in full-screen mode, with top-of-page.

'X' = list record detail display in popup (without top-of-page).

• detail_initial_lines

value set: SPACE, 'X' ' X' = initial field contents are also output in detail.

' ' = only fields whose contents are not initial are output in the detail view.

• detail_titlebar

value set: SPACE, string(max.30)

' ' = 'Detail: Display' is output as the title of the detail window.

'string' = the string passed is output as the title of the detail window.

Display variants (only relevant for hierarchical-sequential lists)

• header_text only relevant for hierarchical-sequential lists

value set: SPACE, CHAR(20)

you can toggle between display field and field list views via pushbuttons in the display variant definition popup for hierarchical-sequential lists. The views refer to the hierarchy level of the fields. This is technically a toggle between the header table and item table fields.

' ' = the header table field pushbutton text is 'Header' by default. CHAR(20) = header table field pushbutton text.

• item_text only relevant for hierarchical-sequential lists

value set: SPACE, CHAR(20)

You can toggle the view between the display fields and the field list via pushbuttons in the display variant definition popup for hierarchical-sequential lists. The views refer to the hierarchy level of the fields. This is technically a toggle between the header table and item table fields.

' ' = the pushbutton text for the item table fields is 'Item' by default. CHAR(20) = item table field pushbutton text.

• item_default only relevant for hierarchical-sequential lists

value set: SPACE, 'X'

' ' = the header table fields are displayed by default in the display variant definition popup. The user can switch to the item table fields interactively.

'X' = the item table fields are displayed by default in the display variant Definition Popup. The user can switch to the header table fields interactively.

Color

• info_fieldname

value set: SPACE, internal output table field name

A whole list record can be colored individually using a color code in a column of the internal output table for the record. Assign the name of the field containing the color code to this parameter. The internal output table field must be of type CHAR(3).

The code must have the following syntax: 'Cxy':

C = color (all codes must start with 'C')

x = color number ('1'-'9')

y = bold ('0' = off, '1' = on)

Note: the color of the key columns is not affected. Key columns can be colored at record or cell level using the complex coloring which is described in the next parameter COLTAB_FIELDNAME.

To color columns, see the documentation of the field catalog parameter FIELDCAT-EMPHASIZE of the IMPORTING parameter IT_FIELDCAT.

• coltab_fieldname

value set: SPACE, internal output table field name

Cells can be colored individually using a color code which is contained in a column of the internal output table for the record containing the cell.

Assign the name of the field to this parameter.

The internal output table field must be of type SLIS_T_SPECIALCOL_ALV.

Principle: the color code field is entered for the record containing the cells to be colored. The field contains an internal table with the above structure, containing the field names of the cells to be colored and the color code. The cell coordinates are determined by the record position containing the color code and the column information in the color table.

The record structure of the internal color table of type SLIS_T_SPECIALCOL_ALV is as follows:

Color table-FIELDNAME = field name of the cell to be colored

Color table-COLOR-COL = color number (1 - 9)

Color table-COLOR-INT = bold (0 = off, 1 = on)

Color table-COLOR-INV = inverse (0 = off, 1 = on)

Color table-NOKEYCOL = ignore key coloring ('X' = yes, ' ' = no)

If the parameter color table-FIELDNAME is not filled, the coloring applies to all fields, so the entire record is colored.

Others

• list_append These operations are not possible for user-defined block lists.

value set: SPACE, 'X'

only relevant for block lists which are not output with the REUSE_ALV_BLOCK_... modules.

It is only useful to output block-lists without specifying the above modules if the number of list blocks exceeds, or may exceed, the maximum number specified in the block module documentation.

Principle: to output a list of n blocks. Call the function module for the list type for the first block.

The caller must enter the maximum list width of the n blocks in the parameter LAYOUT-MIN_LINESIZE in the first call. The event table IT_EVENTS of the event END_OF_LIST must contain the associated form routine name (see also the documentation of the interface parameter

IT_EVENTS). The parameter LAYOUT-LIST_APPEND must be initial.

After the first list has been output, the form routine specified in the event END_OF_LIST is called by Callback. The remaining n-1 blocks are then output by calling the function module for the list type. The parameter LAYOUT-LIST_APPEND must be set = 'X' for these n-1 calls. The event table IT_EVENTS should not contain the event END_OF_LIST or at least be assigned to a different form routine name from the first call.

2.6.2. Default

The default layout settings can often be retained, so that you do not have to pass this structure with changed flags.

2.7. IT_FIELCAT

Field catalog with field descriptions

2.7.1. Description

Field catalog containing descriptions of the list output fields (usually a subset of the internal output table fields). A field catalog is required for every ALV list output.

The field catalog for the output table is built-up in the caller's coding. The build-up can be completely or partially automated by calling the REUSE_ALV_FIELDCATALOG_MERGE module

See also the documentation of the function module REUSE_ALV_FIELDCATALOG_MERGE.

The minimal field catalog is documented under 'default'. The caller can use the other optional parameters to assign output attributes to a field which differ from the default.

A field catalog need not be built-up and passed explicitly only under the following conditions:

• The internal table to be output has the same structure as a Data Dictionary structure which is referred to in the internal table declaration using LIKE or INCLUDE STRUCTURE.

• all fields in this structure are to be output

• the structure name is passed to ALV in the parameter I_STRUCTURE_NAME.

See also the documentation of the IMPORTING paramter I_STRUCTURE_NAME.

Positioning

• row_pos (row position)

value set: 0, 1 - 3

Only relevant if the list output is to be multi-line (two or three lines) by default.

A multi-line list can also be defined by the user interactively if the default list is one-line.

The parameter specifies the relative output line of the column in a multi-line list.

• col_pos (column position)

value set: 0, 1 - 60

only relevant when the default relative column positions differ from the field catalog field sequence. The parameter specifies the relative column position of the field in the list output. The column order can be changed interactively by the user. If this parameter is initial for all field catalog entries, columns appear in the field catalog field sequence.

Identification

• fieldname (field name)

value set: internal output table field name (required parameter)

Name of the internal output table field which is described by this field catalog entry

• tabname (internal output table)

value set: SPACE, internal output table name

This parameter is used in 'manual' field catalog build-up only for hierarchical-sequential lists.

Name of the internal output table which contains the field FIELDCAT-FIELDNAME.

Data Dictionary reference

• ref_fieldname (reference field name)

value set: SPACE, Data Dictionary field name

Name of the Data Dictionary field referred to.

This parameter is only used when the internal output table field described by the current field catalog entry has a reference to the Data Dictionary (not a program field), and the field name in the internal output table is different from the name of the field in the Data Dictionary. If the field names are identical, naming the Data Dictionary structure or table in the FIELDCAT-REF_TABNAME parameter is sufficient.

• ref_tabname (reference table/structure field name)

value set: SPACE, name of a Data Dictionary structure or table

Structure or table name of the referred Data Dictionary field.

This parameter is only used when the internal output table field described by the current field catalog entry has a Data Dictionary reference (not a program field).

Reference to fields with currency/measurement unit

Each internal output table sum or quantity field whose decimal places are to be formatted appropriately for the unit in the list must follow the convention:

• the field is of data type QUAN or CURR (internal type P) (the field must really have this physical data type. Overwriting the physical data type with the parameter FIELDCAT-DATATYPE has no effect)

• There is a field in the internal output table which contains the associated unit.

• There is also an entry in the field catalog for the unit field.

(If the unit is not to appear as a column in the list, and cannot be interactively displayed as a column, e.g. because it is always unambiguous and is therefore explicitly output by the caller in the list header, the field catalog units field entry can take the parameter FIELDCAT-TECH = 'X'.

The association of a value field to a unit affects the output as follows:

• appropriate decimal places display for the unit

• an initialized field with a link to a non-initial unit is output as '0' for the unit (if FIELDCAT-NO_ZERO is initial). When this field is summed, this unit affects whether the units are homogeneous.

• an initialized field with a link to an initial unit is output as SPACE. When this field is summed, the unit SPACE does not affect the homogeneity of the units.

• When non-initial fields with an initial unit are summed, the unit SPACE is considered to be a unit.

Link to currency unit

• cfieldname (currency unit field name)

value set: SPACE, output table field name

Only relevant for amount columns with associated unit.

Name of the internal output table field containing the currency unit associated with the amount field FIELDCAT-FIELDNAME. The field in FIELDCAT-CFIELDNAME must have its own field catalog entry.

• ctabname (internal currency unit field output table)

value set: SPACE, output table field name

only relevant for hierarchical-sequential lists

Name of the internal output table containing the FIELDCAT-CFIELDNAME field.

Link to measurement unit

• qfieldname (measurement unit field name)

value set: SPACE, output table field name

only relevant for quantity columns with unit link.

Name of the internal output table field containing the measurement unit associated with the quantity field FIELDCAT-FIELDNAME.

The field in FIELDCAT-QFIELDNAME must have its own field catalog entry.

• qtabname (internal measurement unit field output table)

value set: SPACE, output table field name

only relevant for hierarchical-sequential lists

Name of the internal output table containing the FIELDCAT-QFIELDNAME field.

Column output options

• outputlen (column width)

value set: 0 (initial), n

For fields with a Data Dictionary link this parameter can be left initial.

For fields without a Data Dictionary link (program field) the parameter must be given the value of the desired field list output length (column width).

initial = column width is the output length of the referred Data Dictionary field (domain).

n = column width is n characters

• key (key column)

value set: SPACE, 'X' 'X' = kex field (key field output in color)

Key fields can not be interactively hidden. Parameter FIELDCAT-NO_OUT must be left initial.

For exceptions see the documentation of the FIELDCAT-KEY_SEL parameter.

• key_sel (hideable key column)

value set: SPACE, 'X'

only relevant when FIELDCAT-KEY = 'X'

Key field which can be hidden interactively.

The key column sequence cannot be changed interactively by the user.

The output is controlled by the FIELDCAT-NO_OUT parameter analogously to non-key fields.

• no_out (field in field list)

value set: SPACE, 'X' 'X' = field is not displayed in the current list.

The user can interactively choose the field for output from the field list.

The user can display the contents of these fields at line level using the 'Detail' function.

See also the 'Detail screen' documentation of the parameter IS_LAYOUT.

• tech (technical field)

value set: SPACE, 'X' 'X' = technical field

Field cannot be output in the list and cannot be displayed interactively.

Field can only be used in the field catalog (not in IT_SORT, ...).

• emphasize (highlight columns in color)

value set: SPACE, 'X' or 'Cxyz' (x:'1'-'9'; y,z: '0'=off '1'=on)

'X' = column is colored with the default column highlight color.

'Cxyz' = column is colored with a coded color:

• C: Color (coding must begin with C)

• x: color number

• y: bold

• z: inverse

• hotspot (column as hotspot)

value set: SPACE, 'X'

'X' = column cells are output as hotspots

• fix_column (fix column)

value set: SPACE, 'X'

Not relevant for block lists (output of several lists consecutively)

'X' = column fixed (does not scroll horizontally)

All columns to be fixed must have this flag, starting from the left. If a column without this flag is output, only the columns to the left of this column are fixed. The user can change the column fixing interactively. See also the documentation of the Layout parameter

IS_LAYOUT-NO_KEYFIX of the IMPORTING paramter IS_LAYOUT.

• do_sum (sum over column)

value set: SPACE, 'X' 'X' = a sum is to be calculated over this internal output table field.

This function can also be called by the user interactively.

• no_sum (sums forbidden)

value set: SPACE, 'X' 'X' = no sum can be calculated over this field, although the data type of the field would allow summing.

• input (column ready for input)

Function not available

Format column contents

• icon

value set: SPACE, 'X' 'X' = column contents to be output as an icon.

The caller must consider the printability of icons.

• symbol

value set: SPACE, 'X' 'X' = column contents are to be output as a symbol.

The internal output table column must be a valid symbol character.

The caller must consider the printability of symbols.

Symbols can usually be printed, but may not always be output correctly, depending on the printer configuration.

• just (justification)

value set: SPACE, 'R', 'L', 'C'

Only relevant for fields of data type CHAR or NUMC

' ' = default justification for this data type

'R' = right-justified output

'L' = left-justified output

'C' = centered output

The justification of the column header always follows the justification of the columns. Independent justification of the column neader is not possible.

• lzero (leading zeros)

value set: SPACE, 'X'

Only relevant for fields of data type NUMC

ALV outputs NUMC fields right-justified without leading zeros by default.

'X' = output with leading zeros

Note: If a NUMC field is output left-justified or centered by FIELDCAT-JUST, leading zeros are output. If the output of leading zeros is suppressed by a Data Dictionary reference ALPHA conversion exit, the output is always left-justified.

• no_sign (no +/- sign) Only relevant for value fields

value set: SPACE, 'X' 'X' = value output without +/ sign

• no_zero (suppress zeros) Only relevant for value fields

value set: SPACE, 'X' 'X' = suppress zeros

• edit_mask (field formatting)

value set: SPACE, template

template = see documentation of WRITE formatting option USING EDIT MASK template

The output conversion conv can be made by template = '== conv'.

Texts

The following text parameters should be specified for program fields without a Data Dictionary reference. The texts are taken from the Data Dictionary for fields with a Data Dictionary reference. If this is not desired, the text parameters can also be specified. The Data Dictionary texts are then ignored. If the user changes the column width interactively, the column header text with the appropriate length is always used. The interactive function 'Optimize column width' takes account of both the field contents and the column headers: if all field contents are shorter than the shortest column header, the column width depends on the column header.

The 'long field label' is also used in display variant definition, sort, etc. popups.

• seltext_l (long field label)

• seltext_m (medium field label)

• seltext_s (short field label)

• reptext_ddic (header)

analogous to the Data element maintenance 'Header'

The specified text is not necessarily output in the list, an optimum among all texts is sought.

• ddictxt (specify text)

value set: SPACE, 'L', 'M', 'S'

You can specify with values 'L', 'M', and 'S', the keyword that should always be used as column header. If the column width changes, no attempt is made in this case to find an appropriate header for the new output width.

Parameters for program fields without Data Dictionary reference

see also 'Text' parameters

• datatype (data type)

value set: SPACE, Data Dictionary data type (CHAR, NUMC,...)

Only relevant for fields without Data Dictionary reference

Program field data type

• ddic_outputlen (external output length)

value set: 0 (initial), n

Only relevant for fields without Data Dictionary reference whose output is nevertheless to be modified by a conversion exit.

Prerequisites:

• FIELDCAT-EDIT_MASK = '==conv'

see also the documentation of the parameter FIELDCAT-EDIT_MASK

• FIELDCAT-INTLEN = n

see also the documentation of the parameter FIELDCAT-INTLEN

n = external format field output length

The column width FIELDCAT-OUTPUTLEN need not be the same as the external format output length (FIELDCAT-DDIC_OUTPUTLEN).

• intlen (internal output length)

value set: 0 (initial), n

Only relevant for fields without Data Dictionary reference whose output is nevertheless to be modified by a conversion exit.

Prerequisites:

• FIELDCAT-EDIT_MASK = '==conv'

see also the documentation of the parameter FIELDCAT-EDIT_MASK

• FIELDCAT-DDIC_OUTPUTLEN = n

see also the documentation of the parameter FIELDCAT-DDIC_OUTPUTLEN

n = internal format field output length

• rollname (data element)

value set: SPACE, Data Dictionary data element name

F1 help can be provided for a program field without a Data Dictionary reference, or F1 help which differs from the Data Dictionary help can be provided for a field with a Data Dictionary reference, using this parameter.

When F1 help is called for this field, the documentation of the specified data element is displayed.

If the FIELDCAT-ROLLNAME is initial for fields with a Data Dictionary reference, the documentation of the data element of the referred Data Dictionary field is output.

Others

• sp_group (field group key)

value set: SPACE, CHAR(1)

Field group key.

Keys are assigned to group names in the IT_SPECIAL_GROUPS parameter (see also the documentation of the parameter IT_SPECIAL_GROUPS).

When such an assignment is made in the field catalog and in IT_SPECIAL_GROUPS, the fields are grouped correspondingly in the display variant popup.

• reprep (Report/Report interface selection criterion)

value set: SPACE, 'X'

Prerequisites:

• The system contains the Report/Report interface (function group RSTI, table TRSTI)

• Parameter LAYOUT-REPREP = 'X'

(see also the documentation of the parameter LAYOUT-REPREP of the IMPORTING parameter IS_LAYOUT )

'X' = When the Report/Report interface is called, the value of this field is passed in the selected interface start record as a selection criterion.

2.7.2. Default

• The following entries are usually sufficient for internal table fields with a reference to a field defined in the Data Dictionary :

• fieldname

• ref_tabname

Notes:

ALV gets the remaining information from the Data Dictionary.

If no relative column position (COL_POS) is specified, the fields are output in the list in the order in which they were added to the field catalog.

REF_FIELDNAME need only be specifid when the name of the internal table field differs from the name of the referred Data Dictionary field.

Information which is explicitly entered in the field catalog is not overwritten by information from the Data Dictionary.

Priority rule:

Entries in the field catalog have priority over differing entries in the Data Dictionary.

• The following entries are usually sufficient for internal table fields without a reference to the Data Dictionary (program fields):

• fieldname

• outputlen

• datatype

• seltext_s

• seltext_m

• seltext_l

Notes:

F1 help can be provided for program fields by assigning a data element to the parameter ROLLNAME.

If the parameters SELTEXT_S, SELTEXT_M, SELTEXT_L, and REPTEXT_DDIC contain appropriate field labels, the program field column headers are also adjusted appropriately when the column width changes.

2.8. IT_EXCLUDING

Table of inactive function codes

2.8.1. Description

The optional IMPORTING parameter IT_EXCLUDING is an internal table. It is only needed if the caller uses the list tool standard interface but wants to deactivate interface functions which he or she does not need. In this case the function codes of these standard functions are entered in the table.

2.9. IT_SPECIAL_GROUP

Grouping fields for column selection

2.9.1. Description

If fields have been grouped in the field catalogue by a shared value of the parameter SP_GROUP, the technical key of the group (FIELDCAT-SP_GROUP) is assigned to the field group text in this internal table.

See also the documentation of the field catalog parameter FIELDCAT-SP_GROUP of the MPORTING parameter IT_FIELDCAT and the Layout parameter LAYOUT-GROUP_BUTTONS of the IMPORTING parameter IS_LAYOUT.

2.10. IT_SORT

Sort criteria for first list display

2.10.1. Description

The caller specifies the sorting and/or subtotalling of the basic list in the internal table IT_SORT.

This internal table has the following fields:

• Spos Sort sequence

• Fieldname Internal output table field name

• Tabname Name of the internal output table

Only relevant for hierarchical-sequential lists

• Up 'X' = sort in ascending order

• Down 'X' = sort in descending order

• Subtot 'X' = subtotal at group value change

• group

'* ' = new page at group value change

'UL' = underline at group value change

The formatting options are constants of the domain SLIS_CTRLS.

See also the documentation of GROUP_CHANGE_EDIT of the interface structure IS_LAYOUT

for more information about group value change formatting.

• comp (INTERNAL USE ONLY)

• expa

Prerequisite:

IT_SORT-SUBTOT = 'X', i.e. sort criterion is also subtotal criterion

If the first list output is only to be expanded to total level n, and can then be further expanded interactively by the user, the flag should be set at the total level criterion for level n

2.11. IT_FILTER

Filter criteria for first list output

2.11.1. Description

Filter criteria table. Filter criteria which result, e.g. from explicitly loading an initial display variant, can be passed to list output in this parameter. This table should never be built-up 'manually'.

2.12. IS_SEL_HIDE

Selection information modification

2.12.1. Description

Only relevant when the layout parameter

LAYOUT-GET_SELINFOS of the IMPORTING structure IS_LAYOUT is set.

Complex type for modifying the information displayed in the selection info popup:

• mode: 'R' = only the entries passed in the internal table IS_SEL_HIDE-T_ENTRIES are output in the popup. Selection info which the list tool read in the selection screen (when called by a report with a selection screen) are replaced by the values passed.

'S' = the selection info which the list tool read in the selection screen of the calling report are modified by the entries in the table IS_SEL_HIDE-T_ENTRIES.

• t_entries: Selection info table

• t_entries-mode: 'A' = output the selection info for the current table record additionally in the info popup.

'D' = do not output select option or SELNAME parameter selection info in the popup.

• t_entries-selname: (only used in t_entries-mode = 'D') Name of the select option or parameter.

The following table fields are only used in t_entries-mode = 'A'. They contain the selection information to be added.

• t_entries-field: DDIC field name of the field for which selection information is to be output.

• t_entries-table: DDIC table names of t_entries-field.

• t_entries-stext: Field name in info popup.

If t_entries-field and t_entries-table have been entered, this text is taken from DDIC.

• t_entries-valuf: Selection condition 'from' value (external format)

• t_entries-valut: Selection condition 'to' value (external format)

• t_entries-sign0: (I)nclusive (E)xclusive

• t_entries-optio: All values of the select options Option field allowed.

The remaining fields are used internally and are not relevant for the caller.

2.13. I_DEFAULT

Initial variant active/inactive logic

2.13.1. Description

Initial variant logic active/inactive.

Prerequisite: The parameter IS_VARIANT has the appropriate value.

See also the documentation of the IMPORTING parameter IS_VARIANT.

2.13.2. Value Range

SPACE = no initial variant can be defined 'X' = initial variant can be defined

2.13.3. Default

SPACE

2.14. I_SAVE

Variants can be saved

2.14.1. Description

Controls the storage mode

Prerequisite: The IS_VARIANT parameter has the appropriate value.

See also the documentation of the IMPORTING parameter IS_VARIANT.

2.14.2. Value Range

• ' ' = display variants cannot be saved

Defined display variants (e.g. delivered display variants) can be selected for presentation independently of this flag. Changes can not be saved.

• 'X' = standard save

Display variants can be saved as standard display variants. User-specific saving is not possible.

• 'U' = only user-specific saving

The user can only save display variants user-specifically

• 'A' = standard and user-specific saving

The user can save a display variant user-specifically and as standard display variant. The user chooses in the display variant save popup.

2.14.3. Default

SPACE

2.15. IS_VARIANT

Variant information

2.15.1. Description

This structure is only relevant if display variants are to be saved and/or read. Variant information including the name of the list output variant. The access path must be specified in the fields REPORT (required field), HANDLE (optional) and/or LOG_GROUP (optional) to allow ALV to read display variants. If display variants are also to be saved, the parameter I_SAVE must also be entered.

See also the documentation of the IMPORTING parameter I_SAVE.

A variant is identified uniquely by:

• the program to which it is assigned (REPORT)

• the handle if, e.g. several lists with various structures and data are called (HANDLE) in a program (I_CALLBACK_PROGRAM)

The handle is a unique user-assigned CHAR(4) field, which assigns the call to the current internal output table structure.

Example: Various lists can be output in program x, depending on a user action.

Display variants are to be able to be defined for each of these lists.

This functionality is guaranteed by assigning a HANDLE for each list. If variants are saved for this program and handle, the handle must not change.

• the logical group if, e.g. the same list is made with different settings (LOG_GROUP) via different transactions

The logical group is a unique user-assigned CHAR(4) field which determines the assignment.

Example: The program x is called via the transactions T1 and T2. The field catalog fields offered to the user vary depending on the transaction code by assignment to logical groups.

If variants are saved for the program and logical group, the logical group must not change.

• the user name, if variants are saved user-specifically (USERNAME)

This parameter is never entered manually as the variant name is unique.

• the variant name (VARIANT).

This parameter is only to be entered if a particular variant is to be read and the list is to be output with this variant via this structure.

2.15.2. Value Range

The above fields must be specified to be able to call a list with a variant.

2.15.3. Default

If the structure is initial but saving is active (I_SAVE is not initial), IS_VARIANT-REPORT is set to I_CALLBACK_PROGRAM. The function module REUSE_ALV_VARIANT_F4 provides variant possible entry help.

2.16. IT_EVENTS

Table of events to perform

Description

This table tells ALV which events are processed by the caller by CALLBACK.

The table of possible events per list type can be initialized using the module REUSE_ALV_EVENTS_GET.

You can display the names of the constants in the type pools SLIS which represent the individual events using the individual test function in the function module

REUSE_ALV_EVENT_NAMES_GET. Only events with a form routine name are processed.

The table structure contains the fields:

• IT_EVENTS-NAME

Name of the Callback event.

Possible Callback events:

• Action

USER_COMMAND USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE SLIS_SELFIELD

Process actions on the list

As this is a frequently-used Callback event, the form routine can also be passed directly in the interface in the IMPORTING parameter I_CALLBACK_USER_COMMAND.

PF_STATUS_SET USING RT_EXTAB TYPE SLIS_T_EXTAB

If a user list status is to be set, it must be done in the form routine assigned to this event. The ALV function codes, which must not be active, are in the Parameter RT_EXTAB. This table must be passed with the SET PF-STATUS command (with inactive user function codes as well, if necessary).

The STANDARD status of the function group SALV should be used as a template for a user-specific status.

As this is a frequently-used Callback event, its form routine can also be passed directly in the interface in the IMPORTING parameter I_CALLBACK_PF_STATUS_SET.

ITEM_DATA_EXPAND USING RS_SELFIELD TYPE SLIS_SELFIELD RFLG_ALL TYPE C

Only relevant for hierarchical-sequential lists using the layout parameter IS_LAYOUT-EXPAND_FIELDNAME of the structure IS_LAYOUT.

Exit for passing item entries (ITEM table) for a header record which was expanded interactively by the user.

RS_SELFIELD-TABINDEX contains the header table index for which the item entries are to be put in the global item output table (T_OUTTAB_SLAVE). The Callback is only called if ALV has no items for a header which is to be expanded.

RFLG_ALL is passed with 'X' if the user shows all items. The application must ensure that entries are not repeated in the item table. RS_SELFIELD is initial in this case.

CALLER_EXIT USING RS_DATA Is called at the beginning of the function module to make special settings. It is not usually used.

• List processing events

IMPORTANT: The application Callback routine must not manipulate the internal output table and/or its header record. This restriction applies to all Callbacks which are called in the list output and run under the 'List processing events'.

TOP_OF_LIST no USING parameter. Information output at the start of the list

END_OF_LIST no USING parameter. Information output at the end of the list

TOP_OF_PAGE no USING parameter

Equivalent to the list processing TOP-OF-PAGE event

END_OF_PAGE no USING parameter. Not available for hierarchical-sequential lists.

Information output at the end of a page. This is only called for printing.

TOP_OF_COVERPAGE no USING parameter

The selection information and list status are output together (if they exist) on a separate page by default. See also the documentation of the parameters:

IS_PRINT-NO_COVERPAGE

IS_PRINT-NO_PRINT_SELINFOS

IS_PRINT-NO_PRINT_LISTINFOS

IS_LAYOUT-GET_SELINFOS

The user can format the header area of the 'cover page' himself or herself by specifying a Callback routine for this event.

END_OF_COVERPAGE no USING parameter

Analogously to TOP_OF_COVERPAGE the user can add other information to the information output by ALV (selection information, list status) at this event.

FOREIGN_TOP_OF_PAGE no USING parameter

The Top-of-page event is always processed in ALV and is only passed to the caller via the Callback mechanism. This is still the case if the caller, e.g. by a user action, processes a branch list which was not formatted by ALV (e.g. a popup with additional information about the list record selected and displayed by ALV).

In this case, top-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event top-of-page still occurs in ALV. When ALV notices a top-of-page which was not caused by an ALV output, the form routine in FOREIGN_TOP_OF_PAGE is called.

FOREIGN_END_OF_PAGE no USING parameter

The event end-of-page is always processed in ALV and only passed to the caller via callback. This is still the case, e.g. when the caller processes a details list which was not formatted by ALV (e.g. a popup with further information about selected list records which were displayed by ALV).

In this case, end-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event end-of-page still occurs in ALV. When ALV notices an end-of-page that was not caused by an ALV output, the form routine in FOREIGN_END_OF_PAGE is called.

BEFORE_LINE_OUTPUT USING RS_LINEINFO TYPE SLIS_LINEINFO

Output information before each output line. Should only be used in justified cases because it costs a lot of performance.

AFTER_LINE_OUTPUT USING RS_LINEINFO TYPE SLIS_LINEINFO

Output information after each output line. Should only be used in justified cases because it costs a lot of performance.

• Internal use only

LIST_MODIFY USING R_TABNAME TYPE SLIS_TABNAME

R_INDEX LIKE SY-TABIX

R_INDEX_ITEM LIKE SY-TABIX

R_INDEX_SUM LIKE SY-TABIX

• IT_EVENTS-FORM

Name of the form routine which should be called in the calling program at the event.

2.17. IT_EVENT_EXIT

Standard fcode exit requests table

2.17.1. Description

Table for passing ALV standard function codes, to return control to the user before and/or after execution with the callback event USER_COMMAND.

See also the documentation of the IMPORTING parameter I_CALLBACK_USER_COMMAND.

This table should only be passed when the application wants to react to the execution of standard functions.

This could, e.g. be to check the authorization for a standard function or to select data depending on the current display variant. The table fields are as follows:

• ucomm

Standard function code which is also passed in the callback event USER_COMMAND.

Example: ucomm = '&OL0' means that the application also gets control at the display variant definition function code.

• before

'X' = the application gets control before ALV executes the function.

• after

'X' = the application gets control after ALV has executed the function, but before the list is output.

Example: ucomm = '&OL0' and after = 'X'.

The application gets control after the user has left the display variant definition popup.

In the function code processing form routine which is passed to ALV in the I_CALLBACK_USER_COMMAND parameter, the application can now get the field catalog which may have been modified by the user, using the module

REUSE_ALV_LIST_LAYOUT_INFO_GET , and then reselect the data for the new output fieldes in the internal output table, if necessary.

If the application sets the SELFIELD-REFRESH flag (USER_COMMAND form routine interface reference parameter) after the selection, the list is output again. Output fields added by the user and reselected data now appear.

2.18. IS_PRINT

Print information

2.18.1. Description

Print control parameter

• PRINT

value set: SPACE, 'X' 'X' = the list is to be printed and not displayed on the screen. Other settings can be made in the print parameter screen.

• NO_PRINT_SELINFOS

value set: SPACE, 'X' 'X' = do not print selection info (see LAYOUT-GET_SELINFOS)

• NO_COVERPAGE

value set: SPACE, 'X' 'X' = do not print selection information and list status on a separate page.

• NO_NEW_PAGE

value set: SPACE, 'X' For internal use only

• RESERVE_LINES

value set: 0, n n = number of lines to be printed by the user in the footer area in the Callback at the event. Not relevant for hierarchical-sequential lists and block lists.

• END_OF_PAGE.

• NO_PRINT_LISTINFOS

value set: SPACE, 'X' 'X' = Do not print list status (sort, subtotal and filter information).

• NO_CHANGE_PRINT_PARAMS

value set: SPACE, 'X' 'X' = The current print parameters are used. If the list is wider, the output width is not dynamically adjusted.

SPACE = (default) The output format (number of columns) is dynamically adjusted to the list width (max. 255).

2.19. IT_SCREEN_START_COLUMN

Coordinates for list in dialog box

2.19.1. Description

Only to be used if the list is output in a popup. x coordinate of the top left-hand corner of the popup.

2.20. IT_SCREEN_START_LINE

Coordinates for list in dialog box

2.20.1. Description

Only used if the list is output in a popup. y coordinate of the top left-hand corner of the popup.

2.21. IT_SCREEN_END_COLUMN

Coordinates for list in dialog box

2.21.1. Description

Only used if the list is output in a popup. x coordinate of the bottom right-hand corner of the popup.

2.22. IT_SCREEN_END_LINE

Coordinates for list in dialog box

2.22.1. Description

Only used if the list is output in a popup. y coordinate of the bottom right-hand corner of the popup.

2.23. E_EXIT_CAUSED_BY_CALLER

Delete list in CALLBACK_USER_COMMAND

2.23.1. Description

Parameter which states whether the caller left the list (SELFIELD-EXIT = 'X') in CALLBACK USER_COMMAND

2.24. ES_EXIT_CAUSED_BY_USER

How the user left the list

2.24.1. Description

If one of the ALV standard function codes for 'Back', 'Cancel' or 'Exit' occurs, the current list is discarded and the ALV function module ends. In this case the exporting structure ES_EXIT_CAUSED_BY_USER contains one of the following flags:

• ES_EXIT_CAUSED_BY_USER-BACK = 'X' 'Back' occurred

• ES_EXIT_CAUSED_BY_USER-CANCEL = 'X' 'Cancel' occurred

• ES_EXIT_CAUSED_BY_USER-EXIT = 'X' 'Exit' occurred

The function which occured determines the further navigation in the application.

2.25. T_OUTTAB

Table with data to be displayed

2.25.1. Description

Internal table with any structure containing the data to be output in list form.

This table can contain more fields than are relevant for the list output (display fields and field list). Only the fields named in field catalog and the layout structure are used for the list output. Other internal table fields are ignored. The value of the field FIELDCAT-NO_OUT in the field catalog determines whether a field is output directly in the list, or whether this field is initially put in the field list. The user can interactively move fields between this field list and the output field list to display or hide them. If the internal table is defined in the calling program without a header, no F1 help is possible in the list.

3. “REUSE_ALV_LIST_DISPLAY” EXCEPTIONS

3.1. PROGRAMME ERRORS

Program errors

3.1.1. Exception type

If the exception is not handled by the calling program, the following applies:

(X) an error message is sent.

( ) a termination message is sent.

( ) a runtime error occurs.

Enjoii SAP