ibm-information-center/dist/eclipse/plugins/i5OS.ic.dbp_5.4.0.1/rbafocloseex2.htm

127 lines
6.5 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Example 2: Multiple sets of files with similar processing options" />
<meta name="abstract" content="In this example, different files are used for each application. The user normally works with one application for a considerable length of time before selecting a new application." />
<meta name="description" content="In this example, different files are used for each application. The user normally works with one application for a considerable length of time before selecting a new application." />
<meta name="DC.Relation" scheme="URI" content="rbafoclose.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rbafocloseex2" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Example 2: Multiple sets of files with similar processing options</title>
</head>
<body id="rbafocloseex2"><a name="rbafocloseex2"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example 2: Multiple sets of files with similar processing options</h1>
<div><p>In this example, different files are used for each application.
The user normally works with one application for a considerable length of
time before selecting a new application.</p>
<div class="section"><p>Assume that a menu requests the operator to specify the application
program (for example, accounts receivable or accounts payable) that uses the
Open Database File (OPNDBF) command to open the required files. When the application
is ended, the Close File (CLOF) command closes the files. The CLOF command
is used to help reduce the amount of main storage needed by the job. </p>
</div>
<div class="section"><div class="p">An example of the accounts receivable programs follows: <div class="note"><span class="notetitle">Note:</span> By
using the code examples, you agree to the terms of the <a href="codedisclaimer.htm">Code license and disclaimer information</a>.</div>
<pre>PGMC: PGM /* PGMC PROGRAM */
DCLF FILE(DISPLAY)
BEGIN: SNDRCVF RCDFMT(TOPMENU)
IF (&amp;RESPONSE *EQ '1') CALL ACCRECV
IF (&amp;RESPONSE *EQ '2') CALL ACCPAY
.
.
IF (&amp;RESPONSE *EQ '90') SIGNOFF
GOTO BEGIN
ENDPGM
ACCREC: PGM /* ACCREC PROGRAM */
DCLF FILE(DISPLAY)
OVRDBF FILE(A) SHARE(*YES)
OVRDBF FILE(B) SHARE(*YES)
OPNDBF FILE(A) OPTION(*ALL) ....
OPNDBF FILE(B) OPTIONS(*INP) ...
BEGIN: SNDRCVF RCDFMT(ACCRMENU)
IF (&amp;RESPONSE *EQ '1') CALL PGM21
IF (&amp;RESPONSE *EQ '2') CALL PGM22
.
.
IF (&amp;RESPONSE *EQ '88') DO /* Return */
CLOF FILE(A)
CLOF FILE(B)
RETURN
ENDDO
GOTO BEGIN
ENDPGM</pre>
</div>
</div>
<div class="section"><p>The program for the accounts payable menu would be similar, but
with a different set of OPNDBF and CLOF commands.</p>
</div>
<div class="section"><p>For this example, files A and B were created with SHARE(*NO).
Therefore, an OVRDBF command must precede the OPNDBF command. As in Example
1, the amount of main storage used by each job can be reduced by placing the
OPNDBF commands in a separate program and calling it. A separate program can
also be created for the CLOF commands. The OPNDBF commands can be placed in
an application setup program that is called from the menu, which transfers
control to the specific application program menu (any overrides specified
in this setup program are kept). However, calling separate programs for these
functions also uses system resources and, depending on the frequency with
which the different menus are used, it might be better to include the OPNDBF
and CLOF commands in each application program menu as shown in this example.</p>
</div>
<div class="section"><div class="p">Another choice is to use the Reclaim Resources (RCLRSC) command
in PGMC (the setup program) instead of using the CLOF command. The RCLRSC
command closes any files and frees any leftover storage associated with any
files and programs that were called and have since returned to the calling
program. However, RCLRSC does <em>not</em> close files that are opened with
the following parameters specified on the OPNDBF or Open Query
File (OPNQRYF) command: <ul><li>OPNSCOPE(*ACTGRPDFN), and the open is requested from some activation group
other than the default.</li>
<li>OPNSCOPE(*ACTGRP) reclaims if the RCLRSC command is from an activation
group with an activation group number that is lower than the activation group
number of the open.</li>
<li>OPNSCOPE(*JOB).</li>
<li>TYPE(*PERM).</li>
</ul>
</div>
</div>
<div class="section"><div class="p">The following example shows the RCLRSC command used to close files: <pre> .
.
IF (&amp;RESPONSE *EQ '1') DO
CALL ACCRECV
RCLRSC
ENDDO
IF (&amp;RESPONSE *EQ '2') DO
CALL ACCPAY
RCLRSC
ENDDO
.
.</pre>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafoclose.htm" title="Listed here are the considerations for closing a database file that is shared in the same job or activation group.">Close considerations for files shared in a job or activation group</a></div>
</div>
</div>
</body>
</html>