Quantcast
Channel: SCN : Document List - ABAP Development
Viewing all articles
Browse latest Browse all 935

Progress Indicator with estimated remaining time style windows.

$
0
0

Thisexample showsmy techniqueso thatthe user knowstheexecution timeandto cancelthe query ifnotappropriate.Hope youhelps.

 

process.jpg

 

CODE:

 

*&---------------------------------------------------------------------*
*& Report  Z_TEST_COUNT
*&
*&---------------------------------------------------------------------*
*&
*& By: J.Julio González
*&---------------------------------------------------------------------*

REPORT  Z_TEST_COUNT.

DATA: L_SYTABIX LIKE SY-TABIX.
DATA: LINES TYPE I.
DATA: PERCENT TYPE I.
DATA: CHARPERCENT TYPE STRING.
DATA: VPERCENT TYPE I.
DATA: TEXTPROGRESS TYPE STRING.
DATA: T_TEMP TYPE TIMESTAMP.
DATA: TOTAL_TEMP TYPE TIMESTAMP.
DATA: REST_TEMP TYPE TIMESTAMP.
DATA: SECONDS TYPE I.
DATA: SECONDS_C TYPE STRING.
DATA: TEMP TYPE STRING.
DATA: TI_SFLIGHT LIKE SFLIGHT OCCURS 0 WITH HEADER LINE.

*LOAD INTERNAL TABLE FOR EXAMPLE
SELECT * FROM SFLIGHT INTO TABLE TI_SFLIGHT.

*CALCULATE THE NUMBER OF RECORDS
DESCRIBE TABLE TI_SFLIGHT LINES LINES.

*DATA PROCESSING
LOOP AT TI_SFLIGHT.
PERCENT
= 100 * SY-TABIX / LINES.
MOVE PERCENT TO CHARPERCENT.
L_SYTABIX
= SY-TABIX.
VPERCENT
= PERCENT MOD 5.


****EMULATE PROCESSES********
WAIT UP TO 1 SECONDS.
**************************

* RECALCULATED EVERY 5 PERCENT.
IF VPERCENT = 0.
GET RUN TIME FIELD T_TEMP.
IF T_TEMP IS NOT INITIAL AND PERCENT IS NOT INITIAL.
VPERCENT
= PERCENT MOD 10.
IF  PERCENT = 5 OR VPERCENT = 0.
TOTAL_TEMP
=  ( T_TEMP * 100 ) / PERCENT .
REST_TEMP
= ( TOTAL_TEMP - T_TEMP ) / 1000000.
ENDIF.
ENDIF.
SECONDS
= REST_TEMP.
MOVE SECONDS TO SECONDS_C.
CONCATENATE SECONDS_C 'S' INTO TEMP.
CONCATENATE 'DATA PROCESSING...' CHARPERCENT '% COMPLETE, REMAINING TIME:' TEMP INTO TEXTPROGRESS SEPARATED BY SPACE.

* SHOW THE PROGRESS INDICATOR
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE
= PERCENT
TEXT = TEXTPROGRESS.
CLEAR VPERCENT.
ENDIF.
ENDLOOP.


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>