Page 1 of 2

Write the matched and unmatched record into files

PostPosted: Thu Aug 02, 2012 1:01 pm
by jvinoth
Hi,
I have two Input files.

Input file:1
------------
Record length:65,FB

Input file:2
-------------
Record length:469,FB

I need to compare the first file field(1,15) with the second file field(1,15).
if it matches then need to write the matched record of the Inputfile1 to the matched outputfile.
if it not matches with the second file then write the unmatched record of the inputfile1 to the unmathced outputfile.

please tell me how to do this using sort(joinkeys).
Input file:1
-------------
111111111111111
333333333333333
555555555555555
777777777777777
888888888888888

Input file:2
-------------
2222222222222  aaaa  gggg
1111111111111  trrd  hdgf
8888888888888  hrrr  reds
9999999999999  jgtf  fdes
5555555555555  iuyt  wesd

Mathced outputfile
------------------
1111111111111
5555555555555
8888888888888

Unmatched outputfile
--------------------
3333333333333
7777777777777

Thank you so much

Re: Write the matched and unmatched record into files

PostPosted: Thu Aug 02, 2012 5:21 pm
by jvinoth
I have used the below syntax and i'm getting both the paired and unpaired records of the inputfile1.
SORT FIELDS=COPY                   
JOINKEYS FILES=F1,FIELDS=(1,15,A)   
JOINKEYS FILES=F2,FIELDS=(1,15,A)   
JOIN UNPAIRED,F1                   
REFORMAT FIELDS=(F1:1,65)           

please tell me how to write seperately as paired record in onefile and unpaired record into aother file.


Thank you so much.

Re: Write the matched and unmatched record into files

PostPosted: Thu Aug 02, 2012 7:33 pm
by dick scherrer
Hello,

You now have 2 topics on this question. Will there be more? Which should we delete?

For starters, remove the SORT FIELDS=COPY

d

Re: Write the matched and unmatched record into files

PostPosted: Thu Aug 02, 2012 8:57 pm
by jvinoth
how can i get the matched record then.
remove another post sorry for same post in another form.

Re: Write the matched and unmatched record into files

PostPosted: Thu Aug 02, 2012 9:52 pm
by skolusu
jvinoth wrote:how can i get the matched record then. remove another post sorry for same post in another form


From your earlier posts , it is aware that you are running syncsort and I am not sure as to why you keep posting syncsort questions in DFSORT forum. You cannot use DFSORT control cards for syncsort. Please post your questions in syncsort forum.

Re: Write the matched and unmatched record into files

PostPosted: Thu Aug 02, 2012 11:28 pm
by dick scherrer
Hello,

My bad - i should have remembered that jvinoth uses Syncsort . . . . I'll try to do better ;)

how can i get the matched record then.
Why would issuing a COPY first have anything to do with joining 2 files by their "key"?

Suggest you look in this part of the forum for other JOIN examples. Or review the material kin the Syncsort documentation.

Did you try moving the COPY or did you just assume that would not work/help?

Edited for correctness/clarification

Re: Write the matched and unmatched record into files

PostPosted: Fri Aug 03, 2012 12:25 am
by Alissa Margulies
The sort control statement is required. Try the following Syncsort step:
//STEP1  EXEC PGM=SORT                     
//SORTJNF1 DD *                           
1111111111111                             
3333333333333                             
5555555555555                             
7777777777777                             
8888888888888                             
//SORTJNF2 DD *                           
2222222222222  AAAA  GGGG                 
1111111111111  TRRD  HDGF                 
8888888888888  HRRR  REDS                 
9999999999999  JGTF  FDES                 
5555555555555  IUYT  WESD                 
//SORTOF01 DD DSN=MATCHED.RECORDS,DISP=...
//SORTOF02 DD DSN=UNMATCHD.RECORDS,DISP=...
//SYSOUT   DD SYSOUT=*                     
//SYSIN    DD *                             
  JOINKEYS FILE=F1,FIELDS=(1,15,A)       
  JOINKEYS FILE=F2,FIELDS=(1,15,A)       
  JOIN UNPAIRED,F1                       
  REFORMAT FIELDS=(F1:1,65,F2:1,1)       
  SORT FIELDS=COPY                       
  OUTFIL FILES=01,INCLUDE=(66,1,CH,NE,X'40'),BUILD=(1,65)
  OUTFIL FILES=02,INCLUDE=(66,1,CH,EQ,X'40'),BUILD=(1,65)
/*

I believe this should produce the desired output.

Re: Write the matched and unmatched record into files

PostPosted: Fri Aug 03, 2012 11:35 am
by jvinoth
Thank you so mcuh alissa..

Re: Write the matched and unmatched record into files

PostPosted: Fri Aug 03, 2012 12:20 pm
by jvinoth
Please clarify mu doubt alissa.. why we are moving F2:1,1 in reformat field...

Re: Write the matched and unmatched record into files

PostPosted: Fri Aug 03, 2012 12:46 pm
by BillyBoyo
You need something from the F2 record to tell you whether it is "there" or not.

If there is an unmatched F1, the F2 will be set to a "fill" value of all spaces.

If there is a match the F2 will contain data. If your F2,1,1 might genuinely contain space, you can set the FILL to a different value (like X'FF') which the field cannot contain.