Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Compare two files and replace file2 values with file1 values

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
vinuk2009

New User


Joined: 30 Apr 2009
Posts: 19
Location: chennai

PostPosted: Tue Sep 04, 2012 10:35 pm    Post subject: Compare two files and replace file2 values with file1 values
Reply with quote

Hi,

I have two fixed length files. file1 has record length 80 and file2 has record length 600. I need to compare these two files and replace file2 values file1 values if the key in file1 match with key in file2. key in file1 starts from 10 and ends at 18. key in file2 starts from 6 and ends at 14. I need to replace file2 values start from 20 to 28 with file1 values start from 1 to 9 if the file1 key matches with file2 key otherwise we need not to replace. Also I need to keep header and trailer of file2 as it is. header record is first record on the file and trailer record is last record in the file. Could some one please help me in achieving this result.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Sep 04, 2012 10:41 pm    Post subject: Re: Compare two files and replace file2 values with file1 va
Reply with quote

Quote:
Could some one please help me in achieving this result.


Can you this and post the sysout so we can see what level of sort you have at your site, please?

Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT   DD SYSOUT=*
//SORTIN DD *
RECORD
/*
//SORTOUT DD DUMMY
//SYSIN   DD   *
  OPTION COPY
/*


JOINKEYS would be the favourite if you have it, but we need to know the results of the above to see if you do and what else you may have.
Back to top
View user's profile Send private message
vinuk2009

New User


Joined: 30 Apr 2009
Posts: 19
Location: chennai

PostPosted: Tue Sep 04, 2012 10:48 pm    Post subject: Reply to: Compare two files and replace file2 values with fi
Reply with quote

Hi Bill,

Thank you for looking into this post. Our site will support DFSORT as well as join keys. So please give me solution by using any of the above.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Sep 04, 2012 10:49 pm    Post subject:
Reply with quote

other than position in the file,
is there a way to interrogate and recognize the head and trailer records?

The sysout was requested,
because JOINKEYS is available with G.

hopefully none of the H functions are necessary if you only have G.

re: http://ibmmainframes.com/viewtopic.php?t=33389
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Sep 04, 2012 10:55 pm    Post subject: Re: Reply to: Compare two files and replace file2 values wit
Reply with quote

vinuk2009 wrote:
Hi Bill,

Thank you for looking into this post. Our site will support DFSORT as well as join keys. So please give me solution by using any of the above.


Post the SYSOUT from the sample job that BILL gave you to run.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Sep 04, 2012 10:58 pm    Post subject: Reply to: Compare two files and replace file2 values with fi
Reply with quote

How did we slip from giving you help to giving you a solution?

With respect, I'd like to see the requested output before investing time into giving you some pointers.
Back to top
View user's profile Send private message
vinuk2009

New User


Joined: 30 Apr 2009
Posts: 19
Location: chennai

PostPosted: Wed Sep 05, 2012 9:54 pm    Post subject:
Reply with quote

Hi Bill,

Sorry for late response. I have executed your sort job and the information of DFSORT from the sysout is as follows. I believe you are looking for this information.

ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AND,MORE
ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R12 - 01:52 ON WED SEP 05, 2012 -
0 OPTION COPY 00001601
ICE201I H RECORD TYPE IS F - DATA STARTS IN POSITION 1
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Sep 06, 2012 5:12 am    Post subject: Reply to: Compare two files and replace file2 values with fi
Reply with quote

Thank you vinuk2009.

It is a fairly simple JOINKEYS.

Specify the key for each file on the JOINKEYS statement. If the files are already sorted, specify SORTED,NOSEQ on the JOINKEYS statement. If not sorted, they will be sorted by default.

JOIN UNPAIRED,F2

Assuming that F2 is your main file.

REFORMAT FIELDS=(F2:1,600,F1:1,9,?)

INREC IFOUTLEN=600,
IFTHEN=(WHEN=(610,1,CH,EQ,C'B),
OVERLAY=(20:602,9)


And that'd be about it.

I'm assuming that the file 1 can never match a header/trailer record; that you want all unmatch file 2 records on your output file; that you are unconcerned about unmatched file 1 records; you are not really "comparing" the recors, but joining/matching on the key fields.

The header/trailer point that you brought up is a red-herring, unless there is more you are not telling.

Edit: Corrected 601 to 602, per Kolusu :-)
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Sep 07, 2012 12:35 am    Post subject: Reply to: Compare two files and replace file2 values with fi
Reply with quote

vinuk2009,

use the following DFSORT JCL which will give you the desired results
Code:

//STEP0100 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//INA      DD DISP=SHR,DSN=Your Input FB 600 Byte file
//INB      DD DISP=SHR,DSN=Your Input FB 80 Byte file
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                         
  OPTION COPY                                           
  JOINKEYS F1=INA,FIELDS=(06,9,A)                       
  JOINKEYS F2=INB,FIELDS=(10,9,A)                       
  JOIN UNPAIRED,F1                                     
  REFORMAT FIELDS=(F1:1,600,?,F2:1,9)                   
  INREC IFOUTLEN=600,                                   
  IFTHEN=(WHEN=(601,1,CH,EQ,C'B'),OVERLAY=(20:602,9))   
//*
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us