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 2 files

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
hari108
Beginner


Joined: 03 Feb 2006
Posts: 16
Topics: 4

PostPosted: Tue Jul 22, 2008 4:05 am    Post subject: Merge 2 files Reply with quote

Hi,

I want to merge files in a particular fashion
The first record should be from file1, second from file 2, 3rd from file1 and so on.
File1:
00000000000001000000000000000000000000
00000000000002000000000000000000000000
00000000000003000000000000000000000000

File2:
0000000000000101KADHC01000 00000P
0000000000000201KADHC01000 00000P
0000000000000301KADHC01000 00000P

Output:
00000000000001000000000000000000000000
0000000000000101KADHC01000 00000P
00000000000002000000000000000000000000
0000000000000201KADHC01000 00000P
00000000000003000000000000000000000000
0000000000000301KADHC01000 00000P

Kindly help me out.
Thanks in advance.
_________________
Thanks,
Hari
Back to top
View user's profile Send private message Yahoo Messenger
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue Jul 22, 2008 4:50 am    Post subject: Reply with quote

why don't you spend some time searching the utilities forum, look at the stickies, etc?
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
hari108
Beginner


Joined: 03 Feb 2006
Posts: 16
Topics: 4

PostPosted: Tue Jul 22, 2008 5:48 am    Post subject: Reply with quote

Sorry i tried searching but could not find information related to my requirement.
It would be of great help if you can provide me the link.
_________________
Thanks,
Hari
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Jul 22, 2008 10:26 am    Post subject: Reply with quote

hari108,

The following DFSORT/ICETOOL JCL will give you the desired results. I assumed that your both input files are FB recfm and 80 byte lrecl

Code:

//STEP0100 EXEC PGM=ICETOOL                                 
//TOOLMSG  DD SYSOUT=*                                       
//DFSMSG   DD SYSOUT=*                                       
//IN1      DD *                                             
00000000000001000000000000000000000000 1                     
00000000000002000000000000000000000000 3                     
00000000000003000000000000000000000000 5                     
//IN2      DD *                                             
0000000000000101KADHC01000 00000P  2                         
0000000000000201KADHC01000 00000P  4                         
0000000000000301KADHC01000 00000P  6                         
//T1       DD DSN=&&T1,DISP=(MOD,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT      DD SYSOUT=*                                       
//TOOLIN   DD *                                             
  COPY FROM(IN1) USING(CTL1)                                 
  COPY FROM(IN2) USING(CTL2)                                 
  SORT FROM(T1) USING(CTL3)                                 
//CTL1CNTL DD *                                             
  OUTFIL FNAMES=T1,OVERLAY=(81:SEQNUM,8,PD,START=1,INCR=2)   
//CTL2CNTL DD *                                             
  OUTFIL FNAMES=T1,OVERLAY=(81:SEQNUM,8,PD,START=2,INCR=2)   
//CTL3CNTL DD *                                             
  SORT FIELDS=(81,8,PD,A)                                   
  OUTFIL FNAMES=OUT,BUILD=(1,80)                             
/*                                                           


Hope this helps...
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/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 Jul 22, 2008 10:33 am    Post subject: Reply with quote

Hari,

If the records in file1 and file2 actually have sequence numbers in 1-14 as shown, you could do a simple MERGE using the sequence numbers as the key like this:

Code:

//S1    EXEC  PGM=ICEMAN                   
//SYSOUT    DD  SYSOUT=*                   
//SORTIN1 DD *                             
00000000000001000000000000000000000000     
00000000000002000000000000000000000000     
00000000000003000000000000000000000000
/*   
//SORTIN2 DD *                             
0000000000000101KADHC01000 00000P         
0000000000000201KADHC01000 00000P         
0000000000000301KADHC01000 00000P       
/*   
//SORTOUT DD SYSOUT=*                     
//SYSIN    DD    *                         
  OPTION EQUALS                           
  MERGE FIELDS=(1,14,ZD,A)                 
/*

_________________
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
Alain Benveniste
Beginner


Joined: 04 May 2003
Posts: 92
Topics: 4
Location: Paris, France

PostPosted: Tue Jul 22, 2008 11:02 am    Post subject: Reply with quote

Hari,

Frank says
Quote:

If the records in file1 and file2 actually have sequence numbers in 1-14 as shown, you could do a simple MERGE using the sequence numbers as the key like this:


if the sequence number is not present as shown, I suppose we could presrve Frank's idea by concatenate the files and create an extra field using a INREC with SEQNUM and RESTART=(16,2) parameters (bold field) then MERGE based on this extra field.

Home now. I can't test this.

Alain
Back to top
View user's profile Send private message
Alain Benveniste
Beginner


Joined: 04 May 2003
Posts: 92
Topics: 4
Location: Paris, France

PostPosted: Tue Jul 22, 2008 11:06 am    Post subject: Reply with quote

I think MERGE will not work. Sort card would be better...
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 Jul 22, 2008 3:26 pm    Post subject: Reply with quote

Quote:
I think MERGE will not work. Sort card would be better...


You mean MERGE wouldn't work if the sequence numbers were not present and you had to generate them ... right? MERGE will work if the sequence numbers are present.

Quote:
if the sequence number is not present as shown, I suppose we could presrve Frank's idea by concatenate the files and create an extra field using a INREC with SEQNUM and RESTART=(16,2) parameters (bold field) then MERGE based on this extra field.


I think you mean 15,2 (00 in file1 or 01 in file2) but that assumes those values are really in the input records and the sequence numbers aren't. Possible I guess, but ...
_________________
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
hari108
Beginner


Joined: 03 Feb 2006
Posts: 16
Topics: 4

PostPosted: Tue Jul 22, 2008 9:44 pm    Post subject: Reply with quote

Thanks a lot Frank Smile
Merge technique worked Very Happy
_________________
Thanks,
Hari
Back to top
View user's profile Send private message Yahoo Messenger
Alain Benveniste
Beginner


Joined: 04 May 2003
Posts: 92
Topics: 4
Location: Paris, France

PostPosted: Wed Jul 23, 2008 5:58 am    Post subject: Reply with quote

Frank,

I talked about my post not yours Smile
By MERGE will not work, I meant that it will not work if the files are concatenated. Replacing MERGE per a SORT card will do it.

And I didn't suppose this will work:
Code:

//STEP0001 EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN1 DD *
00000000000001000000000000000000000000
00000000000002000000000000000000000000
00000000000003000000000000000000000000
/*
//SORTIN2 DD *
0000000000000101KADHC01000 00000P
0000000000000201KADHC01000 00000P
0000000000000301KADHC01000 00000P
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  INREC FIELDS=(1,80,SEQNUM,5,ZD)
  MERGE FIELDS=(81,5,ZD,A)
  OUTREC FIELDS=(1,80)
/*


But now I tested it, I got the result too (And this way, I think we don't need OPTION EQUALS...)

Alain
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
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