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
 

 

Replace records while combining

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

New User


Joined: 23 Sep 2006
Posts: 21
Location: India

PostPosted: Mon Sep 19, 2011 7:58 pm    Post subject: Replace records while combining
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Mon Sep 19, 2011 8:30 pm    Post subject: Reply to: Replace records while combining
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 Moderator


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

PostPosted: Mon Sep 19, 2011 11:16 pm    Post subject:
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: 21
Location: India

PostPosted: Tue Sep 20, 2011 1:12 am    Post subject:
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 Moderator


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

PostPosted: Tue Sep 20, 2011 1:27 am    Post subject:
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    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 Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


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