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

how to compare two counts


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
marimuthu_G

New User


Joined: 25 Feb 2008
Posts: 8
Location: India

PostPosted: Mon Mar 03, 2008 2:54 pm
Reply with quote

hii,
i have count of no.of records from one file and i want to know whether its equal to the count of other file
Back to top
View user's profile Send private message
Arunprasad.k

New User


Joined: 04 Jan 2008
Posts: 7
Location: Chennai, India

PostPosted: Mon Mar 03, 2008 3:19 pm
Reply with quote

I assume that you have the counts in two files and want to compare those two (numerals).

Also provide the following details.

#1 Is there a common field in both the files (say some key field)?
#2 Does both the files (containing the record counts) have same number of records? If no post what needs to be done in that case.
#3 What should be done if the record counts are equal and when not equal.

Tip: Use SPlICE operator and merge the two file and then compare the counts (the numeric field you want to compare).

Arun.
Back to top
View user's profile Send private message
marimuthu_G

New User


Joined: 25 Feb 2008
Posts: 8
Location: India

PostPosted: Mon Mar 03, 2008 3:57 pm
Reply with quote

ill rephrase my question:--
I have a input file with N records.
I get 2 output files (derived from the input file) with X and Y as thier record counts respectively.
I want to check whehter the sum of no of records (X+Y) in the output files is equal to no of records in the input file (N)

I.e X+Y=N

I want to ABEND the job if X+Y <> N
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: Mon Mar 03, 2008 10:12 pm
Reply with quote

What program or utility are you using to create the 2 output files with X and Y? Can you have that program create an output file with N at the same time? What do the output records look like? What is the RECFM and LRECL of the output files? Do you actually need an ABEND or would a non-zero return code do as well?
Back to top
View user's profile Send private message
marimuthu_G

New User


Joined: 25 Feb 2008
Posts: 8
Location: India

PostPosted: Tue Mar 04, 2008 10:38 am
Reply with quote

the 3 files are already created(out of which 2 files just have a number say x & y respectively, lrecl20) and their recfm is fb and the third file(having n records,lrecl=1300)is first counted for the no. of records and then we want to see whether x+y=n we want an abend...if not equal
Back to top
View user's profile Send private message
Arunprasad.k

New User


Joined: 04 Jan 2008
Posts: 7
Location: Chennai, India

PostPosted: Tue Mar 04, 2008 10:16 pm
Reply with quote

This is one possible solution in DFSORT.

