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

Making an ALV report Interactive !!!!

Former Member
0 Likes
714

Hi,

Can somebody tell me how do I make an ALV report interactive? The primary list is an ALV classic and I would like to display an Interactive GRID report in the secondary list.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
688

Hi Venkat,

Below mentioned is a example ALV interactive report i developed for training .. plz go through....

REPORT zkali_interactive.

TABLES : marc,

makt.

TYPE-POOLS: slis.

TYPES : BEGIN OF t_marc,

matnr TYPE marc-matnr,

werks TYPE marc-werks,

pstat TYPE marc-pstat,

ekgrp TYPE marc-ekgrp,

END OF t_marc,

BEGIN OF t_makt,

matnr type makt-matnr,

spras type makt-spras,

maktx type makt-maktx,

maktg type makt-maktg,

end of t_makt.

DATA: i_marc TYPE STANDARD TABLE OF t_marc,

i_makt TYPE STANDARD TABLE OF t_makt,

w_marc TYPE t_marc,

w_makt type t_makt,

i_fieldcatlog TYPE STANDARD TABLE OF slis_fieldcat_alv,

w_fieldcatlog TYPE slis_fieldcat_alv,

i_fieldcat TYPE STANDARD TABLE OF slis_fieldcat_alv,

w_fieldcat TYPE slis_fieldcat_alv,

v_events TYPE slis_t_event,

wa_event TYPE slis_alv_event,

v_repid TYPE syrepid,

it_listheader TYPE slis_t_listheader.

*Title displayed when the alv list is displayed

DATA: i_title_ekko TYPE lvc_title VALUE 'FIRST LIST DISPLAYED'.

DATA: i_title_ekpo TYPE lvc_title VALUE 'SECONDRY LIST DISPLAYED'.

SELECTION-SCREEN BEGIN OF BLOCK b1.

SELECT-OPTIONS : so_matnr FOR marc-matnr,

so_werks FOR marc-werks.

SELECTION-SCREEN END OF BLOCK b1.

INITIALIZATION.

v_repid = sy-repid.

PERFORM bulid_fieldcatlog.

PERFORM event_call.

PERFORM populate_event.

START-OF-SELECTION.

PERFORM retrive_data.

PERFORM build_listheader USING it_listheader.

PERFORM display_data.

*data : wa_text like thead OCCURS 0.

*

*CALL FUNCTION 'READ_TEXT'

  • EXPORTING

  • CLIENT = SY-MANDT

  • id = 'ST'

  • language = 'EN'

  • name = 'ZTEST_TEXT'

  • object = 'TEXT'

    • ARCHIVE_HANDLE = 0

    • LOCAL_CAT = ' '

    • IMPORTING

    • HEADER =

  • tables

  • lines = wa_text

    • EXCEPTIONS

    • ID = 1

    • LANGUAGE = 2

    • NAME = 3

    • NOT_FOUND = 4

    • OBJECT = 5

    • REFERENCE_CHECK = 6

    • WRONG_ACCESS_TO_ARCHIVE = 7

    • OTHERS = 8

  • .

*IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

*ENDIF.

&----


*& Form bulid_fieldcatlog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM bulid_fieldcatlog.

w_fieldcatlog-tabname = 'I_MARC'.

w_fieldcatlog-fieldname = 'MATNR'.

w_fieldcatlog-seltext_m = 'Material ID'.

APPEND w_fieldcatlog TO i_fieldcatlog.

CLEAR w_fieldcatlog.

w_fieldcatlog-tabname = 'I_MARC'.

w_fieldcatlog-fieldname = 'WERKS'.

w_fieldcatlog-seltext_m = 'Plant'.

APPEND w_fieldcatlog TO i_fieldcatlog.

CLEAR w_fieldcatlog.

w_fieldcatlog-tabname = 'I_MARC'.

w_fieldcatlog-fieldname = 'PSTAT'.

