MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Merge two files laterally
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
manojagrawal
Beginner


Joined: 25 Feb 2003
Posts: 124
Topics: 29

PostPosted: Tue Mar 04, 2003 4:53 am    Post subject: Reply with quote

Hi,

While going through this post of yours, i have come up with quite a few questions. I guess im not very clear on these and thus am getting confused.

1. Regarding the very first post, the code for the JCL given by you, how is the key matching done? Is it for sure that the input files File1 and File2 will have the keys in the same order and all keys will coresspond.

Code:
File1:
AAAAAAAABBBBBBBBBBCCCCCCDDDDDDEEEEEE
AAAAAAAAZZZZZZZZZZCCCCCCDDDDDDEEEEEE

File2:
AAAAAAAABBBBBBBBBBFFFFFFGGGGGGHHHHHH

What happens if these are the input files? What happens if the key is not the first 18 characters?


2. For the other approach that you linked too, I am unclear on that too. How are the CNTL fields specified. And how is the sum done? Also the Outrec format given in OUTFIL.


What if the keys for the 2 files are in separate locations? What if we have input files like this:

Code:
File1:
AAA1 BB1 CC1
AAA2 BB2 CC1
AAA3 BB3 CC2
AAA4 BB4 CC3

File2:
XXX1 CC1
XXX2 CC2
XXX3 CC3

Now, we want to merge the 2 files laterally, so that we get the output as:

Code:
Output:
AAA1 BB1 CC1 XXX1
AAA2 BB2 CC1 XXX1
AAA3 BB3 CC2 XXX2
AAA4 BB4 CC3 XXX3


Sorry for the long list of questions, but the answers here are great and as I am going through all these posts, I keep coming up with something. This place is really really helpful. Thanks!

Regards,
Manoj.
Back to top
View user's profile Send private message
manojagrawal
Beginner


Joined: 25 Feb 2003
Posts: 124
Topics: 29

PostPosted: Tue Mar 04, 2003 5:07 am    Post subject: Reply with quote

One more thing,

For the lengths of the input file, the first one lets take it to be exactly 10 and the second top be 100. (The spaces I showed in the I/P files are just for clarity)

Regards,
Manoj.
_________________
Thanks & Regards,
Manoj.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12402
Topics: 75
Location: San Jose

PostPosted: Tue Mar 04, 2003 7:05 am    Post subject: Reply with quote

manojagrawal,

Thanks for the goodwords about mvsforums. I am happy that you are finding this place quite helpful. Spread the word about mvsforums to your friends and co-workers.

Now coming to your questions.

Quote:

Regarding the very first post, the code for the JCL given by you, how is the key matching done? Is it for sure that the input files File1 and File2 will have the keys in the same order and all keys will coresspond.


NO they can be any order without duplicates. The final step any way sorts it on the key and with OPTION EQUALS ensures that we take the first record from the set of duplicates.

Quote:

For the other approach that you linked too, I am unclear on that too. How are the CNTL fields specified. And how is the sum done? Also the Outrec format given in OUTFIL.


I am just want to mention it again , all the above posted solutions will not work for duplicte keys.It works only if both the files are unique.so for sample data you showed this method of merging will not work.Even if the position of key fields is not the same, we will change the postions of the key fields to be in the position of file1.

Quote:

For the lengths of the input file, the first one lets take it to be exactly 10 and the second top be 100. (The spaces I showed in the I/P files are just for clarity)


If the input file lenghts are different, we make them equal by padding with binary zeroes.

About how cntl fields are specifed and summing is done.
Let us take this simple ex:

I have file1 with lrecl 20

Code:


ABCD 1234567890



now I have another file with LRECL 100

Code:

BLAH BLAH      BLAH BLAH     BLAH BLAH  ABCD   KOLUSU    BLAH BLAH   BLAH BLAH


Now I want to merge these files and have

Code:


ABCD 1234567890 KOLUSU


so basically I am adding 'kolusu' at the end of the file 1

now the control cards for file 1. since we want the entire file1 rec as is we will write it out and also pad with 6 binary zeroes for the word 'kolusu'

Code:

 OUTFIL FNAMES=T1,OUTREC=(1,20,   $ INPUT AS IS
                          6Z)     $ PAD WITH 6 BINARY ZEORES FOR SUMMING


from file2 all you need is the matching key and text kolusu from it.so you just copy them

Code:


 OUTFIL FNAMES=T2,OUTREC=(50,4,     $ KEY ABCD STARTS AT 50 FOR 4 BYTES
                          10Z,      $ PAD WITH 10 BINARY ZEORES FOR THE 2 FIELD IN FILE1
                          60,6)     $ THE TEXT KOLUSU FOR 6 BYTES


now both the files are of lrecl 26 and we can contatenate them together and do the sum on the bytes 21 thru 26.Since the sum fields are binary are you can sum them in chunks 2, 4 bytes.

