IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Join different parts of 2 files into a single file


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rocky_balboa

New User


Joined: 24 Mar 2010
Posts: 61
Location: Cape of Good Hope

PostPosted: Wed Apr 21, 2010 10:19 pm
Reply with quote

Hi

I have the following two files. The two files are of different record lengths.

FILE 1
----------------
12 key1 data1
14 key2 data2
18 key3 data3

FILE 2
----------------
key1 dataa
key2 datab
key3 datac

How do I get file 3 in the following format?

FILE 2
----------------
key1 dataa 12
key2 datab 14
key3 datac 18

Thanks
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Wed Apr 21, 2010 10:37 pm
Reply with quote

Please provide the RECFM and LRECL for each input file? Could there can be duplicates in file1 and/or file2? Also if possible, give us position for each field .

Let us know your DFSort PTF level...if you are unsure please submit below job and send us informational messages.

Code:
//SORTSTEP EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
ABC
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  SORT     FIELDS=COPY
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Apr 21, 2010 10:39 pm
Reply with quote

Hello Rocky and welcome to the forum.

your post is in the DFSORT forum, as such we assume your sort product is DFSORT.

Please refer to Franks post about determining your PTF levels and provide the info.

record format, record length is helpful information.

the field positions are also handy.

as well as a brief explanation of what you want.
though your example is reasonably understandable,
your not having used BBCode it is very difficult to guess the offsets.

an example of an explanation is:

[START EXPLANATION]
I have a common key field in two files:
file 1, 80 byte Fixed key is in position 800 - 840 and is 13 char long
File 2, 120 byte fixed key is in position 776 - 875 and is 13 char long.

I want to join the two files, based on key match,
and the output file should consist of:
field 1 from file 1, positions 7 - 18, in output file position 1 -12
key from either file, in output position 19 - 28
field 3 from file 2, positions 87 -99 in output file position 35 - 99

output file should be 11 bytes Fixed.
[END EXPLANATION]
Back to top
View user's profile Send private message
rocky_balboa

New User


Joined: 24 Mar 2010
Posts: 61
Location: Cape of Good Hope

PostPosted: Thu Apr 22, 2010 7:46 pm
Reply with quote

Thanks..

I use SYNCSORT(RELEASE 1.3 BATCH 0494 TPF LEVEL 2.0).

The FILE1 is of record length 100 . Key is in position 4-7(fixed key position)- No duplicates in this file.

The FILE2 is of record length 80 . Key is in position 1-4(fixed key position)- No duplicates in this file.

I want to join the two files with o/p file containing all the data(1-78) in FILE2 with the last two positions having data from the first two positions of FILE1. Record length of o/p is 80.The o/p file should contain only those records from FILE2 which has match is found in FILE1(based on the key). The rest of the records from FILE2 should be in a different file.
Back to top
View user's profile Send private message
rocky_balboa

New User


Joined: 24 Mar 2010
Posts: 61
Location: Cape of Good Hope

PostPosted: Thu Apr 22, 2010 7:50 pm
Reply with quote

Sorry I forgot to mention that all the data type is alphanumeric.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Apr 22, 2010 8:55 pm
Reply with quote

The Syncsort Manual wrote:
The join facility of SyncSort for z/OS provides the capability to join records from two source files. Each record from the first file with a given value in one or more fields (the join key) is joined to each record from the second file that has an identical value in its join key. The joined records are passed to the sort/copy process. The power of this facility is enhanced by the ability to eliminate records from either or both files and to control the disposition of paired and unpaired records resulting from the join operation.
Try it, you'll like it.....
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Sat Apr 24, 2010 3:08 am
Reply with quote

Rocky,

While I fully encourage reading the manual and first trying it out on your own, you seem to be relatively new to the forums, so here is a solution you can try:
Code:
//SORT1  EXEC PGM=SORT             
//SORTJNF1 DD *                   
12 KEY1 DATA1                     
14 KEY2 DATA2                     
18 KEY3 DATA3                     
//SORTJNF2 DD *                   
KEY1 DATAA                         
KEY2 DATAB                         
KEY3 DATAC                         
//SORTOUT DD SYSOUT=*             
//SYSOUT  DD SYSOUT=*             
//SYSIN   DD *                     
   JOINKEYS FILES=F1,FIELDS=(4,4,A)
   JOINKEYS FILES=F2,FIELDS=(1,4,A)
   REFORMAT FIELDS=(F2:1,11,F1:1,2)
   SORT FIELDS=COPY               
/*                                 
Back to top
View user's profile Send private message
rocky_balboa

New User


Joined: 24 Mar 2010
Posts: 61
Location: Cape of Good Hope

PostPosted: Wed May 12, 2010 6:47 pm
Reply with quote

Thanks Alissa

Sorry for replying late....Actually I solved my problem using ICETOOL..... after 'CICS Guy' post and did not check for any updates....

Earlier I was working with DFSORT but in the new environment it's SYNCSORT...

It's nice to know an alternative way!!!!!
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed May 12, 2010 11:29 pm
Reply with quote

Quote:
It's nice to know an alternative way!!!!!


For the record, you had that alternate way in DFSORT too which also supports JOINKEYS.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 4
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top