MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Record count

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
YSMVS
Beginner


Joined: 19 May 2004
Posts: 51
Topics: 25
Location: My House

PostPosted: Thu Nov 04, 2004 2:47 pm    Post subject: Record count Reply with quote

Hi all,

I saw kolusus reply for finding the number of records in the file. http://www.mvsforums.com/helpboards/viewtopic.php?t=7&highlight=count

My reqmt is to compare the record count of two files in a step and if they match then I want to proceed to next step. Can any one throw some light on how to do this ?

Cheers,
YSMVS
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Nov 04, 2004 3:56 pm    Post subject: Reply with quote

Here's one way to do it with DFSORT/ICETOOL. The ICETOOL step sets RC=0 if the counts match or RC=12 if they don't match.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=...  input file1
//IN2 DD DSN=...  input file2
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CTL3CNTL DD DSN=&&C1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
* IN1->T1:  Create a record with the count for input file1:
* nnnnnnnn
  COPY FROM(IN1) USING(CTL1)
* IN1->CTL3CNTL:  Create an INCLUDE statement as follows:
*  INCLUDE COND=(1,8,ZD,EQ,mmmmmmmm)
* where mmmmmmmm is the count for input file2
  COPY FROM(IN2) USING(CTL2)
* Use the INCLUDE statement to output one record if
* nnnnnnnn=mmmmmmmm, or 0 records otherwise.
* If output record was produced (nnnnnnnn=mmmmmmmm), set RC=0.
* Otherwise, set RC=12.
  COUNT FROM(T1) USING(CTL3) EMPTY
/*
//CTL1CNTL DD *
  OUTFIL FNAMES=T1,REMOVECC,NODETAIL,
   OUTREC=(8X),TRAILER1=(COUNT=(M11,LENGTH=8))
/*
//CTL2CNTL DD *
  OUTFIL FNAMES=CTL3CNTL,REMOVECC,NODETAIL,
   OUTREC=(80X),
   TRAILER1=(' INCLUDE COND=(1,8,ZD,EQ,',COUNT=(M11,LENGTH=8),
     ')')
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Thu Nov 04, 2004 3:59 pm    Post subject: Reply with quote

This series of steps did the trick for me:

Code:

//STEP0001 EXEC PGM=SORT             
//SYSOUT   DD   SYSOUT=*             
//SORTIN   DD   DISP=SHR,DSN=dataset1
//SORTOUT  DD   DSN=&&T1,DISP=(NEW,PASS),UNIT=VIO   
//SYSIN    DD   DATA                               
  OPTION COPY                                       
  OUTFIL REMOVECC,NODETAIL,                         
    SECTIONS=(1,2,                                 
      TRAILER3=(1:COUNT=(M10,LENGTH=10)))           
/*                                                 
//*                                                 
//STEP0002 EXEC PGM=SORT                           
//SYSOUT   DD   SYSOUT=*
//SORTIN   DD   DISP=SHR,DSN=dataset2
//SORTOUT  DD   DSN=&&T2,DISP=(NEW,PASS),UNIT=VIO   
//SYSIN    DD   DATA                               
  OPTION COPY                                       
  OUTFIL REMOVECC,NODETAIL,                         
    SECTIONS=(1,2,                                 
      TRAILER3=(1:COUNT=(M10,LENGTH=10)))           
/*                                                 
//* 
//STEP0003 EXEC PGM=ICETOOL                                     
//TOOLMSG  DD   SYSOUT=*                                         
//DFSMSG   DD   SYSOUT=*                                         
//IN       DD   DSN=&&T1,DISP=(OLD,PASS)                         
//         DD   DSN=&&T2,DISP=(OLD,PASS)                         
//OUT      DD   DSN=&&T3,DISP=(NEW,PASS),UNIT=VIO               
//GARBAGE  DD   SYSOUT=*                                         
//TOOLIN   DD   DATA                                             
  SELECT FROM(IN) TO(OUT) ON(1,10,CH) NODUPS DISCARD(GARBAGE)   
  COUNT FROM(OUT) NOTEMPTY                                       
/*                                                               

where STEP0003 will end with RC=0 if both datasets have the same record count, RC=12 if they are different.
Back to top
View user's profile Send private message
YSMVS
Beginner


Joined: 19 May 2004
Posts: 51
Topics: 25
Location: My House

PostPosted: Thu Nov 04, 2004 4:48 pm    Post subject: Reply with quote

Hi Frank,

I am afraid, I have only syncsort in my site. Can this solution be worked out in Syncsort ? Do I need to make any change ?

Cheers,
YSMVS
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Nov 04, 2004 6:02 pm    Post subject: Reply with quote

Superk,

You could do all of that in one ICETOOL step rather than three DFSORT steps.

And you don't need DISCARD(GARBAGE) since you aren't using the GARBAGE output.

Note that your method does three COPY operations (COPY, COPY, COUNT) and one SORT operation (SELECT), whereas my method does three COPY operations (COPY, COPY, COUNT) without a SORT operation. It's always best to avoid sorting if you can for optimum efficiency.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Nov 04, 2004 6:03 pm    Post subject: Reply with quote

YSMVS,

Sorry, but I don't answer questions about Syncsort. Maybe somebody else can help you with that.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12377
Topics: 75
Location: San Jose

PostPosted: Thu Nov 04, 2004 8:38 pm    Post subject: Reply with quote

Ysmvs,

The following JCl will give you the desired results. A brief explanation of the job.

The first step gets the count from the 1st file
The second step gets the count from the 2nd file

The next step we concate the above created count files and sort on the count field and using sum fields we eliminate the dupes.

using startrec on outfil we always will write out the second record.

Now if the both records are matched , there will only be one record since we are using sum fields=none. So writing the output from second record will end in an empty file. It is where we use the NULLOUT parm where we can set the return code to 0,4,or 16. Here I am setting the return code to 4 in this case.

If the records do not match then we have 1 record in the output and the return code will automatically be zero.

Now using cond on the following steps we either skip or run the other steps.

Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD DSN=YOUR 1ST INPUT FILE,
//            DISP=SHR
//SORTOUT  DD DSN=&T1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                         
  OUTFIL NODETAIL,TRAILER1=(COUNT)                         
/*                                                       
//STEP0200 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD DSN=YOUR 2ND INPUT FILE,
//            DISP=SHR
//SORTOUT  DD DSN=&T2,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                         
  OUTFIL NODETAIL,TRAILER1=(COUNT)                         
/*                                                       
//STEP0300 EXEC PGM=SORT                 
//SYSOUT   DD SYSOUT=*                   
//SORTIN   DD DSN=&T1,DISP=OLD           
//         DD DSN=&T2,DISP=OLD           
//SORTOUT  DD SYSOUT=*                   
//SYSIN    DD *                           
  OPTION NULLOUT=RC4                     
  SORT FIELDS=(2,8,CH,A)                 
  SUM FIELDS=NONE                         
  OUTFIL STARTREC=2                       
/*


Btw if you had searched the utility forum you would have found this topic which discussed simialr requirement.

http://www.mvsforums.com/helpboards/viewtopic.php?t=2163&highlight=empty

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group