2014 Feb 03 10:40 AM
Hi
Could you help me How to capture data & Save from editable ALV using OOPS( not from get_selected rows method)
if user enter in multiple rows (i my case 2 fields are editable) then click on save then all rows should be updated .
I guess it can be done through events .. could you please throw some light on this ?
Thanks ,
Mayank
2014 Feb 03 11:20 AM
Have you tried the method CL_GUI_ALV_GRID->CHECK_CHANGED_DATA at PAI?
This method will give you the updated data in the internal table used for ALV.
Thanks
Abhinab
Hi
Could you help me How to capture data & Save from editable ALV using OOPS( not from get_selected rows method)
if user enter in multiple rows (i my case 2 fields are editable) then click on save then all rows should be updated .
I guess it can be done through events .. could you please throw some light on this ?
Thanks ,
Mayank
2014 Feb 03 10:47 AM
Hi Mayank
Please check in program ALV sample program BCALV_EDIT_04 for the same
Nabheet
2014 Feb 03 10:59 AM
Hi Mayank,
Refer below .. i hope you it will satisfy your requirements..
2014 Feb 03 11:20 AM
Have you tried the method CL_GUI_ALV_GRID->CHECK_CHANGED_DATA at PAI?
This method will give you the updated data in the internal table used for ALV.
Thanks
Abhinab
2014 Feb 03 11:22 AM
Hello Mayank ,
You can use CHECK_CHANGED_DATA method in the class Cl_GUI_ALV_GRID.
CHECK_CHANGED_DATA is used to check the value change in the Internal table , If internal table is changed then
Declarations:
Class trig_events definition .
Methods : Check_change for event CHECK_CHANGED_DATA of CL_GUI_ALV_GRID.
endclass.
In the event implementations.
Method check_change.
loop at it_final into wa_final.
update ur internal table.
endloop.
2014 Feb 03 11:36 AM
Hii Mayank,
You can meet your requirement without using get_selected_rows.
Do the below step,
In your class defination, create a method edit_data FOR EVENT data_changed OF cl_gui_alv_grid.
In the method, edit_data implementation.
CALL METHOD obj_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified
EXCEPTIONS
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.
* STOP.
ENDIF.
Then in PBO of screen, You can Call this method edit_data as
CALL METHOD <local class object name>->edit_data. OR you register the event using set hanlderas
SET HANDLE <local class object name>->edit_dat FOR obj_grid. "<refrence of class CL_GUI_ALV_GRID>.
To save the edited values to database table code in the PAI of the screen.
Set the PF-STATUS(SAVE, BACK, EXIT and CANCEL button).
For saving the data code like below,
IF sy-ucomm EQ 'SAVE'.
CALL METHOD obj_grid>check_changed_data. "To automatically register the changed of cell data without hiiting enter in grid display
* IMPORTING
* e_valid =
* CHANGING
* c_refresh = 'X'
IF sy-subrc EQ 0.
UPDATE <database table name> FROM TABLE <internal table displaying in grid>.
IF sy-subrc EQ 0.
MESSAGE 'Update successful' TYPE'S'.
ELSE.
MESSAGE 'Updation Failed' TYPE 'E'.
ENDIF.
ENDIF.
Then Refresh the table display to reflect the change,
CALL METHOD obj_grid->refresh_table_display
EXCEPTIONS
finished = 1
OTHERS = 2.
IF sy-subrc <> 0.
* STOP.
ENDIF.
ENDIF.
Regards
Syed