|
|
| Author |
Message |
sumannaidu
New User
Joined: 21 May 2005 Posts: 13 Location: mumbai
|
|
|
|
| i want a JCL that will compare two files with similar record length and similar fields and create one output file that contains only unmatched records |
|
| Back to top |
|
 |
References
|
Posted: Tue May 06, 2008 6:40 pm Post subject: Re: compare two files and write output file with unmatched recor |
 |
|
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 3973 Location: San Jose, CA
|
|
|
|
You need to give more details of what you want to do.
Please show an example of the records in each input file (relevant fields only) and what you expect for output. If input file1 can have duplicates within it, show that in your example. If input file2 can have duplicates within it, show that in your example. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of each input file. |
|
| Back to top |
|
 |
ajithgeorvar
New User
Joined: 01 Apr 2005 Posts: 1
|
|
|
|
I too was interested in knowing how to use DFSORT and write out unmatched records.
Say there are 2 files File A and File B of which first 10 chars is key data. We need to find the records in File A which arent in File B or vice versa (means unmatched).
Data in File A (80chars long):
1111111111 RECORD1XXXXXXXXXXXXXXXXXXXXXXX
2222222222 RECORD2YYYYYYYYYYYYYYYYYYYYYYYYYY
Data in File B (80chars long):
1111111111 RECORD1AAAAAAAAAAAAAAAAAAAAAAA
3333333333 RECORD2BBBBBBBBBBBBBBBBBBBBBBB
The output file if its Records in A, but not in B need to have:
2222222222 RECORD2YYYYYYYYYYYYYYYYYYYYYYYYYY
Can we do it with DFSORT? |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 3973 Location: San Jose, CA
|
|
|
|
Ajith,
For the example you show, where there are no duplicates within fileA and no duplicates within fileB, you can use a DFSORT/ICETOOL job like this:
| Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=... input fileA (FB/80)
//IN2 DD DSN=... input fileB (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=... output file (FB/80)
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SELECT FROM(T1) TO(OUT) ON(1,10,CH) NODUPS USING(CTL3)
/*
//CTL1CNTL DD *
INREC OVERLAY=(81:C'A')
/*
//CTL2CNTL DD *
INREC OVERLAY=(81:C'B')
/*
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,INCLUDE=(81,1,CH,EQ,C'A'),
BUILD=(1,80)
/*
|
If you do have duplicates within either input file, show a better example of the records in each input file for that situation and what you expect for output. |
|
| Back to top |
|
 |
haohao
New User
Joined: 23 May 2008 Posts: 7 Location: beijing China
|
|
|
|
that requirement is very similar to mine. in my case the two files might have duplicate key records both. take for example:
file structure: the two input file have the same file structure as below:
01 FILE-RECORD
03 FILE-KEY PIC X(10).
03 FILE-DATE PIC X(50).
file A's content:
1111111111AAAAAAAAAAAAAAAAAA
1111111111BBBBBBBBBBBBBBBBBB
1111111111CCCCCCCCCCCCCCCCCC
2222222222AAAAAAAAAAAAAAAAAA
2222222222BBBBBBBBBBBBBBBBBB
3333333333AAAAAAAAAAAAAAAAAA
4444444444CCCCCCCCCCCCCCCCCC
file B's content:
1111111111DDDDDDDDDDDDDDDDDD
1111111111FFFFFFFFFFFFFFFFFF
4444444444AAAAAAAAAAAAAAAAAA
I want generate two files ,one file contains all records from file A which key are different from file B's key.
another file contains all recoreds from file A and file B which records have the same key in file B.
SO the first output file should as below:
2222222222AAAAAAAAAAAAAAAAAA
2222222222BBBBBBBBBBBBBBBBBB
3333333333AAAAAAAAAAAAAAAAAA
the second output file should as below:
1111111111AAAAAAAAAAAAAAAAAA
1111111111BBBBBBBBBBBBBBBBBB
1111111111CCCCCCCCCCCCCCCCCC
1111111111DDDDDDDDDDDDDDDDDD
1111111111FFFFFFFFFFFFFFFFFF
4444444444AAAAAAAAAAAAAAAAAA
4444444444CCCCCCCCCCCCCCCCCC
I hope I made my requirement clear. how can it be done by DFSORT? thanks a lot for your help!! |
|
| Back to top |
|
 |
Skolusu
DFSORT Developer
Joined: 07 Dec 2007 Posts: 225 Location: San Jose
|
|
|
|
haohao,
The following DFSORT/ICETOOL JCL which will give you the desired results
| Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
1111111111DDDDDDDDDDDDDDDDDD
1111111111FFFFFFFFFFFFFFFFFF
4444444444AAAAAAAAAAAAAAAAAA
//IN2 DD *
1111111111AAAAAAAAAAAAAAAAAA
1111111111BBBBBBBBBBBBBBBBBB
1111111111CCCCCCCCCCCCCCCCCC
2222222222AAAAAAAAAAAAAAAAAA
2222222222BBBBBBBBBBBBBBBBBB
3333333333AAAAAAAAAAAAAAAAAA
4444444444CCCCCCCCCCCCCCCCCC
//T1 DD DSN=&&T1,DISP=(MOD,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT1 DD SYSOUT=*
//OUT2 DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) USING(CTL1)
COPY FROM(IN2) USING(CTL2)
SPLICE FROM(T1) TO(OUT1) ON(01,10,CH) -
WITHALL WITH(01,60) USING(CTL3) KEEPNODUPS KEEPBASE
//CTL1CNTL DD *
OUTFIL FNAMES=T1,BUILD=(1,60,1,10)
//CTL2CNTL DD *
OUTFIL FNAMES=T1,BUILD=(1,60,10X)
//CTL3CNTL DD *
OUTFIL FNAMES=OUT1,BUILD=(01,60),INCLUDE=(61,10,CH,EQ,1,10,CH)
OUTFIL FNAMES=OUT2,SAVE
/* |
Hope this helps.. |
|
| Back to top |
|
 |
haohao
New User
Joined: 23 May 2008 Posts: 7 Location: beijing China
|
|
|
|
hi,San Jose:
That's great! I have tested it, It's well done, thank you very much! |
|
| Back to top |
|
 |
|
|
|