compare two files:

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
User avatar
anilanju
Member
Posts: 47
Joined: Mon Nov 10, 2008 6:59 pm

compare two files:

Post by anilanju » Mon Feb 16, 2009 5:47 pm

Hi

I need to compare two files, which has number of tranasctions like shown below..

one file has more records than the other one and in random order.
I want the common records in one output file and the
uncommon records in other file.

FILE 1:

0000000000
7CM ABC411..
7CL EFD357..
7AC DCB682..

FILE 2:

7CM ABC411..
7CL EFD357..
7CL BNJ281..
7CM MNG282..
7AC DCB682..

Output as:
FILE 1:

0000000000
7CM ABC411..
7CL EFD357..
7AC DCB682..

FILE 2:
7CL BNJ281..
7CM MNG282..

Thanks
Anju

User avatar
rangab
Active Member
Posts: 56
Joined: Fri Mar 17, 2006 3:21 pm

Post by rangab » Mon Feb 16, 2009 8:45 pm

Hi,

Uncommon records from both files into one single file?

What are the LRECL & RECFM of these files?

Thanks.
========
Ranga...:-0)
========
Learn Which You Don't Know - Teach Others Which They Don't Know.

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

Post by Frank Yaeger » Mon Feb 16, 2009 9:13 pm

0000000000 is an "uncommon" record, so by your "rules" it should be in output file2, not in output file1 as you show. Given that, here's a DFSORT/ICETOOL job that will do what you asked for. I assumed you wanted to check for duplicates on positions 1-12, but the ON field can be changed for other situations as appropriate.

Code: Select all

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//CON DD DSN=...  input file1
//    DD DSN=...  input file2
//OUT1 DD DSN=...  output file1
//OUT2 DD DSN=...  output file2
//TOOLIN DD *
SELECT FROM(CON) TO(OUT1) ON(1,12,CH) FIRSTDUP
SELECT FROM(CON) TO(OUT2) ON(1,12,CH) NODUPS
/*
OUT1 will have:

Code: Select all

7AC DCB682.. 
7CL EFD357.. 
7CM ABC411.. 
OUT2 will have:

Code: Select all

0000000000   
7CL BNJ281.. 
7CM MNG282.. 
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

User avatar
anilanju
Member
Posts: 47
Joined: Mon Nov 10, 2008 6:59 pm

compare two files:

Post by anilanju » Mon Feb 23, 2009 6:38 pm

Hi Frank

My requirement has changed a bit.
I need to compare one PS file with record lenght 58,with VSAM file whose key lenght is 10, its a KSDS.

Please let me know wht to do, i tried using the same code but its is not working..

Regards
Ajnu
Last edited by anilanju on Mon Feb 23, 2009 8:11 pm, edited 2 times in total.

User avatar
anilanju
Member
Posts: 47
Joined: Mon Nov 10, 2008 6:59 pm

Post by anilanju » Mon Feb 23, 2009 7:06 pm

Hi Frank

Its giving me error RC=20.I am basically interested in the uncommon records.
I want the records which are uncommon in both the files to be in the output file.

Please its urgent..

Regards Anu

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

Post by Frank Yaeger » Mon Feb 23, 2009 9:10 pm

RC=20 usually indicates a message data set is missing. That would be TOOLMSG or DFSMSG.

Since your requirement has changed to using a VSAM file and non-VSAM file as input, you won't be able to concatenate them.

If you need more help with this, then since your requirements have changed, you need to show me a new example of your input records and what you expect for output. Give me all of the details like RECFM and LRECL of the ps file, starting position, length and format of all the relevant fields in both input files, etc.
Please its urgent..
Then perhaps you should have taken the time to give the needed information so I could help you more quickly.
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

User avatar
anilanju
Member
Posts: 47
Joined: Mon Nov 10, 2008 6:59 pm

Compare two files

Post by anilanju » Mon Feb 23, 2009 9:47 pm

Hi

This is the example i am the output along with the information:

PS FILE : LREC:58, recfm:FB

0000000000
7CM ABC411
7CL EFD357
7AC DCB682
7CL BNJ281
7CM MNG282

VSAM 2: Key lenght 10, LREC=58. KSDS

7CM ABC411
7CL BNJ281


PS file has large number of records, while VSAM has few records.

I need UNCOMMON RECORDS in my output as:
PS file:LREC=58, RECFM:FB

0000000000
7CL EFD357
7AC DCB682
7CM MNG282

Starting position is 1, and last position is 10.

Regards
Anju

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

Post by Frank Yaeger » Mon Feb 23, 2009 10:10 pm

You can use a DFSORT/ICETOOL job like the following to do what you asked for. I assumed the output records could be sorted in key order. If you need them in their original order, you'll need another step.

Code: Select all

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN1 DD DSN=...  ps input file (FB/58)
//IN2 DD DSN=.... VSAM input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=...  ps output file (FB/58)
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2) VSAMTYPE(F)
SELECT FROM(T1) TO(OUT) ON(1,10,CH) NODUPS USING(CTL3)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(59:C'1')
/*
//CTL2CNTL DD *
  INREC OVERLAY=(59:C'2')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,OMIT=(59,1,CH,EQ,C'2'),
    BUILD=(1,58)
/*
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

User avatar
anilanju
Member
Posts: 47
Joined: Mon Nov 10, 2008 6:59 pm

Post by anilanju » Tue Feb 24, 2009 4:48 pm

Hi

This code worked properly...thanks a lot

//STEP0010 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SORTWK01 DD UNIT=SYSDA,SPACE=(CYL,(100,100),RLSE)
//CON DD DSN=in1
// DD DSN=in2
//OUT1 DD DSN=out1
//TOOLIN DD *
SELECT FROM(CON) TO(OUT1) ON(1,10,CH) NODUPS
/*

But i am facing other problem now..

I am gettin uncommon records from both the input files and i just want the uncommon records from just one file.
ex:


PS FILE : LREC:58, recfm:FB ,in1

0000000000
7CM ABC411
7CL EFD357
7AC DCB682
7CL BNJ281
7CM MNG282

VSAM 2: Key lenght 10, LREC=58. in2

7CM ABC411
7ww ANU123
7CL BNJ281

output:
PS file:LREC=58, RECFM:FB

0000000000
7ww ANU13 **
7CL EFD357
7AC DCB682
7CM MNG282

** i dont want his record in my output..just the uncommon records from 1st input file.

Regards
Anu

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 Feb 24, 2009 9:14 pm

Huh? I gave you a new DFSORT/ICETOOL job for your new requirement. You are showing the old DFSORT/ICETOOL job for your old requirement. The new job does what you want based on what you described previously. Why are you still using the old job?
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

User avatar
anilanju
Member
Posts: 47
Joined: Mon Nov 10, 2008 6:59 pm

Post by anilanju » Wed Feb 25, 2009 7:41 pm

Hi Dear

Thanks a lot. :lol:

The second solution worked perfectly fine.

Thanks a ton

Regards
Anju :D

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