I would like to do the following in a JCL using SYNCSORT or any other tool. We do not have DFSORT.
I have a dataset with the last record (trailer record) containing
number of records in the dataset excluding the trailer.
I would like to count the number of records (excluding the trailer
record) and compare the number with the value stored as the first 13
bytes of the trailer record. If both numbers are equal, I would like to
set the RC = 0 in the JCL.
Joined: 26 May 2005 Posts: 28 Location: Northern VA, USA
This will require programming of one sort or another. I include REXX and CLIST and batch TSO/ISPF in 'programming'. There isn't a JCL facility to do what you want.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
This will require programming of one sort or another. ... There isn't a JCL facility to do what you want.
Not sure if you're including DFSORT/ICETOOL in "programming", but this can be done with DFSORT/ICETOOL. Since the poster said "We do not have DFSORT", I did not post a DFSORT/ICETOOL solution.
Joined: 26 May 2005 Posts: 28 Location: Northern VA, USA
In reply to Frank Yeager:
You learn something everyday! Well, I do, anyway. :-)
I did not know DFSORT could compare a derived value like record count to a value contained within an output record.
I'll just toddle off and RTFM now.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
Interested to know how it can be done in DFSORT.
Here's a DFSORT/ICETOOL job that does what was asked for:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//TOOLIN DD *
* Create one record as follows:
* dddddddddddddxxxxxxxxxxxxx
* where ddddddddddddd is the record count in the last record.
* xxxxxxxxxxxxx is the actual count - 1.
COPY FROM(IN) USING(CTL1)
* If ddddddddddddd is equal to xxxxxxxxxxxxx, set RC=0.
* If ddddddddddddd is not equal to xxxxxxxxxxxxx, set RC=12.
COUNT FROM(T1) EMPTY USING(CTL2)
/*
//CTL1CNTL DD *
OUTFIL FNAMES=T1,REMOVECC,NODETAIL,
TRAILER1=(1,13,COUNT-1=(M11,LENGTH=13))
/*
//CTL2CNTL DD *
INCLUDE COND=(1,13,CH,EQ,14,13,CH)
/*
Not to bring up a dead topic, but I was in a similar situation, and my site has syncsort not DFSORT so I thought I was screwed. I did some digging, and found a solution using syncsort:
Code:
//******************************************
//****COUNT RECORDS IN FILE USING SYNCSORT
//******************************************
//STEPH EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DS=MY.INFILE.TOCOUNT,
// DISP=SHR
//SORTOUT DD DSN=THE.INFILE.RECORD.COUNT,
// DISP=(NEW,CATLG,CATLG),
// DCB=(RECFM=FB,LRECL=008),
// UNIT=SYSDA,
// SPACE=(TRK,(1,1))
//SYSIN DD DATA
SORT FIELDS=COPY
OUTFIL NODETAIL,REMOVECC,TRAILER1=(COUNT)
/*
THIS CODE WILL COUNT THE RECORDS IN THE SORTIN FILE AND CREATE A 1 RECORD FILE WITH ONLY THE NUMBER OF RECORDS IN THE INFILE UP TO 8 BYTES (UP TO 99999999):
LIKE:
Code:
*****123
WHERE * = A LEFT PADDING SPACE
>>>>>PLEASE REMEMBER<<<<<
I AM TERRIBLE WITH MAINFRAME, so don't bother asking me for help. I merely stumbled across a workable pre-built solution in use that worked for me so I decided to share it with others. I do not have the knowledge to, nor did I actually come up with this code myself!
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
bigred,
What you show is NOT what was asked for. What you show merely gives the count of the input records, and has been shown numerous times on this board by myself and others. The actual requirement, satisfied by the DFSORT/ICETOOL job I showed was the following:
Quote:
I have a dataset with the last record (trailer record) containing
number of records in the dataset excluding the trailer.
I would like to count the number of records (excluding the trailer
record) and compare the number with the value stored as the first 13
bytes of the trailer record. If both numbers are equal, I would like to
set the RC = 0 in the JCL.
What you show is NOT what was asked for. What you show merely gives the count of the input records, and has been shown numerous times on this board by myself and others. The actual requirement, satisfied by the DFSORT/ICETOOL job I showed was the following:
Quote:
I have a dataset with the last record (trailer record) containing
number of records in the dataset excluding the trailer.
I would like to count the number of records (excluding the trailer
record) and compare the number with the value stored as the first 13
bytes of the trailer record. If both numbers are equal, I would like to
set the RC = 0 in the JCL.
Sure, but this solution is for SYNCSORT not DFSORT/ICEMAN. You are correct though that it doesn't meet the original guy's requirements, I posted it in the wrong thread.