w_fieldcatlog-seltext_m = 'Maintenance Status'.

APPEND w_fieldcatlog TO i_fieldcatlog.

CLEAR w_fieldcatlog.

w_fieldcatlog-tabname = 'I_MARC'.

w_fieldcatlog-fieldname = 'EKGRP'.

w_fieldcatlog-seltext_m = 'Purchasing Group'.

APPEND w_fieldcatlog TO i_fieldcatlog.

CLEAR w_fieldcatlog.

ENDFORM. " bulid_fieldcatlog

&----


*& Form event_call

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM event_call.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = v_events.

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. " event_call

&----


*& Form retrive_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM retrive_data.

SELECT matnr

werks

pstat

ekgrp

INTO TABLE i_marc

FROM marc

WHERE matnr IN so_matnr AND

werks IN so_werks.

ENDFORM. " retrive_data

&----


*& Form display_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display_data.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

i_callback_user_command = 'USER_COMMAND'

i_callback_top_of_page = 'TOP_OF_PAGE '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

i_grid_title = i_title_ekko

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

it_fieldcat = i_fieldcatlog

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

i_save = 'A'

  • IS_VARIANT =

it_events = v_events

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_ADD_FIELDCAT =

  • IT_HYPERLINK =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = i_marc

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. " display_data

&----


*& Form populate_event

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM populate_event.

READ TABLE v_events INTO wa_event WITH KEY name = 'TOP_OF_PAGE'.

IF sy-subrc EQ 0.

wa_event-form = 'TOP_OF_PAGE'.

MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =

wa_event-form.

ENDIF.

READ TABLE v_events INTO wa_event WITH KEY name = 'USER_COMMAND'.

IF sy-subrc EQ 0.

wa_event-form = 'USER_COMMAND'.

MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =

wa_event-name.

ENDIF.

ENDFORM. " populate_event

&----


*& Form TOP_OF_PAGE

&----


  • text

----


FORM top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_listheader

  • i_logo =

  • I_END_OF_LIST_GRID =

.

ENDFORM. "TOP_OF_PAGE

&----


*& Form build_listheader

&----


  • text

----


  • -->P_IT_LISTHEADER text

----


FORM build_listheader USING it_listheader TYPE slis_t_listheader.

DATA :hline TYPE slis_listheader.

hline-info = 'this is my Alv pgm'.

hline-typ = 'H'.

ENDFORM. " build_listheader

&----


*& Form USER_COMMAND

&----


  • text

----


  • -->R_UCOMM text

  • -->, text

  • -->RS_SLEFIELDtext

----


FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN '&IC1'.

READ TABLE i_marc INTO w_marc INDEX rs_selfield-tabindex.

PERFORM build_fieldcatlog_ekpo.

PERFORM event_call_ekpo.

PERFORM populate_event_ekpo.

PERFORM data_retrieval_ekpo USING w_marc.

PERFORM build_listheader_ekpo USING it_listheader.

PERFORM display_alv_ekpo.

ENDCASE.

ENDFORM. "user_command

&----


*& Form build_fieldcatlog_ekpo

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_fieldcatlog_ekpo.

w_fieldcat-tabname = 'I_MAKT'.

w_fieldcat-fieldname = 'MATNR'.

w_fieldcat-seltext_l = 'Material ID'.

APPEND w_fieldcat TO i_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-tabname = 'I_MAKT'.

w_fieldcat-fieldname = 'SPRAS'.

w_fieldcat-seltext_l = 'Lang'.

APPEND w_fieldcat TO i_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-tabname = 'I_MAKT'.

w_fieldcat-fieldname = 'MAKTX'.

w_fieldcat-seltext_l = 'Material Description'.

APPEND w_fieldcat TO i_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-tabname = 'I_MAKT'.

w_fieldcat-fieldname = 'MAKTG'.

w_fieldcat-seltext_l = 'Material Description in upper case'.

APPEND w_fieldcat TO i_fieldcat.

