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: 

Interactive ALV

Former Member
0 Kudos

Hi friends,

I have one ALV output.In that if i click on one column one more ALV grid has to display.If i click on some column in the second ALV Grid i want to open one more ALV grid or some transaction.That means i have to identify the column and which i have clicked and display the desired output.

Pls suggest the solution.

Thanks&Regards,

DRB.

9 REPLIES 9

Former Member
0 Kudos

Hi Ravi,

Try useing the methods 'GET_SELECTED_CELLS' or

'GET_SELECTED_COLUMNS' and 'GET_CURRENT_CELL'.

Thanks & Regards,

Siri.

Message was edited by: Srilatha T

Former Member
0 Kudos

Former Member
0 Kudos

Ravi,

Welcome to SDN !!!

Use the methods GET_SELECTED_ROWS_BASE (to get the selected row no) and GET_CELL_DATA (selected Cell Data) present in the class CL_GUI_ALV_GRID.

Using these methods, u can fullfil the requirement.

Thanks

Kam

former_member181962
Active Contributor
0 Kudos

Hi ravi,

Are you sure you are clicking in the columns? Or is it rows? If it is rows, then write the code in a form routine to hadle what should happen next.

like this,

FORM DETAIL USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

CASE R_UCOMM.

WHEN 'DETAIL'.

IF RS_SELFIELD-FIELDNAME EQ 'VBELN'.

write the code to get the data for the next alv grid and also call the alv grid display function module.

endif.

ENDCASE.

ENDFORM.

This form name has to be passed to the alv grid's function module's I_CALLBACK_USER_COMMAND parameter.

If you are really loking for columns, then do as Srilatha suggested.

Regards,

Ravi

Former Member
0 Kudos

Hi Ravi,

You can check the SAP demo programs for ALV .

Search with BALV you will see lots of programs.In that you cane see demo programs for your qusetion.

Thanks

Rajeev

former_member188685
Active Contributor
0 Kudos

Hi Ravi,

If u are going for Normal ALV then

&----


*& Form USER_COMMAND

&----


  • For User Command

----


FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM SELFIELD TYPE SLIS_SELFIELD.

CASE UCOMM.

**-When User Double Clicks

WHEN '&IC1'.

IF SELFIELD-TABINDEX <> 0.

**if user clicks on sales order

IF SELFIELD-SEL_TAB_FIELD = 'IT_FINAL-VGBEL'.

READ TABLE IT_FINAL INDEX SELFIELD-TABINDEX

TRANSPORTING VGBEL.

IF SY-SUBRC = 0.

SET PARAMETER ID 'AUN' FIELD IT_FINAL-VGBEL.

ENDIF.

CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

ENDIF.

**if user clicks on Delivery

IF SELFIELD-SEL_TAB_FIELD = 'IT_FINAL-VBELN'.

READ TABLE IT_FINAL INDEX SELFIELD-TABINDEX

TRANSPORTING VBELN.

IF SY-SUBRC = 0.

SET PARAMETER ID 'VL' FIELD IT_FINAL-VBELN.

ENDIF.

CALL TRANSACTION 'VL02N' AND SKIP FIRST SCREEN.

ENDIF.

**if user clicks on Order Control Hold Reason code

IF SELFIELD-SEL_TAB_FIELD = 'IT_FINAL-ZZOCHOLDRC'

OR SELFIELD-SEL_TAB_FIELD = 'IT_FINAL-ZZPROMDT'.

READ TABLE IT_FINAL INDEX SELFIELD-TABINDEX

TRANSPORTING

VGBEL

VGPOS

ZZOCHOLDRC.

IF SY-SUBRC = 0.

**second list

<b> PERFORM GET_HU_DATA.

PERFORM POPULATE_FIELDCAT2.

PERFORM LIST_DISPLAY.</b>

ENDIF.

ENDIF.

ENDIF.

regards

vijay

former_member188685
Active Contributor
0 Kudos

if u are going for Grid

then

look this code.

use event handlers

&----


*& Report ZALV_TEST4 *

*& *

&----


*& PROGRAM NAME:ZALV_TEST4. *

*& DESCRIPTION:INTERACTIVE REPORT USING ALV. *

*& DEVELOPER:KALPANA B *

*& START OF DATE:04/18/2005. *

*& END OF DATE:04/20/2005. *

&----


