IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

JCL to compare counts


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
dharmadam_man

New User


Joined: 20 Apr 2005
Posts: 8

PostPosted: Wed Apr 20, 2005 8:45 pm
Reply with quote

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.


Example
DRU034
CPC045
RFK056
0000000000003
Back to top
View user's profile Send private message
SteveConway

New User


Joined: 26 May 2005
Posts: 28
Location: Northern VA, USA

PostPosted: Thu May 26, 2005 10:27 pm
Reply with quote

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.

Cheers,,,Steve
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri May 27, 2005 6:24 am
Reply with quote

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.
Back to top
View user's profile Send private message
Deepa.m

New User


Joined: 28 Apr 2005
Posts: 99

PostPosted: Fri May 27, 2005 4:05 pm
Reply with quote

Interested to know how it can be done in DFSORT.
if this set continues N times in the file ..how will you repeat the comparison.??
Back to top
View user's profile Send private message
SteveConway

New User


Joined: 26 May 2005
Posts: 28
Location: Northern VA, USA

PostPosted: Fri May 27, 2005 7:59 pm
Reply with quote

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.

Cheers,,,Steve
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri May 27, 2005 8:56 pm
Reply with quote

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)
/*
Back to top
View user's profile Send private message
SteveConway

New User


Joined: 26 May 2005
Posts: 28
Location: Northern VA, USA

PostPosted: Fri May 27, 2005 9:40 pm
Reply with quote

Very cool, Frank. You continue to educate me. Much appreciated.


Cheers,,,Steve
Back to top
View user's profile Send private message
bigreddastud

New User


Joined: 19 Jan 2006
Posts: 6

PostPosted: Thu Jan 19, 2006 4:33 am
Reply with quote

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!
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Jan 19, 2006 4:58 am
Reply with quote

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.
Back to top
View user's profile Send private message
bigreddastud

New User


Joined: 19 Jan 2006
Posts: 6

PostPosted: Thu Jan 19, 2006 7:49 pm
Reply with quote

Frank Yaeger wrote:
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.


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.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Jan 19, 2006 8:36 pm
Reply with quote

FYI, your count job will work for DFSORT as well.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Compare two files with a key and writ... SYNCSORT 3
No new posts Select two different counts from SQL... DB2 6
No new posts Compare latest 2 rows of a table usin... DB2 1
No new posts How to compare two rows of same table DB2 11
Search our Forums:

Back to Top