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 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
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Nov 28, 2002 12:10 pm    Post subject: Merge two files laterally Reply with quote

I have two files.

Code:

File1:
AAAAAAAABBBBBBBBBBCCCCCCDDDDDDEEEEEE

File2:
AAAAAAAABBBBBBBBBBFFFFFFGGGGGGHHHHHH


Required output:

Code:
 
AAAAAAAABBBBBBBBBBCCCCCCDDDDDDEEEEEEFFFFFFGGGGGGHHHHHH



Solution:

The following DFSORT/ICETOOL JCL will give you the desired results.As per the example all the fields in both files are 6 bytes length.A brief explanation of the job.

The first copy operator takes in the file1 and reformats it using outrec. we copy the first 36 bytes as is and after that we add 18 binary zeroes for the fields of file2.After that we pad the rest of the bytes with spaces( assuming that your input files is 80 bytes in length).We also add a sequence number at the end.

The second copy operator takes in the file2 and reformats it using outrec.The first 36 bytes will be padded with binary zeroes and after that we copy 3 fields ( f,g,h) and also make it 80 bytes. we also add the sequence number at the end.

Now the final sort takes in these 2 temp files and sort it on the seqnum and summing the fields from 36 to 54 bytes there by achieving the desired results.We also strip off the seqnum while writting the out.


Code:

//STEP0100 EXEC PGM=ICETOOL                               
//*                                                       
//TOOLMSG  DD SYSOUT=*                                     
//DFSMSG   DD SYSOUT=*                                     
//IN1      DD *                                           
AAAAAAAABBBBBBBBBBCCCCCCDDDDDDEEEEEE
//IN2      DD *                                           
AAAAAAAABBBBBBBBBBFFFFFFGGGGGGHHHHHH
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE) 
//T2       DD DSN=&T2,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE) 
//CON      DD DSN=&T1,DISP=(OLD,PASS),VOL=REF=*.T1         
//         DD DSN=&T2,DISP=(OLD,PASS),VOL=REF=*.T2         
//OUT      DD DSN=YOUR OUTPUT FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(TRK,(1,1),RLSE)
//TOOLIN   DD *                                     
   COPY FROM(IN1) USING(CTL1)                         
   COPY FROM(IN2) USING(CTL2)                         
   SORT FROM(CON) USING(CTL3)                         
//CTL1CNTL DD *                                     
   OUTFIL FNAMES=T1,OUTREC=(1,36,18Z,80:X,SEQNUM,8,ZD)
//CTL2CNTL DD *                                     
   OUTFIL FNAMES=T2,OUTREC=(36Z,19,18,80:X,SEQNUM,8,ZD)
//CTL3CNTL DD *                                     
   OPTION EQUALS                                       
   SORT FIELDS=(81,8,ZD,A)                             
   SUM FIELDS=(37,8,45,8,53,2),FORMAT=BI               
   OUTFIL FNAMES=OUT,OUTREC=(1,80)                     
