Copyright 2024 - BV TallVision IT

Once reporting output is displayed, you may want to refresh this reported output without having the user restart your report. There's remarkably little to it... The WRITE statements that are used set up a report are outputted all at once when the last WRITE is finished. Using the WRITE after that (E.g. after AT LINE-SELECTION will start a new reporting "layer".

To refresh a report, the game-plan is to make sure the existing report is overwritten, rather than putting a new layer on top of it. Have a closer look at this example:

WRITE: / 'Hello world'.

* Manual change to the report list number
  WRITE: / 'Bye', / 'World'. 

The key is subtracting 1 from SY-LSIND, which is the system variabele for the active report index. Execute this little program and double click on the text displayed. For your own understanding it might be useful to try and spot the difference if you also try to leave the line with SY-LSIND out. You might have used the TOP-OF-PAGE event when setting up your report. After refreshing the report, this section will disappear. No worries, the TOP-OF-PAGE handling for reports after refreshing is defined like: TOP-OF-PAGE DURING LINE-SELECTION. All you need to do is repeat your coding here.

One step further: when a report contents is refreshed, the system will automatically refresh it's scrolling settings as well, so you don't really "stay where you are".

Refresh a report - and hang on to the position in the report

Your user is somewhere in page 3 of your report and just clicked on the option to refresh the report. A refreshed version is build and output, and the user is directed to the top of this new list. This can be awkward. Consider the following routine:


  DATA: begin of lw_position, 
          staro type SY-STARO,
          staco type sy-staco, 
          curow type sy-curow, 
          cucol type sy-cucol,
          cpage type sy-cpage, 
        end of lw_position.  

* Hang on to position information
  move-corresponding sy to lw_position. 
* Reset the list level 
  SY-LSIND = 0.		
* Redo the WRITE statements (compose refreshed output)
* Scroll back
  SCROLL LIST INDEX 1 TO PAGE lw_position-cpage 
                         LINE lw_position-lirow
  SCROLL LIST INDEX 1 TO COLUMN lw_position-licol.
  SET CURSOR lw_position-cucol lw_position-curow. 


The example performs a refresh for the main list level, level 1. If you want to use this in "deeper" levels, you have to subtract one from SY-LSIND rather than set it to zero. Also make sure that there is no page-split in this report, to ensure the SCROLL LIST ... TO FIRST PAGE ... will work.