– 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
1. Close if file if open
2. Delete the override using qcmdexc
3. OVRDBF to override the file and member using qcmdexc
3. open the file
Why override at all? In recent releases, RPG can name which file and member it wants without any overrides at all. See a <a href=”http://itknowledgeexchange.techtarget.com/itanswers/how-to-access-any-perticular-menber-of-any-pf/”>basic example of specifying file and/or member</a> 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.