메뉴 건너뛰기

SAP 한국 커뮤니티

Progress Bar 표기 로직

양키(이경환) 2014.02.13 22:38 조회 수 : 3649

 


TYPESBEGIN OF T_MARA,
         MATNR LIKE MARA-MATNR,
       END OF T_MARA.
DATAIT_MARA TYPE STANDARD TABLE OF T_MARA INITIAL SIZE 0,
      WA_MARA TYPE T_MARA.
DATAMARA_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.
  CLEARGD_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.
  DATAW_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'(002INTO 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