IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Replace records while combining


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mrdinesh

New User


Joined: 23 Sep 2006
Posts: 24
Location: India

PostPosted: Mon Sep 19, 2011 7:58 pm
Reply with quote

Hi,
I have two files which are Variable length files. I am trying to combine the two files and in the process I want to replace the matching keys with the key in the secong file. For example

File 1 Contains the followin records

1000...ABCD
1001...DCDE
1002...EFGH
1003...WXYZ
1004...NOPQ
1005...RSTU

File 2 Contains the following records

1000...WXYZ
1001...ABCD


My output file should consist like

1000...WXYZ
1001...ABCD
1002...EFGH
1003...WXYZ
1004...NOPQ
1005...RSTU

The Key for both the files is the first 4 bytes.

Thanks,
Dinesh
Back to top
View user's profile Send private message
THINKSRINIII
Warnings : 1

New User


Joined: 09 Jan 2009
Posts: 88
Location: India

PostPosted: Mon Sep 19, 2011 8:23 pm
Reply with quote

Hi Dinesh,

Your requirement is still not clear.
Can you explain how you need your output?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Sep 19, 2011 8:30 pm
Reply with quote

there is a little miswording,
Quote:
I want to replace the matching keys with the key in the secong file.
but nothing that prevents understanding the requirement
for matching keys ( the first 4 bytes ) use the data from file 2
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Sep 19, 2011 11:16 pm
Reply with quote

Dinsesh,

We really do need more information.

What is the LRECL of each input file?

Since the files are VB, the key (first field) starts in position 5 (after the RDW). Where does the second field start (after the RDW)? Is there more data after the second field? Is it variable in length?

Does file1 have any keys that don't have a match in file2?
Does file2 have any keys that don't have a match in file1?
If there can be mismatches, then show an example of that with the expected output.

You seem to be referring to both the first field and second field as "key" whereas really you should only refer to the first field as "key" since that's the one you're matching on. The second field is just data.
Back to top
View user's profile Send private message
mrdinesh

New User


Joined: 23 Sep 2006
Posts: 24
Location: India

PostPosted: Tue Sep 20, 2011 1:12 am
Reply with quote

Frank, Here is a much detailed information on the files

Both the files are in VB and has a LRECL of 1000.The first file consists of a set of records which are accumulated from the start of the year. The second file consists of the records that are updated/newly added records on a day. At the end of the day the second file needs to be merged with the file 1.

The key to both the files is the first 25 characters in it.
When the key from file 1 matches with the key in file 2 the record from file 2 need to be written in output file ignoring the file 1 record.

When the key from file 1 does not matches with the key from file 2 both the file 1 and file 2 records need to be written to the output file.

For example consider the following example

File 1 Key File 1 data
1000... ABCD
1001... EFGH
1002... HIJK
1003... LMNO
1004... PQRS
1005... UVWX


File 2 Key File 2 data
1000... UPDATED ABCD
1006... NEWLY ADDED YZAB

The output should be like this

1000... UPDATED ABCD
1001... EFGH
1002... HIJK
1003... LMNO
1004... PQRS
1005... UVWX
1006... NEWLY ADDED YZAB

Please let me know if it is still not clear.

Thanks,
Dinesh
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Sep 20, 2011 1:27 am
Reply with quote

Since you don't have any duplicates within each file, you can use a DFSORT/ICETOOL job like the following. Be sure that file2 is first in the concatenation.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//CON DD DSN=...  input file2 (VB/1000)
//    DD DSN=...  input file1 (VB/1000)
//OUT DD DSN=...  output file (VB/1000)
//TOOLIN DD *
SELECT FROM(CON) TO(OUT) ON(5,25,CH) FIRST
/*
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top