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

ALV refresh with the Old Data

Former Member
0 Likes
879

Hi All,

I have a question with OO ALV. I have an Editable ALV output which contains around 10 fields. In the output the User can Edit/Insert/Delete the Records, and on the application tool bar I have a button (CHANGE)by which the user can swtich between the change and display mode of ALV.

Once the ALV list is displayed, when the user click on change the output is open for Editing. Lets say the user deletes the record, and again clicks on the change(which should take to display) by giving the message "Changes made will be lost" and the old data should get displayed.

The logic i followed is,

1. displayed the ALV.

CALL METHOD gr_grid->set_table_for_first_display

EXPORTING

it_toolbar_excluding = gt_exclude

is_layout = gs_layout

CHANGING

it_fieldcatalog = pt_fieldcat

it_outtab = pt_outtab[].

2. when I click on the change button, the ALV is set for Edit using

CALL METHOD gr_grid->set_ready_for_input

EXPORTING

i_ready_for_input = 1.

lets say, now the record in the output is deleted, and I clicked on Change again, which should take me to display with the old data.

can you help me in displaying the old data.

Hi All,

I have a question with OO ALV. I have an Editable ALV output which contains around 10 fields. In the output the User can Edit/Insert/Delete the Records, and on the application tool bar I have a button (CHANGE)by which the user can swtich between the change and display mode of ALV.

Once the ALV list is displayed, when the user click on change the output is open for Editing. Lets say the user deletes the record, and again clicks on the change(which should take to display) by giving the message "Changes made will be lost" and the old data should get displayed.

The logic i followed is,

1. displayed the ALV.

CALL METHOD gr_grid->set_table_for_first_display

EXPORTING

it_toolbar_excluding = gt_exclude

is_layout = gs_layout

CHANGING

it_fieldcatalog = pt_fieldcat

it_outtab = pt_outtab[].

2. when I click on the change button, the ALV is set for Edit using

CALL METHOD gr_grid->set_ready_for_input

EXPORTING

i_ready_for_input = 1.

lets say, now the record in the output is deleted, and I clicked on Change again, which should take me to display with the old data.

can you help me in displaying the old data.

3 REPLIES 3
Read only

naimesh_patel
Active Contributor
0 Likes
718

You copy your internal table into one temporary table and use it when you want to refresh data back to original ALV.


CALL METHOD gr_grid->set_table_for_first_display
....

T_DATA_BACKUP[] = T_OUTTAB[].

When you want to refresh it back, you set the T_OUTTAB from the T_DATA_BACKUP and call the refresh method for ALV.

Like:


T_OUTTAB[] = T_DATA_BACKUP[].
o_alv->refresh_table_display( ).

Regards,

Naimesh Patel

Read only

0 Likes
718

HI Naimesh,

Yes, I did the same..in my code, if i implement I am getting the below problem.

After the ALV display, I copied the data t_outtab in local table like t_outab_temp.

I got the ALV output first time, I am into Edit mode using the change button on the tool bar. Deleted one Record, and again clicked on Change button( it will take to display by giving the message), I refreshed the ALV as you said. the data is fine.

if I perform the same operation again, I am not getting the delete record back, how ever the internal table has the correct no. of records, but the output is less.

Thanks for you response.

Read only

0 Likes
718

It works good for me.

I copied the program BCALV_EDIT_01 to Z program and add the required logic. Backup of the table after the ALV display


    gt_backup = gt_outtab.

Refreshing the ALV table display in the perform SWITCH_EDIT_MODE


*§3.Use IS_READY_FOR_INPUT to fetch current substate of editable cells.
  IF g_grid->is_ready_for_input( ) EQ 0.
*§4.Use SET_READY_FOR_INPUT to switch between the substates.
    CALL METHOD g_grid->set_ready_for_input
                     EXPORTING i_ready_for_input = 1.
  ELSE.
*------ ADD Begin
    message I398(00) with 'Data not saved.!'.
    gt_outtab = gt_backup.
    g_grid->refresh_table_display( ).
*------- ADD end
    CALL METHOD g_grid->set_ready_for_input
                     EXPORTING i_ready_for_input = 0.
  ENDIF.

Regards,

Naimesh Patel