I want to keep all the data of file 1 in the result and only 1 field from file 2.
I have been trying following code to try it out, but its not working. I am getting an empty file when I dont try to normalize the keys. I get an error when I try to normalize the keys (because one of the keys is actually a CH type, I am getting syntax error on the conversion to ZDF or ZDC for that matter).
I have been trying following code to try it out, but its not working. I am getting an empty file when I dont try to normalize the keys. I get an error when I try to normalize the keys (because one of the keys is actually a CH type, I am getting syntax error on the conversion to ZDF or ZDC for that matter).
Based on SYMNAMES, if keys in both the files are in same format(CH or ZD), why would you need to convert them? Are you saying you need to convert them for matching?
Based on the test data you provided, I don't see any records matching on key fields from both the files.
I was converting them because the documentation for JOINKEYS say -
Quote:
The keys will be treated as binary, so they must be "normalized". For example, if the keys are actually zoned decimal, they must have all C and D signs, or all F and D signs. You can use an INREC statement in JNF1CNTL and/or JNF2CNTL to normalize the keys for the F1 file and/or F2 file, respectively, if appropriate.
Also, I am putting some matching records from file 2 here for reference:
I tried that, it does match the records, but then in the output my CH fields are messed-up. like.. ' XXXXXXXXXX' becomes '00000XXXXXXXXXX'. I dont want these zeroes appended at the start of my CH field.
Also, I was wondering if there is way in the same step for me to change the first key in file 1 to be changed in the resulting output from 001 to abc or 002 to xyz like that.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
I'd try to help you more but I really don't understand the form of your "CH" values. For example, you show:
Code:
00930669A
444444FFFFFFFFC
000000009306691
This is a very strange number as it appears to have leading blanks instead of leading zeros, and a C sign instead of an F sign for plus. If this is actually equivalent to 0009306691, then it must be normalized. If it is just 00930669A, then it doesn't have to be normalized.
JOINKEYS uses binary keys. If your CH keys all use the same conventions, then you don't have to normalize (that is, convert) the keys and the output will look the same as the input. But you said that using the keys without normalizing doesn't give you what you want. So you need to normalize the keys for JOINKEYS. If you want the output to look the same as the input, then you have to convert the normalized keys back to the form you want (or save the keys and restore them). You can use INREC, OUTREC or OUTFIL in SYSIN to change the fields any way you like after you've joined the records with REFORMAT.
Quote:
Also, I was wondering if there is way in the same step for me to change the first key in file 1 to be changed in the resulting output from 001 to abc or 002 to xyz like that.
You can do that with DFSORT's IFTHEN or CHANGE function. You'd have to be more specific about what you want to do exactly for me to show you how to do it.
Thanks for your help. I actually followed your advice and converted the other 2 keys to ZDF and left the Alphanumeric key as it is.. That did the trick.
Thanks a lot for everyone's help. This was my first post and sorry if I wasn't clear about my questions. Will try to articulate it better next time. Thanks!
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Ok.
It appears that your ZD keys are already normalized (they all have F for the plus sign), so you really don't need to convert them either.
Just FYI, if you wanted to convert the keys for JOINKEYS but keep them the same for output, you could save and restore them like this (I assumed your input file had RECFM=FB and LRECL=100):