Code:

 SORT FIELDS=(1,4,CH,A)       $ SORT ON KEY
 SUM FIELDS=(21,4,BI,         $ SUM SORT ON 21 THRU 24
             25,2,BI)         $ SUM SORT ON 25 THRU 26


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
manojagrawal
Beginner


Joined: 25 Feb 2003
Posts: 124
Topics: 29

PostPosted: Tue Mar 04, 2003 7:28 am    Post subject: Reply with quote

Hi Kolusu,

Yep! That did help clear quite a few things for me. But does that mean that what I mentioned CANNOT be done using JCL's? Would I have to go for a programmatical solution for that? I mean read through the first flat file records one at a time, find the corresponding key in the second file, and then merge the fields to a third output file?

Regards,
Manoj.
_________________
Thanks & Regards,
Manoj.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12402
Topics: 75
Location: San Jose

PostPosted: Tue Mar 04, 2003 8:13 am    Post subject: Reply with quote

manojagrawal,


If you are planning to merge a file with duplicates then syncsort is not an ideal product to do that. You still can do that using syncsort as long as there are few records in the file.ie..a max upto 2400 if the matching key is equal to 8 bytes.

But if you have easytrieve at your shop then it is very simple and it need not be a program. It can be a parm and you can use it in a jcl

Hope this helps...

cheers

kolusu

Last Edit: Made changes to the reflect syncsort


Last edited by kolusu on Tue Mar 04, 2003 11:58 am; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
manojagrawal
Beginner


Joined: 25 Feb 2003
Posts: 124
Topics: 29

PostPosted: Tue Mar 04, 2003 8:50 am    Post subject: Reply with quote

Hi Kolusu,

What my aim is to basically get what i mentioned above. If we take the first 7 bytes, you will notice that it is unique. In the second file, bytes 5-7 are unique. I want for each record in file1, i get the corresponding value from file2. Thus file 1 would have unique records if we consider the first 7 bytes (or the entire record) but I want the merge to be done on the last 3 bytes.

As far as easytrieve goes, I have no idea about it. Embarassed Could you please say something about it, or any link that would help. Thanks!!

Regards,
Manoj.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Mar 04, 2003 11:31 am    Post subject: Reply with quote

Manoj,

If you have DFSORT PTF UQ90053 (Feb, 2003) installed, you can use the new SPLICE operator of ICETOOL to do the lateral merge you asked about in 2. of your post above. For complete details on SPLICE, see:

http://www.storage.ibm.com/software/sort/mvs/uq90053/online/srtmutol.html#spl

To recap, you have:

Code:

Input File1
-----------
AAA1 BB1 CC1
AAA2 BB2 CC1
AAA3 BB3 CC2
AAA4 BB4 CC3

Input File2
-----------
XXX1 CC1
XXX2 CC2
XXX3 CC3

Output File1
------------
AAA1 BB1 CC1 XXX1
AAA2 BB2 CC1 XXX1
AAA3 BB3 CC2 XXX2
AAA4 BB4 CC3 XXX3


