TechTalk: Reclaim Resource Revisited

General
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

You probably know that you can use the Reclaim Resource (RCLRSC) command to clean up open files and reclaim program storage. The default value for the Program Level (LVL) parameter is an asterisk (*), which says to close all open files and programs, including the calling program, once the called programs have finished running.

Did you know that you can also specify *CALLER in this parameter? Use this parameter value when you want to leave programs and files open in the calling program while still closing programs and files that were called by the original program. Let's see what this means by way of an example.

PGMSTART (Figure 11) opens FILE1 and calls PGMA (Figure 12), which opens FILE2. The program then exits with the file still open, using the RETRN op code. PGMSTART then calls PGMB (Figure 13), which opens FILE3 and then exits with the file still open, using the RETRN op code. PGMSTART then calls RCLPGMC (Figure 14), a CL program that executes the RCLRSC command, using *CALLER in the LVL parameter. When control returns to PGMSTART, it stops execution, ending with the RETRN op code. When PGMSTART finishes, only FILE1 is left open. The files in PGMA and PGMB are closed, and all storage allocated for them is reclaimed. Another operation could execute PGMSTART again and would be able to use the open access path to FILE1, and all variables would still be in their previous state.

- Shannon O'Donnell

Editor's Note: The help text for the RCLRSC command provides additional information you should know about. For instance, RCLRSC command is not needed to reclaim the resources of all CL programs that end (return) normally, of RPG programs that have the last record (LR) indicator set on, or of any COBOL programs. RCLRSC should not be used if it might be processed while any COBOL program is still active in the application; instead, use the COBOL CANCEL statement.

Other important facts: RCLRSC should not specify LVL(*CALLER) if it is used in a CL

program that also uses the Send File (SNDF), Receive File (RCVF), or Send Receive File (SNDRCVF) commands; using *CALLER in such a program causes unpredictable results when the other commands are used after the program runs. Unpredictable results can also occur if RCLRSC is executed from a command line with the LVL(*CALLER) parameter.

Figure 11: RPG III program PGMSTART

FFILE1 IF E K DISK *

C READ FILE1 99
C *IN99 IFEQ *OFF
C CALL 'PGMA'

C CALL 'PGMB'
C CALL 'RCLPGMC'
C ENDIF
C RETRN FFILE2 IF E K DISK *

C READ FILE2 99
C RETRN FFILE3 IF E K DISK *

C READ FILE3 99
C RETRN

Figure 14: CL program RCLPGMC

PGM

RCLRSC LVL(*CALLER)

ENDPGM

Figure 12: RPG III program PGMA

Figure 13: RPG III program PGMB

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: