View previous topic :: View next topic |
Author |
Message |
murali Beginner
Joined: 21 Apr 2004 Posts: 12 Topics: 9
|
Posted: Wed Aug 11, 2004 5:34 am Post subject: Update file in in easytrieve |
|
|
i have a big file with laks of records and i want to update only a few records which starts policy3. and the other records should not be touched.i do not want another output file. can this be done?
murali |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Wed Aug 11, 2004 5:56 am Post subject: |
|
|
Murali,
Updating a file in place will result in a loss of data, if your pgm abends. So you need to have a backup of your file before running this pgm.
I am assuming that your policy3 field starts at pos 1 and you want to update a field which is in the 30th byte for a length of 20 bytes. Notice that the same input file is used on both infile and fileout.
Code: |
//STEP0100 EXEC PGM=EZTPA00
//STEPLIB DD DSN=EASYTREV.LOADLIB,
// DISP=SHR
//SYSPRINT DD SYSOUT=*
//INFILE DD DSN=INPUT FILE,
// DISP=SHR
//FILEOUT DD DSN=INPUT FILE,
// DISP=OLD
//SYSIN DD *
FILE INFILE
REC-IND 01 07 A
UPDATE-Flag 30 20 A
FILE FILEOUT FB(0 0)
JOB INPUT (INFILE)
IF REC-IND = 'POLICY3'
UPDATE-REC = 'I AM UPDATING THIS RECORD'
PUT FILEOUT FROM INFILE
ELSE
PUT FILEOUT FROM INFILE
END-IF
/*
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
souvik_225 Beginner
Joined: 15 May 2004 Posts: 17 Topics: 2 Location: Mumbai , India
|
Posted: Wed Aug 11, 2004 6:01 am Post subject: |
|
|
Use the UPDATE in file definition, use SEARCH to locate the records and WRITE to rewrite the records. _________________ Thanks and Regards,
Souvik Upadhyay |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Wed Aug 11, 2004 6:35 am Post subject: |
|
|
souvik_225,
The UPDATE with WRITE option is valid only for VSAM files. But the code I have shown updates a reqular sequential file.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
souvik_225 Beginner
Joined: 15 May 2004 Posts: 17 Topics: 2 Location: Mumbai , India
|
Posted: Wed Aug 11, 2004 6:51 am Post subject: |
|
|
Kolusu,
Sorry , I overlooked in my manual that WRITE is for VSAM. _________________ Thanks and Regards,
Souvik Upadhyay |
|
Back to top |
|
|
murali Beginner
Joined: 21 Apr 2004 Posts: 12 Topics: 9
|
Posted: Thu Aug 12, 2004 5:51 am Post subject: |
|
|
thanks kolusu it worked |
|
Back to top |
|
|
|
|