JCL SORT - Count number of records in a file

In this Mainframe Forum - You can post your queries on JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3

Moderators: Frank Yaeger, DikDude, Moderator Group

Post Reply
goalchi27
Member
Posts: 3
Joined: Fri Mar 09, 2007 2:20 pm

JCL SORT - Count number of records in a file

Post by goalchi27 » Fri Mar 23, 2007 1:25 pm

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.
Thanks,
Girish Chintawar

Veera
Moderator
Posts: 111
Joined: Wed Feb 22, 2006 2:59 pm

Post by Veera » Fri Mar 23, 2007 7:53 pm

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.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Fri Mar 23, 2007 9:24 pm

Girish,

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))
/*
SORTOUT will have one record, e.g.

Code: Select all

No of records: 00000002
You can change the format of the count to whatever you like using DFSORT's edit masks.
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

Veera
Moderator
Posts: 111
Joined: Wed Feb 22, 2006 2:59 pm

Post by Veera » Fri Mar 23, 2007 9:31 pm

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.

Veera
Moderator
Posts: 111
Joined: Wed Feb 22, 2006 2:59 pm

Post by Veera » Fri Mar 23, 2007 9:35 pm

How to display the count i mean =(M11,LENGTH=8)) can be tailored..


Thanks
Veera.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Fri Mar 23, 2007 9:57 pm

well can u tell me the reason as why it will not work ???
You will get a syntax error for:

Code: Select all

  SORT FIELDS=COPY, 
Also, SYSPRINT isn't needed and BLKSIZE=0 isn't needed.
How to display the count i mean =(M11,LENGTH=8) can be tailored..
I don't understand this. What are you trying to say? Are you asking a question or making a statement?
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

Veera
Moderator
Posts: 111
Joined: Wed Feb 22, 2006 2:59 pm

Post by Veera » Fri Mar 23, 2007 10:06 pm

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.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Fri Mar 23, 2007 10:27 pm

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.
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

Veera
Moderator
Posts: 111
Joined: Wed Feb 22, 2006 2:59 pm

Post by Veera » Fri Mar 23, 2007 10:48 pm

Hi Frank,

Yes will take care in future. Thanks for the info.

Thanks and Regards,
Veera

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Feb 01, 2016 11:03 pm

<< Content deleted By Admin >>

Post Reply

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



Other References
Mainframe Tools and others