CLEAR w_fieldcat.

ENDFORM. " build_fieldcatlog_ekpo

&----


*& Form event_call_ekpo

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM event_call_ekpo.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = v_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.

ENDFORM. " event_call_ekpo

&----


*& Form populate_event_ekpo

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM populate_event_ekpo.

READ TABLE v_events INTO wa_event WITH KEY name = 'TOP_OF_PAGE'.

IF sy-subrc EQ 0.

wa_event-form = 'TOP_OF_PAGE'.

MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =

wa_event-form.

ENDIF.

ENDFORM. " populate_event_ekpo

&----


*& Form data_retrieval_ekpo

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM data_retrieval_ekpo USING w_marc TYPE t_marc.

SELECT matnr

spras

maktx

maktg

FROM makt

INTO TABLE i_makt

WHERE matnr EQ w_marc-matnr.

*.

ENDFORM. " data_retrieval_ekpo

&----


*& Form build_listheader_ekpo

&----


  • text

----


  • -->P_IT_LISTHEADER text

----


FORM build_listheader_ekpo USING p_it_listheader.

DATA: hline1 TYPE slis_listheader.

hline1-typ = 'H'.

hline1-info = 'CHECKING PGM'.

ENDFORM. " build_listheader_ekpo

&----


*& Form display_alv_ekpo

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display_alv_ekpo.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'

i_callback_top_of_page = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

i_grid_title = i_title_ekpo

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

it_fieldcat = i_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT =

i_save = 'A'

  • IS_VARIANT =

it_events = v_events

TABLES

t_outtab = i_makt

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. " display_alv_ekpo

Regards,

Kali

Hi Venkat,

Below mentioned is a example ALV interactive report i developed for training .. plz go through....

REPORT zkali_interactive.

TABLES : marc,

makt.

TYPE-POOLS: slis.

TYPES : BEGIN OF t_marc,

matnr TYPE marc-matnr,

werks TYPE marc-werks,

pstat TYPE marc-pstat,

ekgrp TYPE marc-ekgrp,

END OF t_marc,

BEGIN OF t_makt,

matnr type makt-matnr,

spras type makt-spras,

maktx type makt-maktx,

maktg type makt-maktg,

end of t_makt.

DATA: i_marc TYPE STANDARD TABLE OF t_marc,

i_makt TYPE STANDARD TABLE OF t_makt,

w_marc TYPE t_marc,

w_makt type t_makt,

i_fieldcatlog TYPE STANDARD TABLE OF slis_fieldcat_alv,

w_fieldcatlog TYPE slis_fieldcat_alv,

i_fieldcat TYPE STANDARD TABLE OF slis_fieldcat_alv,

w_fieldcat TYPE slis_fieldcat_alv,

v_events TYPE slis_t_event,

wa_event TYPE slis_alv_event,

v_repid TYPE syrepid,

it_listheader TYPE slis_t_listheader.

*Title displayed when the alv list is displayed

DATA: i_title_ekko TYPE lvc_title VALUE 'FIRST LIST DISPLAYED'.

DATA: i_title_ekpo TYPE lvc_title VALUE 'SECONDRY LIST DISPLAYED'.

SELECTION-SCREEN BEGIN OF BLOCK b1.

SELECT-OPTIONS : so_matnr FOR marc-matnr,

so_werks FOR marc-werks.

SELECTION-SCREEN END OF BLOCK b1.

INITIALIZATION.

v_repid = sy-repid.

PERFORM bulid_fieldcatlog.

PERFORM event_call.

PERFORM populate_event.

START-OF-SELECTION.

PERFORM retrive_data.

PERFORM build_listheader USING it_listheader.

PERFORM display_data.

*data : wa_text like thead OCCURS 0.

*

