‎2006 Nov 24 12:54 PM
Hi Friends,
Let me know how to handle the event raised by clicking the hotspot of an ALV grid that is placed over one splitter container.
I am explaining the problem in detail:
(1) I have to display an ALV grid and when any hotspot of that ALV grid is clicked,
the row-id should be captured and used to fetch corresponding records from
child table (primarykey-foreign key relationship) and the resulting grid should be
displayed on the same screen at the same time and for any further click, the
child grid is to be refreshed.
(2) For this, I have created one custom container, placed one splitter container having two rows & one column over it and placed the ALV grids over that by getting the corresponding containers of the splitter.
(3) Now, when the hotspot is clicked the SY-UCOMM is empty (even it is not entering the PAI block if I do not place the back button). So, I am not able to get the row-id of the clicked row & without that, can't proceed any further.
(4) Rest of the things are working fine and I have tested that also.
Please help me out as I am new to this field and started practicing ABAP just a month back.
Thanks & Regards
Aditya P. Srivastava
‎2006 Nov 24 7:08 PM
Hi Aditya
Here is the complete for the same,
<b>Some Prerequisites in terms of screen, custom control & flow logic</b>
<i>Screen Name: 9000, Custom Container name : CONTAINER.
flow logic in screen 9000
PROCESS BEFORE OUTPUT.
MODULE status_9000.
MODULE init_9000.
PROCESS AFTER INPUT.
MODULE user_command_9000.</i>
<b>
Here goes the code,</b>
REPORT zkb_2alv_grids.
DATA: i_t000 TYPE TABLE OF t000,
w_t000 TYPE t000,
i_tcurr TYPE TABLE OF tcurr.
Declaration for all the objects required
DATA: o_container TYPE REF TO cl_gui_custom_container,
o_splitter TYPE REF TO cl_gui_easy_splitter_container,
o_container_top TYPE REF TO cl_gui_container,
o_container_bottom TYPE REF TO cl_gui_container,
o_salv_table1 TYPE REF TO cl_salv_table,
o_salv_table2 TYPE REF TO cl_salv_table,
o_salv_columns TYPE REF TO cl_salv_columns_table,
o_salv_column TYPE REF TO cl_salv_column_table.
DATA: o_events TYPE REF TO cl_salv_events_table.
----
CLASS lcl_handle_events DEFINITION
----
CLASS lcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS: on_link_click
FOR EVENT link_click
OF cl_salv_events_table
IMPORTING row column.
ENDCLASS. "lcl_handle_events DEFINITION
----
CLASS lcl_handle_events IMPLEMENTATION
----
CLASS lcl_handle_events IMPLEMENTATION.
METHOD on_link_click.
READ TABLE i_t000 INTO w_t000 INDEX row.
SELECT * FROM tcurr
INTO TABLE i_tcurr
WHERE fcurr = w_t000-mwaer.
o_salv_table2->refresh( ).
ENDMETHOD. "lcl_handle_events
ENDCLASS. "lcl_handle_events IMPLEMENTATION
START-OF-SELECTION.
DATA: event_handler TYPE REF TO lcl_handle_events.
Select Data
SELECT * FROM t000 INTO TABLE i_t000.
CALL SCREEN 9000.
&----
*& Module init_9000 OUTPUT
&----
text
----
MODULE init_9000 OUTPUT.
DATA: lv_cx_salv_msg TYPE REF TO cx_salv_msg,
lw_bal_s_msg TYPE bal_s_msg.
IF NOT o_container IS BOUND.
Create a Custom Control
CREATE OBJECT o_container
EXPORTING
container_name = 'CONTAINER'
repid = sy-repid
dynnr = '9000'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Create splitter control
CREATE OBJECT o_splitter
EXPORTING
parent = o_container
orientation = 0
sash_position = 30
with_border = 1
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Assign the left and right control that were splitted
o_container_top = o_splitter->top_left_container.
o_container_bottom = o_splitter->bottom_right_container.
ENDIF. " IF NOT o_container IS BOUND.
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
r_container = o_container_top
IMPORTING
r_salv_table = o_salv_table1
CHANGING
t_table = i_t000.
CATCH cx_salv_msg INTO lv_cx_salv_msg.
lv_cx_salv_msg->if_alv_message~get_message(
RECEIVING
r_s_msg = lw_bal_s_msg ).
MESSAGE ID lw_bal_s_msg-msgid
TYPE lw_bal_s_msg-msgty
NUMBER lw_bal_s_msg-msgno
WITH lw_bal_s_msg-msgv1 lw_bal_s_msg-msgv2
lw_bal_s_msg-msgv3 lw_bal_s_msg-msgv4.
ENDTRY.
Column Settings
o_salv_columns = o_salv_table1->get_columns( ).
o_salv_column ?= o_salv_columns->get_column( 'MWAER' ).
o_salv_column->set_cell_type( 5 ).
o_events = o_salv_table1->get_event( ).
CREATE OBJECT event_handler.
SET HANDLER event_handler->on_link_click FOR o_events.
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
r_container = o_container_bottom
IMPORTING
r_salv_table = o_salv_table2
CHANGING
t_table = i_tcurr.
CATCH cx_salv_msg INTO lv_cx_salv_msg.
lv_cx_salv_msg->if_alv_message~get_message(
RECEIVING
r_s_msg = lw_bal_s_msg ).
MESSAGE ID lw_bal_s_msg-msgid
TYPE lw_bal_s_msg-msgty
NUMBER lw_bal_s_msg-msgno
WITH lw_bal_s_msg-msgv1 lw_bal_s_msg-msgv2
lw_bal_s_msg-msgv3 lw_bal_s_msg-msgv4.
ENDTRY.
Display the ALV Grid
o_salv_table1->display( ).
o_salv_table2->display( ).
ENDMODULE. " init_9000 OUTPUT
&----
*& Module user_command_9000 INPUT
&----
text
----
MODULE user_command_9000 INPUT.
CASE sy-ucomm .
WHEN 'BACK' OR 'EXIT' OR 'CANC'.
SET SCREEN 0.
LEAVE SCREEN.
ENDCASE.
ENDMODULE. " user_command_9000 INPUT
&----
*& Module status_9000 OUTPUT
&----
text
----
MODULE status_9000 OUTPUT.
SET PF-STATUS '9000'.
ENDMODULE. " status_9000 OUTPUT
Regards
Kathirvel
‎2006 Nov 24 1:01 PM
‎2006 Nov 24 1:03 PM
Hi Aditya,
Try this:
While building the fieldcatalog , use the hotspot property for the field u want the hotspot to be used .
Like ls_fieldcat_0200-hotspot = 'X'.
After that handle the hotspot .
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: ls_out TYPE cnv_30350_display,
lv_total TYPE i.
IF i_column_id-fieldname = 'TABNAME'.
READ TABLE gt_out
INTO ls_out
INDEX is_row_no-row_id.
*Put ur code here
endif.
Reward full marks if this helps.
Sandeep
‎2006 Nov 24 2:07 PM
hi
good
go to se38 put BCALV* and put f4 you ll find good example there related to your example , check them and use accordingly.
thanks
mrutyun^
‎2006 Nov 24 3:42 PM
HI,
Once I have implemented something similar, but I used a simple dynpro with two different custom container.
In the hotspot event of the father I refresh the children alv.
I try to find this code and I will send you
bye
enzo
‎2006 Nov 24 7:08 PM
Hi Aditya
Here is the complete for the same,
<b>Some Prerequisites in terms of screen, custom control & flow logic</b>
<i>Screen Name: 9000, Custom Container name : CONTAINER.
flow logic in screen 9000
PROCESS BEFORE OUTPUT.
MODULE status_9000.
MODULE init_9000.
PROCESS AFTER INPUT.
MODULE user_command_9000.</i>
<b>
Here goes the code,</b>
REPORT zkb_2alv_grids.
DATA: i_t000 TYPE TABLE OF t000,
w_t000 TYPE t000,
i_tcurr TYPE TABLE OF tcurr.
Declaration for all the objects required
DATA: o_container TYPE REF TO cl_gui_custom_container,
o_splitter TYPE REF TO cl_gui_easy_splitter_container,
o_container_top TYPE REF TO cl_gui_container,
o_container_bottom TYPE REF TO cl_gui_container,
o_salv_table1 TYPE REF TO cl_salv_table,
o_salv_table2 TYPE REF TO cl_salv_table,
o_salv_columns TYPE REF TO cl_salv_columns_table,
o_salv_column TYPE REF TO cl_salv_column_table.
DATA: o_events TYPE REF TO cl_salv_events_table.
----
CLASS lcl_handle_events DEFINITION
----
CLASS lcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS: on_link_click
FOR EVENT link_click
OF cl_salv_events_table
IMPORTING row column.
ENDCLASS. "lcl_handle_events DEFINITION
----
CLASS lcl_handle_events IMPLEMENTATION
----
CLASS lcl_handle_events IMPLEMENTATION.
METHOD on_link_click.
READ TABLE i_t000 INTO w_t000 INDEX row.
SELECT * FROM tcurr
INTO TABLE i_tcurr
WHERE fcurr = w_t000-mwaer.
o_salv_table2->refresh( ).
ENDMETHOD. "lcl_handle_events
ENDCLASS. "lcl_handle_events IMPLEMENTATION
START-OF-SELECTION.
DATA: event_handler TYPE REF TO lcl_handle_events.
Select Data
SELECT * FROM t000 INTO TABLE i_t000.
CALL SCREEN 9000.
&----
*& Module init_9000 OUTPUT
&----
text
----
MODULE init_9000 OUTPUT.
DATA: lv_cx_salv_msg TYPE REF TO cx_salv_msg,
lw_bal_s_msg TYPE bal_s_msg.
IF NOT o_container IS BOUND.
Create a Custom Control
CREATE OBJECT o_container
EXPORTING
container_name = 'CONTAINER'
repid = sy-repid
dynnr = '9000'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Create splitter control
CREATE OBJECT o_splitter
EXPORTING
parent = o_container
orientation = 0
sash_position = 30
with_border = 1
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Assign the left and right control that were splitted
o_container_top = o_splitter->top_left_container.
o_container_bottom = o_splitter->bottom_right_container.
ENDIF. " IF NOT o_container IS BOUND.
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
r_container = o_container_top
IMPORTING
r_salv_table = o_salv_table1
CHANGING
t_table = i_t000.
CATCH cx_salv_msg INTO lv_cx_salv_msg.
lv_cx_salv_msg->if_alv_message~get_message(
RECEIVING
r_s_msg = lw_bal_s_msg ).
MESSAGE ID lw_bal_s_msg-msgid
TYPE lw_bal_s_msg-msgty
NUMBER lw_bal_s_msg-msgno
WITH lw_bal_s_msg-msgv1 lw_bal_s_msg-msgv2
lw_bal_s_msg-msgv3 lw_bal_s_msg-msgv4.
ENDTRY.
Column Settings
o_salv_columns = o_salv_table1->get_columns( ).
o_salv_column ?= o_salv_columns->get_column( 'MWAER' ).
o_salv_column->set_cell_type( 5 ).
o_events = o_salv_table1->get_event( ).
CREATE OBJECT event_handler.
SET HANDLER event_handler->on_link_click FOR o_events.
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
r_container = o_container_bottom
IMPORTING
r_salv_table = o_salv_table2
CHANGING
t_table = i_tcurr.
CATCH cx_salv_msg INTO lv_cx_salv_msg.
lv_cx_salv_msg->if_alv_message~get_message(
RECEIVING
r_s_msg = lw_bal_s_msg ).
MESSAGE ID lw_bal_s_msg-msgid
TYPE lw_bal_s_msg-msgty
NUMBER lw_bal_s_msg-msgno
WITH lw_bal_s_msg-msgv1 lw_bal_s_msg-msgv2
lw_bal_s_msg-msgv3 lw_bal_s_msg-msgv4.
ENDTRY.
Display the ALV Grid
o_salv_table1->display( ).
o_salv_table2->display( ).
ENDMODULE. " init_9000 OUTPUT
&----
*& Module user_command_9000 INPUT
&----
text
----
MODULE user_command_9000 INPUT.
CASE sy-ucomm .
WHEN 'BACK' OR 'EXIT' OR 'CANC'.
SET SCREEN 0.
LEAVE SCREEN.
ENDCASE.
ENDMODULE. " user_command_9000 INPUT
&----
*& Module status_9000 OUTPUT
&----
text
----
MODULE status_9000 OUTPUT.
SET PF-STATUS '9000'.
ENDMODULE. " status_9000 OUTPUT
Regards
Kathirvel
‎2006 Nov 30 11:44 AM
Hi Kathirvel Balakrishnan,
Thanks a lot for provided me complete code that implements the logic I was thinking. Honestly speaking, I created the code before seeing you post & that too was very similar to the one posted by you. But you have put efforts in providing me really helpful code and that too very soon.
That's why I am awarding you full points for your help and consideration. Hoping for the same support in future also.
Regards,
Aditya P. Srivastava