ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzakj_5.4.0.1/rzakjloggingfile.htm

234 lines
15 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="concept" />
<meta name="DC.Title" content="Example: Use a transaction logging file to start an application" />
<meta name="abstract" content="This example provides sample code and instructions of how to use a transaction logging file to start an application after an abnormal end." />
<meta name="description" content="This example provides sample code and instructions of how to use a transaction logging file to start an application after an abnormal end." />
<meta name="DC.Relation" scheme="URI" content="rzakjscenario.htm" />
<meta name="DC.Relation" scheme="URI" content="rzakjdesc_4.htm" />
<meta name="DC.Relation" scheme="URI" content="rzakjproccprog.htm" />
<meta name="DC.Relation" scheme="URI" content="rzakjnotifyeach.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2004, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2004, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzakjloggingfile" />
<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: Use a transaction logging file to start an application</title>
</head>
<body id="rzakjloggingfile"><a name="rzakjloggingfile"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example: Use a transaction logging file to start an application</h1>
<div><p>This example provides sample code and instructions of how to use
a transaction logging file to start an application after an abnormal end.</p>
<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>
<p>A <dfn class="term">transaction logging file</dfn> is used to start an
application again after a system or job failure when a notify object is not
used. A transaction logging file is often used in interactive applications
to summarize the effects of a transaction.</p>
<p>For example, in an order entry application, a record is typically written
to a transaction logging file for each item ordered. The record contains the
item ordered, the quantity, and the price. In an accounts payable application,
a record is written to a transaction logging file for each account number
that is to receive a charge. This record normally contains such information
as the account number, the amount charged, and the vendor.</p>
<p>In many of the applications where a transaction logging file already exists,
a workstation user can request information about the last transaction entered.
By adding commitment control to the applications in which a transaction logging
file already exists, you can:</p>
<ul><li>Ensure that the database files are updated to a commitment boundary.</li>
<li>Simplify the starting of the transaction again.</li>
</ul>
<p>You must be able to uniquely identify the workstation user if you use a
transaction logging file for starting applications again under commit control.
If unique user profile names are used on the system, that profile name can
be placed in a field in the transaction logging record. This field can be
used as the key to the file.</p>
<p>The following examples assume that an order inventory file is being used
to perform transactions and that a transaction logging file already exists.
The program does the following tasks:</p>
<ol><li>Prompt the workstation user for a quantity and item number.</li>
<li>Update the quantity in the production master file (PRDMSTP).</li>
<li>Write a record to the transaction logging file (ISSLOGL).</li>
</ol>
<p>If the inventory quantity on hand is insufficient, the program rejects
the transaction. The workstation user can ask the program where the data entry
was interrupted, because the item number, description, quantity, user name,
and date are written to the transaction logging file.</p>
<div class="section" id="rzakjloggingfile__pdrmstp"><a name="rzakjloggingfile__pdrmstp"><!-- --></a><h4 class="sectiontitle">DDS for physical file PRDMSTP</h4><pre>SEQNBR *... ... 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... ... 7
1.00 A R PRDMSTR TEXT('Master record')
2.00 A PRODCT 3 COLHDG('Product' 'Number')
3.00 A DESCRP 20 COLHDG('Description')
4.00 A ONHAND 5 0 COLHDG('On Hand' 'Amount')
5.00 A EDTCDE(Z)
6.00 A K PRODCT</pre>
</div>
<div class="section" id="rzakjloggingfile__isslogp"><a name="rzakjloggingfile__isslogp"><!-- --></a><h4 class="sectiontitle">DDS for physical file ISSLOGP used by ISSLOGP</h4><pre>SEQNBR *... ... 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... ... 7
1.00 A R ISSLOGR TEXT('Product log record')
2.00 A PRODCT 3 COLHDG('Product' 'Number')
3.00 A DESCRP 20 COLHDG('Description')
4.00 A QTY 3 0 COLHDG('Quantity')
5.00 A EDTCDE(Z)
6.00 A USER 10 COLHDG('User' 'Name')
7.00 A DATE 6 0 EDTCDE(Y)
8.00 A COLHDG('Date')</pre>
</div>
<div class="section" id="rzakjloggingfile__isslogl"><a name="rzakjloggingfile__isslogl"><!-- --></a><h4 class="sectiontitle">DDS for logical file ISSLOGL</h4><pre>SEQNBR *... ... 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... ... 7
1.00 A LIFO
2.00 A R ISSLOGR PFILE(ISSLOGP)
3.00 A K USER</pre>
</div>
<div class="section"><h4 class="sectiontitle">DDS for display file PRDISSD used in the program</h4><pre>SEQNBR *... ... 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... ... 7 ..
1.00 A REF(ISSLOGP)
2.00 A R PROMPT
3.00 A CA03(98 'End of program')
4.00 A CA02(97 'Where am I')
5.00 A 1 20'ISSUES PROCESSING'
6.00 A 3 2'Quantity'
7.00 A QTY R I +1
8.00 A 62 ERRMSG('Not enough +
9.00 A Qty' 62)
10.00 A +6'Product'
11.00 A PRODCT R I +1
12.00 A 61 ERRMSG('No Product +
13.00 A record found' 62)
14.00 A 55 15 2'No Previous record exists'
15.00 A 24 2'CF2 Last transaction'
16.00 A R RESTART
17.00 A 1 20'LAST TRANSACTION +
18.00 A INFORMATION'
19.00 A 5 2'Product'
20.00 A PRODCT R +1
21.00 A 7 2'Description'
22.00 A DESCRP R +1
23.00 A 9 2'Qty'
24.00 A QTY R +1REFFLD(QTY)</pre>
<p>This process is outlined in the <strong>Program flow</strong>.</p>
</div>
<div class="section" id="rzakjloggingfile__programflow"><a name="rzakjloggingfile__programflow"><!-- --></a><h4 class="sectiontitle">Program flow</h4><br /><img src="rzakj510.gif" alt="Program flow" /><br /><p>The RPG COMMIT operation
code is specified after the PRDMSTP file is updated and the record is written
to the transaction logging file. Because each prompt to the operator represents
a boundary for a new transaction, the transaction is considered a single Enter
transaction.</p>
<p>The user name is passed to the program when it is called.
The access path for the transaction logging file is defined in last-in-first-out
(LIFO) sequence so the program can easily access the last record entered.</p>
<p>The
workstation user can start the program again after a system or job failure
by using the same function that identified where data entry was stopped. No
additional code needs to be added to the program. If you are currently using
a transaction logging file but are not using it to find out where you are,
add the user name to the transaction logging file (assuming that user names
are unique) and use this approach in the program.</p>
<p>The following example
shows the RPG program used. Statements required for commitment control are
marked with arrows (==&gt;).</p>
</div>
<div class="section"><h4 class="sectiontitle">RPG Program</h4><pre> SEQNBR *... ... 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... .. 7 ..
=&gt;1.00 FPRDMSTP UP E K DISK KCOMIT
=&gt;2.00 FISSLOGL IF E K DISK KCOMIT
3.00 PRDISSD CP E WORKSTN
4.00 *ENTRY PLIST
5.00 PARM USER 10
6.00 C*
7.00 C* Initialize fields used in Trans Log Rcd
8.00 C*
9.00 C MOVE UDATE DATE
10.00 C*
11.00 C* Basic processing loop
12.00 C*
13.00 C LOOP TAG
14.00 C EXFMTPROMPT
15.00 C 98 GOTO END End of pgm
16.00 C 97 DO Where am I
17.00 C EXSR WHERE
18.00 C GOTO LOOP
19.00 C END
20.00 C PRODCT CHAINPRDMSTR 61 Not found
21.00 C 61 GOTO LOOP
22.00 C ONHAND SUB QTY TEST 50 62 Less than
23.00 C 62 DO Not enough
24.00 C EXCPTRLSMST Release lock
25.00 C GOTO LOOP
26.00 C END
27.00 C*
28.00 C* Update master record and output the Transaction Log Record
29.00 C*
30.00 C Z-ADDTEST ONHAND
31.00 C UPDATPRDMSTR
32.00 C WRITEISSLOGR
=&gt;33.00 C COMIT
34.00 C GOTO LOOP
35.00 C*
36.00 C* End of program processing
37.00 C*
38.00 C END TAG
39.00 C SETON LR
40.00 C*
41.00 C* WHERE subroutine for "Where am I" requests
42.00 C*
43.00 C WHERE BEGSR
44.00 C USER CHAINISSLOGL 55 Not found
45.00 C N55 EXFMTRESTART
46.00 C ENDSR
47.00 OPRDMSTR E RLSMST</pre>
</div>
<div class="section" id="rzakjloggingfile__prdiss"><a name="rzakjloggingfile__prdiss"><!-- --></a><h4 class="sectiontitle">CL program used to call RPG program PRDISS</h4><pre>SEQNBR *... ... 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... ... 7 ..
1.00 PGM
2.00 DCL &amp;USER *CHAR LEN(10)
3.00 STRCMTCTL LCKLVL(*CHG)
4.00 RTVJOBA USER(&amp;USER)
5.00 CALL PRDISS PARM(&amp;USER)
6.00 MONMSG MSGID(RPG900l) EXEC(ROLLBACK)
7.00 ENDCMTCTL
8.00 ENDPGM</pre>
<p>To use commitment control in this program, a lock level of
*CHG is normally specified. The record is locked by the change until a commit
operation is run. Note that if there is an insufficient quantity of inventory,
the record is explicitly released. (If the record are not explicitly released
in the program, it is released when the next record is read for update from
the file.)</p>
<p>In this example, there is no additional advantage to using
the lock level *ALL. If *ALL were used, a rollback or commit operation must
be used to release the record when an insufficient quantity existed.</p>
<p>The
previous code is a CL program that calls the RPG program PRDISS. Note the
use of STRCMTCTL/ENDCMTCTL commands. The unique user name is retrieved (RTVJOBA
command) and passed to the program. The use of the MONMSG command to cause
a rollback is described in Example: Use a standard processing program to
start an application.</p>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="rzakjdesc_4.htm">Image description</a></strong><br />
The image is a flow chart that describes the program flow for the sample RPG program.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzakjscenario.htm" title="You can read scenarios and examples in this topic to see how one company sets up commitment control. Read code examples for programs that use commitment control.">Scenarios and examples: Commitment control</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="rzakjproccprog.htm" title="A standard processing program is one way to start your application again using one database file as the notify object for all applications. This approach assumes that user profile names are unique by user for all applications using the standard program.">Example: Use a standard processing program to start an application</a></div>
<div><a href="rzakjnotifyeach.htm" title="Using a single, unique notify object for each job allows use of an externally described commit identification even though there might be multiple users of the same program.">Example: Unique notify object for each program</a></div>
</div>
</div>
</body>
</html>