*CALL FUNCTION 'READ_TEXT'

  • EXPORTING

  • CLIENT = SY-MANDT

  • id = 'ST'

  • language = 'EN'

  • name = 'ZTEST_TEXT'

  • object = 'TEXT'

    • ARCHIVE_HANDLE = 0

    • LOCAL_CAT = ' '

    • IMPORTING

    • HEADER =

  • tables

  • lines = wa_text

    • EXCEPTIONS

    • ID = 1

    • LANGUAGE = 2

    • NAME = 3

    • NOT_FOUND = 4

    • OBJECT = 5

    • REFERENCE_CHECK = 6

    • WRONG_ACCESS_TO_ARCHIVE = 7

    • OTHERS = 8

  • .

*IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

*ENDIF.

&----


*& Form bulid_fieldcatlog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM bulid_fieldcatlog.

w_fieldcatlog-tabname = 'I_MARC'.

w_fieldcatlog-fieldname = 'MATNR'.

w_fieldcatlog-seltext_m = 'Material ID'.

APPEND w_fieldcatlog TO i_fieldcatlog.

CLEAR w_fieldcatlog.

w_fieldcatlog-tabname = 'I_MARC'.

w_fieldcatlog-fieldname = 'WERKS'.

w_fieldcatlog-seltext_m = 'Plant'.

APPEND w_fieldcatlog TO i_fieldcatlog.

CLEAR w_fieldcatlog.

w_fieldcatlog-tabname = 'I_MARC'.

w_fieldcatlog-fieldname = 'PSTAT'.

w_fieldcatlog-seltext_m = 'Maintenance Status'.

APPEND w_fieldcatlog TO i_fieldcatlog.

CLEAR w_fieldcatlog.

w_fieldcatlog-tabname = 'I_MARC'.

w_fieldcatlog-fieldname = 'EKGRP'.

w_fieldcatlog-seltext_m = 'Purchasing Group'.

APPEND w_fieldcatlog TO i_fieldcatlog.

CLEAR w_fieldcatlog.

ENDFORM. " bulid_fieldcatlog

&----


*& Form event_call

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM event_call.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = v_events.

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. " event_call

&----


*& Form retrive_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM retrive_data.

SELECT matnr

werks

pstat

ekgrp

INTO TABLE i_marc

FROM marc

WHERE matnr IN so_matnr AND

werks IN so_werks.

ENDFORM. " retrive_data

&----


*& Form display_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display_data.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

i_callback_user_command = 'USER_COMMAND'

i_callback_top_of_page = 'TOP_OF_PAGE '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

i_grid_title = i_title_ekko

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

it_fieldcat = i_fieldcatlog

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

i_save = 'A'

  • IS_VARIANT =

it_events = v_events

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_ADD_FIELDCAT =

  • IT_HYPERLINK =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = i_marc

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. " display_data

&----


*& Form populate_event

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM populate_event.

READ TABLE v_events INTO wa_event WITH KEY name = 'TOP_OF_PAGE'.

IF sy-subrc EQ 0.

wa_event-form = 'TOP_OF_PAGE'.

MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =

wa_event-form.

ENDIF.

READ TABLE v_events INTO wa_event WITH KEY name = 'USER_COMMAND'.

IF sy-subrc EQ 0.

wa_event-form = 'USER_COMMAND'.

MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =

wa_event-name.

ENDIF.

ENDFORM. " populate_event

&----


*& Form TOP_OF_PAGE

&----


  • text

----


FORM top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_listheader

  • i_logo =

  • I_END_OF_LIST_GRID =

.

ENDFORM. "TOP_OF_PAGE

&----


*& Form build_listheader

&----


  • text

----


  • -->P_IT_LISTHEADER text

----


FORM build_listheader USING it_listheader TYPE slis_t_listheader.

DATA :hline TYPE slis_listheader.

hline-info = 'this is my Alv pgm'.

hline-typ = 'H'.

ENDFORM. " build_listheader

&----


*& Form USER_COMMAND

&----


  • text

----


  • -->R_UCOMM text

  • -->, text

  • -->RS_SLEFIELDtext

