Skip to Content
Author's profile photo Anamika Jain

How to create Progress Bar in SAP Reports

Hi All,

This document on ‘Progress Bar Creation’ will explain the simplest way of creating Progress Bar.

You can change the code as per your requirement.

What is Progress Bar:

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 resetting the timeout timer whenever it is called.

Sample code for Progress bar usage.

    REPORT  Z_PROGRESS_BAR.

*Structure
TYPES: BEGIN OF T_BKPF,
        BELNR TYPE BELNR_D,
      END OF T_BKPF.

*Internal Table and Workarea
DATA: IT_BKPF TYPE STANDARD TABLE OF T_BKPF,
      WA_BKPF TYPE T_BKPF.

*Data declaration
DATA: BKPF_LINES TYPE I,
      GD_PERCENT TYPE I.

*Start-of-selection event
STARTOFSELECTION.
*Get Document number from BKPF
  SELECT BELNR
     INTO TABLE IT_BKPF
    FROM BKPF.

  CHECK SYSUBRC EQ 0.
  “Get the total number of records
  BKPF_LINES = SYDBCNT.
  CLEAR GD_PERCENT.

  LOOP AT IT_BKPF INTO WA_BKPF.
    “Form routine for Progress Bar
    PERFORM PROGRESS_BAR USING ‘Retrieving data….’(001)
                                SYTABIX
                                BKPF_LINES.
  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 ned to re-display same percentage anyways)

  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

Thanks,

Anamika

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Nice Document even if you need more on the same.

       

      pl. Refer.

       

      http://scn.sap.com/docs/DOC-35242

       

      Avirat

      Author's profile photo Former Member
      Former Member

      Hi

       

      it also works quick and easy this way:

       

       

       

       

      DATA: lv_percentage TYPE I,

                 lv_message    TYPE String.

       

       

       

      DO 10 TIMES.

       

      lv_message = 'Processing…”.

       

       

       

        CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

          EXPORTING

           percentage = lv_percentage

           text           = lv_message

       

       

       

      add 10 to lv_percentage.

       

      wait up to 1 seconds..

       

       

       

      ENDDO.

       

       

      Regards

      Sascha