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 grid event handling

Former Member
0 Kudos

Hi Everyone,

I have two alv grids displayed in the screen. When the first alv is displayed the first item will be selected in the first grid, based on this item i have to populate the data in second grid.

The first grid is the master and the second grid is the detail and has 1:N relationship. After the initial screen is displayed based on the hotspot click on the master grid I will have to populate the detail grid.

Can anyone provide some sample codes for this.

Thanks in advance,

Prashanth.

4 REPLIES 4

marilyn_pratt
Active Contributor
0 Kudos

Hi Prashant,

If you look at the package (development class) SLIS, you will find a sample program called: BCALV_GRID_02

This is a demo of the technique that I believe you would like to see.

cheers,

Marilyn

andreas_mann3
Active Contributor
0 Kudos

hi,

try that :

1) register event double click

2) define own method in local class:


    handle_dclick for event double_click OF cl_gui_alv_grid importing ES_ROW_NO.

implementation:

    READ TABLE itab1 INTO wa1 INDEX ES_ROW_NO-row_id.
    read table itab2 into wa2 with key
             field1 = wa1-key1
             field2 = wa1-key2,

    row_no-row_id = sy-tabix.
    col_info-fieldname = 'FIELD2'.
    CALL METHOD ebr_grid->set_scroll_info_via_id
       EXPORTING
         IS_COL_INFO    = col_info
         is_row_no      = row_no.

Andreas

Former Member
0 Kudos

Hi,

1) Declare a class to trigger this event.

eg: class : cl_event definition deferred,

data : cl_event type reference to cl_event,

cl_alv type reference to cl_gui_alv_grid.

Class cl_event definition.

public section.

methods : handle_hotspot_click

for event HOTSPOT_CLICK of cl_gui_alv_grid

importing e_row_id e_column_id

endclass.

class cl_event implementation.

method handle_hotspot_click.

read table <final table> using e_row_id

based on this select the lineitems....

....

endmethod.

endclass.

CREATE OBJECT CL_EVENT.

SET HANDLER CL_EVENT->HANDLE_HOTSPOT_CLICK FOR CL_ALV.

CALL cl_alv->set_table_for_first_display to display

the output(line items).

This should solve your problem

Vamsi

ssimsekler
Active Contributor
0 Kudos

Hi Prashhant

You can make use of the tutorial <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/an%20easy%20reference%20for%20alv%20grid%20control.pdf">"An Easy Reference for ALV Grid Control"</a>.

Regards

*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>