


Assuming that you are using native I/O .. F specs and reads and chains .. not SQL
and further assuming that you are not using commitment control
A record is locked when it is acquired, as in a chain or read, by a program that has opened the file for Update (not input). It remains locked until
- the program ends or the file is closed
- the record is updated or deleted
- another record is acquired by this program through the same access path.
- the record is unlocked
Access to a record that is locked will not be possible by another program or job that is attempting to acquire that record for update. A program/job can acquire a locked record when that program/jobs access path is for input.
Phil


Only a couple things to add that I can think of.
SQL will also lock rows that are being updated. And a record is locked when it is acquired for update.
That last bit is useful because a program can open a file in update mode and read records without locking them. This is done in RPG IV by specifying CHAIN or any READ op-code with the (N) extender. A lock won’t be set until the record is eventually input without the (N) extender. That lets you delay the lock until your program has finished all processing of the data. That is most useful in interactive programming when a user might have a record for a long time.
There doesn’t seem to be much else to add.
Tom