Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to save data from editable ALV using OOPS( not from get_selected rows method)

Former Member
0 Likes
9,579

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,176

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

5 REPLIES 5
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
3,176

Hi Mayank

Please check in program ALV sample program BCALV_EDIT_04 for the same

Nabheet

Read only

thangam_perumal
Contributor
0 Likes
3,176

Hi Mayank,

              Refer below .. i hope you it will satisfy your requirements..

SAPTechnical.COM - ALV with editable F4

SAPTechnical.COM - ALV with EDIT and SAVE functionality

Read only

Former Member
0 Likes
3,177

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

Read only

Former Member
0 Likes
3,176

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.

Read only

Former Member
0 Likes
3,176

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