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

Replace records in a file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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 Developer


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

PostPosted: Fri Oct 10, 2008 10:13 pm
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
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 Developer


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

PostPosted: Tue Oct 14, 2008 9:12 pm
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
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 Developer


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

PostPosted: Wed Oct 15, 2008 10:03 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
Search our Forums:

Back to Top