Posted: Sat Sep 22, 2007 5:00 pm Post subject: Обработка Double click и hot spot in AVL
Code:
*----------------------------------------------------------------------*
* Report Z_ALV_HOTSPOT *
*----------------------------------------------------------------------*
* Description : Display data through an ALV Grid and to
* perform EDIT, UPDATE, and DELETE funtion on
* a selected data.
*----------------------------------------------------------------------*
report Z_ALV_HOTSPOT no standard page heading message-id zc1msg.
*&---------------------------------------------------------------------*
*& Declaration Section for Tables used in the Report *
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Declaration Section for the Internal Tables *
*&---------------------------------------------------------------------*
data : t_intab1 like table of zc1address with header line,
w_intab1 like line of t_intab1,
t_intab2 like table of zc1address_exp with header line,
w_intab2 like line of t_intab2.
*&---------------------------------------------------------------------*
*& Declaration Section for EVENT HANDLER CLASS *
*&---------------------------------------------------------------------*
class lcl_event_receiver definition deferred.
*&---------------------------------------------------------------------*
*& Declaration Section for the ALV Grid *
*&---------------------------------------------------------------------*
data: ok_code like sy-ucomm,
i_container type scrfname value 'ADDRESS_BOOK',
addressbook_grid type ref to cl_gui_alv_grid,
addressbook_container type ref to cl_gui_custom_container,
i_event_receiver type ref to lcl_event_receiver,
i_fcat type lvc_t_fcat,
w_fcat like line of i_fcat,
i_fgroup type lvc_t_sgrp,
w_fgroup like line of i_fgroup,
i_layout type lvc_s_layo,
i_variant type disvariant,
x_save,
i_index_rows type lvc_t_row,
i_selected_row like lvc_s_row.
constants: c_check type c value 'X'.
*&---------------------------------------------------------------------*
*& Classes definition for tool bar push button
*&---------------------------------------------------------------------*
class lcl_event_receiver definition.
public section.
methods:
handle_toolbar for event toolbar of cl_gui_alv_grid
importing e_object e_interactive,
handle_user_command for event user_command of cl_gui_alv_grid
importing e_ucomm,
handle_double_click for event double_click of cl_gui_alv_grid
importing e_row e_column,
handle_hotspot_click for event hotspot_click of cl_gui_alv_grid
importing e_row_id e_column_id es_row_no.
endclass.
*&---------------------------------------------------------------------*
*& Classes implementation section
*&---------------------------------------------------------------------*
class lcl_event_receiver implementation.
method handle_toolbar.
constants:
c_button_normal type i value 0,
c_separator type i value 1.
data: ls_toolbar type stb_button.
clear ls_toolbar.
move 3 to ls_toolbar-butn_type.
append ls_toolbar to e_object->mt_toolbar.
clear ls_toolbar.
move 'EDIT' to ls_toolbar-function.
move icon_system_copy to ls_toolbar-icon.
move 'Sets Grid in Edit Mode' to ls_toolbar-quickinfo.
move 'Edit' to ls_toolbar-text.
move ' ' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
move 'UPDATE' to ls_toolbar-function.
move icon_system_save to ls_toolbar-icon.
move 'Updates all the changed data' to ls_toolbar-quickinfo.
move 'Update' to ls_toolbar-text.
move ' ' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
move 'DELETE' to ls_toolbar-function.
move icon_delete to ls_toolbar-icon.
move 'Deletes the current record' to ls_toolbar-quickinfo.
move 'Delete' to ls_toolbar-text.
move ' ' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
move 'REFRESH' to ls_toolbar-function.
move icon_refresh to ls_toolbar-icon.
move 'Refreshes the data in the grid' to ls_toolbar-quickinfo.
move 'Refresh' to ls_toolbar-text.
move ' ' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
endmethod.
* Method that check the events in the created buttons. *
method handle_user_command.
case e_ucomm.
when 'EDIT'.
call method addressbook_grid->set_ready_for_input
exporting i_ready_for_input = 1.
when 'UPDATE'.
perform update_modified_information.
when 'DELETE'.
perform delete_selected_information.
when 'REFRESH'.
perform refresh_table_information.
endcase.
endmethod.
* Method that check the event of double click in the grid *
method handle_double_click.
read table t_intab1 index e_row-index into w_intab1.
read table t_intab2 into w_intab2 with key addcode =
w_intab1-addcode.
if sy-subrc <> 0.
message i005.
else.
call screen 3001 starting at 10 5.
endif.
endmethod.
* Method that processes the hotspot event *
method handle_hotspot_click.
perform handle_hotspot using e_row_id
e_column_id
es_row_no.
endmethod.
endclass.
*&---------------------------------------------------------------------*
*& Selection ScreenSection for the ALV Grid
*&---------------------------------------------------------------------*
selection-screen begin of block add1 with frame title text-001.
select-options : s_acode for zc1address-addcode.
selection-screen end of block add1.
*&---------------------------------------------------------------------*
*& Start Of Selection Event Begins Here *
*&---------------------------------------------------------------------*
start-of-selection.
* Selects the data into internal tables *
select * from zc1address into table t_intab1
where addcode in s_acode.
select * from zc1address_exp into table t_intab2
where addcode in s_acode.
data: begin of info_tab,
client type sy-mandt,
username type sy-uname,
progname type sy-repid,
tcode type sy-tcode,
programmer type sy-repid,
end of info_tab.
data: info_tab1 like table of info_tab with header line,
w_info_tab1 like line of info_tab1.
move sy-mandt to w_info_tab1-client.
move sy-uname to w_info_tab1-username.
move sy-repid to w_info_tab1-progname.
move sy-tcode to w_info_tab1-tcode.
move 'KATHIRVEL BALAKRISHNAN' to w_info_tab1-programmer.
append w_info_tab1 to info_tab1.
*&---------------------------------------------------------------------*
*& Form create_field_catalog
*&---------------------------------------------------------------------*
* This Subroutine Creates the Field Catalogue.
*----------------------------------------------------------------------*
form create_field_catalog.
*&---------------------------------------------------------------------*
*& Form create_field_group
*&---------------------------------------------------------------------*
* Creates the Grouping for the Fields in the Grid
*----------------------------------------------------------------------*
form create_field_group.
* Employee Information Group
w_fgroup-sp_group = 'GEN'.
w_fgroup-text = 'General Details'.
append w_fgroup to i_fgroup.
* Employee Project Information Group
w_fgroup-sp_group = 'CON'.
w_fgroup-text = 'Contact Details'.
append w_fgroup to i_fgroup.
endform. " create_field_group
*&---------------------------------------------------------------------*
*& Form update_modified_information
*&---------------------------------------------------------------------*
* Updates all the changed entries into the database table
*----------------------------------------------------------------------*
form update_modified_information.
endform. " update_modified_information
*&---------------------------------------------------------------------*
*& Form delete_selected_information
*&---------------------------------------------------------------------*
* This Deletes the selected row of data form the ALV grid.
*----------------------------------------------------------------------*
form delete_selected_information.
data : i_lines type i.
* Reading the index of the selected row in the ALV grid.
call method addressbook_grid->get_selected_rows
importing
et_index_rows = i_index_rows.
* Check whether a row is selected or not. If not it popups a
* dialog box as warning to select a row.
describe table i_index_rows lines i_lines.
if i_lines = 0.
message i002.
exit.
endif.
* Reads the selected rows into work area for display
loop at i_index_rows into i_selected_row.
if sy-tabix = 1.
read table t_intab1 index i_selected_row-index into w_intab1.
endif.
endloop.
delete t_intab1 where addcode = w_intab1-addcode .
delete from zc1address where addcode = w_intab1-addcode .
perform refresh_table_information.
if sy-subrc = 0.
message i003.
else.
message i004.
endif.
endform. " delete_selected_information
*&---------------------------------------------------------------------*
*& Form refresh_table_information
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form refresh_table_information.
endform. " refresh_table_information
*&---------------------------------------------------------------------*
*& Form handle_hotspot
*&---------------------------------------------------------------------*
* The Process that are done in a hotspot of ALV
*----------------------------------------------------------------------*
form handle_hotspot using p_e_row_id type lvc_s_row
p_e_column_id type lvc_s_col
p_es_row_no type lvc_s_roid.
read table t_intab1 index p_e_row_id into w_intab1.
read table t_intab2 into w_intab2 with key addcode =
w_intab1-addcode.
if sy-subrc <> 0.
message i005.
else.
call screen 3001 starting at 10 5.
endif.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.