SAP percentage complete progress indicator bar for your ABAP reports

The progress indicator adds a small timer in the lower left corner of the SAP screen. It not only provides the user with an indication of percentage completeness but also stops reports timing out. It does this by reseting the timeout timer whenever it is called.

UPDATE!!!
Progress indicator no-longer prevents timeout in later versions of SAP so you can use TH_REDISPATCH


*&************************************************************
*& DESCRIPTION: Demonstrate Progress indicator               *
*&************************************************************
REPORT  zprogind.
TYPES: BEGIN OF t_mara,
         matnr LIKE mara-matnr,
       END OF t_mara.
DATA: it_mara TYPE STANDARD TABLE OF t_mara INITIAL SIZE 0,
      wa_mara TYPE t_mara.
DATA: mara_lines TYPE i,
      gd_percent TYPE i.
**************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
  SELECT matnr
    INTO TABLE it_mara
    FROM mara.
  CHECK sy-subrc EQ 0.
  mara_lines = sy-dbcnt.
  clear: gd_percent.
  LOOP AT it_mara INTO wa_mara.
    PERFORM progress_bar USING 'Retrieving data...'(001)
                               sy-tabix
                               mara_lines.
*    WAIT UP TO 2 SECONDS.
  ENDLOOP.
  WRITE: /20 'Report is "Complete" OK'.
*&---------------------------------------------------------------------*
*&      Form  PROGRESS_BAR
*&---------------------------------------------------------------------*
FORM progress_bar USING    p_value
                           p_tabix
                           p_nlines.
  DATA: w_text(40),
        w_percentage TYPE p,
        w_percent_char(3).
  w_percentage = ( p_tabix / p_nlines ) * 100.
  w_percent_char = w_percentage.
  SHIFT w_percent_char LEFT DELETING LEADING ' '.
  CONCATENATE p_value w_percent_char '% Complete'(002) INTO w_text.
* This check needs to be in otherwise when looping around big tables
* SAP will re-display indicator too many times causing report to run
* very slow. (No need to re-display same percentage anyway)
  if w_percentage gt gd_percent or p_tabix eq 1.
    CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
           percentage = w_percentage
           text       = w_text.
   gd_percent = w_percentage.
  endif.
endform.                    " PROGRESS_BAR

Related Articles

SAP ALV Reports - ABAP or Advanced List Viewer reports
ALV grid reports using the object methods functionality
ALV TREE Example ABAP code and information for creating ALV tree based reports
SAP Dynamic documents in ABAP objects
SAP dynamic document example screens
ABAP report Progress indicator - When added also Stops report timeout
SAP progress indicator bar to count number of records processed within ABAP report and stop timeout
Prevent ABAP report timeout by Reseting the SAP runtime value using TH_REDISPATCH
ABAP Reporting - Example code and information on various areas of ABAP reporting
ABAP Automatic refresh report to retrieve real time live data from SAP database
Automatic Refresh Report - periodically refreshes results
Capture ABAP report using WRITE statement to internal table with SAP
Write report straight to printer
Convert Spool request to PDF and send as e-mail
Convert Spool request to PDF and send as e-mail
Execute ABAP Report using the SUBMIT statement
ABAP report to display all the selection screen fields and any values input by the user