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 in a file

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

New User


Joined: 27 Sep 2007
Posts: 5
Location: rotterdam

PostPosted: Fri Oct 10, 2008 6:19 pm    Post subject: Replace records in a file
Reply with quote

Hi
I want replace the records in a file according another file:

file1: contains all records
file2: contains only changed records

Example:
file1:
aaaa1111bb
aaaa2222cc
aaaa3333bb
aaaa4444bb
aaaa5555bb

file2:
eeee1111xx
kkkk3333xx

output should be come into file1:
eeee1111xx
aaaa2222cc
kkkk3333xx
aaaa4444bb
aaaa5555bb

I want not change the fields that are changed but replace the record with new one. Keys are the numbers in the file.
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: Fri Oct 10, 2008 10:13 pm    Post subject:
Reply with quote

You can use a DFSORT job like the one below to do what you asked for. I assumed there were no duplicates within file1, and no duplicates within file2, as in your example. Be sure to concatenate the file with the changed records before the file with all records.

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//CON DD *     input file2
eeee1111xx
kkkk3333xx
/*
//    DD *     input file1
aaaa1111bb
aaaa2222cc
aaaa3333bb
aaaa4444bb
aaaa5555bb
/*
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(CON) TO(OUT) ON(5,4,CH) FIRST
/*
Back to top
View user's profile Send private message
erhan

New User


Joined: 27 Sep 2007
Posts: 5
Location: rotterdam

PostPosted: Tue Oct 14, 2008 7:17 pm    Post subject:
Reply with quote

but how can i put the records from file2 to file1 and overwrite if exists?
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 Oct 14, 2008 9:12 pm    Post subject:
Reply with quote

Huh? I gave you a DFSORT job that does what you asked for in your first post. I stated my assumptions.

Did you try the job? If not, try it.

If you did try the job and it didn't do what you want, then you didn't explain what you want correctly or my assumptions were wrong because you didn't give enough information. You need to explain exactly what you want if you expect anyone to help you. Show a good example of the records in your input files and what you want for output, and explain the "rules" for getting from input to output. If either input file has duplicates within it, show that in your example. Give the RECFM and LRECL of the input files. Give the starting position, length and format of each relevant field.
Back to top
View user's profile Send private message
erhan

New User


Joined: 27 Sep 2007
Posts: 5
Location: rotterdam

PostPosted: Wed Oct 15, 2008 12:51 pm    Post subject:
Reply with quote

Sorry Frank. I will explain what i want to do:

FileA and FileB: both FB with 354 reclen. Key is first 17 characters.
In positions 23 thru 29 are the accountnumbers in packed decimal format.
File B has the updated records which should be applied in File A.

FileA:
<key1>.... <accountnbr1><data1>
<key2>.... <accountnbr2><data2>
<key3>.... <accountnbr3><data3>
<key4>.... <accountnbr4><data4>
....

FileB:
<key2>.... <accountnbr2><data2chg>
<key3>.... <accountnbr3><data3chg>

Output should be come into File A:
FileA:
<key1>.... <accountnbr1><data1>
<key2>.... <accountnbr2><data2chg>
<key3>.... <accountnbr3><data3chg>
<key4>.... <accountnbr4><data4>
....
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: Wed Oct 15, 2008 10:03 pm    Post subject:
Reply with quote

You haven't said which fields you want to match on: Key only? Account number only? Key and Account number? I'm going to assume it's the key and account number.

Here's a DFSORT/ICETOOL job that will do what you asked for. Be sure to concatenate FileB before FileA.

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//CON DD DSN=...  input fileB (FB/354)
//    DD DSN=...  input fileA (FB/354)
//OUT DD DSN=...  output file (FB/354)
//TOOLIN DD *
SELECT FROM(CON) TO(OUT) ON(1,17,CH) ON(23,7,PD) FIRST
/*


Again, this does what you want for the cases you described. If there are other cases for which it doesn't do what you want, you need to tell me what those cases are with an example of the input and expected output records.
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 Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 4 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


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