03-17-2006 9:33 AM
Hi,
Can anyone please tell how to save the data which is saved in OO ALV.
A simple sample code will be much appreciated.
Points assured.
Thanks in Advance.
03-17-2006 10:00 AM
Hi,
This is when using FM.............
If u r using FM look at my example.....
data: LC_GLAY TYPE LVC_S_GLAY.
LC_GLAY-EDT_CLL_CB = 'X'.<<<<<------
gt_layout-zebra = 'X'.
gt_layout-detail_popup = 'X'.
gt_layout-colwidth_optimize = 'X'.
call function 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = i_repid
i_callback_user_command = 'USER_COMMAND1'
it_fieldcat = header
is_layout = gt_layout
i_callback_top_of_page = 'TOP-OF-PAGE1'
i_grid_title = text-h17
it_sort = gt_sort[]
i_default = 'X'
i_save = 'U'
is_variant = gt_variant
it_events = gt_events
I_GRID_SETTINGS = LC_GLAY<<<<<<------
TABLES
t_outtab = itab.
clear itab.
----
Form USER_COMMAND1
----
FORM USER_COMMAND1 USING u_ucomm LIKE sy-ucomm
us_selfield TYPE slis_selfield."#EC CALLED
case u_ucomm.
when '&DATA_SAVE'.<<<<<<<<----
This will come after the data was EDITTED and when SAVE was clicked by user in output scren.
Here now in the final internal table(ITAB) you can find the data changed in EDIT mode.
After this you can do manipulation what ever you want.
Thanks.
If this helps you reward with points.
03-17-2006 9:40 AM
Newbie,
The data when update on the grid (Screen) is automatically updated to the internal table that you are using to display the data.
So, all you need to do take the data from the internal table and update the Database, either by calling a BAPI, or directly if we are dealing with custom tables.
However, if you want to identify the changed rows, you will have to activate the events - DATA_CHANGED / DATA_CHANGE_FINISHED and take the changed data there.
Regards,
Ravi
Note : Please reward the posts that help you.
03-17-2006 9:55 AM
Hi Ravi,
Thanks for your reply.
You are right. The data is stored back into the internal table but only if the button in ALV toolbar is clicked, but not when any icon in application toolbar is clicked.
Any sample codes.
Thanks.
03-17-2006 10:04 AM
Newbie,
Call the CHECK_CHANGED_DATA method of the grid as the first statement in the PAI of the screen. This should fix the problem.
Also, I guess you have registered the EDIT event.
Regards,
Ravi
03-17-2006 10:00 AM
Hi,
This is when using FM.............
If u r using FM look at my example.....
data: LC_GLAY TYPE LVC_S_GLAY.
LC_GLAY-EDT_CLL_CB = 'X'.<<<<<------
gt_layout-zebra = 'X'.
gt_layout-detail_popup = 'X'.
gt_layout-colwidth_optimize = 'X'.
call function 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = i_repid
i_callback_user_command = 'USER_COMMAND1'
it_fieldcat = header
is_layout = gt_layout
i_callback_top_of_page = 'TOP-OF-PAGE1'
i_grid_title = text-h17
it_sort = gt_sort[]
i_default = 'X'
i_save = 'U'
is_variant = gt_variant
it_events = gt_events
I_GRID_SETTINGS = LC_GLAY<<<<<<------
TABLES
t_outtab = itab.
clear itab.
----
Form USER_COMMAND1
----
FORM USER_COMMAND1 USING u_ucomm LIKE sy-ucomm
us_selfield TYPE slis_selfield."#EC CALLED
case u_ucomm.
when '&DATA_SAVE'.<<<<<<<<----
This will come after the data was EDITTED and when SAVE was clicked by user in output scren.
Here now in the final internal table(ITAB) you can find the data changed in EDIT mode.
After this you can do manipulation what ever you want.
Thanks.
If this helps you reward with points.
03-17-2006 10:06 AM
Hi KDeepak,
I'm using OO ALV.
The point is the data is not reflected in the internal table if the application toolbar button is pressed.
Thanks.
03-17-2006 10:35 AM
have a look at this PDF:
there is the best way described... use the event data_changed there you will get the data which has been changed by the user...
03-17-2006 10:03 AM
Hi,
Check this information and kindly reward points by clikcing the star on the left of reply,if it helps.
The ALV Grid has events data_changed and data_changed_finished. The former method is
triggered just after the change at an editable field is perceived. Here you can make checks for
the input. And the second event is triggered after the change is committed.
You can select the way how the control perceives data changes by using the method
register_edit_event. You have two choices:
i. After return key is pressed: To select this way, to the parameter i_event_id pass cl_gui_alv_grid=>mc_evt_enter.
ii. After the field is modified and the cursor is moved to another field: For this, pass cl_gui_alv_grid=>mc_evt_modifies to the same parameter.
To make events controlling data changes be triggered, you must select either way by
calling this method. Otherwise, these events will not be triggered.
To control field data changes, ALV Grid uses an instance of the class
CL_ALV_CHANGED_DATA_PROTOCOL and passes this via the event data_changed.
Using methods of this class, you can get and modify cell values and produce error messages.
09-02-2007 7:46 PM
Hi Paul Miller,
have the same problem, and ack you whether your problem is fexed or not yet ?
Thnke
09-02-2007 8:07 PM
Moutaa noureddine,
Welcode to SDN.
You need to use method check_changed_data
*----------------------------------------------------------------------*
* Module Pai INPUT *
*----------------------------------------------------------------------*
* PAI module *
*----------------------------------------------------------------------*
module pai input.
save_ok = ok_code.
clear ok_code.
call method g_grid->check_changed_data
importing
e_valid = v_valid.
case save_ok.
when 'EXIT'.
perform f_exit_program.
when 'CANC'.
perform f_exit_program.
when 'BACK'.
perform f_exit_program.
when 'SAVE'.
if not v_valid is initial. "<<<
perform f_save_data.
endif.
when 'EVEW'.
perform f_set_fcode.
perform f_save_data .
when 'VADD'.
perform f_f4_help_fieldname.
endcase.
endmodule. " Pai INPUT
Please create a new thread with detailed message of your query will get more answers
a®