|
FMyFile UP E DISK C If DType = 'JRNL' And DDStat = 'A' C Eval DDstat = 'X' C Update MyFile01 Assuming: file name is MyFile and record layout is MyFile01 That will do it for you. This will read through every record in MyFile and update as per your specs. This is not very efficient, however, as it does have to read through every record. It does this because the file is opened as the Primary file, and uses the RPG cycle. This program, however, should be perfectly fine for a one time thing, and is normally how I do it. For something that would run every day, or something users would use, I would probably make it a lot more efficient so it runs faster, doesn't have to read the entire file, and doesn't take up as much CPU cycles. If you have a key you can look for, you can do it faster. Say, perhaps, that your key was DType and DDStat (okay, we know they're not, but...) then you could do something like this: FMyFile UF E DISK D MyKeyStat S 4 D MyKeyType S 1 C Eval MyKeyType = 'JRNL' C Eval MyKeyStat = 'A' C MyKey Setll MyFile01 C Read MyFile01 99 C DoW DDType = 'JRNL' And DDStat = 'A' And C NOT *IN99 C Eval DDStat = 'X' C Update Myfile01 C EndDo C C Eval *INLR = *ON C *INZSR BegSR C C MyKey KList C KFld MyKeyType C KFld MyKeyStat There is some way to use Read (E) and check for %EOF, but as I'm on V3R7M0 I am not really familiar with this. Also, I typed this code in Netscape, so the spacing is off, and I may have missed a few things on the file specs and such, but you should get the general idea. Regards, Jim Langston Art Baker wrote: > Hello, > I looking to update a data file with RPG. Normally I've been using > UPDDTA and changing the records, when required, but in this case there is > over 900 records that needed to be updated. My question is which command to > use, SETLL, READE or CHAIN. There are two things to look for in this file, > DTYPE > and DDSTAT. The DTYPE to look for is JRNL and the DDSTAT to look for is 'A'. > Both JRNL and 'A' need to be true then, change the 'A' to an 'X'. > Thanks for any advice, > Art +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.