Application Development 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: 

Editable ALV Grid Refresh Issue

Former Member
0 Kudos

Ok, so this is hard to explain but I will try my best...

I have an issue with an editable grid not refreshing to a blank state after the user exits then re-executes the program.

When the user successfully enters and saves data in the editable grid, the program clears all internal tables and destroys all obejcts related to the grid. However, when the program is re-executed from the selection screen the program displays the editable grid again with the data that was just entered in the previous session. In debugging mode, I can see that the internal table for the grid is empty and that the object is not carried over from the previous run.

This only happens if the user goes into the transaction, enters data, saves the data, backs to the selection screen, and then re-executes. It DOES NOT happen if the user executes, enters data, saves the data, and then exits all the way out to the SAP Easy Acess Menu.

I have tried the refresh grid method, it does not fix this issue. The grid is contained within a custom control on a custom dynpro.

Any ideas would be much appreciated, will award points for solution.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Are you destroying and FREEing both the grid object as well as <b>the container object</b>?

Here is an example PAI.

  case sy-ucomm.
    when 'BACK' or 'CANC'.
<b>    if not alv_container is initial.
        call method alv_container->free.
        clear: alv_container.
        free : alv_container.
      endif.</b>
      if sy-subrc = 0.
        set screen 0.
        leave screen.
      else.
        leave program.
      endif.
    when 'EXIT'.
      if not alv_container is initial.
        call method alv_container->free.
        clear: alv_container.
        free : alv_container.
      endif.
      leave program.
  endcase.

Regards,

Rich Heilman

4 REPLIES 4

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Are you destroying and FREEing both the grid object as well as <b>the container object</b>?

Here is an example PAI.

  case sy-ucomm.
    when 'BACK' or 'CANC'.
<b>    if not alv_container is initial.
        call method alv_container->free.
        clear: alv_container.
        free : alv_container.
      endif.</b>
      if sy-subrc = 0.
        set screen 0.
        leave screen.
      else.
        leave program.
      endif.
    when 'EXIT'.
      if not alv_container is initial.
        call method alv_container->free.
        clear: alv_container.
        free : alv_container.
      endif.
      leave program.
  endcase.

Regards,

Rich Heilman

0 Kudos

It was the 'call method alv_container->free.' statement i was missing with the CLEAR and FREE statements.

Thanks,

Brian.

Former Member
0 Kudos

Brian,

Would it be possible to post the code here?

Sounds like its an issue with the variables.

Also, I am guessing that you would be creating the containers in PAI. Put a IF condition to check for existence of the same before creating the containers.

Regards,

Ravi

Message was edited by: Ravikumar Allampallam

Former Member
0 Kudos

This has nothing to do with the ALV grid. When the user goes back to the selection screen, your variables that hold the data including the internal table that is used in the grid are still holding the previous contents. You will have to clear the contents when the user goes back to the selection screen. There are two way to do this. In the very begining, in your start-of-selection, clear all the variables, internal tables and then start the processing. Another option is to use FREE MEMORY at the end of code as the last executable statement in END-OF-SELECTION.