Application Development 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: 

ALV interactive without using classes

Former Member
0 Kudos
98

hi friends,

i want the code for the ALV interactive double click.when ever i double click on the particular field in the alv grid.it must take me to the other transaction where my before alv grid display screen must disappear.But this code must not use classes concept.

Charita.

2 REPLIES 2

raymond_giuseppi
Active Contributor
0 Kudos
70

Try something like


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
...
I_CALLBACK_PROGRAM = W_REPID
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
...
* you can choose double-click function code with 
* parameter is_layout-F2code 

FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM
P_SELFLD TYPE SLIS_SELFIELD.
case p_ucomm.
* you can use the value of the field clicked on or read the internal table record
* look at description of parameter sli_selfield
when <is_ layout-F2code >.
set parameter id 'AUN' field p_selfld-value. 
call transaction 'VA03' and skip first screen.
endcase.

You can even write a CASE based on fieldname clicked on.

CASE p_selfld.
WHEN <Field1>.
...
ENDCASE.

Regards

Former Member
0 Kudos
70

hi,

try this simple ex for interactive ALV without using classes.

on the 1st screen matno,mattyp will be displayed,when you doubleclick on a row,secondary list will be with displayed item details

TYPE-POOLS:slis.

TYPES:BEGIN OF ty_mara,

matnr LIKE mara-matnr,

mtart LIKE mara-mtart,

END OF ty_mara.

DATA:it_mara TYPE STANDARD TABLE OF ty_mara,

wa_mara TYPE ty_mara.

TYPES:BEGIN OF ty_mard,

matnr LIKE mard-matnr,

werks LIKE mard-werks,

lgort LIKE mard-werks,

END OF ty_mard.

DATA:it_mard TYPE STANDARD TABLE OF ty_mard,

wa_mard TYPE ty_mard.

DATA:i_fcat TYPE slis_t_fieldcat_alv,

w_fcat TYPE slis_fieldcat_alv,

it_listheader TYPE slis_t_listheader,

i_events TYPE slis_t_event,

w_events TYPE slis_alv_event,

i_layout TYPE slis_layout_alv,

i_fcat2 TYPE slis_t_fieldcat_alv,

w_fcat2 TYPE slis_fieldcat_alv,

i_events2 TYPE slis_t_event,

w_events2 TYPE slis_alv_event,

v_repid LIKE sy-repid,

  • title

v_title1 TYPE lvc_title VALUE 'First list displayed',

v_title2 TYPE lvc_title VALUE 'Second list displayed'.

INITIALIZATION.

v_repid = sy-repid.

PERFORM build_fieldcat_mara.

PERFORM event_call.

PERFORM pop_event.

START-OF-SELECTION.

PERFORM get_data.

PERFORM build_header USING it_listheader.

PERFORM display_alv.

&----


*& Form get_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_data .

SELECT matnr mtart FROM mara INTO TABLE it_mara.

ENDFORM. " get_data

&----


*& Form build_header

&----


  • text

----


  • -->P_I_HEADER text

----


FORM build_header USING i_listheader TYPE slis_t_listheader.

DATA: hline TYPE slis_listheader.

hline-info = 'This is Interactive ALV'.

hline-typ = 'H'.

ENDFORM. " build_header

&----


*& Form build_fieldcat

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_fieldcat_mara.

w_fcat-tabname = 'IT_MARA'.

w_fcat-fieldname = 'MATNR'.

w_fcat-col_pos = '1'.

w_fcat-seltext_m = 'Material No.'.

APPEND w_fcat TO i_fcat.

CLEAR w_fcat.

w_fcat-tabname = 'IT_MARA'.

w_fcat-fieldname = 'MTART'.

w_fcat-col_pos = '2'.

w_fcat-seltext_m = 'Material Type'.

APPEND w_fcat TO i_fcat.

CLEAR w_fcat.

ENDFORM. " build_fieldcat

&----


*& 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 = i_events.

ENDFORM. " event_call

&----


*& Form pop_event

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM pop_event .

READ TABLE i_events INTO w_events WITH KEY name = 'TOP_OF_PAGE'.

IF sy-subrc = 0.

w_events-form = 'TOP_OF_PAGE'.

