Page 1 of 1

How to join two files

PostPosted: Fri Sep 03, 2010 5:27 pm
by Carlo
Hi
I would appreciate it if someone can tell me if the following can be done with DFSORT:

I have two files:
File1
AAA11111
AAA22222
AAA33333
BBB22222
BBB44444

File2
AAAMMM
AAANNN
BBBOOO
BBBPPP
(The last three characters in File2 are unique.)

I need a join between the two files that will produce the following:
File3:
AAA11111MMM
AAA22222MMM
AAA33333MMM
AAA11111NNN
AAA22222NNN
AAA33333NNN
BBB22222OOO
BBB44444OOO
BBB22222PPP
BBB44444PPP

Each record in File2 is 'expanded' via the first three characters with the corresponding records in File1. The resultant file has 10 records (2x3 + 2x2).

I would appreciate any help/advice with this query.

Thanks
Carlo

Re: How to join two files

PostPosted: Fri Sep 03, 2010 5:37 pm
by Carlo
BTW - I tried to download the following manual but the web address does not seem valid:

ftp://ftp.software.ibm.com/storage/dfso ... rtugpg.pdf

Does someone have an alternative address I can try?

Thanks
Carlo

Re: How to join two files

PostPosted: Fri Sep 03, 2010 5:43 pm
by MrSpock
Carlo wrote:BTW - I tried to download the following manual but the web address does not seem valid:

ftp://ftp.software.ibm.com/storage/dfso ... rtugpg.pdf

Does someone have an alternative address I can try?

Thanks
Carlo


I don't know. Works OK for me.

Re: How to join two files

PostPosted: Fri Sep 03, 2010 7:46 pm
by Carlo
Hi MrSpock
Thanks - I think it was the company firewall that blocked me. I managed to get to the manual when I linked via my home network.

I hope someone has done this type of join before and can give me a couple of pointers.

Regards
Carlo

Re: How to join two files

PostPosted: Fri Sep 03, 2010 10:57 pm
by Frank Yaeger
Here's a DFSORT JOINKEYS job that will do what you asked for.

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//IN1 DD *
AAA11111
AAA22222
AAA33333
BBB22222
BBB44444
/*
//IN2 DD *
AAAMMM
AAANNN
BBBOOO
BBBPPP
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  JOINKEYS F1=IN2,FIELDS=(1,3,A),SORTED
  JOINKEYS F2=IN1,FIELDS=(1,3,A),SORTED
  REFORMAT FIELDS=(F2:1,6,F1:4,5)
  OPTION COPY
/*

Re: How to join two files

PostPosted: Sat Sep 04, 2010 12:15 am
by Carlo
Hi Frank Yeager
Your prompt feedback is much appreciated - I will give it a try.
Carlo