JCL SORT - Count number of records in a file
Moderators: Frank Yaeger, DikDude, Moderator Group
JCL SORT - Count number of records in a file
Hi all,
I have an input flat file containing number of records. I have to count the no of records and put the count in the output flat file. I need the data in the output file as "No of records:" as one field and the "count" as second field. Please help me out.
I have an input flat file containing number of records. I have to count the no of records and put the count in the output flat file. I need the data in the output file as "No of records:" as one field and the "count" as second field. Please help me out.
Thanks,
Girish Chintawar
Girish Chintawar
Hi Girish Chintawar,
Find below the SORT JCL which will do what you have asked for..
//TESTCNTX JOB (ABCD,04,T,0000),'ICE M',CLASS=K,MSGCLASS=T,
// NOTIFY=&SYSUID
//*
//JOBLIB DD DSN=ABCD.PPROD.LOAD,DISP=SHR
//*
//*
//********************************************************************
//STEP001 EXEC PGM=SORT
//********************************************************************
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD DISP=SHR,
// DSN=ABCD.VEERA.INPUT
//SORTOUT DD DISP=(NEW,CATLG,DELETE),
// DSN=ABCD.VEERA.COUNT1,
// SPACE=(CYL,(5,5),RLSE),
// UNIT=SYSDA,BLKSIZE=0
//SYSIN DD *
SORT FIELDS=COPY,
OUTFIL REMOVECC,NODETAIL,
TRAILER1=(10:'NO OF RECORDS:',COUNT)
/*
//*
Thanks
Veera.
Find below the SORT JCL which will do what you have asked for..
//TESTCNTX JOB (ABCD,04,T,0000),'ICE M',CLASS=K,MSGCLASS=T,
// NOTIFY=&SYSUID
//*
//JOBLIB DD DSN=ABCD.PPROD.LOAD,DISP=SHR
//*
//*
//********************************************************************
//STEP001 EXEC PGM=SORT
//********************************************************************
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD DISP=SHR,
// DSN=ABCD.VEERA.INPUT
//SORTOUT DD DISP=(NEW,CATLG,DELETE),
// DSN=ABCD.VEERA.COUNT1,
// SPACE=(CYL,(5,5),RLSE),
// UNIT=SYSDA,BLKSIZE=0
//SYSIN DD *
SORT FIELDS=COPY,
OUTFIL REMOVECC,NODETAIL,
TRAILER1=(10:'NO OF RECORDS:',COUNT)
/*
//*
Thanks
Veera.
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
Girish,
Veera's job won't work. Here's a DFSORT job that will:
SORTOUT will have one record, e.g.
You can change the format of the count to whatever you like using DFSORT's edit masks.
Veera's job won't work. Here's a DFSORT job that will:
Code: Select all
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=... output file
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,NODETAIL,
TRAILER1=('No of records: ',COUNT=(M11,LENGTH=8))
/*
Code: Select all
No of records: 00000002
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Hi, FRANK
Frank only after executing i will post my answers , its already
executed job it WILL WORK FOR SURE 100%, May be after execution
i will change the jcl so that it doesnt reflect my shop parameters
or so ...... so in doing that if i missed out something it may not work....
I AM SURE IT WILL WORK.....well can u tell me the reason as why it will not work ???
Thanks
Veera.
Frank only after executing i will post my answers , its already
executed job it WILL WORK FOR SURE 100%, May be after execution
i will change the jcl so that it doesnt reflect my shop parameters
or so ...... so in doing that if i missed out something it may not work....
I AM SURE IT WILL WORK.....well can u tell me the reason as why it will not work ???
Thanks
Veera.
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
You will get a syntax error for:well can u tell me the reason as why it will not work ???
Code: Select all
SORT FIELDS=COPY,
I don't understand this. What are you trying to say? Are you asking a question or making a statement?How to display the count i mean =(M11,LENGTH=8) can be tailored..
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Yeah Frank got the point its a copy paste problem.... an extra , ....while foramting it wud have appeared ..but i was wondering as what is wrong since i have put the code only after execution...well ignore my other question i taught u were saying my JCL is wrong because i dint specify the format for the count. Well i am sorry
Thanks
Veera.
Thanks
Veera.
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
Veera,
I'm happy to hear you tested your solution before posting it. I guess you just have to be more careful doing the copy and paste. COUNT without editing is fine if the result happens to be what's needed, but COUNT with editing is more flexible. Peace.
P.S. In the future, I'd suggest using BBCodes to make the code more readable.
I'm happy to hear you tested your solution before posting it. I guess you just have to be more careful doing the copy and paste. COUNT without editing is fine if the result happens to be what's needed, but COUNT with editing is more flexible. Peace.
P.S. In the future, I'd suggest using BBCodes to make the code more readable.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
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