sap ABAP 显示计时秒表 函数“SAPGUI_PROGRESS_INDICATOR”

在运行报表的时候,经常会遇到数据量很大,每一次查询都会花费很长的时间,郁闷的是你不知道到底查询的进度, 所以可以利用函数“SAPGUI_PROGRESS_INDICATOR”来计算进度,显示给用户看。

使用这个函数,你只要输入查询次数和提示文本即可,下面用一个例子来看看这函数的用法:

DATA: g_total TYPE i,
g_cnt type i,
g_index type i.

DATA: gt_sflight TYPE TABLE OF sflight WITH HEADER LINE.

START-OF-SELECTION.

  SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_sflight
  FROM
  sflight.

  DESCRIBE TABLE gt_sflight LINES g_total.


    LOOP AT gt_sflight.
      g_cnt = g_cnt + 1.
      PERFORM progress_indicator USING g_cnt g_total 'Progressing'.
    ENDLOOP.

    WRITE 'success'.

*---------------------------------------------------------------------*
*       FORM progress_indicator                                       *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  VALUE(P_CUR)                                                  *
*  -->  VALUE(P_TOTAL)                                                *
*  -->  VALUE(P_TEXT)                                                 *
*---------------------------------------------------------------------*
FORM progress_indicator USING value(p_cur)
                        value(p_total)
                        value(p_text).
  DATA:lv_text(50) TYPE c,
       lv_idx(3) TYPE n.

  lv_idx = ( P_CUR / P_TOTAL ) * 100.

  CONCATENATE lv_idx '%:' p_text INTO lv_text.

  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
       EXPORTING
            percentage = lv_idx
            text       = lv_text
       EXCEPTIONS
            OTHERS     = 0.

ENDFORM.

效果:
这里写图片描述

你可能感兴趣的:(abap)