Matching record counts using SORT and setting a RC

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
bharathg21
Member
Posts: 5
Joined: Wed Jan 18, 2012 2:31 am

Matching record counts using SORT and setting a RC

Post by bharathg21 » Wed Jan 18, 2012 3:19 am

Hello,

Below is the requirement

I receive 2 files. One with data (file 1) and the other with just the record count (file 2). What I need to do is count the number of records in file 1 and check to see if the value matches with what is present on file 2. If the counts match need to set RC = 0 and if not set it to something else so that it can be handled accordingly in the next step in the JCL. Can this be acheived throug SORT or any other utility. Was checking to see if anything can be done other than writing a COBOL program. Please help. Thank you.

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

Post by Frank Yaeger » Wed Jan 18, 2012 4:03 am

What is the RECFM and LRECL of each input file?

What is the starting position, length and format of the count field in the second input file? Does it just contain one record with the count?
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

bharathg21
Member
Posts: 5
Joined: Wed Jan 18, 2012 2:31 am

Post by bharathg21 » Wed Jan 18, 2012 4:09 am

LRECL of both the files is 80, FB. Yes the second file will only contain the record count.

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

Post by Frank Yaeger » Wed Jan 18, 2012 4:43 am

Again:

What is the starting position, length and format of the count field in the second input file?
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

bharathg21
Member
Posts: 5
Joined: Wed Jan 18, 2012 2:31 am

Post by bharathg21 » Mon Jan 23, 2012 8:36 pm

The second input file is LRECL=80, FB and has only 1 row with record count in first 10 positions and the rest 70 being filler.

Thank you.

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

Post by Frank Yaeger » Tue Jan 24, 2012 12:03 am

Here's a DFSORT/ICETOOL job that will give you RC=0 if the counts match or RC=8 if they don't match. If you want RC=4 instead of RC=8, change RC8 to RC4. If you want RC=12 instead of RC=8, change RC8 to RC12.

Code: Select all

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//RCDS DD DSN=...  input file1 (FB/80)
//CT DD DSN=...    input file2 (FB/80)
//CTL2CNTL DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//TOOLIN DD *
COPY FROM(RCDS) USING(CTL1)
COUNT FROM(CT) EMPTY RC8 USING(CTL2)
//CTL1CNTL DD *
  OUTFIL FNAMES=CTL2CNTL,REMOVECC,NODETAIL,
   TRAILER1=('  INCLUDE COND=(1,10,ZD,EQ,',
     COUNT=(TO=ZD,LENGTH=10),C') ')     
/*
Last edited by Frank Yaeger on Wed Feb 01, 2012 2:31 am, edited 1 time in total.
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

bharathg21
Member
Posts: 5
Joined: Wed Jan 18, 2012 2:31 am

Post by bharathg21 » Fri Jan 27, 2012 1:38 am

Thank you. I will use it in my code.

bharathg21
Member
Posts: 5
Joined: Wed Jan 18, 2012 2:31 am

Post by bharathg21 » Wed Feb 01, 2012 3:08 am

Thank you. It did work for me.

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