----


FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN '&IC1'.

READ TABLE i_marc INTO w_marc INDEX rs_selfield-tabindex.

PERFORM build_fieldcatlog_ekpo.

PERFORM event_call_ekpo.

PERFORM populate_event_ekpo.

PERFORM data_retrieval_ekpo USING w_marc.

PERFORM build_listheader_ekpo USING it_listheader.

PERFORM display_alv_ekpo.

ENDCASE.

ENDFORM. "user_command

&----


*& Form build_fieldcatlog_ekpo

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_fieldcatlog_ekpo.

w_fieldcat-tabname = 'I_MAKT'.

w_fieldcat-fieldname = 'MATNR'.

w_fieldcat-seltext_l = 'Material ID'.

APPEND w_fieldcat TO i_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-tabname = 'I_MAKT'.

w_fieldcat-fieldname = 'SPRAS'.

w_fieldcat-seltext_l = 'Lang'.

APPEND w_fieldcat TO i_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-tabname = 'I_MAKT'.

w_fieldcat-fieldname = 'MAKTX'.

w_fieldcat-seltext_l = 'Material Description'.

APPEND w_fieldcat TO i_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-tabname = 'I_MAKT'.

w_fieldcat-fieldname = 'MAKTG'.

w_fieldcat-seltext_l = 'Material Description in upper case'.

APPEND w_fieldcat TO i_fieldcat.

CLEAR w_fieldcat.

ENDFORM. " build_fieldcatlog_ekpo

&----


*& Form event_call_ekpo

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM event_call_ekpo.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = v_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.

ENDFORM. " event_call_ekpo

&----


*& Form populate_event_ekpo

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM populate_event_ekpo.

READ TABLE v_events INTO wa_event WITH KEY name = 'TOP_OF_PAGE'.

IF sy-subrc EQ 0.

wa_event-form = 'TOP_OF_PAGE'.

MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =

wa_event-form.

ENDIF.

ENDFORM. " populate_event_ekpo

&----


*& Form data_retrieval_ekpo

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM data_retrieval_ekpo USING w_marc TYPE t_marc.

SELECT matnr

spras

maktx

maktg

FROM makt

INTO TABLE i_makt

WHERE matnr EQ w_marc-matnr.

*.

ENDFORM. " data_retrieval_ekpo

&----


*& Form build_listheader_ekpo

&----


  • text

----


  • -->P_IT_LISTHEADER text

----


FORM build_listheader_ekpo USING p_it_listheader.

DATA: hline1 TYPE slis_listheader.

hline1-typ = 'H'.

hline1-info = 'CHECKING PGM'.

ENDFORM. " build_listheader_ekpo

&----


*& Form display_alv_ekpo

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display_alv_ekpo.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'

i_callback_top_of_page = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

i_grid_title = i_title_ekpo

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

it_fieldcat = i_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT =

i_save = 'A'

  • IS_VARIANT =

it_events = v_events

TABLES

t_outtab = i_makt

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. " display_alv_ekpo

Regards,

Kali

6 REPLIES 6
Read only

Former Member
0 Likes
688

Hi,

Look at the Below thread

Regards

Sudheer

Read only

Former Member
0 Likes
688

sorry dude i have no answer, BUT i dont really get what you are trying to achieve.

If you could clarify that a bit more maybe me or others could help you then.

thx

Read only

Former Member
0 Likes
688

Check out package SLIS for examples on ALVs.

Manoj

Read only

Former Member
0 Likes
689

Hi Venkat,

Below mentioned is a example ALV interactive report i developed for training .. plz go through....

REPORT zkali_interactive.

TABLES : marc,

makt.

TYPE-POOLS: slis.

TYPES : BEGIN OF t_marc,

matnr TYPE marc-matnr,

werks TYPE marc-werks,

pstat TYPE marc-pstat,

ekgrp TYPE marc-ekgrp,

