Page 1 of 2

Logic using joinkeys sort

PostPosted: Tue May 28, 2013 3:24 pm
by jvinoth
Hi,

Can anyone suggest me can we do do the below logic using joinkeys sort.

I have two files.

File 1:
-------
Length:60 FB

EX:

1111111222222212375678911AAAAA    BBBBBB           AABB1000
1111111222222212375678911AAAAA    BBBBBB           AABB1000
1111111222222212375678912AAAAA    BBBBBB           AABB1000
1111111222222212375678914AAAAA    BBBBBB           AABB1000


FILE 2:
------
Length:87 FB

EX:

14972709912375678911014.980ISAACS                        KENNETH
57986877891023469889012.700HALL                          LAJUAN
21717631812375678914021.240BISCH                         ANDRE 
57553704391023476689019.100CABANA                        BOWMAN



EXPECTED OUPUT FILE 1:
----------------------

1111111|2222222|AABB1000|ISAACS|12375678911
1111111|2222222|AABB1000|BISCH |12375678914


EXPECTED OUTPUT FILE 2:
-----------------------

1111111|2222222|12375678911|AABB1000|014.980
1111111|2222222|12375678914|AABB1000|021.240


Key comparing in both files are 12375678911,12375678914(file 1--position (15,11) & file 2 --(10,11))

if the keys matched in both records then need to write two files with some records from file 1 & file 2.

Re: JOINKEYS

PostPosted: Tue May 28, 2013 11:56 pm
by dick scherrer
Hello,

Suggest you use the Code tag when posting this kind of info.

You might have gotten replies sooner.

What have you done so far? Post your sort control and JCL.

Re: JOINKEYS

PostPosted: Wed May 29, 2013 11:08 am
by jvinoth
Thanks Dick,

I need to know whether we can use the two reformats in a single sort card.

Re: JOINKEYS

PostPosted: Wed May 29, 2013 5:11 pm
by bodatrinadh
Hi Vinoth,

Can anyone suggest me can we do do the below logic using joinkeys sort.


Your task can be acheived in Joinkeys...

I need to know whether we can use the two reformats in a single sort card.


No. Sort won't allow TWO reformats in a single sort card.

Re: JOINKEYS

PostPosted: Wed May 29, 2013 6:38 pm
by jvinoth
thanks,

So how can we create two files with the needed information from the file1 & file2. I think we can do this by using the reformat please correct me if I am wrong.

Re: JOINKEYS

PostPosted: Wed May 29, 2013 7:36 pm
by dick scherrer
Hello,

Consider using two OUTFIL FNAMES and BUILD statements. You can create multiple output files in one step.

Re: JOINKEYS

PostPosted: Thu May 30, 2013 5:29 pm
by jvinoth
Thanks Dick,

can you please provide sample code if possible.

Re: JOINKEYS

PostPosted: Thu May 30, 2013 5:32 pm
by jvinoth
SORT FIELDS=COPY
JOINKEYS FILES=F1,FIELDS=(14,11,A)
JOINKEYS FILES=F2,FIELDS=(10,11,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(
OUTFIL FILES=01,INCLUDE=(
OUTFIL FILES=02,INCLUDE=(

can tell me how to use the reformat in this case because i need to output files which has the records from file1 & file2.

Re: JOINKEYS

PostPosted: Thu May 30, 2013 10:20 pm
by bodatrinadh
Vinoth,

Try this code


//STEP01   EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SYSPRINT DD SYSOUT=*                                           
//SORTJNF1 DD *                                                 
1111111222222212375678911AAAAA    BBBBBB           AABB1000     
1111111222222212375678911AAAAA    BBBBBB           AABB1000     
1111111222222212375678912AAAAA    BBBBBB           AABB1000     
1111111222222212375678914AAAAA    BBBBBB           AABB1000     
//SORTJNF2 DD *                                                 
14972709912375678911014.980ISAACS                        KENNETH
57986877891023469889012.700HALL                          LAJUAN 
21717631812375678914021.240BISCH                         ANDRE   
57553704391023476689019.100CABANA                        BOWMAN 
//OUTPUT1  DD SYSOUT=*                                           
//OUTPUT2  DD SYSOUT=*                                           
//SYSIN    DD *                                                 
  JOINKEYS FILE=F1,FIELDS=(15,11,A)                             
  JOINKEYS FILE=F2,FIELDS=(10,11,A)                             
  REFORMAT FIELDS=(F1:1,80,F2:1,80)                             
  SORT FIELDS=(1,80,CH,A)                                       
  SUM FIELDS=NONE                                                     
  OUTFIL FNAMES=OUTPUT1,BUILD=(1,7,C'|',8,7,C'|',52,08,C'|',108,6,C'|',
                             15,11)                                 
  OUTFIL FNAMES=OUTPUT2,BUILD=(1,7,C'|',8,7,C'|',15,11,C'|',52,8,C'|',
                            101,7)                                   

Re: JOINKEYS

PostPosted: Thu May 30, 2013 10:40 pm
by bodatrinadh
Vinoth,

I didn't notice the input file attributes.Pls change according to your requirement.