Count the records and print at end.
Moderators: Frank Yaeger, Moderator Group
Count the records and print at end.
Hi
i need to count the number of recors in a fil and write them in the end
of the file.
example:
HTEST
123968711BM
234968711CM
234968896BM
567968858DM
567968889AM
TRILER
HERE in trailer i want the number of records to be printed.example here total is 5.
rec lenght: 38
rec format: FB
Regards
i need to count the number of recors in a fil and write them in the end
of the file.
example:
HTEST
123968711BM
234968711CM
234968896BM
567968858DM
567968889AM
TRILER
HERE in trailer i want the number of records to be printed.example here total is 5.
rec lenght: 38
rec format: FB
Regards
-
- Member
- Posts: 25
- Joined: Tue Apr 28, 2009 10:53 pm
- Location: USA
- Contact:
Are the HEADER and TRAILER records already part of the data set? If so, here is a SyncSort for z/OS job that will produce the record count:
This is the output produced from the above job:
Code: Select all
//SORT1 EXEC PGM=SORT
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD *
HTEST
123968711BM
234968711CM
234968896BM
567968858DM
567968889AM
TRILER
//SYSIN DD *
OMIT COND=(1,6,CH,EQ,C'TRILER')
SORT FIELDS=COPY
OUTFIL FILES=OUT,
TRAILER1=(1:C'TOTAL RECORD COUNT IS',1X,
COUNT-1=(EDIT=(IIIT))),REMOVECC
/*
Code: Select all
HTEST
123968711BM
234968711CM
234968896BM
567968858DM
567968889AM
TOTAL RECORD COUNT IS 5
anilanju,
If you want to update the existing trailer record without creating a new one, then use the following DFSORT JCL
The output from this job is
If you want to update the existing trailer record without creating a new one, then use the following DFSORT JCL
Code: Select all
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
HTEST
123968711BM
234968711CM
234968896BM
567968858DM
567968889AM
TRILER
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFOUTLEN=38,IFTHEN=(WHEN=INIT,OVERLAY=(39:SEQNUM,5,ZD)),
IFTHEN=(WHEN=(1,6,CH,EQ,C'TRILER'),
OVERLAY=(10:39,5,ZD,SUB,+2,M10,LENGTH=5))
/*
Code: Select all
HTEST
123968711BM
234968711CM
234968896BM
567968858DM
567968889AM
TRILER 5
Hi
The code is working fine.
but i just have small query.
OMIT COND=(1,1,CH,EQ,C'T')
SORT FIELDS=COPY
OUTFIL FILES=OUT,
TRAILER1=(1:C'T',1X,
COUNT-1=(EDIT=(IIIIIIT))),REMOVECC
END
from this the trailer record i am getting is
T 103235
i want these spaces to be removed, as the number of records is not fixed.
i want the output as
T103235, so whenever the count changes, it moves
for example:if count is 1000025 then it should be
T1000025.
The code is working fine.
but i just have small query.
OMIT COND=(1,1,CH,EQ,C'T')
SORT FIELDS=COPY
OUTFIL FILES=OUT,
TRAILER1=(1:C'T',1X,
COUNT-1=(EDIT=(IIIIIIT))),REMOVECC
END
from this the trailer record i am getting is
T 103235
i want these spaces to be removed, as the number of records is not fixed.
i want the output as
T103235, so whenever the count changes, it moves
for example:if count is 1000025 then it should be
T1000025.
-
- Member
- Posts: 25
- Joined: Tue Apr 28, 2009 10:53 pm
- Location: USA
- Contact:
One alternative is to print the leading zeros:
Producing these results:
Another alternative is to modify Kolusu's job as follows:
Which produces these results:
Code: Select all
//SYSIN DD *
OMIT COND=(1,1,CH,EQ,C'T')
SORT FIELDS=COPY
OUTFIL FILES=OUT,
TRAILER1=(1:C'T',
COUNT-1=(EDIT=(TTTTTTT))),REMOVECC
/*
Code: Select all
HTEST
123968711BM
234968711CM
234968896BM
567968858DM
567968889AM
T0000005
Code: Select all
//SYSIN DD *
SORT FIELDS=COPY
INREC IFOUTLEN=38,
IFTHEN=(WHEN=INIT,OVERLAY=(39:SEQNUM,5,ZD)),
IFTHEN=(WHEN=(1,1,CH,EQ,C'T'),
OVERLAY=(2:39,5,ZD,SUB,+2,M10,LENGTH=5),HIT=NEXT),
IFTHEN=(WHEN=(1,1,CH,EQ,C'T'),
BUILD=(1,1,2,5,JFY=(SHIFT=LEFT)))
/*
Code: Select all
HTEST
123968711BM
234968711CM
234968896BM
567968858DM
567968889AM
T5
Alissa Margulies,
You really don't need the extra IFTHEN. you can do it in the same pass.
You really don't need the extra IFTHEN. you can do it in the same pass.
Code: Select all
//SYSIN DD *
SORT FIELDS=COPY
INREC IFOUTLEN=38,IFTHEN=(WHEN=INIT,OVERLAY=(39:SEQNUM,5,ZD)),
IFTHEN=(WHEN=(1,6,CH,EQ,C'T'),
OVERLAY=(39:39,5,ZD,SUB,+2,M10,LENGTH=5,2:39,5,JFY=(SHIFT=LEFT)))
/*
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page