From: Mike Grawl To: All
It was my understanding that when an RPG program ended with *INLR on, all files would be closed. Here is what happened. Program A is interactive and ends with *INLR on; program B ends with RETRN. When program A is run and ended without calling program B, all files are closed. When program A is run, and calls program B, and program A is ended; all the files opened by program B remain open. I used the Work with Job (WRKJOB) command, option 14 to determine which files are open both before and after running program A.
My solution to be sure all files were closed was to run the Reclaim Resource (RCLRSC) command using QCMDEXC prior to moving '1' to *INLR.
From: Sharon Cannon To: Mike Grawl
*INLR only closes files that were opened in that specific program. Unless you do something to close files opened by a called program, they will remain open until the user signs off, ending the job.
RCLRSC is one way to close all files. However, I often use a final call to the called program for the express purpose of setting *INLR on. The code fragments in 1 illustrate this technique.
RCLRSC is one way to close all files. However, I often use a final call to the called program for the express purpose of setting *INLR on. The code fragments in Figure 1 illustrate this technique.
Closing Files at Program End
Figure 1 Ending a Subprogram
Calling Program *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 C* Call sub program C '6' IFEQ ACTION C EXSR SUBPGM C MOVE 'X' CALLED 1 C END (other code) C* End of program routine: end the sub pgm if it was called C ENDPGM TAG C CALLED IFEQ 'X' C EXSR SUBPGM C ENDIF C* Call sub pgm subroutine C SUBPGM BEGSR C CALL 'PROGRAMB' C PARM 'Y' PGMEND 1 C ENDSR Called Program *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 C *ENTRY PLIST C PARM PGMEND 1 C* End program if Pgm end switch is set C PGMEND IFNE *BLANK C MOVE *ON *INLR C RETRN C ENDIF
LATEST COMMENTS
MC Press Online