Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member209119
Active Participant

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
START-OF-SELECTION.
*Get Document number from BKPF
  SELECT BELNR
     INTO TABLE IT_BKPF
    FROM BKPF.

  CHECK SY-SUBRC EQ 0.
  "Get the total number of records
  BKPF_LINES = SY-DBCNT.
  CLEAR GD_PERCENT.

  LOOP AT IT_BKPF INTO WA_BKPF.
    "Form routine for Progress Bar
    PERFORM PROGRESS_BAR USING 'Retrieving data....'(001)
                                SY-TABIX
                                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

2 Comments