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 Stefan
Use 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
Similar Messages
-
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 - Handling selected rows? Sorting in OUTTAB is different from ALV
Dear Experts ,
I have a transaction with ALV grid. I have defined several application specific functions to the ALV grid tool bar. My requirement is to handle the ALV tool bar functions only for the selected rows.
Code snippet:
DATA:
LS_GRID_DS TYPE TYS_DS.
TYPES: BEGIN OF TYS_DS.
INCLUDE TYPE TYS_ALVGRID.
TYPES: STRUCNAME LIKE DD02L-TABNAME.
TYPES: PRETAB TYPE ZTAB_T,
OUTTAB TYPE ZTAB_T,
OUTTAB_HIDDEN TYPE ZTAB_T,
OUTTAB_SUM TYPE ZTAB_T,
OUTTAB_ROLLBACK TYPE ZTAB_T,
END OF TYS_DS.
LOOP AT ls_grid_ds-marked_rows INTO ss_index_split
WHERE rowtype IS INITIAL.
( Marked rows is correctly giving the row numbers of the highlighted rows)
READ TABLE ls_grid_ds-outtab INTO ss_sel_rows_ds_split
INDEX ss_index_split-index.
ISSUE : Sorting in ls_grid_ds-outtab internal table is different from ALV Grid display.
Hence, though ls_grid_ds-marked_rows giving correct rows, I am not able to handle the my requirement correctly.
Why sorting in gs_grid_ds-outtab is different from ALV display? How can they made in sync?
Thank you in Advance.
Sravan.
Edited by: Raja Sravan on Jan 16, 2009 1:13 AMHello Raja
The OUTTAB is usually in sync with the display on the frontend grid control because it is a CHANGING parameter (of method SET_TABLE_FOR_FIRST_DISPLAY).
Question: Do you "feed" ls_grid_ds-outtab to the parameter IT_OUTTAB of method SET_TABLE_FOR_FIRST_DISPLAY?
If not then it is obvious why you get discrepancies.
Regards
Uwe -
ALV Grid Display Editable Field Disables Zebra Style
Hi all,
First of all, I want to say: "I did my research." I found a post with a very similar question but not identically my case, or at least I can't solve it the same way. [Here is the reference post.|Re: Check box impact on ALV grid (Using OOPS)]
My Goal: I have an ALV Grid which I want to display using the ZEBRA style in the layout and also make one field in the field catalog editable.
My Issue: As soon as you make one field editable in the field catalog using the EDIT option, the ZEBRA style in the layout does not works. I also have key fields in the ALV Grid which I want to keep as KEY and which get painted dark blue.
I can't use the individual row coloring method used in the reference link above since this overrides the blue coloring of the key fields in the ALV. I haven't gone through all the effort of individually painting each cell on the grid, and honestly I don't think it is efficient.
My Question: Is there a way to have editable fields in the ALV Grid and keep the ZEBRA setting working?
Please, I will really appreciate if you can read and try to understand my issue before posting incoherent solutions or answers. I don't want to waste anybody's time nor mine.Shiva,
Thanks for your reply; it someway addresses what I am looking for. Unfortunately, I've already went through that reference code; it has exactly the same problem that I am facing.
If you take that code for example, and you throw it u201Cas-isu201D in your ABAP editor you'll see that even when the ZEBRA style is being used in the layout, since the EDIT option in the field catalog is being set for field NETPR, the ZEBRA style gets lost; only the whole editable column gets white. You can go ahead and play a little bit with that piece of code and you will see what I am saying.
Regards -
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 -
Problem with alv grid control editable
Hello all. I ask your help with this question because I did not find the answer in the forum. Sorry for my pour english.
I have an alv grid control (OO) with the standards buttons 'insert a line', 'delete a line', 'copy a line'.
My problem is I want to catch the event of these buttons, because after I register the events mc_evt_enter y mc_evt_modifies, when I push the button to insert a new line the alv grid show the new line and then get a dump with error: Field symbol has not yet been assigned.
My problem is that no event is launched when I push the button. I tried to catch the event before command but it does not happen.
It is like these standard buttons works apart and it is not possible to find out what they are doing.
I have read the manual easy reference for alv grid control, and I created the class lcl_event_handler exactly equal.
I have tried to debug the code in order to find the error but I can find out where it has been done.
Thank you in advance. If anybody needs to see my code I will send you or post you.David,
What you need to do for that is to enable the editing field by field. You will have to add a field STYLE type LVC_T_STYL to the DATA table. This nested internal table will hold the information for each field of the row, whether the column is editable or not. So, if you have 5 columns, then the nested internal table will have 5 rows for each row of the main internal table.
Once this is done, you will have to append a blank row to the table, making all the fields editable and REFRESH the display.
Regards,
Ravi
Note: Please mark the answers as helpful if they help. -
ALV grid field editable/non editable at runtime
Hi All,
I am working on alv grid using containers. I have to make few cells in grid to editable and few othres to non editable which I did using styles by defining table type lvc_t_styl and updating my main internal table. Now once grid is displayed for first time (using set_table_for_first_display) it has required fields in editable and non editable as required. But now on triggering of data_changed event I have to change the editable cells to non editable and the non editable cells to editable. I tried doing this as same way as I have done before calling set_table_for_first_display method i.e. by defining table of type lvc_t_styl in data_changed event and modifying my main internal table but this time the editable fields are changed to non editable and again becomes editable. Same problem with non editable cells also. They become editable and again becomes non ediatble of there own. Can anyone suggest any solution.
<b>Note: Points awarded for helpful answers</b>
nullHi,
Check this link.I am explaining the steps for this.
Kindly reward points by clicking the star on the left of reply,if it helps.<a href="https://wiki.sdn.sap.com/wiki/display/Snippets/ALV-Editingandsavingtheeditedvaluesin+Database(OOPS)">Editing OOPS ALV</a> -
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. -
Dear Colleagues,
I develop an ALV grid with OO standard methods. Before the first display of the table I define the editable fields. It works fine.
I have a problem : if the table is empty and I press the standard icons "Append a line" or "Insert a line", the new line don't have the defined editable characteristics.for fields. Is there a standard method which I have forgotten ?
Thanks a lot and kind regards
Petervs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_delete_row.
APPEND vs_toolbar_excluding TO i_toolbar_excluding.
vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_append_row.
APPEND vs_toolbar_excluding TO i_toolbar_excluding.
vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_copy_row.
APPEND vs_toolbar_excluding TO i_toolbar_excluding.
vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_insert_row.
APPEND vs_toolbar_excluding TO i_toolbar_excluding.
vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_copy.
APPEND vs_toolbar_excluding TO i_toolbar_excluding.
vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_cut.
APPEND vs_toolbar_excluding TO i_toolbar_excluding.
vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_paste.
APPEND vs_toolbar_excluding TO i_toolbar_excluding.
vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_undo.
APPEND vs_toolbar_excluding TO i_toolbar_excluding.
vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
APPEND vs_toolbar_excluding TO i_toolbar_excluding.
* Displaying the output in ALV Grid
vs_layout_grid-no_rowmark = 'X'.
vs_layout_grid-zebra = 'X'.
vs_layout_grid-cwidth_opt = 'X'.
vs_layout_grid-edit = 'X'.
vs_layout_grid-ctab_fname = 'CT'.
vs_layout_grid-stylefname = 'CELLTAB'.
CALL METHOD v_grid->set_table_for_first_display
EXPORTING
i_save = 'X'
is_layout = vs_layout_grid
it_toolbar_excluding = i_toolbar_excluding[]
CHANGING
it_outtab = itab[]
it_fieldcatalog = it_fieldcat[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE 'ALV Grid display unsuccessful' TYPE 'I'.
STOP.
ENDIF. " IF sy-subrc NE 0
ELSE. " IF w_custom_container...
* Refresh the container if it already exists
CALL METHOD v_grid->refresh_table_display
EXCEPTIONS
finished = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE 'Refreshing the container is not successful' TYPE 'I'.
STOP.
ENDIF. -
Problem with ALV grid in edit mode
Hello, gurus!
I have a problem with ALV-grid. Sometimes when I call F4 help for a cell, data is inserted in a different cell. And when I call check_changed_data method, my internal table (passed to ALV-control in set_table_for_first_display) does not updates properly. In what can be a problem?
Thanks,
MikhailHi Prabhu,
MODULE pbo_100 OUTPUT.
SET PF-STATUS 'MAIN100'.
title_of_report = text-010.
SET TITLEBAR '0100' WITH title_of_report.
DATA: g_event_receiver TYPE REF TO lcl_event_handler.
IF z_custom_container IS INITIAL .
CREATE OBJECT z_custom_container
EXPORTING
container_name = 'ALV_ZAC'.
CREATE OBJECT alv_grid
EXPORTING
i_parent = z_custom_container.
g_repid = sy-repid.
gs_variant-report = g_repid.
x_save = 'A'.
PERFORM check_alv_grid_fields.
ps_layout-cwidth_opt = 'X'.
ps_layout-edit = 'X'.
CALL METHOD alv_grid->set_ready_for_input
EXPORTING
i_ready_for_input = '1'.
* CALL METHOD alv_grid->register_edit_event
* EXPORTING
* i_event_id = cl_gui_alv_grid=>mc_evt_enter.
APPEND s_list_rec to it_list_rec.
CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
is_layout = ps_layout
is_variant = gs_variant
i_save = x_save
CHANGING
it_fieldcatalog = pt_fieldcat
it_outtab = it_list_rec[].
CALL METHOD alv_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
CALL METHOD alv_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
ENDIF.
FORM check_alv_grid_fields .
DATA: ls_fcat LIKE LINE OF pt_fieldcat.
REFRESH pt_fieldcat .
CLEAR: ps_layout, ls_fcat.
ls_fcat-fieldname = 'VBELN'.
ls_fcat-ref_field = 'VBELN'. ls_fcat-ref_table = 'LIPS'. " .
ls_fcat-outputlen = 9.
* ls_fcat-datatype = 'CHAR'.
* ls_fcat-inttype = 'C'.
APPEND ls_fcat TO pt_fieldcat.
CLEAR: ls_fcat.
ls_fcat-fieldname = 'ERDAT'.
ls_fcat-ref_field = 'ERDAT'. ls_fcat-ref_table = 'LIPS'.
ls_fcat-outputlen = 9.
* ls_fcat-f4availabl = 'X' .
* ls_fcat-datatype = 'DATS'.
* ls_fcat-inttype = 'D'.
APPEND ls_fcat TO pt_fieldcat.
CLEAR: ls_fcat.
ENDFORM. " check_alv_grid_fields
FORM save_p .
CLEAR l_valid.
CALL METHOD alv_grid->check_changed_data
IMPORTING
e_valid = l_valid.
IF l_valid IS INITIAL.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = text-i01
txt1 = text-i02
txt2 = text-i03
txt3 = text-i04.
ELSE.
i_dat_reg = zrumm_prr-cdprr.
CLEAR is_temp_otc.
freshit i_prrpus_fax.
freshit i_list2_ot.
LOOP AT it_list_rec INTO s_list_rec.
MOVE-CORRESPONDING s_list_rec TO i_list2_ot.
i_list2_ot-fgrup = 'RECE'.
i_list2_ot-prrnu = i_num_prr.
APPEND i_list2_ot.
MOVE-CORRESPONDING s_list_rec TO i_prrpus_fax.
APPEND i_prrpus_fax.
ENDLOOP.
ENDIF.
Edited by: Mikhail Sarychev on Mar 16, 2011 6:41 AM
Edited by: Mikhail Sarychev on Mar 16, 2011 6:49 AM
Edited by: Mikhail Sarychev on Mar 16, 2011 6:49 AM -
Dear all,
I would like to do a refresh of the ALV GRID table display in event "handle_data_changed_finished".
"refresh_table_display" is NOT working.
I obviously need to go through PAI & PBO to refresh the table display.
Is there something to syncronize the data?
There must be an easy solution...
bye
Niko
Niko Prindesis
Itelligence AGDear Andreas,
thank you!
If I call "SAPGUI_SET_FUNCTIONCODE" in "handle_data_changed_finished", I can trigger the PAI/PBO.
So this solves my problem!
But ...
... isn't there a solution without going through PAI/PBO???
I want to stay in the ALVGrid control!
bye
Niko -
Group feature at ALV grid with editable columns
Am I right ?
Group function by using a sorted layout is disabled while having one (or more) editable columns, isn't it ?
... or is there a possibility to use gouped rows ?
Greetings
MarkusAlso...
*& Report ZDEMO_ALVGRID_EDIT *
*& Example of a simple ALV Grid Report *
*& The basic ALV grid, Enhanced to display specific fields as *
*& editable depending on field value *
REPORT ZDEMO_ALVGRID_EDIT .
TABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
field_style TYPE lvc_t_styl, "FOR DISABLE
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA: it_fieldcat TYPE lvc_t_fcat, "slis_t_fieldcat_alv WITH HEADER LINE,
wa_fieldcat TYPE lvc_s_fcat,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE lvc_s_layo, "slis_layout_alv,
gd_repid LIKE sy-repid.
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM set_specific_field_attributes.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
wa_fieldcat-fieldname = 'EBELN'.
wa_fieldcat-scrtext_m = 'Purchase Order'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-outputlen = 10.
wa_fieldcat-emphasize = 'X'.
wa_fieldcat-key = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'EBELP'.
wa_fieldcat-scrtext_m = 'PO Item'.
wa_fieldcat-col_pos = 1.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'STATU'.
wa_fieldcat-scrtext_m = 'Status'.
wa_fieldcat-col_pos = 2.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'AEDAT'.
wa_fieldcat-scrtext_m = 'Item change date'.
wa_fieldcat-col_pos = 3.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-scrtext_m = 'Material Number'.
wa_fieldcat-col_pos = 4.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MENGE'.
wa_fieldcat-scrtext_m = 'PO quantity'.
wa_fieldcat-col_pos = 5.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MEINS'.
wa_fieldcat-scrtext_m = 'Order Unit'.
wa_fieldcat-col_pos = 6.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'NETPR'.
wa_fieldcat-scrtext_m = 'Net Price'.
wa_fieldcat-edit = 'X'. "sets whole column to be editable
wa_fieldcat-col_pos = 7.
wa_fieldcat-outputlen = 15.
wa_fieldcat-datatype = 'CURR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'PEINH'.
wa_fieldcat-scrtext_m = 'Price Unit'.
wa_fieldcat-col_pos = 8.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
Set layout field for field attributes(i.e. input/output)
gd_layout-stylefname = 'FIELD_STYLE'.
gd_layout-zebra = 'X'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = gd_repid
i_callback_user_command = 'USER_COMMAND'
is_layout_lvc = gd_layout
it_fieldcat_lvc = it_fieldcat
i_save = 'X'
TABLES
t_outtab = it_ekko
EXCEPTIONS
program_error = 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. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
UP TO 10 ROWS
FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE it_ekko.
ENDFORM. " DATA_RETRIEVAL
*& Form set_specific_field_attributes
populate FIELD_STYLE table with specific field attributes
form set_specific_field_attributes .
DATA ls_stylerow TYPE lvc_s_styl .
DATA lt_styletab TYPE lvc_t_styl .
Populate style variable (FIELD_STYLE) with style properties
The NETPR field/column has been set to editable in the fieldcatalog...
The following code sets it to be disabled(display only) if 'NETPR'
is gt than 10.
LOOP AT it_ekko INTO wa_ekko.
IF wa_ekko-netpr GT 10.
ls_stylerow-fieldname = 'NETPR' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
"set field to disabled
APPEND ls_stylerow TO wa_ekko-field_style.
MODIFY it_ekko FROM wa_ekko.
ENDIF.
ENDLOOP.
endform. " set_specific_field_attributes
REWARD POINTS IF usefful !! -
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,
ronHi 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 -
How to handle editing events in a JComboBox
I have a editable JComboBox. User can select value either using the drop-down box or by editing.
I am able to get the drop-down selct event. However, I am not sure how should I handle the edit event on JComboBox.
Particularly, here is the use-case I wish to handle.
User edited the JComboBox by clicking back space key. I want to fire an event once user is done editing. How can I find if user is done editing ?User, please always tell us your jdev version.
In general you use a valueChangeListener which is fired when the user tabs out of the field...
Timo -
ALV Grid Options ( Editable/Drill Down)
Hi ,
I have a requirement, in which i need a replace a view content with an editable,drop
down to fields in an ALV grid and should be able to drill down or a pop up view on some of the field
attributes. can you please provide some sample code to do in ABAP WEBDYNPRO.
Thanks and Regards,
KumarHi,
Please refer this article: https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c060fcb4-2c62-2b10-d2b2-f32407a5cc6f
I hope it helps.
Regards
Arjun
Maybe you are looking for
-
This item is being modified. Please try again later. - Can't purchase.
Trying to buy The Knife "Silent Shout" and all I get is "This item is being modified. Please try again later." Is this something I'm doing wrong? Or is there a problem at the store? macbook pro Mac OS X (10.4.6)
-
When I send a Group message from my address book, the entire group gets listed in the "To" line. How do I get each member to receive the message individually without listing all members? Its just messy is all. Any help is greatly appreciated.
-
I am trying to update the itunes software on my Mac but I keep getting an instalation alert saying please close itunes. It is already closed, the only option then left is to quit instalation. I want the update though. Can anyone help?
-
Functionality of the Transaction Code
Hi Any one help how to find out the functionality of one particular T.Code. Say for example i want to know functionality of T.code FS10N. Is there any way to find like that. padma
-
Is construction of webi directly in production a best practice?
with bex-query and universes well consolidated and tested by a IT group, can be considered the construction of webis directly in production without going through test and quality a Business Objects best practice? is possible allow end-users (non IT p