Code:
//S1     EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//INX      DD *                                                         
0000000008                                                             
//INY      DD *                                                         
0000000002                                                             
//INN      DD *                                                         
AAAAAAA                                                                 
BBBBBBB                                                                 
CCCCCCC                                                                 
DDDDDDD                                                                 
EEEEEEE                                                                 
FFFFFFF                                                                 
GGGGGGG                                                                 
HHHHHHH                                                                 
IIIIIII                                                                 
JJJJJJJ                                                                 
//T1       DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(1,1)),DISP=(MOD,PASS)     
//T2       DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(1,1)),DISP=(MOD,PASS)     
//OUT      DD DSN=&&O1,UNIT=SYSDA,SPACE=(CYL,(1,1)),DISP=(MOD,PASS)     
//TOOLIN   DD *                                                         
COPY   FROM(INX)  TO(T1)                               USING(CTL1)     
COPY   FROM(INY)  TO(T1)                               USING(CTL2)     
SPLICE FROM(T1)   TO(T2)       ON(31,8,ZD) WITH(11,10) USING(CTL3)     
SORT   FROM(INN)  TO(T2)                               USING(CTL4)     
SPLICE FROM(T2)   TO(OUT)      ON(81,1,CH) WITH(11,10)                 
/*                                                                     
//CTL1CNTL DD *                                                         
  INREC BUILD=(1,10,31:SEQNUM,8,ZD)                                     
/*                                                                     
//CTL2CNTL DD *                                                         
  INREC BUILD=(11:1,10,31:SEQNUM,8,ZD)                                 
/*                                                                     
//CTL3CNTL DD *                                                         
 OUTFIL FNAMES=T2,OUTREC=(01,10,UFF,ADD,11,20,UFF,                     
                          EDIT=(TTTTTTTTTT),81:C'$')                   
/*                                                                     
//CTL4CNTL DD *                                                         
  SORT FIELDS=(1311,1,CH,A)                                             
  INREC  IFTHEN=(WHEN=INIT,OVERLAY=(1301:C'0000000001',1311:C'&'))     
  SUM FIELDS=(1301,10),FORMAT=ZD                                       
  OUTFIL FNAMES=T2,OUTREC=(01:10X,11:1301,10,81:C'$')                   
/*                                                                     
//S2     EXEC PGM=ICEMAN,PARM='NULLOUT=RC16'                           
//SORTIN   DD DSN=&&O1,DISP=(OLD,DELETE,DELETE)                         
//SORTOUT  DD SYSOUT=*                                                 
//SYSOUT   DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  OPTION COPY                                                           
  INCLUDE COND=(1,10,ZD,EQ,11,10,ZD)                                   
/*                                                                     


Experts, I have a question. How can I give NULLOUT option in a CNTL which is used for SPLICE operation.

To put that simply, How could I have avoided step S2 by giving NULLOUT option in the last SPLICE operation?

Arun.
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: Tue Mar 04, 2008 11:07 pm
Reply with quote

If you are using z/OS DFSORT V1R5 (which supports NULLOUT and NULLOFL), then you can use USING(xxxx) for SPLICE and put NULLOFL=RC16 on the OUTFIL statement with FNAMES=OUT.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Mar 04, 2008 11:09 pm
Reply with quote

marimuthu,

The following JCL will set a return code of 16 if the counts dont match, and a return code of 0 if the counts match

Code:

//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*     
//DFSMSG   DD SYSOUT=*     
//IN1      DD DSN=YOUR 20 BYTE LRECL FILE1,
//            DISP=SHR
//IN2      DD DSN=YOUR 20 BYTE LRECL FILE2,
//            DISP=SHR
//IN3      DD DSN=YOUR 1300 BYTE LRECL FILE,
//            DISP=SHR
//T1       DD DSN=&&T1,DISP=(MOD,PASS),SPACE=(TRK,(1,1),RLSE)
//OUT      DD SYSOUT=*                                       
//TOOLIN   DD *                         
  COPY FROM(IN1) USING(CTL1)           
  COPY FROM(IN2) USING(CTL1)           
  COPY FROM(IN3) USING(CTL2)           
  SORT FROM(T1) USING(CTL3)             
//CTL1CNTL DD *                         
  OUTFIL FNAMES=T1,REMOVECC,NODETAIL,                   
  OUTREC=(10X),TRAILER1=(2:C'+',COUNT=(M11,LENGTH=8))
/*
//CTL2CNTL DD *                         
  OUTFIL FNAMES=T1,REMOVECC,NODETAIL,                   
  OUTREC=(10X),TRAILER1=(2:C'-',COUNT=(M11,LENGTH=8))
/*                                     
//CTL3CNTL DD *                         
  SORT FIELDS=(1,1,CH,A)               
  INREC OVERLAY=(2:2,9,SFF,PD,LENGTH=8)
  SUM FIELDS=(2,8,PD)                   
  OUTFIL FNAMES=OUT,NULLOFL=RC16,       
  INCLUDE=(2,8,PD,EQ,0)                 
//*                                     
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: Tue Mar 04, 2008 11:30 pm
Reply with quote

marimuthu_G,

Here's a DFSORT/ICETOOL job that will do what you asked for. I assumed your count files each have one record with a 10-byte ZD count, but the job can be changed appropriately for whatever you have. You need to have z/OS DFSORT V1R5 to use NULLOFL (it isn't supported with DFSORT R14). If x+y=n, the job will pass back RC=0. If x+y<>n, the job will issue a U0209 ABEND.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  first count data set (has 10-byte ZD count)
//       DD DSN=...  second count data set (has 10-byte ZD count)
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  OUTFIL REMOVECC,NODETAIL,
    BUILD=(80X),
    TRAILER1=('TOT_XY,+',TOT=(1,10,ZD,TO=ZD,LENGTH=12))
/*
//S2    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//IN DD DSN=...  input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//OUT DD DUMMY
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
COPY FROM(T1) USING(CTL2)
/*
//CTL1CNTL DD *
  OUTFIL FNAMES=T1,REMOVECC,NODETAIL,
    BUILD=(12X),
    TRAILER1=(COUNT=(TO=ZD,LENGTH=12))
/*
//CTL2CNTL DD *
  OMIT COND=(1,12,ZD,NE,TOT_XY)
  DEBUG ABEND
  OUTFIL FNAMES=OUT,NULLOFL=RC16
/*
Back to top
View user's profile Send private message
marimuthu_G

New User


Joined: 25 Feb 2008
Posts: 8
Location: India

PostPosted: Thu Mar 13, 2008 12:06 pm
Reply with quote

Hi Kolusu,
i had asked a ques..how to compare counts.....
and you gave the following solution...

Code:

//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*     
//DFSMSG   DD SYSOUT=*     
//IN1      DD DSN=YOUR 20 BYTE LRECL FILE1,
//            DISP=SHR
//IN2      DD DSN=YOUR 20 BYTE LRECL FILE2,
//            DISP=SHR
//IN3      DD DSN=YOUR 1300 BYTE LRECL FILE,
//            DISP=SHR
//T1       DD DSN=&&T1,DISP=(MOD,PASS),SPACE=(TRK,(1,1),RLSE)
//OUT      DD SYSOUT=*                                       
//TOOLIN   DD *                         
  COPY FROM(IN1) USING(CTL1)           
  COPY FROM(IN2) USING(CTL1)           
  COPY FROM(IN3) USING(CTL2)           
  SORT FROM(T1) USING(CTL3)             
//CTL1CNTL DD *                         
  OUTFIL FNAMES=T1,REMOVECC,NODETAIL,                   
  OUTREC=(10X),TRAILER1=(2:C'+',COUNT=(M11,LENGTH=8))
/*
//CTL2CNTL DD *                         
  OUTFIL FNAMES=T1,REMOVECC,NODETAIL,                   
  OUTREC=(10X),TRAILER1=(2:C'-',COUNT=(M11,LENGTH=8))
/*                                     
//CTL3CNTL DD *                         
  SORT FIELDS=(1,1,CH,A)               
  INREC OVERLAY=(2:2,9,SFF,PD,LENGTH=8)
  SUM FIELDS=(2,8,PD)                   
  OUTFIL FNAMES=OUT,NULLOFL=RC16,       
  INCLUDE=(2,8,PD,EQ,0)                 
//*     


but the prob..is that it always gives rc=16....for x+y=n & x+y<>n also..
please answer this.....
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Mar 13, 2008 9:47 pm
Reply with quote

marimuthu_G,

The JCL I have shown works fine giving me the right results. If it not working for you, then I need to see the DFSMSG sysout. Show me the messages . Note that you need z/OS DFSORT V1R5 and higher which supports NULLOUT and NULLOFL . If you are running a different version then may be you are getting a syntax error which results in RC16
Back to top
View user's profile Send private message
Shanthi Jayaraman

New User


Joined: 11 Jun 2007
Posts: 26
Location: Malaysia

PostPosted: Thu Jun 05, 2008 2:14 pm
Reply with quote

Dear All,

I have a requirement where the total number of records is specified in the header.
I need to compare if it match with the total records in the file and return an error code if it is not match.

I have got something like this :

Code:
//S050 EXEC PGM=ICETOOL                     
//TOOLMSG DD SYSOUT=*                       
//DFSMSG DD SYSOUT=*                       
//IN DD DSN=ABC
//TOOLIN DD *                               
COUNT FROM(IN) EQUAL(3592) RC4             
/*                                 


At the part where I hardcode 3592, I need to get the count specified in the file ABC.

Content of file ABC :

9903592 09052008
111111 111111 222 33
111111 111111 222 33
111111 111111 222 33
111111 111111 222 33

99 tells its the header.
The record count starts at position 3 and of length 5.

Thank you for the help.
Back to top
View user's profile Send private message
Shanthi Jayaraman

New User


Joined: 11 Jun 2007
Posts: 26
Location: Malaysia

PostPosted: Thu Jun 05, 2008 5:48 pm
Reply with quote

Dear All,

I manage to get what I want using the below.
But its hit and trial, I still need to understand why it works :

Code:
//S1    EXEC  PGM=ICEMAN                                       
//SYSOUT    DD  SYSOUT=*                                       
//SORTIN DD DSN=ABC,DISP=SHR               
//SYM    DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//HDR DD DSN=&&H1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)   
//SYSIN    DD    *                                             
  OPTION COPY                                                 
  OUTFIL FNAMES=SYM,REMOVECC,NODETAIL,                         
    TRAILER1=('RCOUNT,',COUNT=(M11,LENGTH=5))                 
  OUTFIL FNAMES=HDR,INCLUDE=(1,2,ZD,EQ,99)                     
/*                                                             
//S2    EXEC  PGM=ICEMAN                                       
//SYSOUT    DD  SYSOUT=*                                       
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)                         
//SORTIN DD DSN=&&H1,DISP=(OLD,PASS)                           
//SORTOUT DD DUMMY                                             
//SYSIN    DD    *                                             
  OPTION COPY,NULLOUT=RC4                                     
  INCLUDE COND=(3,5,ZD,EQ,RCOUNT)                             


Thank you
Back to top
View user's profile Send private message
V S Amarendra Reddy

Active User


Joined: 13 Sep 2006
Posts: 216
Location: USA

PostPosted: Thu Jun 05, 2008 9:45 pm
Reply with quote

Do you mean to say the code is working fine or do you want to explain the logic??
Back to top
View user's profile Send private message
Shanthi Jayaraman

New User


Joined: 11 Jun 2007
Posts: 26
Location: Malaysia

PostPosted: Fri Jun 06, 2008 7:56 am
Reply with quote

The code is working fine and I manage to understand the logic also yesterday night.

I have another problem now, my senior is asking why I didn't use ICETOOL as she never heard of ICEMAN.

I am not sure of the differences...can anyone help?
The code works in development but am not sure if it will work in production cause so far no one used ICEMAN here...
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Jun 06, 2008 8:07 am
Reply with quote

Hello,

To make her more comfortable, run your job using PGM=SORT (sort and iceman invoke the same load module).
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 Jun 06, 2008 9:35 pm
Reply with quote

Quote:
I have another problem now, my senior is asking why I didn't use ICETOOL as she never heard of ICEMAN.


Explain to your "senior" that PGM=ICEMAN and PGM=SORT both invoke DFSORT. There is no difference between them. PGM=ICETOOL invokes DFSORT's ICETOOL utility.

PGM=SORT and PGM=ICEMAN have been available for over 30 years.
PGM=ICETOOL is a relative newcomer in that it has only been available since 1991. icon_lol.gif
Back to top
View user's profile Send private message
Shanthi Jayaraman

New User


Joined: 11 Jun 2007
Posts: 26
Location: Malaysia

PostPosted: Mon Jun 09, 2008 10:18 am
Reply with quote

Thanx Dick & Frank, I will try to explain...
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 -> DFSORT/ICETOOL

 


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