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

233 lines
14 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?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: Unique notify object for each program" />
<meta name="abstract" content="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." />
<meta name="description" content="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." />
<meta name="DC.Relation" scheme="URI" content="rzakjusenotify.htm" />
<meta name="DC.Relation" scheme="URI" content="rzakjdesc_5.htm" />
<meta name="DC.Relation" scheme="URI" content="rzakjloggingfile.htm" />
<meta name="DC.Relation" scheme="URI" content="rzakjnotifyall.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="rzakjnotifyeach" />
<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: Unique notify object for each program</title>
</head>
<body id="rzakjnotifyeach"><a name="rzakjnotifyeach"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example: Unique notify object for each program</h1>
<div><p>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.</p>
<p>In the following examples, a database file is used as a notify object and
it is used only by this program.</p>
<p>The program has two database files (PRDMSTP and PRDLOCP) that must be updated
for receipts to inventory. The display file used by the program is named PRDRCTD.
A database file, PRDRCTP, is used as the notify object. This notify object
is defined to the program as a file and is also used as the definition of
a data structure for the notify function.</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>
<div class="section" id="rzakjnotifyeach__FIGPFPRDL"><a name="rzakjnotifyeach__FIGPFPRDL"><!-- --></a><h4 class="sectiontitle">DDS for physical file PRDLOCP</h4><pre>SEQNBR *... ... 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... ... 7
1.00 A R PRDLOCR TEXT('Location record')
2.00 A PRODCT 3 COLHDG('Product' 'Number')
3.00 A LOCATN 6 COLHDG('Location')
4.00 A LOCAMT 5 0 COLHDG('Location' 'Amount')
5.00 A EDTCDE(Z)
6.00 A K PRODCT
7.00 A K LOCATN</pre>
</div>
<div class="section" id="rzakjnotifyeach__prdrctd"><a name="rzakjnotifyeach__prdrctd"><!-- --></a><h4 class="sectiontitle">DDS for display file PRDRCTD</h4><pre>SEQNBR *... ... 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... ... 7 ..
1.00 A REF(PRDMSTP)
2.00 A R PROMPT
3.00 A CA03(98 'End of program')
4.00 A SETOFF(71 'RESTART')
5.00 A 1 20'PRODUCT RECEIPTS'
6.00 A 3 2'Quantity'
7.00 A QTY 3 OI +1
8.00 A +6'Product'
9.00 A PRODCT R I +1
10.00 A 61 ERRMSG('No record +
11.00 A found in the +
12.00 A master file' 62)
13.00 A +6'Location'
14.00 A LOCATN R I +1REFFLD(LOCATN PRDLOCP)
15.00 A 62 ERRMSG('No record +
16.00 A found in the +
17.00 A location file' 62)
18.00 A 9 2'Last Transaction'
19.00 A 71 +6'This is restart +
20.00 A information'
21.00 A DSPATR(HI BL)
22.00 A 12 2'Quantity'
23.00 A 12 12'Product'
24.00 A 12 23'Location'
25.00 A 12 35'Description'
26.00 A LSTPRD R 14 15REFFLD(PRODCT)
27.00 A LSTLOC R 14 26REFFLD(LOCATN *SRC)
28.00 A LSTQTY R 14 5REFFLD(QTY *SRC)
29.00 A EDTCDE(Z)
30.00 A LSTDSC R 14 35REFFLD(DESCRP)</pre>
</div>
<div class="section" id="rzakjnotifyeach__prdrctp"><a name="rzakjnotifyeach__prdrctp"><!-- --></a><h4 class="sectiontitle">DDS for notify object and externally described
data structure (PRDRCTP)</h4><pre>SEQNBR *... ... 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... ... 7 ..
1.00 A LIFO
2.00 A REF(PRDMSTP)
3.00 A R PRDRCTR
4.00 A USER 10
5.00 A PRODCT R
6.00 A DESCRP R
7.00 A QTY 3 0
8.00 A LOCATN R REFFLD(LOCATN PRDLOCP)
9.00 A K USER</pre>
<p>The program processes the notify object as follows:</p>
<ul><li>At the beginning, the program randomly processes the notify object and
displays a record if it exists for the specific key: <ul><li>If multiple records exist, the last record for this key is used because
the PRDRCTP file is in LIFO sequence.</li>
<li>If no record exists, a transaction was not interrupted so it is not necessary
to start again.</li>
<li>If the program fails before the first successful commit operation, it
does not consider that starting again is required.</li>
</ul>
</li>
<li>The routine to clear the notify object occurs at the end of the program: <ul><li>If there were multiple failures, the routine can handle deletion of multiple
records in the notify object.</li>
<li>Although the system places the commit identification in a database file,
the commit identification must be specified as a variable in the RPG program.</li>
<li>Because RPG allows a data structure to be externally described, a data
structure is a convenient way of specifying the commit identification. In
this example, the data structure uses the same external description that the
database file used as the notify object.</li>
</ul>
</li>
</ul>
<p>The processing for this program prompts the user for a product number,
a location, and a quantity:</p>
<ul><li>Two files must be updated: <ul><li>Product master file (PRDMSTP)</li>
<li>Product location file (PRDLOCP)</li>
</ul>
</li>
<li>A record in each file must exist before either is updated.</li>
<li>The program moves the input fields to corresponding last fields after
each transaction is successfully entered. These last fields are displayed
to the operator on each prompt as feedback for what was last entered.</li>
<li>If information for starting again exists, it is moved to these last fields
and a special message appears on the display.</li>
</ul>
<p>This process is outlined in the following figure. The user name is
passed to the program to provide a unique record in the notify object.</p>
</div>
<div class="section" id="rzakjnotifyeach__programflow"><a name="rzakjnotifyeach__programflow"><!-- --></a><h4 class="sectiontitle">Program flow</h4><br /><img src="rzakj511.gif" alt="Program flow" /><br /><p>The following example is
about the RPG source code. The notify object (file PRDRCTP) is used as a normal
file at the beginning and end of the program, and is also specified as the
notify object in the CL (STRCMTCTL command) before calling the program.</p>
</div>
<div class="section" id="rzakjnotifyeach__rpgsource"><a name="rzakjnotifyeach__rpgsource"><!-- --></a><h4 class="sectiontitle">RPG source</h4><pre>SEQNBR *... ... 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... ... 7 ..
1.00 FPRDMSTP UF E K DISK KCOMIT
2.00 FPRDLOCP UF E K DISK KCOMIT
3.00 FPRDRCTD CF E WORKSTN
4.00 F*
5.00 F* The following file is the specific notify object for this pgm.
6.00 F* It is accessed only in a restart situation and at the
7.00 F* end of the program to delete any records. The records
8.00 F* are written to the notify object by Commitment Control.
9.00 F*
10.00 FPRDRCTP UF E K DISK
11.00 ICMTID E DSPRDRCTP
12.00 C *ENTRY PLIST
13.00 C PARM USER10 10
14.00 C MOVE USER10 USER
15.00 C*
16.00 C* Check for restart information - get last rcd per user
17.00 C* PRDRCTP file access path is in LIFO sequence
18.00 C*
19.00 C USER CHAINPRDRCTR 20 Not found
20.00 C N20 DO Restart
21.00 C EXSR MOVLST Move to last
22.00 C SETON 71 Restart
23.00 C END
24.00 C*
25.00 C* Basic processing loop
26.00 C*
27.00 C L00P TAG
28.00 C EXFMTPROMPT
29.00 C 98 GOTO END End of pgm
30.00 C PRODCT CHAINPRDMSTR 61 Not found
31.00 C 61 GOTO L00P
32.00 C KEY KLIST
33.00 C KFLD PRODCT
34.00 C KFLD LOCATN
35.00 C KEY CHAINPRDLOCR 62 Not found
36.00 C 62 DO
37.00 C EXCPTRLSMST Release lck
38.00 C GOTO L00P
39.00 C END
40.00 C ADD QTY ONHAND Add
41.00 C ADD QTY LOCAMT
42.00 C UPDATPRDMSTR Update
43.00 C UPDATPRDLOCR Update
44.00 C*
45.00 C* Commit and move to previous fields
46.00 C*
47.00 C CMTID COMIT
48.00 C EXSR MOVLST Move to last
49.00 C GOTO L00P
50.00 C*
51.00 C* End of program processing
52.00 C*
53.00 C END TAG
54.00 C SETON LR
55.00 C*56.00 C* Delete any records in the notify object
57.00 C*
58.00 C DLTLP TAG
59.00 C USER CHAINPRDRCTR 20 Not found
60.00 C N20 DO
61.00 C DELETPRDRCTR Delete
62.00 C GOTO DLTLP
63.00 C END
64.00 C*
65.00 C* Move to -Last Used- fields for operator feedback
66.00 C*
67.00 C MOVLST BEGSR
68.00 C MOVE PRODCT LSTPRD
69.00 C MOVE LOCATN LSTLOC
70.00 C MOVE QTY LSTQTY
71.00 C MOVE DESCRP LSTDSC
72.00 C ENDSR
73.00 OPRDMSTR E RLSMST</pre>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="rzakjdesc_5.htm">Image description</a></strong><br />
The image is a flow chart that describes the program flow for the sample program.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzakjusenotify.htm" title="When a program is started after an abnormal end, it can look for an entry in the notify object. If the entry exists, the program can start a transaction again. After the transaction has been started again, the notify object is cleared by the program to prevent it from starting the same transaction yet another time.">Example: Use a notify object to start an application</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="rzakjloggingfile.htm" title="This example provides sample code and instructions of how to use a transaction logging file to start an application after an abnormal end.">Example: Use a transaction logging file to start an application</a></div>
<div><a href="rzakjnotifyall.htm" title="Using a single notify object for all programs is advantageous because all information required to start again is in the same object and a standard approach to the notify object can be used in all programs. In this situation, use a unique combination of user and program identifications to make sure that the program accesses the correct information when it starts again.">Example: Single notify object for all programs</a></div>
</div>
</div>
</body>
</html>