Wednesday, April 14, 2010

Using a status bar in ABAP Programs

Thought this would be cool to share with my ABAPer friends:

 

When writing a report that you know is going to take a long time to run, and it is an interactive report, use the status bar function to help your user see how far into the processing the report is, and give them a little bit of an idea how long it may be before it is finished and it displays. Start at the start of selection and use the status function module…

START-OF-SELECTION.
       CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
          percentage = 05
        text       = 'starting load 5%'.

“SAPGUI_PROGRESS_INDICATOR” is a SAP function module for doing just that. I started my program out with one just inside the start of selection. This didn’t seem to do much because it skips past the start of selection and into the form routines rather quickly. I put another one after the sequel statement loading the bulk of the data into the internal tables.

 

  IF NOT sy-subrc IS INITIAL.
    ps_flag = 'N'.
  ELSE.
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
      EXPORTING
        percentage = 10
        text       = '...Main table loaded 10% done'.
  ENDIF.

 

The percentage export tells the function module how much in percentage to shade the clock that is on the status bar.

The text is what appears on the status bar next to the clock.

 

FORM

continue_process.

  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
    EXPORTING
      percentage = 20
      text       = '...Processing data. 20% '.

In the form routines that take a while to run put another one to help keep track of the progress.

 

When you are about to list the report put your final one in with 100% loaded and a message telling your user that their report is coming.

END-OF-SELECTION.
  IF ws_flag = 'Y' AND NOT gt_dump IS INITIAL.
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
      EXPORTING
        percentage = 100
        text       = '.....Here comes your report. 100% '.
    CALL SCREEN 50.

  ELSE.
    
MESSAGE i208(00WITH 'No information returned.'(001).
  
ENDIF.

 

Post a Comment