report zalv_test4 .

&----


*& Tables

&----


*tables

tables:ekko, "Purchase header

ekpo. "Item details

types:begin of t_ekko ,

ebeln like ekko-ebeln,

bukrs like ekko-bukrs,

bstyp like ekko-bstyp,

bsart like ekko-bsart,

rowcolor(4) type c,

cellcolor type lvc_t_scol,

end of t_ekko.

&----


*& selecton screen *

&----


selection-screen:begin of block main.

select-options:s_ebeln for ekko-ebeln. "Purchase Document

selection-screen:end of block main.

&----


*& Internal Tables

&----


data:begin of it_ekpo occurs 0,

ebeln like ekpo-ebeln,

bukrs like ekpo-bukrs,

werks like ekpo-werks,

matkl like ekpo-matkl,

meins like ekpo-meins,

menge like ekpo-menge,

end of it_ekpo.

data:it_ekko type table of t_ekko with header line.

*DATA:X_EKKO TYPE T_EKKO.

data:itab type standard table of t_ekko.

data:t_ekpo like standard table of ekpo.

data:it_fieldcat type lvc_t_fcat.

data: x_fieldcat type lvc_s_fcat.

data:it_layout type lvc_s_layo.

data:v_cellval(10) type c,

ls_cellcolor type lvc_s_scol.

----


  • CLASS lcl_event_handler DEFINITION

----


class lcl_event_handler definition .

public section .

methods:

handle_hotspot_click for event hotspot_click of cl_gui_alv_grid

importing e_row_id e_column_id es_row_no.

endclass. "lcl_event_handler DEFINITION

----


  • CLASS lcl_event_handler IMPLEMENTATION

----


class lcl_event_handler implementation.

*Handle Hotspot Click

method handle_hotspot_click .

perform handle_hotspot_click using e_row_id e_column_id es_row_no .

endmethod. "lcl_event_handler

endclass. "lcl_event_handler IMPLEMENTATION

&----


*& Global Definitions

&----


data:go_grid type ref to cl_gui_alv_grid,

go_custom_container type ref to cl_gui_custom_container,

go_handler type ref to lcl_event_handler.

&----


  • Start of selection

----


start-of-selection.

set screen '100'.

&----


*& Module STATUS_0100 OUTPUT

&----


module status_0100 output.

set pf-status 'PF_1'.

set titlebar 'ABC'.

if go_custom_container is initial.

perform form_getdata.

perform form_create.

perform form_fieldcat.

perform form_layout.

perform alv_display.

endif.

endmodule. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


module user_command_0100 input.

case sy-ucomm.

when 'EXIT'.

leave to screen 0.

when 'BACK'.

leave to screen 0.

endcase.

endmodule. " USER_COMMAND_0100 INPUT

&----


*& Form form_getdata

&----


form form_getdata .

select ebeln

bukrs

bstyp

bsart

into corresponding fields of table it_ekko

from ekko

where ebeln in s_ebeln.

itab[] = it_ekko[].

  • IT_EKKO-ROWCOLOR = 'C300'.

  • CELLCOLOR-FNAME = 'BUKRS'.

  • CELLCOLOR-COL = '4'.

endform. " form_getdata

&----


*& Form form_fieldcat

&----


form form_fieldcat .

x_fieldcat-col_pos = 1.

x_fieldcat-fieldname = 'EBELN'.

x_fieldcat-tabname = 'EKKO'.

x_fieldcat-scrtext_l = 'PNO'.

x_fieldcat-hotspot = 'X'.

x_fieldcat-key = ' '.

append x_fieldcat to it_fieldcat.

x_fieldcat-col_pos = 2.

x_fieldcat-fieldname = 'BUKRS'.

x_fieldcat-tabname = 'EKKO'.

x_fieldcat-scrtext_l = 'Ccode'.

x_fieldcat-key = ' '.

append x_fieldcat to it_fieldcat.

x_fieldcat-col_pos = 3.

x_fieldcat-fieldname = 'BSTYP'.

x_fieldcat-tabname = 'EKKO'.

x_fieldcat-scrtext_l = 'DOC CATEGORY'.

x_fieldcat-key = ' '.

append x_fieldcat to it_fieldcat.

x_fieldcat-col_pos = 4.

x_fieldcat-fieldname = 'BSART'.

x_fieldcat-tabname = 'EKKO'.

