View previous topic :: View next topic
|
Author |
Message |
Balasubramanian
New User
Joined: 23 Apr 2005 Posts: 13 Location: Bangalore
|
|
|
|
Hi,
file1:-
Code: |
field1 field2
----------------------------
1 1
1 3
1 4
1 5
1 6
2 0
2 1
2 2
2 3
|
file2:-
Code: |
field1 field2
----------------------------
1 1
1 1
1 1
1 3
1 4
1 5
2 1
2 2
2 2
2 2
|
file1 doesnt contain duplicates and file2 contains duplicates
Have to find the values that are in file1 and not in file2.
Output should be
Code: |
field1 field2
----------------------------
1 6
2 0
2 3
|
Can anybody help to do the above using JCl.
Thanks & Regards,
Balasubramanian S |
|
Back to top |
|
|
sivakumar. K. M
New User
Joined: 22 Nov 2005 Posts: 3
|
|
|
|
Here's a DFSORT/ICETOOL job that will do what you asked for:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD * input file1
1 1
1 3
1 4
1 5
1 6
2 0
2 1
2 2
2 3
/*
// DD * input file2
1 1
1 1
1 1
1 3
1 4
1 5
2 1
2 2
2 2
2 2
/*
//OUT DD DSN=... output file
//TOOLIN DD *
SELECT FROM(CON) TO(OUT) ON(1,2,CH) NODUPS
/* |
|
Back to top |
|
|
Phantom
New User
Joined: 04 Sep 2005 Posts: 25
|
|
|
|
Sivakumar K.M
Quote: |
Balasubramaniam
Have to find the values that are in file1 and not in file2.
|
When you use NODUPS option of SORT, it will pick up non-duplicate entries from both files. But the original poster just wanted data from file 1 that are not in file 2. But your code will also pickup data from file 2 that is not available in file 1 which will not give desired results.
The other way to accomplish this is
1. To generate dynamic sort cards
2. Using SPLICE
Balasubramaniam,
For Solution # 1, (dynamic sort card) - You cannot use this method if your input file 1 (without dups) is huge. How many records do you have ?
For Solution # 2 - You need to have latest version of Syncsort or Dfsort. What sort product do you have ? and what is the version.
Thanks,
Phantom |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Actually, for the input data shown, NODUPS will work since there aren't any nondup records in file2. For the more general case where there are nondup records in file2, you can use a DFSORT/ICETOOL job like this:
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
1 1
1 3
1 4
1 5
1 6
2 0
2 1
2 2
2 3
//IN2 DD *
1 0 <--- added nondup in file2
1 1
1 1
1 1
1 3
1 4
1 5
2 1
2 2
2 2
2 2
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=... output file
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SELECT FROM(T1) TO(OUT) ON(1,1,CH) ON(20,1,CH) NODUPS USING(CTL3)
/*
//CTL1CNTL DD *
OUTREC FIELDS=(1,80,81:C'1')
/*
//CTL2CNTL DD *
OUTREC FIELDS=(1,80,81:C'2')
/*
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,INCLUDE=(81,1,CH,EQ,C'1'),
OUTREC=(1,80)
/*
|
Alternatively, you could use the SPLICE operator of DFSORT's ICETOOL as discussed at:
www.ibm.com/servers/storage/support/software/sort/mvs/tricks/srtmst02.html#t05 |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Phantom wrote
Quote: |
2. Using SPLICE
For Solution # 2 - You need to have latest version of Syncsort or Dfsort. |
This may be true for Syncsort, but it is definitely NOT TRUE for DFSORT. DFSORT's ICETOOL has had SPLICE since the Feb, 2003 DFSORT PTF! The "latest version" of DFSORT is the Dec, 2004 PTF (which is not very new at this point). |
|
Back to top |
|
|
Phantom
New User
Joined: 04 Sep 2005 Posts: 25
|
|
|
|
You are correct Frank,
I should have said "You need to have Dfsort or latest version of syncsort" instead of saying the other way ! But whatever you said is what I meant.
Thanks,
Phantom |
|
Back to top |
|
|
Balasubramanian
New User
Joined: 23 Apr 2005 Posts: 13 Location: Bangalore
|
|
|
|
Hi all
Thanks for your immediate response and valid comments.
Thanks & Regards,
Balasubramanian S |
|
Back to top |
|
|
Alain Benveniste
New User
Joined: 14 Feb 2005 Posts: 88
|
|
|
|
Code: |
The "latest version" of DFSORT is the Dec, 2004 PTF (which is not very new at this point).
|
I'm really looking forward to seeing what will bring the next one !!!
alain |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
I think it will make you happy. |
|
Back to top |
|
|
lav
New User
Joined: 30 Nov 2005 Posts: 3
|
|
|
|
Can anyone Explain how could this be achieved using Dynamic Sort card ? |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
lav, could you explain what is a "Dynamic Sort card"? |
|
Back to top |
|
|
lav
New User
Joined: 30 Nov 2005 Posts: 3
|
|
|
|
Even i am not sure of what this "dynamic sort card" is. Phantom had metioned this as 1 solution in his above post. Just wanted to know what he meant by that and how it can be done? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Phantom was talking about dynamically generating an INCLUDE or OMIT statement using the values from file2, and then using that INCLUDE or OMIT statement to select the records from file1. That method cannot be used for large files since there's a limit to the number of INCLUDE or OMIT conditions you can use. The SELECT method I showed can be used for large files. |
|
Back to top |
|
|
lav
New User
Joined: 30 Nov 2005 Posts: 3
|
|
|
|
How to generate an INCLUDE statement when the number of records that will be present in a file is not known? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
That's the dynamic part. You use OUTREC to create a "condition" line (e.g. p,m,CH,EQ,C'string',OR,) for each record in file2, and then pass that as a control statement to be used against file1. This method is very limited vs the general SELECT method I showed, so I won't bother to show it here. |
|
Back to top |
|
|
|