Page 1 of 1

Join two files, replacing file1 values with file2 values

PostPosted: Fri Oct 25, 2013 10:18 pm
by krunalbaf
Hi Team,
I have two files:
File-1 of length - 260 (key at 209,16)
File-2 of length - 27 (Key at 12,16)
I need to match the files and write the output into a file of length 260 having values copied from file-1 with change:
Position 209 of output file - should have record from file-2 postiion (1,11)
Position 220 of output file - should have 5 spaces
Position 225 of output file - should have record from file-2 postiion (1,11)
Position 236 of output file - should have 5 spaces
Position 241 of output file - should have record from file-2 postiion (12,16)

can you please help how can I have the records in the output file.

Regards,
Krunal Bafna

Re: Join two files, replacing file1 values with file2 values

PostPosted: Sat Oct 26, 2013 5:38 pm
by NicC
Is that 12 for 16 (16 bytes) or from 12 to 16 (5 bytes)?

Re: Join two files, replacing file1 values with file2 values

PostPosted: Mon Oct 28, 2013 12:53 am
by dick scherrer
Hello and welcome to the forum,

Questions like this are better done with some sample input and output that show what you want to do.

These do not need to be full-size records, but enough to show how your rules will change the data. For what you want, you could use samples of less than 80 bytes.

Re: Join two files, replacing file1 values with file2 values

PostPosted: Mon Oct 28, 2013 1:05 am
by BillyBoyo
As well as what Dick has suggested, you need to confirm that your output will only be for matches on the key.

If this is so, you need to find a JOINKEYS example. If it has a JOIN, remove it (so you only get matches). You need a REFORMAT statement. You can include on that, in the order which you require for output, all the F1 pieces of data, intermingled with the F2 pieces of data. That should nearly do it. Where you need the blanks, just include five bytes from F1 or F2. It doesn't matter what they are, as you will make them blank.

You make them blank in the "Main Task", after the JOINKEYS statements and the REFORMAT.

Use INREC OVERLAY=(pos1,5,C' ',pos2,5,C' ') or however many you want.

Have a go, and let us know if you encounter problems. Show us what you have if you get it working, and we can check it over.