View previous topic :: View next topic |
Author |
Message |
andrew Beginner
Joined: 18 Dec 2004 Posts: 5 Topics: 2
|
Posted: Fri Feb 24, 2006 3:33 am Post subject: EasyTrieve TERMINATION proc not really at the end |
|
|
Hi Every,
Has a TERMINATION proc to print record count at the end of report. However, when SEQUENCE present in report definition. The count always less than the actual count. Even more surprising, when the display the count in FINISH proc, the count is correct !?
Physical input record count = 3607
Records printed on report = 3607
Record count printed at FINISH = 3607
Record count printed at TERMINATION = 3607 (without SEQUENCE)
Record count printed at TERMINATION = 2889 (with SEQUENCE, how come )
Does anyone has an idea to explain this? It seems that when SEQUENCE is effective, TERMINATION is the last line of report but not the last record of JOB. A simplifed code is included.
Andrew.
Code: |
FILE REP1 PRINTER
FILE EMP
EMP-NAME 1 40 A
EMP-SALARY 41 9 N
W-CNT W 4 P VALUE 0
*
JOB INPUT EMP FINISH FINAL-PROC
W-CNT = W-CNT + 1
PRINT REP1
*
FINAL-PROC. PROC
DISPLAY 'TOTAL EMP READ AT FINAL ' W-CNT
END-PROC
*
REPORT REP1 PRINTER PRINT01
SEQUENCE EMP-SALARY
LINE EMP-NAME EMP-SALARY
TERMINATION. PROC
DISPLAY SKIP 1 'TOTAL EMP READ AT TERM ' W-CNT
END-PROC
*
* RESULT IS
* TOTAL EMP READ AT FINAL 3607
* TOTAL EMP READ AT TERM 2889
|
|
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Fri Feb 24, 2006 6:16 am Post subject: |
|
|
Andrew,
The mismatches in Counts is due to Duplicates in the input. If your input has duplicates the counts are off. Since you are not doing a summary report , it only reports unique values. Try removing the duplicates and re-run the same job. you will see the counts to be the same.
oh btw you really don't need a variable for count and then manually increment it everytime. you can use the system defined variable RECORD-COUNT.
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
andrew Beginner
Joined: 18 Dec 2004 Posts: 5 Topics: 2
|
Posted: Fri Feb 24, 2006 11:48 pm Post subject: |
|
|
Kolusu,
Yes, no issue when SEQUENCE with a unique field. In fact my original program sequence on year of date joined, and a lot computations based on count of records, sum of salary at control breaks. In fact the AFTER-BREAK proc also got incorrect result. It took me half a day to narrow down to this issue. Eventually solved by adding a DFSORT step and remove SEQUENCE from EZT program.
My question is: when SEQUENCE with a non-unique field, is it a wrong approach to put user accumulation logic in JOB, but to be printed on control break? (If we need statistics beyond simple sum and tally provided by CONTROL. My original program need to look up a rate in external file based on year to compute the total at control break.)
Anyway this surprised me and going to avoid TERMINATE and AFTER-BREAK user logic when SEQUENCE with non-unique field.
Andrew. |
|
Back to top |
|
 |
|
|