|
View previous topic :: View next topic
|
| Author |
Message |
rajesh_m
New User
Joined: 15 Apr 2008 Posts: 39 Location: India
|
|
|
|
Hi,
I have below requirement, could anyone please help me in achieving this.
Sample Input.
KEY1 A
KEY1 B
KEY1 C
KEY1 D
KEY2 A
KEY2 B
KEY3 E
KEY3 F
KEY4 A
KEY4 B
Output Should be:
KEY2 A
KEY2 B
KEY4 A
KEY4 B
We would need keys which is having values A and B, we should OMIT remaining keys. |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
have you tried anything ? Have you searched for INCLUDE DFSORT ?
Gerry |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
rajesh_m,
With z/OS DFSORT V1R5 PTF UK51706 or z/OS DFSORT V1R10 PTF UK51707 (Nov, 2009), DFSORT now supports the JOINKEYS function which is used for matching the keys and get the desired results
Use the same file for both SORTJNF1 and SORTJNF2 and for JNF2 file select all the records without an 'A' or 'B' in col 6 and eliminate the dups. Once you join these records to file1 records we can eliminate all the matching records and write out just unpaired records from F1
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD DSN=Your input file,DISP=SHR
//SORTJNF2 DD DSN=Your input file,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS FILES=F1,FIELDS=(1,4,A)
JOINKEYS FILES=F2,FIELDS=(1,4,A)
JOIN UNPAIRED,F1,ONLY
//JNF2CNTL DD *
OMIT COND=(6,1,SS,EQ,C'A,B')
SUM FIELDS=NONE
//* |
For complete details on JOINKEYS and the new date conversion functions available with the Nov, 2009 DFSORT PTF, see:
www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000174
| gcicchet wrote: |
| have you tried anything ? Have you searched for INCLUDE DFSORT ? |
Gerry,
I would be really interested to know how it can be done with an INCLUDE condition. The condition here is check if each key has just an 'A' and 'B' record alone and it cannot have any other codes |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi Skolusu,
my mistake, I misinterpreted the request.
Gerry |
|
| Back to top |
|
 |
rajesh_m
New User
Joined: 15 Apr 2008 Posts: 39 Location: India
|
|
|
|
Thanks Skolusu! Its is working, great logic.
But, if we want to select 'C' also along with 'A' and 'B' it is failing, for example.
Sample Input.
KEY1 A
KEY1 B
KEY1 C
KEY1 D
KEY2 A
KEY2 B
KEY2 C
KEY3 E
KEY3 F
KEY4 A
KEY4 B
The desired output should be
KEY2 A
KEY2 B
KEY2 C
But i'm getting
KEY2 A
KEY2 B
KEY2 C
KEY4 A
KEY4 B
Any idea how to avoid this situation. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
rajesh_m,
Use the following control cards
| Code: |
//SYSIN DD *
OPTION COPY
JOINKEYS FILES=F1,FIELDS=(1,4,A)
JOINKEYS FILES=F2,FIELDS=(1,4,A)
JOIN UNPAIRED,F1,ONLY
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(241:SEQNUM,1,ZD,RESTART=(1,4))),
IFTHEN=(WHEN=GROUP,BEGIN=(241,1,ZD,EQ,1),PUSH=(161:1,80),RECORDS=3),
IFTHEN=(WHEN=GROUP,BEGIN=(241,1,ZD,EQ,2),PUSH=(081:1,80),RECORDS=2)
OUTFIL INCLUDE=(241,1,ZD,EQ,3),BUILD=(161,80,/,81,80,/,1,80)
//*
//JNF2CNTL DD *
OMIT COND=(6,1,SS,EQ,C'A,B,C')
SUM FIELDS=NONE
//* |
|
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
as I don't have z/OS DFSORT V1R5 PTF UK51706 or z/OS DFSORT V1R10 PTF UK51707 (Nov, 2009) installed, here is another solution
| Code: |
//STEP0001 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
KEY1 A
KEY1 B
KEY1 C
KEY1 D
KEY2 A
KEY2 B
KEY2 C
KEY3 E
KEY3 F
KEY4 A
KEY4 B
/*
//T1 DD DSN=&&T1,
// DISP=(,PASS,DELETE),
// UNIT=SYSDA,
// SPACE=(TRK,(5,5),RLSE)
//T2 DD DSN=&&T2,
// DISP=(,PASS,DELETE),
// UNIT=SYSDA,
// SPACE=(TRK,(5,5),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN) TO(T1) ON(1,4,CH) EQUAL(3)
COPY FROM(T1) TO(T2) USING(CTL1)
SELECT FROM(T2) TO(OUT) ON(1,4,CH) EQUAL(3)
/*
//CTL1CNTL DD *
INCLUDE COND=(6,1,CH,EQ,C'A',OR,
6,1,CH,EQ,C'B',OR,
6,1,CH,EQ,C'C')
/*
|
Gerry |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Gerry,
You really don't need 3 passes to get the desired results. Here is a two pass DFSORT/ICETOOL job
| Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
KEY1 A
KEY1 B
KEY1 C
KEY1 D
KEY2 A - RECORD 1
KEY2 B - RECORD 2
KEY2 C - RECORD 3
KEY3 D
KEY3 E
KEY3 F
KEY4 A
KEY4 B
KEY5 A
KEY5 B
KEY5 D
//T1 DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN) TO(T1) ON(1,4,CH) EQUAL(3) USING(CTL1)
SELECT FROM(T1) TO(OUT) ON(1,4,CH) EQUAL(3)
//*
//CTL1CNTL DD *
OUTFIL FNAMES=T1,INCLUDE=(6,1,SS,EQ,C'A,B,C')
//* |
|
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi Skolusu
thanks for the process improvement, one minor issue, FNAMES=P1 should be FNAMES=T1
Gerry |
|
| Back to top |
|
 |
rajesh_m
New User
Joined: 15 Apr 2008 Posts: 39 Location: India
|
|
|
|
| Thanks Skolusu and Gerry!! |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| gcicchet wrote: |
Hi Skolusu
thanks for the process improvement, one minor issue, FNAMES=P1 should be FNAMES=T1
Gerry |
Sorry. Corrected the post. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|