ALV Grid: Unregister keyboard events?
Hi guys,
once again I've got some trouble with my ALV-grid control.
In order to implement my own functionality for removing and adding lines to my alv grid I removed the standard-buttons from the toolbar and added my own.
Unfortunately the user can still remove lines from the alv by pressing the DEL key on the keyboard.
Adjusting the layout by setting ps_layout-no_rowins = 'X' and ps_layout-no_rowmove = 'X' doesn't work for me since the alv contains a field CHDATE to show the date when the line was last edited. If the user presses the DEL key there's no way for me to adjust this field.
So, does anyone have an idea how to "unregister" these keyevents?
Any help is much appreciated!
Best regards,
ron
Hi guys,
i just found a way to prevent the deletion of a line by pressing DEL on the keyboard.
All you have to do is include an additional field (type LVC_T_STYL) to your outtab.
This structure include the following fields:
FIELDNAME LVC_FNAME
STYLE LVC_STYLE
STYLE2 LVC_STYLE
STYLE3 LVC_STYLE
STYLE4 LVC_STYLE
MAXLEN INT4
This structures is normally used to set the style for a cell by specifying the FIELDNAME.
When FIELDNAME is initial the style works for the line. So instead of changing the fieldname just leave it blank and change STYLE to cl_gui_alv_grid=>MC_STYLE_NO_DELETE_ROW
This way the line can neither be removed with the standard "REMOVE LINE"-button nor by pressing DEL.
Keep in mind that it doesn't work when you change the layout to layout-no_rowins = 'X' and layout-no_rowmove = 'X'.
Regards,
Ron
Similar Messages
-
ALV Grid Handle Edit Event (Lost Focus)
Hi all,
I have some problems with the ALV Grid.
Target:
I have an ALV Grid with editable Column. If the user insert, update or delete the content of the column and leave the column (column lost focus) i'd like to do somthing - this means I need a event for this action. Can anybody help me to solve this problem?
Thanks StefanUse Event data_changed and data_changed_finished of the cl_gui_alv_grid.Then all you have to do is registering your event to the ALV and fill the methods with what you want to do.In ALV Grid, There is no event to capture the lost focus of a column if you don't modify it.
CLASS lcl_event_receiver DEFINITION.
METHODS:
*$ Check the change
handle_data_changed FOR EVENT data_changed
OF cl_gui_alv_grid
IMPORTING er_data_changed
e_ucomm
e_onf4
e_onf4_before
e_onf4_after,
handle_data_changed_finished
FOR EVENT data_changed_finished
OF cl_gui_alv_grid
IMPORTING e_modified
et_good_cells
sender,
ENDCLASS. "LCL_EVENT_RECEIVER DEFINITION -
Hi,
I have alv grid using cl_gui_alv_grid. I want to capture the row selection event and display the detail below the table.
how do I capture the row selection.? I want to display the details below as and when the row selection changed.
Regards
PanneerMore detail example, also works with multiple selections:
data go_alv type ref to cl_gui_alv_grid.
data go_handler type ref to lcl_event_receiver.
* CLASS lcl_event_receiver DEFINITION
class lcl_event_receiver definition.
public section.
methods delayed_change_select
for event delayed_changed_sel_callback of cl_gui_alv_grid.
endclass. "lcl_event_receiver DEFINITION
* CLASS lcl_event_receiver IMPLEMENTATION
class lcl_event_receiver implementation.
method delayed_change_select.
message 'Selection changed' type 'S'.
endmethod. "delayed_change_selection
endclass. "lcl_event_receiver IMPLEMENTATION
*& Module STATUS_0100 OUTPUT
module status_0100 output.
data lt_fcat_lvc type lvc_t_fcat.
data lt_fcat_alv type slis_t_fieldcat_alv.
data ls_layo type lvc_s_layo.
set pf-status 'MAIN'.
if go_alv is initial.
ls_layo-sel_mode = 'A'.
* ls_layo-sel_mode = 'B'. "Also works
* ls_layo-sel_mode = 'C'. "Also works
* ls_layo-sel_mode = 'D'. "Also works
call method go_alv->set_table_for_first_display
exporting
is_layout = ls_layo
changing
it_fieldcatalog = lt_fcat_lvc
it_outtab = gt_data[].
create object go_handler.
set handler go_handler->delayed_change_select for go_alv.
call method go_alv->register_delayed_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_delayed_change_select.
endif.
endmodule. " STATUS_0100 OUTPUT -
I have created an ALV grid with a dropdown as one of the columns. This all works fine, except that I want to be able to react to a change in the value of each line's dropdown.
Currently I am reacting to the DATA_CHANGED event of the ALV grid, but that is too late. This event is only triggered if you change the value of the dropdown and then hit enter, or click on another cell or row.
I want to be able to react to a change in the value immediately without having to lose focus of the dropdown.
Is this possible?
As an example, I have a table of records with one column as a dropdown called "Reason". A change in "reason" should change which fields in the row are editable. I'm sure I could just make sure to call the check_changed_data method before saving but I am hoping for a more user-friendly approach where as the new value is selected, the columns in the row can change to their required editable status.
Of course points will be awarded.Hi David,
Instead of using delayed call back event here i hav used data_changed event and this exacty suits ur requirement.....
even here we have to register the edit events............
PROGRAM bcalv_edit_06.
* Purpose:
* ~~~~~~~~
* This example shows how to define a dropdown listbox for all cells
* of one column in an editable ALV Grid Control.
* To check program behavior
* ~~~~~~~~~~~~~~~~~~~~~~~~~
* Klick on the dropdown button of column 'WUNIT'. It shows
* 'KG' and 'G' as suitable units for luggage weight.
* (The standard F4-Help shows many other units that does not
* make sense in this context).
* Essential steps (search for '§')
* ~~~~~~~~~~~~~~~
* 1.Define a dropdown table and pass it to ALV.
* 2.Set status of column WUNIT to editable and set a dropdown handle.
CLASS lcl_event_responder DEFINITION.
PUBLIC SECTION.
METHODS refresh_changed_data FOR EVENT data_changed
OF cl_gui_alv_grid
IMPORTING er_data_changed
e_ucomm.
ENDCLASS. "event_responder DEFINITION
DATA: ok_code LIKE sy-ucomm,
save_ok LIKE sy-ucomm,
g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
handler TYPE REF TO lcl_event_responder,
g_grid TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container,
gt_fieldcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo,
g_max TYPE i VALUE 100.
DATA: gt_outtab TYPE TABLE OF sbook.
* MAIN *
END-OF-SELECTION.
CALL SCREEN 100.
* MODULE PBO OUTPUT *
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
IF g_custom_container IS INITIAL.
PERFORM create_and_init_alv CHANGING gt_outtab
gt_fieldcat.
ENDIF.
ENDMODULE. "pbo OUTPUT
* MODULE PAI INPUT *
MODULE pai INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN OTHERS.
* do nothing
ENDCASE.
ENDMODULE. "pai INPUT
* FORM EXIT_PROGRAM *
FORM exit_program.
LEAVE PROGRAM.
ENDFORM. "exit_program
*& Form BUILD_FIELDCAT
* text
* <--P_GT_FIELDCAT text
FORM build_fieldcat CHANGING pt_fieldcat TYPE lvc_t_fcat.
DATA ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SBOOK'
CHANGING
ct_fieldcat = pt_fieldcat.
LOOP AT pt_fieldcat INTO ls_fcat.
IF ls_fcat-fieldname EQ 'WUNIT'.
*§2.Set status of column WUNIT to editable and set a dropdown handle.
ls_fcat-edit = 'X'.
ls_fcat-drdn_hndl = '1'.
ls_fcat-outputlen = 7.
* Field 'checktable' is set to avoid shortdumps that are caused
* by inconsistend data in check tables. You may comment this out
* when the test data of the flight model is consistent in your system.
ls_fcat-checktable = '!'. "do not check foreign keys
MODIFY pt_fieldcat FROM ls_fcat.
ENDIF.
ENDLOOP.
ENDFORM. "build_fieldcat
*& Form CREATE_AND_INIT_ALV
* text
* <--P_GT_OUTTAB text
* <--P_GT_FIELDCAT text
* <--P_GS_LAYOUT text
FORM create_and_init_alv CHANGING pt_outtab LIKE gt_outtab[]
pt_fieldcat TYPE lvc_t_fcat.
DATA: lt_exclude TYPE ui_functions,
lt_f4 TYPE lvc_t_f4 WITH HEADER LINE.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT g_grid
EXPORTING i_parent = g_custom_container.
* Build fieldcat and set column WUNIT
* edit enabled. Assign a handle for the dropdown listbox.
PERFORM build_fieldcat CHANGING pt_fieldcat.
* Optionally restrict generic functions to 'change only'.
* (The user shall not be able to add new lines).
PERFORM exclude_tb_functions CHANGING lt_exclude.
* Define a drop down table.
PERFORM set_drdn_table.
SELECT * FROM sbook INTO TABLE pt_outtab UP TO g_max ROWS.
IF sy-subrc NE 0.
* generate own entries if database table is empty
PERFORM generate_entries CHANGING pt_outtab.
ENDIF.
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
it_toolbar_excluding = lt_exclude
CHANGING
it_fieldcatalog = pt_fieldcat
it_outtab = pt_outtab.
* Set editable cells to ready for input initially
CALL METHOD g_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
g_grid->register_edit_event(
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified ). "Registering edit events
CREATE OBJECT handler.
SET HANDLER handler->refresh_changed_data FOR g_grid.
CLEAR lt_f4.
lt_f4-fieldname = 'WUNIT'.
lt_f4-register = 'X'.
APPEND lt_f4.
ENDFORM. "CREATE_AND_INIT_ALV
*& Form EXCLUDE_TB_FUNCTIONS
* text
* <--P_LT_EXCLUDE text
FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
* Only allow to change data not to create new entries (exclude
* generic functions).
DATA ls_exclude TYPE ui_func.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.
APPEND ls_exclude TO pt_exclude.
ENDFORM. " EXCLUDE_TB_FUNCTIONS
*& Form set_drdn_table
* text
* --> p1 text
* <-- p2 text
FORM set_drdn_table.
*§1.Define a dropdown table and pass it to ALV.
* One listbox is referenced by a handle, e.g., '1'.
* For each entry that shall appear in this listbox
* you have to append a line to the dropdown table
* with handle '1'.
* This handle can be assigned to several columns
* of the output table using the field catalog.
DATA: lt_dropdown TYPE lvc_t_drop,
ls_dropdown TYPE lvc_s_drop.
* First listbox (handle '1').
ls_dropdown-handle = '1'.
ls_dropdown-value = 'KG'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = 'G'.
APPEND ls_dropdown TO lt_dropdown.
CALL METHOD g_grid->set_drop_down_table
EXPORTING
it_drop_down = lt_dropdown.
ENDFORM. " set_drdn_table
*& Form generate_entries
* text
* <--P_LT_SLFIGHT text
FORM generate_entries CHANGING pt_sbook TYPE STANDARD TABLE.
* This form is only needed if database table sbook is empty.
* It generates some entries so that you may
* still try out this example program.
DATA: ls_sbook TYPE sbook,
l_month(2) TYPE c,
l_day(2) TYPE c,
l_date(8) TYPE c,
l_prebookid TYPE i.
ls_sbook-carrid = 'LH'.
ls_sbook-connid = '0400'.
ls_sbook-forcurkey = 'DEM'.
ls_sbook-loccurkey = 'USD'.
ls_sbook-custtype = 'B'.
DO 110 TIMES.
l_prebookid = sy-index.
ls_sbook-forcuram = sy-index * 10.
ls_sbook-loccuram = ls_sbook-loccuram * 2.
ls_sbook-customid = sy-index.
ls_sbook-counter = 18.
ls_sbook-agencynum = 11.
l_month = sy-index / 10 + 1.
DO 2 TIMES.
l_day = 3 + l_month + sy-index * 2.
l_date+0(4) = '2000'.
l_date+4(2) = l_month.
l_date+6(2) = l_day.
ls_sbook-fldate = l_date.
SUBTRACT 3 FROM l_day.
ls_sbook-order_date+0(6) = l_date+0(6).
ls_sbook-order_date+6(2) = l_day.
ls_sbook-bookid = l_prebookid * 2 + sy-index.
IF sy-index EQ 1.
ls_sbook-smoker = 'X'.
ELSE.
ls_sbook-smoker = space.
ENDIF.
ls_sbook-luggweight = l_prebookid * 10.
IF ls_sbook-luggweight GE 1000.
ls_sbook-wunit = 'G'.
ls_sbook-class = 'C'.
ELSE.
ls_sbook-wunit = 'KG'.
ls_sbook-class = 'Y'.
ENDIF.
IF ls_sbook-bookid > 40 AND ls_sbook-wunit EQ 'KG'.
ls_sbook-invoice = 'X'.
ENDIF.
IF ls_sbook-bookid EQ 2.
ls_sbook-cancelled = 'X'.
ls_sbook-class = 'F'.
ENDIF.
APPEND ls_sbook TO pt_sbook.
ENDDO.
ENDDO.
ENDFORM. " generate_entries
* CLASS event_responder IMPLEMENTATION
CLASS lcl_event_responder IMPLEMENTATION.
METHOD refresh_changed_data.
BREAK-POINT.
ENDMETHOD. "click
ENDCLASS. "event_responder IMPLEMENTATION -
ALV GRID - double click event - hot spot event
Dear developers
I am building a custom application using ALV GRID (OO method).
I have three ALV's on the screen.
User selects a cell on the first ALV from the list. say a specific product group.
The second ALV displays the product records depnding on selection of first ALV. (this works fine).
when the user selects a cell of a specific column on ALV grid 2 using double click event or hotspot I am always getting row ID as 1 , irrespective of the user clickin on row 2 or 3 on the specific cell.
To carry out further processing , I need to get the exact row the user is selecting which I expected to be available in LVC_S_ROID. My further process works always with ROW ID as 1.
I am using event hot spot in alv grid 1. In grid 2 I tried both hot spot and double click . But both returns the index value of row as 1 , irrespective of the cell being clicked is beyond row 1. in second grid.
Looking forward for help or suggestion on this,
Regards
KumarHi
The handler is implemented as follows for all ALV GRIDs.
I give below only the relevant one grid 2 from my code.
Class definition
**03/17/2005 skulist hotspot
handle_skulist FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no,
Class implementation
**03/17/2005 sku list by currency hotspot on listprice
METHOD handle_skulist .
PERFORM handle_skulist USING e_row_id e_column_id es_row_no.
ENDMETHOD. "HANDLE_HOTSPOT_CLICK
DATA gr_event_handler TYPE REF TO lcl_event_handler.
DATA gr_event_handler_4 TYPE REF TO lcl_event_handler.
The above are done in an include and are public in nature.
Also note that I have similar implementation for similar events for grid 1 bu the event handlers are registered in different names.
The code below is in the maib program , under a custom container for grid 2
CREATE OBJECT gr_event_handler_4.
SET HANDLER gr_event_handler_4->handle_skulist FOR gr_alvgrid1.
*Based on the user action on grid 2 this form is getting executed. But as I said earlier the parameter I am getting for index is 1 always.
FORM handle_skulist USING i_row_id1 TYPE lvc_s_row
i_column_id1 TYPE lvc_s_col
is_row_no1 TYPE lvc_s_roid. -
Hi there,
I have a grid table being filled of which I know, that it doesn't contain all necessary data to allow the user to continue.
As there are no mandatory flags to the fields I want to call a method (e.g. SET_DELTA_CELLS: it's marked INTERNAL only and doesn't seam to work anyway) to emulate user input or just trigger the event DATA_CHANGED.
I also thought about using method ADD_ROWS, but I don't need excess rows that I need to remove again.
What other possibilities are there?>
Alan Downing wrote:
> Hi Prabhu,
>
> thanks for your answer.
> Alas, it would require the user to actively change a field and press ENTER or change a cell in order for DATA_CHANGED to being fired.
>
> The point is, that I need to check certain data independent of user action (change of cell data). If the user presses the save/ok/continue button he must not be allowed to continue unless all data of the grid is filled where required.
>
> regards
> Alan
Hi Alan,
You could write a subroutine which will do all the validations and call this subroutine for every user action for which you think the data should be validated. You could pass the old and new table to this subroutine and compare the values to see if the requirement is fulfilled and the data is valid.
Hope this helps.
Best regards,
Advait -
ALV-Grid: Is it possible to catch "LOCAL Function Codes" in any Event ??
Hi,
is it possible that i can catch a "Local Function Code" in ALV Grid with an Event??
For example if you click to an Grid Button on the toolbar than it must call an Event!
..........BUTTON: Local APPEND (existing in ALV Toolbar)
Function Code: '&LOCAL&APPEND'
My Idea is:
--- IF i click to the Button "Local APPEND" in the ALV toolbar, than it must after this command give me an Message( "It was Successfull" ).
But the "Local Function Codes" dont called the Event "User_command" OR "After_user_command" is there any other Event for this "Local Function Codes"???
Have anyone an idea?
Thanks in forward.
ErsinHi,
See following thread.
http://scn.sap.com/thread/715996
Thanks
Santosh -
Report with 5 ALV grids on 1 screen
I am trying to build a screen/report with 5 ALV grids which are interactive. One grid will display all sales order. When I click on a Sales order Hotspot, the items of the sales order would appear in the ALV grid box below.
When i click on an sales order item hotspot, i want the delivery information in another alv grid in the same screen.
There should be 2 more grids - one displaying the customer information -name,address, in one grid and one grid for open items if any. Any advice is welcome . Should I be creating a split container/docking container or multiple containers ? Sample code is welcome.
Edited by: Shareen Hegde on Apr 2, 2008 9:25 PMHello Shareen
Below I have added my sample report ZUS_SDN_THREE_ALV_GRIDS showing three interactive ALV grids. Perhaps it might be useful to you. I would prefer one or multiple splitter containers over multiple "stand-alone" containers.
*& Report ZUS_SDN_THREE_ALV_GRIDS
*& Display Customer data in three ALV lists:
*& 1st ALV: Customers
*& 2nd ALV: Sales order of selected customer (double-click)
*& 3rd ALV: Positions of selected sales order (double-click)
*& Double-click on material -> display material (MM02)
*& NOTE: dynpro does not contain any elements (ok_code -> GD_OKCODE)
*& Flow logic of dynpro '0100':
*&PROCESS BEFORE OUTPUT.
*& MODULE STATUS_0100.
*&PROCESS AFTER INPUT.
*& MODULE USER_COMMAND_0100.
REPORT zus_sdn_three_alv_grids.
DATA:
gd_okcode TYPE ui_func,
go_docking TYPE REF TO cl_gui_docking_container,
go_splitter TYPE REF TO cl_gui_splitter_container,
go_splitter_2 TYPE REF TO cl_gui_splitter_container,
go_cell_top TYPE REF TO cl_gui_container,
go_cell_bottom TYPE REF TO cl_gui_container,
go_cell_left TYPE REF TO cl_gui_container,
go_cell_right TYPE REF TO cl_gui_container,
go_grid1 TYPE REF TO cl_gui_alv_grid,
go_grid2 TYPE REF TO cl_gui_alv_grid,
go_grid3 TYPE REF TO cl_gui_alv_grid.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1,
gt_vbak TYPE STANDARD TABLE OF vbak,
gt_vbap TYPE STANDARD TABLE OF vbap.
PARAMETERS:
p_bukrs TYPE bukrs DEFAULT '1000'.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no
sender. " sending control, i.e. ALV grid that raised event
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
* define local data
DATA:
ls_knb1 TYPE knb1,
ls_vbak TYPE vbak,
ls_vbap TYPE vbap.
* Distinguish according to sending grid instance
CASE sender.
WHEN go_grid1.
READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row-index.
CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
CALL METHOD go_grid1->set_current_cell_via_id
EXPORTING
* IS_ROW_ID =
* IS_COLUMN_ID =
is_row_no = es_row_no.
* Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code( 'ORDERS' ).
WHEN go_grid2.
READ TABLE gt_vbak INTO ls_vbak INDEX e_row-index.
CHECK ( ls_vbak-vbeln IS NOT INITIAL ).
CALL METHOD go_grid1->set_current_cell_via_id
EXPORTING
* IS_ROW_ID =
* IS_COLUMN_ID =
is_row_no = es_row_no.
* Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code( 'ORDER_DETAILS' ).
WHEN go_grid3.
READ TABLE gt_vbap INTO ls_vbap INDEX e_row-index.
CHECK ( ls_vbap-matnr IS NOT INITIAL ).
SET PARAMETER ID 'MAT' FIELD ls_vbap-matnr.
CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
WHEN OTHERS.
RETURN.
ENDCASE.
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = p_bukrs.
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
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 container
CREATE OBJECT go_splitter
EXPORTING
parent = go_docking
rows = 1
columns = 2
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
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.
* Get cell container
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_cell_left.
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 2
RECEIVING
container = go_cell_right.
* Create 2nd splitter container
CREATE OBJECT go_splitter_2
EXPORTING
parent = go_cell_left
rows = 2
columns = 1
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
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.
* Get cell container
CALL METHOD go_splitter_2->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_cell_top.
CALL METHOD go_splitter_2->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = go_cell_bottom.
* Create ALV grids
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_cell_top
EXCEPTIONS
OTHERS = 5.
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 OBJECT go_grid2
EXPORTING
i_parent = go_cell_bottom
EXCEPTIONS
OTHERS = 5.
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 OBJECT go_grid3
EXPORTING
i_parent = go_cell_right
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Set event handler
SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid1.
SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid2.
SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid3.
* Display data
CALL METHOD go_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'KNB1'
CHANGING
it_outtab = gt_knb1
EXCEPTIONS
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.
REFRESH: gt_vbak.
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'VBAK'
CHANGING
it_outtab = gt_vbak " empty !!!
EXCEPTIONS
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.
REFRESH: gt_vbap.
CALL METHOD go_grid3->set_table_for_first_display
EXPORTING
i_structure_name = 'VBAP'
CHANGING
it_outtab = gt_vbap " empty !!!
EXCEPTIONS
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.
* Link the docking container to the target dynpro
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
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.
* NOTE: dynpro does not contain any elements (ok_code -> GD_OKCODE)
CALL SCREEN '0100'.
* Flow logic of dynpro:
*PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
*PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'. " contains push button "ORDERS"
* SET TITLEBAR 'xxx'.
* Refresh display of detail ALV list
CALL METHOD go_grid2->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
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.
* Refresh display of detail ALV list
CALL METHOD go_grid3->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
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.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
* User has pushed button "Display Orders"
WHEN 'ORDERS'.
PERFORM customer_show_orders.
WHEN 'ORDER_DETAILS'.
PERFORM order_show_details.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form CUSTOMER_SHOW_ORDERS
* text
* --> p1 text
* <-- p2 text
FORM customer_show_orders .
* define local data
DATA:
ld_row TYPE i,
ls_knb1 TYPE knb1.
CALL METHOD go_grid1->get_current_cell
IMPORTING
e_row = ld_row.
READ TABLE gt_knb1 INTO ls_knb1 INDEX ld_row.
CHECK ( syst-subrc = 0 ).
SELECT * FROM vbak INTO TABLE gt_vbak
WHERE kunnr = ls_knb1-kunnr.
REFRESH: gt_vbap.
ENDFORM. " CUSTOMER_SHOW_ORDERS
*& Form ORDER_SHOW_DETAILS
* text
* --> p1 text
* <-- p2 text
FORM order_show_details .
* define local data
DATA:
ld_row TYPE i,
ls_vbak TYPE vbak.
CALL METHOD go_grid1->get_current_cell
IMPORTING
e_row = ld_row.
READ TABLE gt_vbak INTO ls_vbak INDEX ld_row.
CHECK ( syst-subrc = 0 ).
SELECT * FROM vbap INTO TABLE gt_vbap
WHERE vbeln = ls_vbak-vbeln.
ENDFORM. " ORDER_SHOW_DETAILS
Regards
Uwe -
Getting keyboard events on ALV grid
Hi,
I have an ALV Grid where it is possible to edit data. If user selects a row and presses delete/cut button with mouse event is triggered and I can access those events in code. Although if user selects a row and presses "Del" or "Ctrl + X" then I can't access those events in code. Is there a way to access keyboard events inside my code?Have a look at BCALV_GRID_EDIT -> if you select the first checkbox (p_cell = Update on cell change) then you will find that "data_changed" event can catch the line deletion via the keystrokes described.. in the event in this program, you could get the rows deleted from "rr_data_changed->mt_deleted_rows".
if p_cell = 'X'.
call method grid1->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
else.
Jonathan -
Hi,
I am working on ALV Grid Control. When the user clicks enter button on the keyboard the event DATA_CHANGED is triggered. I am actually collecting the data entered on the screen in the handler method of this event.
Now, I want the same functionality with the Enter button on the SAP Screen (this button appears next to the Command Box in SAP Screen). Whenever I click the button in the SAP Screen, the DATA_CHANGED is not called.
How can I make the button on the screen work the same way as the Enter button on the keyboard.
This is very urgent requirement. Please help me.
Regards,
VaraHi ,
You are missing OK CODE at your Container Screen(Where you defined the custom Control to populate your ALV grid).
Please define General attribute "OK_CODE" in your screen which you are using for Container(Where you defined the custom Control to populate your ALV GRID)..
In User Command routine:
Case OK_CODE = 'DATA_CHANGED'.
ENDCASE.
Hope this may help you.
Regards,
Lanka -
ALV GRID edit mode keyboard issue
Hi,
I have created a program that displays an ALV GRID.
From the Layout I said to edit in edit mode the ALV Grid.
In the menu toolbar I exclude the button 'cut - copy -paste and delete line'.
When I run the program I see that these buttons are not displayed --> OK.
BUT my problem is: if I use the keyboard then the ALV Grid manages these actions.
For instance. I select some lines and press the key DELETE on the keyboard --> the lines are removed and that is not that I expect because I removed this action from the toolbar.
For the cut - copy and paste it's the same.
Do you have a solution for me --> intercept an event or change the function keys or ....
I would like that the ALV Grid does not manage the keys delete, CRTL-C, CRTL-V in edit mode.
Thanks,
Stevie,Hi Steve
I was not aware of this. So, I recommend you to try this:
At the event <b>"before_user_command"</b> you can terminate the process by resetting the ALV user command.
<u><b>e.g.</b></u>
CASE e_ucomm .
WHEN '&INFO' .
CALL METHOD gr_alvgrid->set_user_command
EXPORTING i_ucomm = space.
ENDCASE .
This code within the event overrides the '&INFO' function and terminates its process. For cut and copy, you can find out ucomm values by putting a break point inside the event and tracing the value of <b>"i_ucomm"</b>.
For some relevant issues, you can inspect 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>.
<i>As another thing, since you are a new SDN member, you are welcome and let me introduce you the SDN forums pointing system: You can assign points to posts you find helpful while solving your question. You can reward points by clicking the yellow star icon at header of each reply post. You can reward;
- one 10 points (solved)
- two 6 points (very helpful answer)
- many 2 points (helpful answer)</i>
Kind regards...
*--Serdar -
ALV GRID Problem when delete key is pressed from keyboard
I have created a ALV Grid using cl_gui_alv_grid class
I this I made one field editable based on some conditions
and used SEL_MODE as 'A' ( i tried 'D' too) in the LAYOUT Settings
When I select the records and press the DELETE key from keyboard
the records are getting deleted, and i am not able to catch this action
in the debug mode
(FYI: I have written my own set of code for delete row in the USER COMMAND EVENT which is not getting triggered in this case )
Can any body help me with thishave you used this to trigger the event
SET HANDLER W_EVENT_RECEIVER->HANDLE_USER_COMMAND FOR W_GRID -
How to trigger ENTER event in oo ALV grid
Hi,
Can anybody help me out in catching the ENTER event in the oo ALV Grid. My requirement is as follows,
I have oo ALV Grid displaying hell lot of columns, in that vendor number column is an editable field so when the user enters the vendor number the immediate next cell showing the vendor name should be populated with the corresponding name as soon as he press enter button, I have search help also for vendor field.
Please give me some sample program which i can just do the copy+paste sort of as today is the deadline for the object.
Regards,
SumanHi,
This example is working. Please try this one.
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed e_onf4 e_ucomm.
ENDCLASS. "lcl_event_receiver DEFINITION
* CLASS lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
DATA : modi TYPE TABLE OF lvc_s_modi ,
modis TYPE lvc_s_modi,
wa LIKE LINE OF git_alv_items,
lv_matnr TYPE matnr.
modi = er_data_changed->mt_mod_cells .
LOOP AT modi INTO modis WHERE fieldname = 'MATNR'.
MOVE modis-value TO lv_matnr.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = lv_matnr
IMPORTING
output = lv_matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
READ TABLE git_alv_items INTO wa INDEX modis-row_id .
IF sy-subrc = 0.
SELECT SINGLE maktx FROM makt
INTO wa-maktx
WHERE matnr = lv_matnr
AND spras = sy-langu.
MODIFY git_alv_items FROM wa INDEX modis-row_id.
ENDIF.
ENDLOOP.
IF sy-subrc = 0.
CALL METHOD alv_grid->refresh_table_display
EXPORTING
is_stable = gs_stbl.
ENDIF.
ENDMETHOD. "handle_data_changed
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
DATA : eventreceiver TYPE REF TO lcl_event_receiver.
SET HANDLER eventreceiver->handle_data_changed FOR alv_grid.
CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = layo_alv
i_bypassing_buffer = 'X'
i_buffer_active = ''
CHANGING
it_outtab = git_alv_items
it_fieldcatalog = fcat_alv
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
CALL METHOD alv_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter. -
Issue with ALV Grid and events
Hi,
I am creating an ALV Grid with fields Matnr,Charg,Labst,Meins. The first three fields are editable and the last (MEINS) is read only.
Now I am trying to fill the MEINS field programmaticly after entering the MATNR and confirm with enter/return.
I think that I have to "overload" the enter event of the alv grid to fill the MEINS everytime when a MATNR was entered. But I don't know how I could implementing this. Could you give me a hint how I could solve this problem?
(The behavior should look like in transaction MIGO)
ThanksHi Alex
When you press enter an event is triggerd and function code is filled in sy-ucoom or you can say in ok_code. At that time PAI event occurs. In PAI of that screen you need to check ok_code and load new data in table which you passed to ALV and also refresh the ALV.
data: ok_code like sy-ucomm.
PAI----screen 100
case ok_code.
when 'ENTER'.
select data
and refresh ALV
then again call
funtion to display ALV
Regards
Aditya -
How to capture the event in ALV grid display?
Hi experts,
How to capture the event in an ALV grid display which is editable. I have to capture the TAB key or ENTER key.
regards,
Arul Jothi.Hi Arul,
Take a look at sample program BCALV_EDIT_03. (Find string "register ENTER" in the program to see how to register)
Basically you have to Register edit events using method call REGISTER_EDIT_EVENT and then write a handler method for event DATA_CHANGED..
If you are using a REUSE..GRID fm then first get the grid reference using function module GET_GLOBALS_FROM_SLVC_FULLSCR and then repeat the above procedure..
Hope this helps..
Sri
Message was edited by: Srikanth Pinnamaneni
Maybe you are looking for
-
Global vriable is not being reflected in the portal
Hi, I have to hide the element depening upon the value of the variable, the variable is global defined in the interface. My problem is that all the variables values are being reflected back in the form exept the global variable value. I have assigned
-
How to add two list in one frame using REUSE_ALV_LIST_DISPLAY
Hi, I want to display two list in single output by calling FM 'REUSE_ALV_LIST_DISPLAY' twice. I saw one topic posted by Arunava Das as 'ALV Problem' but didn't get the steps to do that. Here is his way of doing that "What I have done is gone for the
-
Issue with 'Archivation of Request Administration Data' in BW
I read couple of SAP notes and SDN about how to reduce database size in BW. There is one way told us 'Archivation of Request Administration Data'. The link is http://help.sap.com/saphelp_nw70/helpdata/en/42/ead8d7b55e1bd2e10000000a11466f/content.htm
-
Text disappearing in tagged PDFs
I recently upgraded to Acrobat Professional 9. When creating PDFs via "Convert to Adobe PDF" in Word with tagging enabled, I'm sometimes seeing text disappear in the conversion process so that whole lines are missing from the PDF. Using the print di
-
Can't "see" shared music across network
I have my main iTunes library on the big iMac downstairs, which is cabled into my Time Capsule for it's network connection. I have "share my library" turned on. One of the ports on the TC is connected (via a mains-circuit ethernet extender plug-pair)