x_fieldcat-scrtext_l = 'DOC TYPE'.

x_fieldcat-key = ' '.

append x_fieldcat to it_fieldcat.

endform. " form_fieldcat

&----


*& Form form_layout

&----


form form_layout .

  • IT_LAYOUT-ZEBRA = 'X'.

it_layout-grid_title = 'PURCHASE'.

it_layout-smalltitle = 'X'.

it_layout-sel_mode = 'A'.

it_layout-info_fname = 'ROWCOLOR'.

endform. " form_layout

&----


*& Form alv_display

&----


form alv_display .

call method go_grid->set_table_for_first_display

exporting

i_structure_name = 'IT_EKKO'

is_layout = it_layout

changing

it_fieldcatalog = it_fieldcat

it_outtab = itab.

endform. " alv_display

*FORM handle_user_command USING i_ucomm TYPE syucomm .

  • DATA lt_selected_rows TYPE lvc_t_roid .

  • DATA ls_selected_row TYPE lvc_s_roid .

  • CALL METHOD go_grid->get_selected_rows

  • IMPORTING et_row_no = lt_selected_rows .

*endform.

&----


*& Form handle_hotspot_click

&----


  • -->I_ROW_ID text

  • -->I_COLUMN_IDtext

  • -->IS_ROW_NO text

----


form handle_hotspot_click using i_row_id type lvc_s_row

i_column_id type lvc_s_col

is_row_no type lvc_s_roid.

data:v_value(18) type c,

v_ebeln(18) type c.

*IT_EKKO-ROWCOLOR = 'C300'.

read table it_ekko index i_row_id .

*ls_cellcolor-fname = ' ' .

*ls_cellcolor-color-col = '7' .

*ls_cellcolor-color-int = '1' .

it_ekko-rowcolor = 'C600'.

*APPEND ls_cellcolor TO IT_EKKO-cellcolor

. modify itab index i_row_id from it_ekko.

modify it_ekko index i_row_id.

perform form_refresh.

  • PERFORM ALV_DISPLAY.

if sy-subrc = 0 and i_column_id-fieldname = 'EBELN'.

perform form_sel.

perform form_refresh.

perform form_ekpo.

perform form_disp.

endif .

endform . "handle_hotspot_click

&----


*& Form form_create

&----


form form_create .

create object go_custom_container

exporting container_name = 'C_TEXT1'.

create object go_grid

exporting i_parent = go_custom_container.

create object go_handler.

  • SET HANDLER GO_HANDLER->HANDLE_USER_COMMAND FOR GO_GRID.

set handler go_handler->handle_hotspot_click for go_grid.

endform. " form_create

&----


*& Form FORM_REFRESH

&----


form form_refresh .

call method go_grid->refresh_table_display

  • EXPORTING

  • IS_STABLE =

  • I_SOFT_REFRESH =

exceptions

finished = 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. " FORM_REFRESH

&----


*& Form form_sel

&----


form form_sel .

call method go_grid->get_current_cell

importing

  • E_ROW =

e_value = v_cellval

  • E_COL =

  • ES_ROW_ID =

  • ES_COL_ID =

  • ES_ROW_NO =

.

endform. " form_sel

&----


*& Form form_ekpo

&----


form form_ekpo .

select * from ekpo

into table t_ekpo

where ebeln = v_cellval .

endform. " form_ekpo

&----


*& Form form_disp

&----


form form_disp .

call method go_grid->set_table_for_first_display

exporting

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • I_CONSISTENCY_CHECK =

i_structure_name = 'EKPO'

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT = 'X'

  • IS_LAYOUT =

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

changing

it_outtab = t_ekpo

  • IT_FIELDCATALOG =

  • IT_SORT =

  • IT_FILTER =

exceptions

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

others = 4

.

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

Former Member
0 Kudos

hi,

The interactive ALV can be done by the following steps:

C_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND' shud be declared.

Then C_USER_COMMAND can be passed to the I_CALLBACK_USER_COMMAND in the ALV FM. The control can be handled in the form USER_COMMAND .

FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD .

IF RS_SELFIELD-FIELDNAME = 'fname' then calling the second display. Hope it helps.

regards,

kalpana

Former Member
0 Kudos

Hi Ravi,

Check this sample program in BCALV_GRID_02.

Thanks

Rajeev