Page 1 of 1

SORT 2 files with different record length

PostPosted: Mon Oct 20, 2014 8:09 pm
by shankar_dh
Hi,

I have 2 files with different record length (both are FB)
File 1 -- LRECL 100
File 2 -- LRECL 80

Can we sort (using IBM SORT utility) these 2 files and write out put to File 3 of record length 80.

I know the solution of 2 steps where
Step 1 --> Convert File 1 to record length 80
Step 2 --> SORT it in regular way.

But, Is there any way to achieve it in only one step avoid multiple reads?
Because I have millions of records in File 1 and Step1 will be only to reduce records from 100 to 80 and again need to read the million of records in step 2 to sort.

I want to use the below control card but its not holds good if the 2 files are of different length.

SUM FIELDS=(NONE)
SORT FIELDS=(1,10,CH,A)
OUTREC FIELDS=(1:1,80)

Re: SORT 2 files with different record length

PostPosted: Mon Oct 20, 2014 8:18 pm
by BillyBoyo
Are File 1 and File 2 in sequence already?

You mention "millions". Is that on both files, or what?

Re: SORT 2 files with different record length

PostPosted: Mon Oct 20, 2014 8:27 pm
by shankar_dh
Thanks Billiboyo for the quick response.

Both are not in sorted order.
Only File 1 has millions of records.

I need to merge both files in to File 3 in sorted order.

Re: SORT 2 files with different record length

PostPosted: Mon Oct 20, 2014 9:32 pm
by BillyBoyo
Since you can't, generally, concatenate two FB of different LRECL, I think you have three approaches.

Firstly, is the two-step that you have. Cut the File 1 down to 80, then concatenate and SORT in the second step.

Secondly, there is ICETOOL, which can give you one step, but you will still have two passes of File 1 (which is what you want to avoid).

Thirdly, JOINKEYS.

The JOINKEYS would be straightforward if you have no duplicate keys.

So, the next question is whether you have duplicate keys. Internally on File 1? Internally on File 2? Between File 1 and File 2? Some combination of these.

Re: SORT 2 files with different record length

PostPosted: Tue Oct 21, 2014 4:39 pm
by shankar_dh
Yes, I have duplicates.
I think, I would need to go with either option 1 or 2.
Thanks for your time and suggestion.

Re: SORT 2 files with different record length

PostPosted: Tue Oct 21, 2014 5:25 pm
by BillyBoyo
You didn't describe the types of duplicates as per my question.

The JOINKEYS may still be the most efficient. If the job is a once-off, use number 1. If a regular job, compare timings to the JOINKEYS, It does mean coding it out, but we can assist if necessary.