REUSE_ALV_LIST_DISPLAY- 28

light111Interactive List ALV

 

 

The previous post REUSE_ALV_LIST_DISPLAY- 27  shows how to take user input layout and pass to the list alv. This post shows how to make interactive list alv.


Code Snippet:


———-data declarations——–
TYPE-POOLS: slis.
TYPES: BEGIN OF ty_flight,
box.
INCLUDE STRUCTURE spfli.
TYPES: END OF ty_flight.
DATA: lt_spfli TYPE TABLE OF ty_flight.
DATA: ls_spfli TYPE ty_flight.
DATA: ls_layout TYPE slis_layout_alv.
DATA: lt_fieldcat TYPE slis_t_fieldcat_alv.

* Table for interactive list
DATA: lt_sflight TYPE TABLE OF sflight.
———————————–
START-OF-SELECTION.
PERFORM build_data.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_list_alv.

&————————————————-
& Form BUILD_DATA
&————————————————-*
FORM build_data.
SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE lt_spfli UP TO 20 ROWS.
ENDFORM. ” BUILD_DATA

&———————————————————————
& Form BUILD_FIELDCATALOG
&———————————————————————*
FORM build_fieldcatalog.

CALL FUNCTION ‘REUSE_ALV_FIELDCATALOG_MERGE’
EXPORTING
i_program_name = sy-cprog
i_structure_name = ‘SPFLI’
CHANGING
ct_fieldcat = lt_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.

ENDFORM. ” BUILD_FIELDCATALOG

&————————————————–
& Form BUILD_LAYOUT
&————————————————–*
FORM build_layout.
ls_layout-zebra = ‘X’.
ls_layout-box_fieldname = ‘BOX’.
ENDFORM. ” BUILD_LAYOUT

&—————————————————
& Form DISPLAY_LIST_ALV
&—————————————————-*
FORM display_list_alv.

CALL FUNCTION ‘REUSE_ALV_LIST_DISPLAY’
EXPORTING
i_callback_program = sy-cprog
is_layout = ls_layout
it_fieldcat = lt_fieldcat
i_callback_user_command = ‘MAKE_INTERACTIVE’  ” This is the subroutine name which is going to be called when user makes double click on basic list
TABLES
t_outtab = lt_spfli
EXCEPTIONS
program_error = 1
OTHERS = 2.
CASE sy-subrc.
WHEN 1.
MESSAGE ‘Program Error’ TYPE ‘I’.
WHEN OTHERS.
ENDCASE.
ENDFORM. ” DISPLAY_LIST_ALV

FORM make_interactive USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN ‘&IC1’.
CHECK rs_selfield-fieldname = ‘CARRID’.
READ TABLE lt_spfli INTO ls_spfli INDEX rs_selfield-tabindex.
CHECK sy-subrc IS INITIAL.
PERFORM build_data_interactive USING ls_spfli-carrid
ls_spfli-connid.
PERFORM display_list_alv_interactive.
WHEN OTHERS.
ENDCASE.
ENDFORM.
&———————————————————————
& Form BUILD_DATA_INTERACTIVE
&———————————————————————*
FORM build_data_interactive USING VALUE(p_carrid)
VALUE(p_connid).
CLEAR: lt_sflight.
SELECT * FROM sflight INTO TABLE lt_sflight WHERE carrid = p_carrid
AND connid = p_connid.

ENDFORM. ” BUILD_DATA_INTERACTIVE
&———————————————————————
*& Form DISPLAY_LIST_ALV_INTERACTIVE
FORM display_list_alv_interactive.

CHECK lt_sflight IS NOT INITIAL.
CALL FUNCTION ‘REUSE_ALV_LIST_DISPLAY’
EXPORTING
i_callback_program = sy-cprog
i_structure_name = ‘SFLIGHT’
TABLES
t_outtab = lt_sflight
EXCEPTIONS
program_error = 1
OTHERS = 2.
CASE sy-subrc.
WHEN 1.
MESSAGE ‘Program Error’ TYPE ‘I’.
WHEN OTHERS.
ENDCASE.

ENDFORM. ” DISPLAY_LIST_ALV_INTERACTIVE


Program Output: First basic list is displayed and it shows records from SPFLI table.  If user double clicks on any value of the CARRID field, then interactive list is displayed.

1

All records from SFLIGHT table displayed with particular carrid and connid value. Go back.

2

Double click on a different carrid value.

3

Here again the interactive list shows the details.

4


 

Advertisements

One thought on “REUSE_ALV_LIST_DISPLAY- 28

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s