– the ovrdbf must be in effect when the file is open
– since you want to change the ovrride during processing use USROPN keyword on the f-spec
– the member can only be over ridden once…dltovr before the ovrdbf command .. but that also looses the file1 to file2 .. so
the RPG program will
- Close if file if open
- Delete the override using qcmdexc
- OVRDBF to override the file and member using qcmdexc
- Open the file process….
Why override at all? In recent releases, RPG can name which file and member it wants without any overrides at all. See a basic example of specifying file and/or member with a constant literal. You can also use variables. If the file variables is 21 bytes long, you can set the value to “LIBRARY/FILENAME” format.
Your RPG can set the variable values before opening the file if the file is USROPN.