END OF t_marc,

BEGIN OF t_makt,

matnr type makt-matnr,

spras type makt-spras,

maktx type makt-maktx,

maktg type makt-maktg,

end of t_makt.

DATA: i_marc TYPE STANDARD TABLE OF t_marc,

i_makt TYPE STANDARD TABLE OF t_makt,

w_marc TYPE t_marc,

w_makt type t_makt,

i_fieldcatlog TYPE STANDARD TABLE OF slis_fieldcat_alv,

w_fieldcatlog TYPE slis_fieldcat_alv,

i_fieldcat TYPE STANDARD TABLE OF slis_fieldcat_alv,

w_fieldcat TYPE slis_fieldcat_alv,

v_events TYPE slis_t_event,

wa_event TYPE slis_alv_event,

v_repid TYPE syrepid,

it_listheader TYPE slis_t_listheader.

*Title displayed when the alv list is displayed

DATA: i_title_ekko TYPE lvc_title VALUE 'FIRST LIST DISPLAYED'.

DATA: i_title_ekpo TYPE lvc_title VALUE 'SECONDRY LIST DISPLAYED'.

SELECTION-SCREEN BEGIN OF BLOCK b1.

SELECT-OPTIONS : so_matnr FOR marc-matnr,

so_werks FOR marc-werks.

SELECTION-SCREEN END OF BLOCK b1.

INITIALIZATION.

v_repid = sy-repid.

PERFORM bulid_fieldcatlog.

PERFORM event_call.

PERFORM populate_event.

START-OF-SELECTION.

PERFORM retrive_data.

PERFORM build_listheader USING it_listheader.

PERFORM display_data.

*data : wa_text like thead OCCURS 0.

*

*CALL FUNCTION 'READ_TEXT'

  • EXPORTING

  • CLIENT = SY-MANDT

  • id = 'ST'

  • language = 'EN'

  • name = 'ZTEST_TEXT'

  • object = 'TEXT'

    • ARCHIVE_HANDLE = 0

    • LOCAL_CAT = ' '

    • IMPORTING

    • HEADER =

  • tables

  • lines = wa_text

    • EXCEPTIONS

    • ID = 1

    • LANGUAGE = 2

    • NAME = 3

    • NOT_FOUND = 4

    • OBJECT = 5

    • REFERENCE_CHECK = 6

    • WRONG_ACCESS_TO_ARCHIVE = 7

    • OTHERS = 8

  • .

*IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

*ENDIF.

&----


*& Form bulid_fieldcatlog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM bulid_fieldcatlog.

w_fieldcatlog-tabname = 'I_MARC'.

w_fieldcatlog-fieldname = 'MATNR'.

w_fieldcatlog-seltext_m = 'Material ID'.

APPEND w_fieldcatlog TO i_fieldcatlog.

CLEAR w_fieldcatlog.

w_fieldcatlog-tabname = 'I_MARC'.

w_fieldcatlog-fieldname = 'WERKS'.

w_fieldcatlog-seltext_m = 'Plant'.

APPEND w_fieldcatlog TO i_fieldcatlog.

CLEAR w_fieldcatlog.

w_fieldcatlog-tabname = 'I_MARC'.

w_fieldcatlog-fieldname = 'PSTAT'.

w_fieldcatlog-seltext_m = 'Maintenance Status'.

APPEND w_fieldcatlog TO i_fieldcatlog.

CLEAR w_fieldcatlog.

w_fieldcatlog-tabname = 'I_MARC'.

w_fieldcatlog-fieldname = 'EKGRP'.

w_fieldcatlog-seltext_m = 'Purchasing Group'.

APPEND w_fieldcatlog TO i_fieldcatlog.

CLEAR w_fieldcatlog.

ENDFORM. " bulid_fieldcatlog

&----


*& Form event_call

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM event_call.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = v_events.

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. " event_call

&----


*& Form retrive_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM retrive_data.