MODIFY i_events FROM w_events TRANSPORTING form WHERE name = w_events-name.

ENDIF.

READ TABLE i_events INTO w_events WITH KEY name = 'USER_COMMAND'.

IF sy-subrc = 0.

w_events-form = 'USER_COMMAND'.

MODIFY i_events FROM w_events TRANSPORTING form WHERE name = w_events-name.

ENDIF.

ENDFORM. " pop_event

&----


*& Form display_alv

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display_alv .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = v_repid

i_callback_user_command = 'USER_COMMAND'

i_callback_top_of_page = 'TOP_OF_PAGE'

i_grid_title = v_title1

IS_LAYOUT = I_LAYOUT

it_fieldcat = i_fcat

  • IT_SORT = IT_SORT

I_SAVE = 'A'

  • IS_VARIANT = IS_VARIANT

it_events = i_events

TABLES

t_outtab = it_mara.

ENDFORM. " display_alv

&----


*& Form top_of_page

&----


  • text

----


FORM top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_listheader.

ENDFORM. "top_of_page

&----


*& Form user_command

&----


  • text

----


  • -->R_UCOMM text

----


FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield type slis_selfield.

CASE r_ucomm.

WHEN '&IC1'.

READ TABLE it_mara INTO wa_mara INDEX rs_selfield-tabindex.

PERFORM build_fieldcat_mard.

PERFORM event_call_mard.

PERFORM pop_event_mard.

PERFORM get_mard.

PERFORM build_header_mard USING it_listheader.

PERFORM display_mard.

ENDCASE.

ENDFORM. "user_command

&----


*& Form build_fieldcat_mard

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_fieldcat_mard .

w_fcat2-tabname = 'IT_MARD'.

w_fcat2-fieldname = 'MATNR'.

w_fcat2-col_pos = '1'.

w_fcat2-seltext_m = 'Material No.'.

APPEND w_fcat2 to i_fcat2.

CLEAR w_fcat2.

w_fcat2-tabname = 'IT_MARD'.

w_fcat2-fieldname = 'WERKS'.

w_fcat2-col_pos = '1'.

w_fcat2-seltext_m = 'Plant'.

APPEND w_fcat2 to i_fcat2.

CLEAR w_fcat2.

w_fcat2-tabname = 'IT_MARD'.

w_fcat2-fieldname = 'LGORT'.

w_fcat2-col_pos = '1'.

w_fcat2-seltext_m = 'Storage'.

APPEND w_fcat2 to i_fcat2.

CLEAR w_fcat2.

ENDFORM. " build_fieldcat_mard

&----


*& Form event_call_mard

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM event_call_mard .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = i_events2.

ENDFORM. " event_call_mard

&----


*& Form pop_event_mard

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM pop_event_mard .

READ TABLE i_events2 INTO w_events2 WITH KEY name = 'TOP_OF_PAGE'.

IF sy-subrc = 0.

w_events2-form = 'TOP_OF_PAGE'.

MODIFY i_events2 FROM w_events2 TRANSPORTING form WHERE

name = w_events2-name.

ENDIF.

ENDFORM. " pop_event_mard

&----


*& Form get_mard

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_mard .

SELECT matnr werks lgort FROM mard INTO TABLE it_mard

  • for all entries in it_mara

where matnr = wa_mara-matnr.

ENDFORM. " get_mard

&----


*& Form build_header_mard

&----


  • text

----


  • -->P_IT_LISTHEADER text

----


FORM build_header_mard USING i_listheader TYPE slis_t_listheader.

DATA:hline1 TYPE slis_listheader.

hline1-typ = 'H'.

hline1-info = 'CHECKING PGM'.

ENDFORM. " build_header_mard

&----


*& Form display_mard

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display_mard .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = v_repid

i_callback_top_of_page = 'TOP_OF_PAGE'

i_grid_title = v_title2

  • IS_LAYOUT = IS_LAYOUT

it_fieldcat = i_fcat2

  • IT_SORT = IT_SORT

  • I_DEFAULT = 'X'

I_SAVE = 'A'

  • IS_VARIANT = IS_VARIANT

it_events = i_events2

TABLES

t_outtab = it_mard

.

ENDFORM. " display_mard

do award points for all helpful answers

Regards