Page 1 of 1

Merge 2 Files.

PostPosted: Sat May 02, 2015 12:34 am
by Vineet
Hi All,

I have 2 Sequential Files (File A, File B) both files have LRECL = 131, RECFM = FB. I want to merge both the Files based on 4 Key Fields. In Both the Files Key Fields are @ different Positions so not sure how to Merge. Below is Example.

File A
Date : 41,10,CH,A
Store : 31,9,CH,A
Item : 11,14,CH,A
Indicatore : 26,4,CH,A

File B
Date : 21,10,CH,A
Store : 41,9,CH,A
Item : 31,14,CH,A
Indicatore : 36,4,CH,A

How can I merge both the Files using SORT.

Thanks
Kind Rgd's

Vineet Anand

Re: Merge 2 Files.

PostPosted: Sat May 02, 2015 12:43 am
by BillyBoyo
Are the keys unique? Within each file and between the files? Is there anything on each record which would indicate which file they came from?

Re: Merge 2 Files.

PostPosted: Sun May 03, 2015 9:11 pm
by Vineet
These are the Unique Keys in both the Files & using these keys only we need to write the Record to the O/P file. O/P having attribute LRECL = 131, RECFM=FB.

Thanks

Re: Merge 2 Files.

PostPosted: Mon May 04, 2015 6:32 pm
by BillyBoyo
If you can't identify which record comes from which file, you can't use MERGE, as the same key would be needed, and you'd not know how to get the correct data into the key for both files.

So, use JOINKEYS. Specify SORTED,NOSEQCK on the JOINKEYS statements. I'd suggest putting something on your output so you could be certain which record is of which type, otherwise you'll just have scrambled your data.