Skip to Content

This example shows my technique so that the user knows the execution time and to cancel the query if not appropriate. Hope you helps.

/wp-content/uploads/2013/08/process_265685.jpg

CODE:

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

REPORT  Z_TEST_COUNT.

DATA: L_SYTABIX LIKE SYTABIX.
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 * SYTABIX / LINES.
MOVE PERCENT TO CHARPERCENT.
L_SYTABIX
= SYTABIX.
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.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply