Tips and Tricks for the ABAP® Programming Language
Y9030018 – Testing/Debugging – Variable Delay for each processed subroutine
The user can see which subroutine is currently executes. At the same time a few trace informations are saved in an internal table.
ABAP™-Source-Code
You can copy and paste the source code directly into the ABAP™-Workbench.
REPORT Y9030018 LINE-SIZE 250. "Release 3.1G, 4.5A
************************************************************************
* Copyright (c) 1999 by CT-Team, 33415 Verl
*
* you can use or modify this report for your own work as long
* as you don't try to sell or republish it.
* in no event will the author be liable for indirect, special,
* Incidental, or consequental damages (if any) arising out of
* the use of this report.
*
************************************************************************
*//////////////////////////////////////////////////////////////////////*
MOVE: 'Info at SAPGUI and TRACE-LIST about FORM-trace '
TO SY-TITLE.
*//////////////////////////////////////////////////////////////////////*
*************** Tables **********************
TABLES: T100, T022D, T022T, TSP01, TSP1T, TEDE1, THLPF.
*************** Parameters **********************
PARAMETERS: P_DISPL(1) TYPE C DEFAULT 'N',
P_TRACE(1) TYPE C DEFAULT 'J'.
*************** Variablendeklaration **********************
DATA: ROCKS TYPE I.
DATA: TIME1 TYPE I.
DATA: TIME2 TYPE I.
DATA: TIME3(15) TYPE P.
DATA: WORK1(150) TYPE C.
*************** internal Tables **********************
DATA: BEGIN OF I_TRACETAB OCCURS 10,
Z1(150) TYPE C,
END OF I_TRACETAB.
*
DATA: VTAB(400) TYPE C OCCURS 30 WITH HEADER LINE.
*************** macros **********************
GET RUN TIME FIELD TIME1. "initial
*.......................................................................
DEFINE TRACE1.
WRITE &1 TO WORK1+100.
IF WORK1 CP '*# '. ENDIF.
MOVE '/' TO WORK1+SY-FDPOS(1).
CONDENSE WORK1.
END-OF-DEFINITION.
*.......................................................................
DEFINE TRACE2.
TIME3 = &1 - TIME1.
WRITE 'UPRO-time:/ ' TO WORK1+100.
CONDENSE WORK1.
WRITE TIME3 TO WORK1+100.
CONDENSE WORK1.
END-OF-DEFINITION.
*.......................................................................
DEFINE DISPLAY1.
APPEND WORK1 TO I_TRACETAB.
ROCKS = ROCKS + 5.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = ROCKS
TEXT = WORK1.
CLEAR WORK1.
END-OF-DEFINITION.
*.......................................................................
*//////////////////////////////////////////////////////////////////////*
************* Programmsteuerung *******************
*//////////////////////////////////////////////////////////////////////*
GET RUN TIME FIELD TIME1.
WRITE: /1 'Information for programming...' COLOR 6.
ULINE.
*...............................................................
DO 11 TIMES. "a sample
PERFORM SY-INDEX OF READ-T100
READ-T022T
READ-T022D
READ-TSP01
UPRO-4
READ-TSP1T
READ-TEDE1
READ-THLPF
READ-T022D
READ-TSP1T
UPRO-4.
ENDDO.
*
*
IF P_TRACE EQ 'J'.
PERFORM DISPLAY-TRACETAB.
ELSE.
WRITE: /1 'Only short information at SAPGUI'.
ENDIF.
*//////////////////////////////////////////////////////////////////////*
************* subprogramms *******************
*//////////////////////////////////////////////////////////////////////*
************************************************************************
* read external table T100
************************************************************************
FORM READ-T100.
*
WRITE: /5 'READ-T100 is here' COLOR 5.
*.......................................................................
GET RUN TIME FIELD TIME1.
TRACE1: 'READ-T100', SY-UZEIT, TIME1.
*
SELECT * INTO TABLE VTAB FROM T100
UP TO 20 ROWS
WHERE SPRSL EQ SY-LANGU
AND ARBGB EQ '01'.
*
IF P_DISPL EQ 'J'.
PERFORM UPRO-5.
ENDIF.
*
GET RUN TIME FIELD TIME2.
TRACE2: TIME2.
DISPLAY1.
*
ENDFORM.
************************************************************************
* Read external table T022D
************************************************************************
FORM READ-T022D.
*
WRITE: /5 'READ-T022D is here' COLOR 5.
*.......................................................................
*
GET RUN TIME FIELD TIME1.
GET TIME.
TRACE1: 'READ-T022D', SY-UZEIT, TIME1.
*
SELECT * INTO TABLE VTAB FROM T022D
UP TO 20 ROWS.
*
IF P_DISPL EQ 'J'.
PERFORM UPRO-5.
ENDIF.
*
GET RUN TIME FIELD TIME2.
TRACE2: TIME2.
DISPLAY1.
*
ENDFORM.
************************************************************************
* Read external table T022T
************************************************************************
FORM READ-T022T.
*
WRITE: /5 'READ-T022t is here' COLOR 5.
*.......................................................................
*
GET RUN TIME FIELD TIME1.
GET TIME.
TRACE1: 'READ-T022T', SY-UZEIT, TIME1.
*
SELECT * INTO TABLE VTAB FROM T022T
UP TO 15 ROWS.
*
IF P_DISPL EQ 'J'.
PERFORM UPRO-5.
ENDIF.
*
GET RUN TIME FIELD TIME2.
TRACE2: TIME2.
DISPLAY1.
*
ENDFORM.
************************************************************************
* Read external table TSP01
************************************************************************
FORM READ-TSP01.
*
WRITE: /5 'READ-TSP01 is here' COLOR 5.
*.......................................................................
*
GET RUN TIME FIELD TIME1.
GET TIME.
TRACE1: 'READ-TSP01', SY-UZEIT, TIME1.
*
SELECT * INTO TABLE VTAB FROM TSP01
UP TO 10 ROWS.
*
IF P_DISPL EQ 'J'.
PERFORM UPRO-5.
ENDIF.
*
GET RUN TIME FIELD TIME2.
TRACE2: TIME2.
DISPLAY1.
*
ENDFORM.
************************************************************************
* Read external table TSP1T
************************************************************************
FORM READ-TSP1T.
*
WRITE: /5 'READ-TSP1T is here' COLOR 5.
*.......................................................................
*
GET RUN TIME FIELD TIME1.
GET TIME.
TRACE1: 'READ-TSP1T', SY-UZEIT, TIME1.
*
SELECT * INTO TABLE VTAB FROM TSP1T
UP TO 11 ROWS.
*
IF P_DISPL EQ 'J'.
PERFORM UPRO-5.
ENDIF.
*
GET RUN TIME FIELD TIME2.
TRACE2: TIME2.
DISPLAY1.
*
ENDFORM.
************************************************************************
* Read external Table TEDE1
************************************************************************
FORM READ-TEDE1.
*
WRITE: /5 'READ-TEDE1 is here' COLOR 5.
*.......................................................................
*
GET RUN TIME FIELD TIME1.
GET TIME.
TRACE1: 'READ-TEDE1', SY-UZEIT, TIME1.
*
SELECT * INTO TABLE VTAB FROM TEDE1
UP TO 15 ROWS.
*
IF P_DISPL EQ 'J'.
PERFORM UPRO-5.
ENDIF.
*
GET RUN TIME FIELD TIME2.
TRACE2: TIME2.
DISPLAY1.
*
ENDFORM.
************************************************************************
* Read external table THLPF
************************************************************************
FORM READ-THLPF.
*
WRITE: /5 'READ-THLPF is here' COLOR 5.
*.......................................................................
*
GET RUN TIME FIELD TIME1.
GET TIME.
TRACE1: 'READ-THLPF', SY-UZEIT, TIME1.
*
SELECT * INTO TABLE VTAB FROM THLPF
UP TO 13 ROWS.
*
IF P_DISPL EQ 'J'.
PERFORM UPRO-5.
ENDIF.
*
GET RUN TIME FIELD TIME2.
TRACE2: TIME2.
DISPLAY1.
*
ENDFORM.
************************************************************************
* only a wait in the form
************************************************************************
FORM UPRO-4.
*
WRITE: /5 'upro-4 is here' COLOR 5.
*.......................................................................
*
GET RUN TIME FIELD TIME1.
GET TIME.
TRACE1: 'upro-4', SY-UZEIT, TIME1.
*
WAIT UP TO 3 SECONDS.
*
GET RUN TIME FIELD TIME2.
TRACE2: TIME2.
DISPLAY1.
*
ENDFORM.
************************************************************************
* only a loop in the form
************************************************************************
FORM UPRO-5.
*
WRITE: /5 'upro-5 is here' COLOR 5.
*.......................................................................
*
GET RUN TIME FIELD TIME1.
GET TIME. "update for field SY-UZEIT
TRACE1: 'upro-5', SY-UZEIT, TIME1.
*
WAIT UP TO 1 SECONDS.
LOOP AT VTAB.
WRITE: /1 VTAB.
ENDLOOP.
*
GET RUN TIME FIELD TIME2.
TRACE2: TIME2.
DISPLAY1.
*
ENDFORM.
************************************************************************
* display trace-data
************************************************************************
FORM DISPLAY-TRACETAB.
*
DATA: F1(15) TYPE C.
DATA: F2(8) TYPE N.
DATA: F3(15) TYPE N.
DATA: F4(10) TYPE C.
DATA: F5(20) TYPE N.
DATA: SLASH(2) VALUE '/'.
DATA: Z_SUM(10) TYPE P DECIMALS 2.
*.......................................................................
SKIP 2. ULINE.
WRITE: /5 'Display-tracetab' COLOR 3.
ULINE.
*.......................................................................
*
LOOP AT I_TRACETAB.
SPLIT I_TRACETAB AT SLASH INTO F1 F2 F3 F4 F5.
WRITE: /1 F1,
16 F2,
28 F3,
40 F4,
58 F5.
ENDLOOP.
*
GET RUN TIME FIELD TIME2.
Z_SUM = TIME2 / 1000000.
*
SKIP 2. ULINE.
WRITE: /1 'Duration: ', Z_SUM, 'Seconds'.
*
ENDFORM.
************************************************************************
************************************************************************
******************* Programmende ***************************************
