轉:在ABAP中實現進度條的例子

dicksonjyl560101發表於2015-04-25

小弟在做一個專案時使用者提出程式執行時顯示進度條的問題,加之本人以前也碰到這種需要求,所以按以前在WIN32下的程式設計經驗,設計了一個進度條顯示INCLUDE程式。這個程式可以顯示條狀進度條以及進度百份比,並可以顯示註釋,現將程式碼COPY如下:

*&---------------------------------------------------------------------*
*& Include ZSHOWMES *
*&---------------------------------------------------------------------*
*& Author : wuping *
*& Create Date : 2006-05-17 *
*& Program Type : Report *
*& SAP Release : 4.7C *
*& Description : 用來做資訊型別 *
*&---------------------------------------------------------------------*

*&---------------------------------------------------------------------*
*& Form SCHEDULE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --&gt p1 text
* *----------------------------------------------------------------------*
form schedule using
c_message type c
i_percent type i.
data: c_sche(204).

if i_percent <= 0 or i_percent > 100 .
c_sche = '百分比錯誤!!!'.
else.
data: c_percent(4),
c_block(6) type c value '■■',
i_blocklen type i,
i_count type i,
i_col type i,
i_len type i,
i_temp type i value 0,
i_mod type i.
i_blocklen = strlen( c_block ).
c_percent = i_percent.
condense c_percent.
c_percent+3(1) = '%'.
c_sche = c_percent.
i_count = i_percent / 4.
do i_count times.
i_col = ( i_temp * i_blocklen ) + 4.
c_sche+i_col(i_blocklen) = c_block.
i_temp = i_temp + 1.
enddo.
i_len = strlen( c_message ).
i_mod = i_len mod 2.
if i_mod = 1.
i_len = i_len + 1.
endif.
if i_len > 0.
c_sche+4(i_len) = c_message.
endif.
i_len = strlen( c_sche ).
endif.
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
percentage = 0
text = c_sche
exceptions
others = 1.
endform. " SCHEDULE


以下是呼叫這個INCLUDE的示例程式:
*&---------------------------------------------------------------------*
*& Report ZTEMP_8 *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*

report ztemp_8 .
include zshowmes.
data: i_prog type i,
i_prog2 type i.

START-OF-SELECTION.
do 100 times .
do 100000 times.
i_prog2 = i_prog2 + 1.
enddo.
i_prog = i_prog + 1.
write: / '第' no-gap , i_prog no-gap , '次執行:',i_prog2.
perform schedule using '' i_prog. "呼叫上面的INCLUDE顯示進度
enddo.
希望各位ABAP同仁能提出更好的實現方法

原文:http://www.itpub.net/570329.html

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29829936/viewspace-1598572/,如需轉載,請註明出處,否則將追究法律責任。

相關文章