/*                                                   


For another approach, see the "Join fields from two files on a key" Smart DFSORT Trick at:

http://www.ibm.com/servers/storage/support/software/sort/mvs/tricks/
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Tue Dec 17, 2002 7:41 am    Post subject: Reply with quote

Kolusu,
I think there is a flaw in the CTL1CNTL and CTL2CNTL DD statements.
Quote:

After that we pad the rest of the bytes with spaces( assuming that your input files is 80 bytes in length).

You have put 80:X which means put a space at the 80th column. Your intention was to pad spaces till 80 bytes.

The code would still run fine. But, I just thought of pointing out the mismatch in what you wanted and what will happen. Smile
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Dec 17, 2002 8:26 am    Post subject: Reply with quote

Cogito,
The solution is not flawed.80:X tells DFSORT to pad with blanks up to position 80.your assumption is wrong that it will only put a space in the 80th column.


Kolusu


Last edited by kolusu on Tue Dec 17, 2002 8:57 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Tue Dec 17, 2002 8:42 am    Post subject: Reply with quote

Today I learnt a new thing.

Suppose, instead of 80:X, if you had coded 50:X, the columns till 50 would be spaces. After that? They appear as dots in my file. When you say col_num:X, col_num stands for col_num of O/P file. This rule and the above observation (dots) made me assume that every byte of O/P file must be "told" what it must carry. So, I did not even test before posting!

I apologise.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Dec 17, 2002 8:47 am    Post subject: Reply with quote

Cogito,

If your file is 80 bytes length and you code 50:x , then it will pad with spaces up to the 50th position and from the 51st position you will have binary zeroes(as seen like dots) upto position 80.

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 Dec 17, 2002 11:41 am    Post subject: Reply with quote

Cogito,

80:X means to pad with blanks from the next position to position 80. 50:X means to pad with blanks from the next position to position 50.

If you had:

Code:

  OUTREC FIELDS=(1,20,50:X)


DFSORT would pad with blanks from position 21 to position 50. If you do not specify the LRECL for the output data set, then DFSORT would automatically set the LRECL/record length from the OUTREC length (50). If you do specify the LRECL (or the data set is old and already has an LRECL), then DFSORT keeps the specified record length and pads with zeroes after the last OUTREC position to the LRECL.

For example, the OUTREC statement above will give you 50-byte records with blanks from 21-50 if the SORTOUT statement is:

Code:

//SORTOUT DD DSN=&&O1,DISP=(,PASS),SPACE=(TRK,5),UNIT=SYSDA


whereas, the OUTREC statement above will give you 80-byte records with blanks from 21-50 and binary zeros from 51-80 if the SORTOUT statement is either:

Code:

//SORTOUT DD DSN=&&O2,DISP=(,PASS),SPACE=(TRK,5),UNIT=SYSDA,
//  LRECL=80


or

Code:

//SORTOUT DD DSN=&&O3,DISP=(OLD,PASS)


where &O3 was previously given an LRECL of 80.

Note that for OUTFIL (unlike INREC or OUTREC), you will get an error message and terminate if the OUTREC=(...) length does not match the LRECL of the output data set. That is:

Code:

  OUTFIL OUTREC=(1,20,50:X)


with:

Code:

//SORTOUT DD DSN=&&O2,DISP=(,PASS),SPACE=(TRK,5),UNIT=SYSDA,
//  LRECL=80


would result in termination with this error message:

Code:

ICE222A 0 50 BYTE FIXED RECORD LENGTH IS NOT EQUAL TO 80 BYTE LRECL FOR SORTOUT


So if you want padding with binary zeros to the LRECL, use INREC or OUTREC. If you want termination, use OUTFIL.
_________________
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:40 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Tue Dec 17, 2002 10:54 pm    Post subject: Reply with quote

Thanks a lot, Frank! You saved a lot of blind guessing and wading through manuals.

There is one feature of DFSORT that is far better than anything else. That is: FRANK YAEGER.

Very Happy
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
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 Dec 18, 2002 11:54 am    Post subject: Reply with quote

Laughing
_________________
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
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Tue Feb 25, 2003 4:48 pm    Post subject: Reply with quote

If you have DFSORT PTF UQ90053 (Feb, 2003) installed, you can do this more easily with the new SPLICE operator of DFSORT's ICETOOL, as follows:

Code:

//STEP0200 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//IN2      DD DSN=...  input file 2
//T2       DD DSN=&&T2,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//CON      DD DSN=...  input file 1
//         DD DSN=*.T2,VOL=REF=*.T2,DISP=(OLD,PASS)
//OUT DD DSN=...  output file
//TOOLIN   DD *
* Reformat IN2
   COPY FROM(IN2) USING(CTL2)
* SPLICE IN1 and reformatted IN2 together
   SPLICE FROM(CON) TO(OUT) ON(1,1,CH) WITH(37,18)
/*
//CTL2CNTL DD *
   OUTFIL FNAMES=T2,OUTREC=(1,1,37:19,18,80:X)
/*


For complete information on the new SPLICE operator of DFSORT's ICETOOL, see:

http://www.storage.ibm.com/software/sort/mvs/uq90053/online/srtmutol.html#spl
_________________
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
SureshKumar
Intermediate


Joined: 23 Jan 2003
Posts: 211
Topics: 21

PostPosted: Thu Feb 27, 2003 6:43 pm    Post subject: Reply with quote

Kolosu,
How can I do this using syncsort ? Thanks.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Feb 27, 2003 7:02 pm    Post subject: Reply with quote

SureshKumar,

You can do it with syncsort by changing the PGM name to SYNCTOOL in the solution posted by me

Hope this helps...

cheers

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


Joined: 23 Jan 2003
Posts: 211
Topics: 21

PostPosted: Fri Feb 28, 2003 8:54 am    Post subject: Reply with quote

Kolusu,
Is Synctool an alias for Syncsort ? or is it a addon to Syncsort. When I try to use Synctool I get an RC=20. This error is not from sort, what could it be, does it mean my installation does not have synctool ? Thanks
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Feb 28, 2003 11:26 am    Post subject: Reply with quote

SureshKumar,

As far as I know synctool is just another add on tool from syncsort. Your installation do have synctool. The return code of 20 means that there is something wrong with your toolin statements. post your jcl and the error messages and I will try to fix them.

A dumb question to ask. Are you using the same JCL posted by me replacing the pgm name to synctool or are you using an existing regular sort job with pgm name synctool??

Thanks

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
SureshKumar
Intermediate


Joined: 23 Jan 2003
Posts: 211
Topics: 21

PostPosted: Fri Feb 28, 2003 11:33 am    Post subject: Reply with quote

Well, May be my answer is dumb, i used the same jcl
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Feb 28, 2003 11:54 am    Post subject: Reply with quote

SureshKumar,

Let us put the sarcasm aside and concentrate on solving the problem. You still did not post the error messages. please post the error messages from TOOLMSG & DFSMSG.

Thanks

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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 1, 2, 3, 4  Next
Page 1 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