Page 1 of 1

Joinkey without SORTING

PostPosted: Mon Jun 30, 2014 3:59 pm
by rockstar2020
I am looking for solution to my requirement any help would be appreciated.

FIle 1 -
ALEX A 55000
BOB  B 25000
JOHN A 45000
MECH C 12000
ZETA D 11000


File -2
MECH WWWWWW
ZETA XXXXXX
BOB  EEEEEE
ALEX RRRRRR


Required O/P FILE-
MECH WWWWWW 12000
ZETA XXXXXX 11000
BOB  EEEEEE 25000
ALEX RRRRRR 55000


Code -
//SYSIN DD *                                 
  JOINKEYS FILE=F1,FIELDS=(1,4,A)             
  JOINKEYS FILE=F2,FIELDS=(1,4,A)             
  JOIN UNPAIRED,F2                           
  REFORMAT FIELDS=(F1:1,4,x,F2:13,6)
  OPTION COPY                                 
    OUTFIL FILES=01                           
/*   


Problem I am facing is the o/p gets sorted out of FILE 2 and am getting o/p as below.
ALEX RRRRRR 55000
BOB  EEEEEE 25000
MECH WWWWWW 12000
ZETA XXXXXX 11000


I dont want to sort FILE 2 and instead i just want to join and produce an o/p file without sorting from FILE 2 and looking for o/p as shown in REQUIRED o/p code. Thank you.

Re: Joinkey without SORTING

PostPosted: Mon Jun 30, 2014 5:02 pm
by BillyBoyo
If file 1 is already in sequence, specify SORT,NOSEQCK on the JOINKEYS statement for file 1.

To get the result back into the file 2 sequence, you will need to SORT it (again, it will be sorted for the JOINKEYS).

In JNF2CNTL, append a sequence number (use INCREC OVERLAY or INREC BUILD depending on whether fixed- or variable-length records.

Then in the main task (so after everything for the join in SYSIN) SORT on the sequence number, then OUTREC BUILD to drop off the sequence number.