Page 1 of 1

conditional look up the key of a file into another

PostPosted: Thu Jan 15, 2015 12:58 pm
by manu4216
Hi.

I'm trying to do this by JCL rather than a program. Do you think is possible? I tryied a sort with joinkeys but not sure if I can include a condition between the 2 files.

Input:
File1: Key date1
File2: Key date2 date3
I need to find the records of File2 with a corresponding record in File1 and the condition: date2 < date1 < date3

Any answer would be appreciated.

Re: conditional look up the key of a file into another

PostPosted: Thu Jan 15, 2015 5:20 pm
by NicC
I'm trying to do this by JCL rather than a program. Do you think is possible?


No - you still need a program - even if it is DFSort. DFSort is not JCL. Nor are the control cards used by DFSort - they are DFSort control cards.

Having gotten the terminology lesson out of the way I will leave it to the sort gurus to set you on the right path - although it may help them if you post the control records that you did try.

Re: conditional look up the key of a file into another

PostPosted: Thu Jan 15, 2015 6:04 pm
by BillyBoyo
Yes, it can be done quite simply. As NicC has said, we need to see what you have tried, to know how best to help.

Re: conditional look up the key of a file into another

PostPosted: Thu Jan 15, 2015 7:02 pm
by manu4216
I used joinkeys to match the records that are in both files and generate File3. But I don't know where and how to include a condition.

joinkeys F1=File1,fields=(1,14,A)
joinkeys F2=File2,fields=(1,14,A)
Join unpaired,F1,F2
Reformat fields=(?,F1:1,100,F2:1,100)
Option copy
Outfil fnames=File3,include=(1,1,CH,EQ,C'B'),BUILD=(1:2,100)


Code'd

Re: conditional look up the key of a file into another

PostPosted: Thu Jan 15, 2015 8:19 pm
by BillyBoyo
It is always best to highlight and copy in your emulator and then paste here, within the Code tags. Re-typing can introduce errors.

If you only want matches, remove the JOIN statement, as matched-records only is the default. You then don't need the matched-marker (the ?). And then you change your INCLUDE= on OUTFIL to do the selection.

Is your data originally already in sequence? You are sorting both the files. If you don't need this you can specify SORTED,NOSEQCK on the JOINKEYS for any data which is already in sequence.

In a JNFnCNTL file, you can reduce the amount of data which is to be processed by doing an INCLUDE for DATE2 less than DATE3.

Re: conditional look up the key of a file into another

PostPosted: Fri Jan 16, 2015 12:01 pm
by manu4216
Ok thanks for the match part tips.

Now the second part: how do I add the condition between the dates?

Re: conditional look up the key of a file into another

PostPosted: Fri Jan 16, 2015 1:22 pm
by BillyBoyo
With INCLUDE=, as I wrote:

 OUTFIL INCLUDE=(date2,LT,date1,AND,date1,LT,date3)


Where daten in the above is the start,length,CH of each of your dates on the REFORMAT record. Even better, use symbols/SYMANES and you can call them date1, date2, date3, or something even more meaningful.

Re: conditional look up the key of a file into another

PostPosted: Sat Jan 17, 2015 2:23 pm
by manu4216
Ok I think I understand. So you add the condition on the REFORMAT record, which contains all the data: key, date1, date2, date3.

Too bad I already did it in Cobol. I only used SORT to match the 2 files by the key, but without condition.