Here's the DFSORT/ICETOOL job for this:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//FILE2 DD *   FILE2
XXX1 CC1
XXX2 CC2
XXX3 CC3
/*
//TB DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CONCT DD DSN=*.TB,VOL=REF=*.TB,DISP=(OLD,PASS)
//      DD *   FILE1
AAA1 BB1 CC1
AAA2 BB2 CC1
AAA3 BB3 CC2
AAA4 BB4 CC3
/*
//OUT DD DSN=...  output file
//TOOLIN DD *
* Reformat File2 so it can be spliced with File1
COPY FROM(FILE2) TO(TB) USING(CTLB)
* Splice the records with matching keys
SPLICE FROM(CONCT) TO(OUT) ON(10,3,CH) WITHALL WITH(1,9)
/*
//CTLBCNTL DD *
  OUTREC FIELDS=(10:6,3,14:1,4,80:X)
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort


Last edited by Frank Yaeger on Wed Mar 19, 2003 4:41 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12402
Topics: 75
Location: San Jose

PostPosted: Tue Mar 04, 2003 12:02 pm    Post subject: Reply with quote

Frank,

I edited my post to reflect it to syncsort and took the liberty of deleting the later post made by you as it is no longer needed.

Wow I am really impressed by SPLICE operator Very Happy

Thanks for correcting me

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12402
Topics: 75
Location: San Jose

PostPosted: Tue Mar 04, 2003 12:08 pm    Post subject: Reply with quote

Manoj,

Take a look at the easytrieve solution posted by me in this thread.

http://www.mvsforums.com/helpboards/viewtopic.php?t=11

The main page of mvsforums has links to easytrieve manual.

http://www.mvsforums.com/

Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Mar 04, 2003 12:10 pm    Post subject: Reply with quote

Kolusu,

Fair enough.

Being able to impress you with SPLICE really makes my day. Very Happy
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
manojagrawal
Beginner


Joined: 25 Feb 2003
Posts: 124
Topics: 29

PostPosted: Wed Mar 05, 2003 2:48 am    Post subject: Reply with quote

Frank, Kolusu,

My Luck, but I think we dont have DFSORT PTF UQ90053 (Feb, 2003) installed, as it says INVALID OPERATOR for splice. Sad What would be the procedure to get it installed?

I think we dont have EASYTRIEVE too. Sad How can we find out whether we have it installed?

Does this mean, we go back to the first method, of a programmatical solution(I'm using PLI)? Thanks for all the suggestions.

Regards,
Manoj.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Mar 05, 2003 11:13 am    Post subject: Reply with quote

Manoj,

If you have DFSORT R14, then your System Programmers can install DFSORT R14 PTF UQ90053 (it's free). Tell them you want it to improve your productivity. Smile
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sandipan
Beginner


Joined: 10 Jul 2003
Posts: 1
Topics: 0

PostPosted: Thu Jul 10, 2003 12:59 am    Post subject: Reply with quote

Hi all,
I am trying to run the jcl but somehow I am getting the following error every time. It seems like the SEQNUM is not being recognised.

Code:

ICE601I 0 DFSORT ICETOOL UTILITY RUN ENDED - RETURN CODE:  16                 
ICE200I 0 IDENTIFIER FROM CALLING PROGRAM IS 0001                             
ICE143I 0 BLOCKSET     COPY  TECHNIQUE SELECTED                               
ICE000I 0 - CONTROL STATEMENTS FOR 5740-SM1, DFSORT REL 14.0 - 00:41 ON THU JU
             OUTFIL FNAMES=T1,OUTREC=(1:1,5,6:6Z,12:SEQNUM,8,PD)             
                                                    $                         
ICE007A 1 SYNTAX ERROR                                                       
ICE146I 0 END OF STATEMENTS FROM CTL1CNTL - PARAMETER LIST STATEMENTS FOLLOW 
          DEBUG NOABEND,ESTAE                                                 
          OPTION LIST,MSGPRT=ALL,MSGDDN=DFSMSG,RESINV=0,SORTDD=CTL1,SORTIN=IN1


The $ sign is coming just below S of SEQNUM.
Can anyone please suggest a possible solution to this?
Thanks,
Sandipan
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Jul 10, 2003 10:33 am    Post subject: Reply with quote

Sandipan,

Your DFSORT level is very old! The SEQNUM parameter was introduced with DFSORT R14 PTF UQ99323 way back in July, 2000. The syntax error for SEQNUM indicates that you do NOT have this functional PTF or any of the subsequent functional PTFs (UQ99331-March, 2002, UQ90053-Feb, 2003) installed. So you can't use any of the DFSORT/ICETOOL function available with those PTFs.

Ask your System Programmer to install DFSORT R14 PTF UQ90053 (Feb, 2003). That will bring you up to the current functional level for DFSORT/ICETOOL.

You can see all of the functions available with the July, 2000 and follow-on PTFs at:

http://www.storage.ibm.com/software/sort/mvs/summary_changes/srtmsocc.html

Your site is paying for these functions (it's part of the basic DFSORT R14 license), so you should be able to take advantage of them.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vivek
Beginner


Joined: 15 Jul 2004
Posts: 95
Topics: 11
Location: Edison,NJ

PostPosted: Wed Oct 06, 2004 9:36 am    Post subject: Reply with quote

i HAVE 3 FILES. i HAVE A COMMON KEY FROM COLUMN 1-13 ON ALL THE THREE FILES. HOW DO I USE SYNCTOOL FOR THIS ?

FILE1
ATLFJ00001004 ADDR1-ADDR3-ADDR4
ATLFJ00001304 ADDR2-ADDR5-ADDR6
ATLFJ00002404 ADDR3-ADDR7-ADDR8

FILE 2
ATLFJ00001004 CITY1-CITY4-CITY7
ATLFJ00001304 CITY2-CITY5-CITY8
ATLFJ00002404 CITY3-CITY6-CITY9

FILE 3
ATLFJ00001004 NAME1-NAME4-NAME7
ATLFJ00001304 NAME2-NAME5-NAME8
ATLFJ00002404 NAME3-NAME6-NAME9

OUTPUT
ATLFJ00001004 ADDR1-ADDR3-ADDR4CITY1-CITY4-CITY7NAME1-NAME4-NAME7
ATLFJ00001304 ADDR2-ADDR5-ADDR6CITY2-CITY5-CITY8NAME2-NAME5-NAME8
ATLFJ00002404 ADDR3-ADDR7-ADDR8CITY3-CITY6-CITY9NAME3-NAME6-NAME9
_________________
Vivek,NJ

Db2,IDMS
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Goto page Previous  1, 2, 3, 4  Next
Page 2 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group