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

Undo functionality in ALV grid after refreshing

Former Member
0 Likes
1,869

I'm required to make an user friendlier sm30. Studying my options I decided to go for using an editable alv grid. After some cells are edited, others (non-editable) are filled with some content that depends on the value assigned to the edited cell. For that, I'm using the handle_data_changed and handle_data_changed_finished events. After I set proper values in these specific non-editable cells, I need to refresh the table in order to show the user the data. I'm doing this by calling refresh_table_display in the later event related method. The problem is that after refreshing the alv grid, I can't undo changes made in the table anymore. It seems like modification stack is stored in some alv grid class attribute, but erased after refreshing. How can I refresh alv grid display and still get the undo functionality to work (if that is possible)?

1 ACCEPTED SOLUTION
Read only

sriharsha_parayatham
Participant
0 Likes
1,298

maintain a table in your class ..

try to log the changes in to this table.

try to have a field called current view in this table. which will be a check box.

now if your table contains data like this..

123 abc aa12

234 def  bb34

456 xyz cc56

and say user chages 2nd row 3rd field from bb34 to bb35.

then you will add a log in your table as

row  column  initial  final    current chk

2      3          bb34   bb35        X

if another row is added , add a line when ever there is an on change event.

row  column  initial  final    current chk

2      3          bb34   bb35      

2      3          bb35   bb36       

3      1          456     789          X

now you can have undo button on the screen of alv.

if the user presses undo button you have track of what has changed , and you can reverse the change using the log table you created...

and when you undo the changes . try to delete the lines that are after the line where chk is ne 'X'..

or there might be a simple solution also , this is just a try...

6 REPLIES 6
Read only

former_member192854
Active Participant
0 Likes
1,298

Hi Paulo,

You might consider to store the begin state at another global variable in your program?

This user friendlier SM30, is also going to insert/update/delete key fields? Then you might also consider a back up table with fields like: tablename, timestamp, ernam and a string, which contains the original data of the table they just altered in XML or a ZIPPED XML string or ZIPPED XML xstring, to be more sufficient.

Good luck!

Best, Sander

Read only

0 Likes
1,298

Thanks for the suggestion Sander, but I kind of worked around my problem. Some of the update I'm doing in the handle_data_changed method are being refreshed without the need for explicitly calling the refreshing method. Other cells are not beind updated on-the-fly, since I'm editing them in other event method (button_click for being more precise), but that won't be necessary for the requirements I have for now. Now I'm facing another problem. I need to store the user who may have done any modification to the table (for log purposes). Since the undo functionality is an undroppable requirement of the system, I have to keep in mind that undoing all changes made in a line of the table (the user can edit more than one cell in a row, in any order he wants) results in not associating such user to the edition of that line. Do you still think the best way to achieve this is by following your suggestion? Still, since there's no method related to the undoing functionality, how can I know that the event handle_data_changed was triggered by the undo toolbar button?

Read only

0 Likes
1,298

Hi Paolo,

if you don't put a commit work in the flow of the program, you don't have any undo trouble.

If you want to make sure / testing purposes etc., then I think my additional idea will be a good one, even if it is just for testing purposes at the first time only.

Best,

Sander

Read only

0 Likes
1,298

the problem is that the alv triggers implicit commit works, this happens everytime a screen is processed, probably you need to use internal tables and then save everything your logs and your tables when a save button is pressed .

You should copy your initial tables and use them to regenarate your alv when a undo button is pressed.

Read only

0 Likes
1,298

I solved my problem by not refreshing the grid at every user interaction. I used a method from one the the parameters of handle_data_changed method to update the cells I want. I don't have any problem with saving either. Actually, if user hits the save button, I store the records into a transparent table and refresh the alv grid intentionally so that he can't undo changes made before saving. Nw I'm facing another related problem (it seems they are never over ). Search help is attached to some editable fields of the alv grid. If user writes values in the cells, the standard undo button works properly. However, if the value assigned to a cell is picked from f4 list, it breaks. That is, pressing undo button after picking a value from search help doesn't cause any change to the table. Is there a way to work around it?

Read only

sriharsha_parayatham
Participant
0 Likes
1,299

maintain a table in your class ..

try to log the changes in to this table.

try to have a field called current view in this table. which will be a check box.

now if your table contains data like this..

123 abc aa12

234 def  bb34

456 xyz cc56

and say user chages 2nd row 3rd field from bb34 to bb35.

then you will add a log in your table as

row  column  initial  final    current chk

2      3          bb34   bb35        X

if another row is added , add a line when ever there is an on change event.

row  column  initial  final    current chk

2      3          bb34   bb35      

2      3          bb35   bb36       

3      1          456     789          X

now you can have undo button on the screen of alv.

if the user presses undo button you have track of what has changed , and you can reverse the change using the log table you created...

and when you undo the changes . try to delete the lines that are after the line where chk is ne 'X'..

or there might be a simple solution also , this is just a try...