Apologies for the unclear Codes above
Rewritten as below:
FPF001 O E K DISK
C eval *inlr = *on
C EVAL P1ACNO = 17
C WRITE PF001R</pre>
<i>I had an understanding that after *INLR becomes On, the system closes all the open files and we can no longer open any.</i>
The question that must be asked in reply is “Where did you get that idea?” Perhaps a source for the idea is in need of clarification.
The LR indicator being on has no effect upon the execution of your program unless you make explicit tests, e.g., IF (*INLR = *ON)…, or unless you are using the RPG “Cycle”.
The effect takes place only after a RETURN is executed. And once you RETURN, you have no opportunity to OPEN any files nor to do anything else with the files — your program has been exited.
Note that LR is intended as a control of “Cycle” code within RPG itself. It doesn’t affect any of your full-procedural code unless you make it so.
And also note that your example program <b>is</b> a “Cycle” program. Because you turned LR on, an exit will happen when you reach the end your code and the PF001 file will be closed at that time. If you chose not to turn LR on, PF001 would be left open.