Open Source Natural Code - ZTRACE

You would use this in any long running batch job where you just want a trace of its progress.

You also need to use FORMAT  PS=1 so you get timely information, otherwise you will only get info when the page buffer is full, which if it was 23 or 60 would defeat the purpose of the copycode.

Copycode ZTRACE

0010 *
0020 * Written by PSM 6/May/08 ... Use INPUT ... Ralph Zbrog
0030 *
0040 * Will generate a trace log for a long extract, must use ZTRACEL
0050 *
0060 * Usage:
0070 * DEFINE DATA LOCAL USING ZTRACEL
0080 * ...
0090 * END-DEFINE
0100 * FORMAT ZP=ON
0110 * ...
0120 * #TRADE-STARTED := *TIMX /* Not needed for 1st trace usage
0130 * #TRACE-EXPECTED := 1234567 /* No of records expected
0140 * ...
0150 * READ MY-DDM ...
0160 *   INCLUDE ZTRACE '#10000' /* Can use #1000, #10000 or #100000
0170 *   ...
0180 * END-READ
0190 * END
0200 *
0210 * The trace output will then be generated every #10000:
0220 *
0230 * <PROGRAM> <TIME> <COUNT> <ELAPSED> <REMAINING> <ETA>
0240 *
0250 * If #TRACE-EXPECTED = 0 then it will just output:
0260 *
0270 * <PROGRAM> <TIME> <COUNT> <ELAPSED>
0280 *
0290 ***********************************************************************
0300 ADD 1 TO #TRACE
0310 IF &1& = 0 THEN
0320   #TRACE-ELAPSED := *TIMX - #TRACE-STARTED
0330   IF #TRACE-EXPECTED= 0 THEN
0340     INPUT (AD=O IP=OFF) *PROGRAM *TIMX #TRACE 4X #TRACE-ELAPSED
0350   ELSE
0360     #TRACE-REMAINING := (#TRACE-ELAPSED * (#TRACE-EXPECTED / #TRACE)
0370       - #TRACE-ELAPSED)
0380     #TRAC-ETA := #TRACE-REMAINING + *TIMX
0390     INPUT (AD=O IP=OFF) *PROGRAM *TIMX #TRACE 4X #TRACE-ELAPSED
0400       2X #TRACE-REMAINING
0410       4X #TRACE-ETA
0420   END-IF
0430 END-IF

Dataarea ZTRACEL:

0010 DEFINE DATA LOCAL
0020 /*
0030 /* Used with ZTRACE copycode
0040 /*
0050 1 #TRACE (N9.0) (EM=ZZZ,ZZZ,ZZ9)
0060 1 REDEFINE #TRACE
0070   2 FILLER 6X
0080   2 #1000 (N3.0)
0090 1 REDEFINE #TRACE
0100   2 FILLER 5X
0110   2 #10000 (N4.0)
0120 1 REDEFINE #TRACE
0130   2 FILLER 4X
0140   2 #100000 (N5.0)
0150 /*
0160 1 #TRACE-STARTED   (T) INIT<*TIMX>
0170 1 #TRACE-ELAPSED   (T) (EM=HH:II:SS)
0180 1 #TRACE-ETA       (T) (EM=HH:II:SS)
0190 1 #TRACE-EXPECTED  (P9.0)
0200 1 #TRACE-REMAINING (T) (EM=HH:II:SS)
0210 /*
0220 END-DEFINE

 

for assistance contact pmacgowan@gmail.com