|
View previous topic :: View next topic
|
| Author |
Message |
Deepan Raj
New User
Joined: 30 Dec 2009 Posts: 9 Location: India
|
|
|
|
Hi,
Can anyone tell me how to do this using Joinkeys in Syncsort. there are two files F1 and F2. both files are compared with their keys, if the key matches then i have to inserted a mark, say 'D' at the end of the record else space in the file F1.
I tried joinkeys and outrec, but not able get the actual result |
|
| Back to top |
|
 |
expat
Global Moderator

Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
| Unless you post the code that you are using, along with an explanation of what is not happening, the release level of the product, the RECFM & LRECL of the two files, the position, length and format of the key fields, there isn't too much people can say to help you. |
|
| Back to top |
|
 |
Deepan Raj
New User
Joined: 30 Dec 2009 Posts: 9 Location: India
|
|
|
|
File F1 - LRECL = 100 and KEY length is 23, position 1
File F2 - LRECL = 100 and KEY length is 23, position 14
i need to compare the key in both files and if it matches then i need to insert a mark for instance 'D' in the file F1.
I tried joinkeys - syncsort
JOINKEYS FILE=F1,
FIELDS=(1,23,A)
JOINKEYS FILE=F2,
FIELDS=(14,23,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,100)
INREC FIELDS=(1:1,100,101:C'D')
SORT FIELDS=(1,4,CH,A)
i need to insert 'D' only in the matched record. this code inserting 'D' in both matched and unmatched record in File F1. |
|
| Back to top |
|
 |
sril.krishy
Active User
Joined: 30 Jul 2005 Posts: 183 Location: hyderabad
|
|
|
|
Hi,
Remove the JOIN UNPAIRED,F1 and do the outrec.Here is the simple example.
| Code: |
//S1 EXEC PGM=SORT
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD *
123 A
234 B
//SORTJNF2 DD *
123 A
456 B
//SORTOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(01,03,A)
JOINKEYS FILES=F2,FIELDS=(01,03,A)
REFORMAT FIELDS=(F1:1,6)
SORT FIELDS=(1,3,CH,A)
OUTREC FIELDS=(1,6,1x,C'D')
|
Note : added a space(1X in outrec) after the first 6 characters and the character 'D'
Thanks
Krishy |
|
| Back to top |
|
 |
Deepan Raj
New User
Joined: 30 Dec 2009 Posts: 9 Location: India
|
|
|
|
Thanks Krishy,
By this code i will get only matched records with mark 'D' in the output.
But in my case, I want both matched and unmatched records, with mark 'D' only in matched records in the output file.
Thanks,
Deepan |
|
| Back to top |
|
 |
Deepan Raj
New User
Joined: 30 Dec 2009 Posts: 9 Location: India
|
|
|
|
Krishy,
I want output as
123 A D
234 B |
|
| Back to top |
|
 |
sril.krishy
Active User
Joined: 30 Jul 2005 Posts: 183 Location: hyderabad
|
|
|
|
Hi,
Try this.
| Code: |
//PS020 EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CTL1JNF1 DD *
123 A
234 B
//CTL1JNF2 DD *
123 A
456 B
//CTL1OF01 DD DSN=AA.T1,
// DISP=(,CATLG,DELETE),
// UNIT=SYSID,
// SPACE=(CYL,(1,1),RLSE)
//FINAL DD DSN=BB.T1,
// DISP=(,CATLG,DELETE),
// UNIT=SYSID,
// SPACE=(CYL,(1,1),RLSE)
//TOOLIN DD *
SORT FROM(CTL1JNF1) USING(CTL1)
SORT FROM(CTL1OF01) TO(FINAL) USING(CTL2)
//CTL1CNTL DD *
SORT FIELDS=COPY
JOINKEYS FILES=F1,FIELDS=(1,3,A)
JOINKEYS FILES=F2,FIELDS=(1,3,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,6,F2:1,6)
OUTFIL FILES=01
//CTL2CNTL DD *
OUTREC IFTHEN=(WHEN=(8,2,CH,NE,C' '),
BUILD=(1,6,C'D')),
IFTHEN=(WHEN=NONE,
BUILD=(1,6))
SORT FIELDS=COPY
|
Thanks
Krishy |
|
| Back to top |
|
 |
Deepan Raj
New User
Joined: 30 Dec 2009 Posts: 9 Location: India
|
|
|
|
Hi Krishy,
Yours working fine. Thanks a lot.
Since this sort the file two times, i tried this
JOINKEYS FILE=F1,
FIELDS=(1,4,A)
JOINKEYS FILE=F2,
FIELDS=(1,4,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,20,F2:1,20)
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(21,4,CH,NE,C' '),
BUILD=(1:1,10,11:C'D',12:11,10)),
IFTHEN=(WHEN=NONE,
BUILD=(1:1,10,11:C' ',12:11,10))
This also doing the same work..
Thanks for ur idea..[/img] |
|
| Back to top |
|
 |
l.nethaji
New User
Joined: 16 Mar 2008 Posts: 90 Location: tamil nadu
|
|
|
|
Hi,
//CTL1CNTL DD *
SORT FIELDS=COPY
JOINKEYS FILES=F1,FIELDS=(1,3,A)
JOINKEYS FILES=F2,FIELDS=(1,3,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,6,F2:1,6)
Based on the first condition we are going to get the output as
123 A
234 B
Can any one explain me how this condition works using the above o/p from first .
CTL2CNTL DD *
OUTREC IFTHEN=(WHEN=(8,2,CH,NE,C' '),
BUILD=(1,6,C'D')),
IFTHEN=(WHEN=NONE,
BUILD=(1,6))
SORT FIELDS=COPY
Pls help |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
What happens when you run it? |
|
| Back to top |
|
 |
Deepan Raj
New User
Joined: 30 Dec 2009 Posts: 9 Location: India
|
|
|
|
Hi Nethaji,
//CTL1CNTL DD *
SORT FIELDS=COPY
JOINKEYS FILES=F1,FIELDS=(1,3,A)
JOINKEYS FILES=F2,FIELDS=(1,3,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,6,F2:1,6)
Based on the first condition u will get output as
123 A123 A
234 B
CTL2CNTL DD *
OUTREC IFTHEN=(WHEN=(8,2,CH,NE,C' '),
BUILD=(1,6,C'D')),
IFTHEN=(WHEN=NONE,
BUILD=(1,6))
SORT FIELDS=COPY
Based on second condition u will get output as
123 AD
234 B
watz ur output??? |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|