Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos
758

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

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.

Labels in this area