SELECT matnr

werks

pstat

ekgrp

INTO TABLE i_marc

FROM marc

WHERE matnr IN so_matnr AND

werks IN so_werks.

ENDFORM. " retrive_data

&----


*& Form display_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display_data.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

i_callback_user_command = 'USER_COMMAND'

i_callback_top_of_page = 'TOP_OF_PAGE '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

i_grid_title = i_title_ekko

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

it_fieldcat = i_fieldcatlog

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

i_save = 'A'

  • IS_VARIANT =

it_events = v_events

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_ADD_FIELDCAT =

  • IT_HYPERLINK =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = i_marc

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. " display_data

&----


*& Form populate_event

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM populate_event.

READ TABLE v_events INTO wa_event WITH KEY name = 'TOP_OF_PAGE'.

IF sy-subrc EQ 0.

wa_event-form = 'TOP_OF_PAGE'.

MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =

wa_event-form.

ENDIF.

READ TABLE v_events INTO wa_event WITH KEY name = 'USER_COMMAND'.

IF sy-subrc EQ 0.

wa_event-form = 'USER_COMMAND'.

MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =

wa_event-name.

ENDIF.

ENDFORM. " populate_event

&----


*& Form TOP_OF_PAGE

&----


  • text

----


FORM top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_listheader

  • i_logo =

  • I_END_OF_LIST_GRID =

.

ENDFORM. "TOP_OF_PAGE

&----


*& Form build_listheader

&----


  • text

----


  • -->P_IT_LISTHEADER text

----


FORM build_listheader USING it_listheader TYPE slis_t_listheader.

DATA :hline TYPE slis_listheader.

hline-info = 'this is my Alv pgm'.

hline-typ = 'H'.

ENDFORM. " build_listheader

&----


*& Form USER_COMMAND

&----


  • text

----


  • -->R_UCOMM text

  • -->, text

  • -->RS_SLEFIELDtext

----


FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN '&IC1'.

READ TABLE i_marc INTO w_marc INDEX rs_selfield-tabindex.

PERFORM build_fieldcatlog_ekpo.

PERFORM event_call_ekpo.

PERFORM populate_event_ekpo.

PERFORM data_retrieval_ekpo USING w_marc.

PERFORM build_listheader_ekpo USING it_listheader.

PERFORM display_alv_ekpo.

ENDCASE.

ENDFORM. "user_command

&----


*& Form build_fieldcatlog_ekpo

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_fieldcatlog_ekpo.

w_fieldcat-tabname = 'I_MAKT'.

w_fieldcat-fieldname = 'MATNR'.

w_fieldcat-seltext_l = 'Material ID'.

APPEND w_fieldcat TO i_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-tabname = 'I_MAKT'.

w_fieldcat-fieldname = 'SPRAS'.

w_fieldcat-seltext_l = 'Lang'.

APPEND w_fieldcat TO i_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-tabname = 'I_MAKT'.

w_fieldcat-fieldname = 'MAKTX'.

w_fieldcat-seltext_l = 'Material Description'.

APPEND w_fieldcat TO i_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-tabname = 'I_MAKT'.

w_fieldcat-fieldname = 'MAKTG'.

w_fieldcat-seltext_l = 'Material Description in upper case'.

APPEND w_fieldcat TO i_fieldcat.

CLEAR w_fieldcat.

ENDFORM. " build_fieldcatlog_ekpo

&----


*& Form event_call_ekpo

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM event_call_ekpo.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = v_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.

ENDFORM. " event_call_ekpo

&----


*& Form populate_event_ekpo

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM populate_event_ekpo.

READ TABLE v_events INTO wa_event WITH KEY name = 'TOP_OF_PAGE'.

IF sy-subrc EQ 0.

wa_event-form = 'TOP_OF_PAGE'.

MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =

wa_event-form.

ENDIF.

ENDFORM. " populate_event_ekpo

&----


*& Form data_retrieval_ekpo

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM data_retrieval_ekpo USING w_marc TYPE t_marc.

SELECT matnr

spras

maktx

maktg

FROM makt

INTO TABLE i_makt

WHERE matnr EQ w_marc-matnr.

*.

ENDFORM. " data_retrieval_ekpo

&----


*& Form build_listheader_ekpo

&----


  • text

----


  • -->P_IT_LISTHEADER text

----


FORM build_listheader_ekpo USING p_it_listheader.

DATA: hline1 TYPE slis_listheader.

hline1-typ = 'H'.

hline1-info = 'CHECKING PGM'.

ENDFORM. " build_listheader_ekpo

&----


*& Form display_alv_ekpo

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display_alv_ekpo.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'

i_callback_top_of_page = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

i_grid_title = i_title_ekpo

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

it_fieldcat = i_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT =

i_save = 'A'

  • IS_VARIANT =

it_events = v_events

TABLES

t_outtab = i_makt

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. " display_alv_ekpo

Regards,

Kali

Read only

Former Member
0 Likes
688

Hi venkat,

1. In alv we cannot use AT LINE Selection

2. For alv, there is a special syntax, so that when we double-click on alv,

our FORM / routine is called and there we display another alv.

3. just copy paste to get a taste of interactive alv.

4.

REPORT abc.

TYPE-POOLS : slis.

*----


Data

DATA : ITAB LIKE T001 OCCURS 0 WITH HEADER LINE.

DATA : alvfc TYPE slis_t_fieldcat_alv.

DATA : STAB LIKE T001 OCCURS 0 WITH HEADER LINE.

*----


Select Data

SELECT * FROM t001 INTO TABLE itab.

*------- Field Catalogue

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = sy-repid

i_internal_tabname = 'ITAB'

i_inclname = sy-repid

CHANGING

ct_fieldcat = alvfc

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

*----


Display

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

it_fieldcat = alvfc

i_callback_program = sy-repid "<-------Important

i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important

TABLES

t_outtab = itab

EXCEPTIONS

program_error = 1

OTHERS = 2.

*----


  • CALL BACK FORM

*----


FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE

slis_selfield.

*----


IMPORTANT.

READ TABLE ITAB INDEX WHATROW-TABINDEX.

*

CLEAR STAB.

SELECT * FROM T001

INTO TABLE STAB

WHERE BUKRS = ITAB-BUKRS.

CLEAR ALVFC.

*------- Field Catalogue

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = sy-repid

i_internal_tabname = 'STAB'

i_inclname = sy-repid

CHANGING

ct_fieldcat = alvfc

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

*----


Display

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

it_fieldcat = alvfc

i_callback_program = sy-repid "<-------Important

TABLES

t_outtab = Stab

EXCEPTIONS

program_error = 1

OTHERS = 2.

ENDFORM. "ITAB_user_command

regards,

amit m.

Read only

dhorions
Contributor
0 Likes
688

Before I give you an answer, let me just quote some of <a href="https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rulesofEngagement&">rules of engagement</a> of this forum :

Step 1: Finding An Answer

Rule number one: Try to find the answer first.

( https://www.sdn.sap.com/irj/sdn/advancedsearch?query=interactive%20alv&cat=sdn_all )

2. Do not use words in capital letters and any of the words: urgent, quickly, burning, etc in your message. Especially not in the title! This just irritates and does not help you get to your goal. From our side, we definitely do not answer faster when we see these words.

<b>The same goes for such things as ??? or !!! in appends. In the English language one ? or ! is sufficient to terminate a sentence.</b>

As for an answer to your question :

A search might help : https://www.sdn.sap.com/irj/sdn/advancedsearch?query=interactive%20alv&cat=sdn_all

There is a <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907">very good document about alv grids</a>, if you search for alv, it's the first result.

If you have read this, and tried to create your own interactive alv report and have a specific problem, ask a question in the forum.