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 

Replace field in a file from that of another file

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


Joined: 19 Apr 2007
Posts: 3
Topics: 2

PostPosted: Wed May 09, 2007 6:14 am    Post subject: Replace field in a file from that of another file Reply with quote

Hi

Please help me to accomplish the following using JCL SORT.
I have 2 files
file 1:
Code:

aaa 1111
bbb 2222
ccc 3333

File 2:
Code:

ddd 4444
eee 5555
ggg 6666


I need the output file with field 1 from file 1 and field 2 from file 2 like below

output:
Code:

aaa 4444
bbb 5555
ccc 6666
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


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

PostPosted: Wed May 09, 2007 6:41 am    Post subject: Reply with quote

dhivya_tcs,

Quote:

Please help me to accomplish the following using JCL SORT.


it is never JCL anything. It can be DFSORT or SYNCSORT or some other 3rd party sorting tool.

are there any matching keys? are the number of records in file1 = num recds File2?

you simply want field 2 in file2 record num x to overlay field2 in file1 record num x
what happens when the number of records in each file is different.

are these large files? it might be faster to edit file 1, copy file 2 at the end, and using overlay (OO) line commands.

if you know ezytrieve or rexx that might be faster.

frank will come along and provide DFSORT guidance, Alissa for SYNCSORT. in the meantime, you might answer my questions for them.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed May 09, 2007 7:08 am    Post subject: Reply with quote

dhivya_tcs,

The following DFSORT/ICETOOL jcl will give you the desired results.

Code:

//STEP0100 EXEC PGM=ICETOOL                                 
//TOOLMSG   DD SYSOUT=*                                     
//DFSMSG    DD SYSOUT=*                                     
//IN1       DD *                                             
AAA 1111                                                     
BBB 2222                                                     
CCC 3333                                                     
//IN2       DD *                                             
DDD 4444                                                     
EEE 5555                                                     
----+----1----+----2----+----3----+----4----+----5----+----6-
GGG 6666                                                     
//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)                                 
  SPLICE FROM(T1) TO(OUT) ON(9,8,CH) -                       
  WITHEACH WITH(5,5) USING(CTL3)                             
//CTL1CNTL  DD *                                             
  OUTFIL FNAMES=T1,                                         
  OUTREC=(1,4,4X,SEQNUM,8,ZD)                               
//CTL2CNTL  DD *                                             
  OUTFIL FNAMES=T1,                                         
  OUTREC=(4X,5,4,SEQNUM,8,ZD)                               
//CTL3CNTL  DD *                                             
  OUTFIL FNAMES=OUT,                                         
  OUTREC=(01,08)                                             
/*                                                           


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
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: Wed May 09, 2007 12:07 pm    Post subject: Reply with quote

dhivya_tcs,

Here's another way to do what you asked for with DFSORT/ICETOOL:

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG   DD SYSOUT=*
//DFSMSG    DD SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/8)
//IN2 DD DSN=...  input file2 (FB/8)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=...  output file (FB/8)
//TOOLIN    DD *
  COPY FROM(IN1) TO(T1) USING(CTL1)
  COPY FROM(IN2) TO(T1) USING(CTL2)
  SPLICE FROM(T1) TO(OUT) ON(9,8,CH) -
    WITH(5,5) USING(CTL3)
/*
//CTL1CNTL  DD *
  INREC OVERLAY=(9:SEQNUM,8,ZD)
/*
//CTL2CNTL  DD *
  INREC BUILD=(5:5,4,9:SEQNUM,8,ZD)
/*
//CTL3CNTL  DD *
  OUTFIL FNAMES=OUT,BUILD=(1,8)
/*


For more information on this technique, see the "Join fields from two files record-by-record" Smart DFSORT Trick at:

http://www.ibm.com/servers/storage/support/software/sort/mvs/tricks/
_________________
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
dhivya_tcs
Beginner


Joined: 19 Apr 2007
Posts: 3
Topics: 2

PostPosted: Thu May 10, 2007 4:41 am    Post subject: Reply with quote

Dick,
Thanks for the info. The number of records in both the files are the same. I just wanted to replace field 2 of file 1 with field 2 of file 2 for all the records.

Kolusu & Frank
Thanks for the help. I got what I needed.
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


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

PostPosted: Sat May 12, 2007 8:53 am    Post subject: Reply with quote

dhivya_tcs,

I apologize to you and everyone else that I have criticized concerning JCL and terminology. I was at another ibm mainframe web site (this one proclaimed to be from India) looking at the available documentation and saw this exact terminology: JCL Utilities.

I can not hold you responsible for mis-information learned at a 'trusted' web site.
_________________
Dick Brenholtz
American living in Varel, Germany
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