Tags:
tag this topic
create new tag
view all tags
---+ READPREV _A new ILF command 'READPREV' has been added._ ---++ Overview: A new ILF command 'READPREV' has been added. This command is similar to READNEXT, except it reads the records in reverse order. ---++ Usage: The syntax of the command is the same as a READNEXT: <pre>····· READPREV ··· ······················ HOLD 0 FT 0 BY ······················ (1) (2) (3) (4) (5) (6) </pre> <div id="_mcePaste">(1) T/F execution conditions</div> <div id="_mcePaste">(2) Application ID</div> <div id="_mcePaste">(3) File name or field name</div> <div id="_mcePaste">(4) Hold type (0=do not hold, 1=hold, 2=hold with potential recovery)</div> <div id="_mcePaste">(5) Fail Type (0=nothing, 1=warning, 2=error, 3=cancel)</div> <div id="_mcePaste">(6) Access key field name</div> Normally, the READPREV statement sets the next status indicator to F or T depending on whether the beginning of the file is or is not reached, respectively. If an [[http://wiki.appx.com/manuals/appx/designer/Chapter_4-06_ILF_Keyword_Reference/BEG_AT.htm][BEG AT]] statement is executed before a READPREV, the status indicator is also set to <em>F </em>if the record read has a key value less than the one specified in the BEG AT statement. Note that the current record area contains the record that is beyond the BEG AT range. If the READPREV sets the next status indicator to _F_, the [[http://wiki.appx.com/manuals/appx/designer/Chapter_4-03_Specifying_Statements/The_FAIL_(or_FT)_Parameter.htm][<em>FAIL </em>or ( _FT_) parameter]] determines what additional action to take. In addition, on a false condition, the predefined field STATUS CODE returns a token indicating the reason for an I/O command failure. This token can be used as a key to read the system message file to obtain a descriptive I/O error message (see [[http://wiki.appx.com/manuals/appx/designer/Chapter_4-07_Predefined_Fields_and_Processes/STATUS_CODE.htm][STATUS CODE]] for details). *Using the Statement* When using this statement in conjunction with an RDBMS table, you can specify a field name instead of a file name to limit the volume of data being passed between APPX and the RDBMS. See the [[http://wiki.appx.com/manuals/appx/designer/Chapter_4-03_Specifying_Statements/Partial-Record_I_O.htm][Partial-Record I/O]] section in [[http://wiki.appx.com/manuals/appx/designer/Chapter_4-03_Specifying_Statements/Specifying_Statements.htm][Chapter 4-3: Specifying Statements]] for more information. <span style="font-size: 10pt;">If a</span> [[http://wiki.appx.com/manuals/appx/designer/Chapter_4-06_ILF_Keyword_Reference/END_AT.htm][END AT]]<span style="font-size: 10pt;">statement for this file is executed before the READPREV, the position in the file is modified before executing the READPREV, based on the value and relation specified in the END AT statement and the keypath identified by the READPREV statement.</span> The key path and position established by the process interpreter for the process control file has no effect on, and is not affected by, the READPREV position. The READPREV statement allows a record to be read and held for update. While a record is held, no other user may update or delete that record. If the record is to be rewritten or deleted, the _HOLD_ specification must be set to _1_ (hold) or _2_ (recover). Otherwise, it should be set to _0_ (no). The recover specification holds the record and internally saves a copy of the record so that a subsequent rewrite or delete can be performed, even if the hold is lost (by reading another record with hold before completing the rewrite or delete). Recover can rehold the record for update, as long as the saved copy is identical to the original record that was read. Note that performance is improved with hold type _1_. Note also that the READPREV statement does not generate an 'In Use' message if the record to be held is currently being held by another user. The READPREV statement waits until the record to be read is freed up by the other user, unless a [[http://wiki.appx.com/manuals/appx/designer/Chapter_4-06_ILF_Keyword_Reference/TIMEOUT.htm][TIMEOUT]] statement with a nonblank label was previously encountered. In that case, processing control transfers to the specified label. *Restrictions* The <strong>READPREV </strong>statement cannot be used with one-record or consecutive files. *Example* <pre> SET 1EX VENDOR NUM = 1 BEG AT 1EX VENDOR IN 1EX VENDOR NUM SET 1EX VENDOR NUM = 100 END AT 1EX VENDOR IN 1EX VENDOR NUM LABEL :READPREV READPREV 1EX VENDOR HOLD 0 FT 0 BY VENDOR NUM T DISPLAY 1EX VENDOR NUM (AT APPEARANCE # ) T GOTO :READPREV </pre> This example will read the 1EX VENDOR file starting at vendor 100, ending with vendor 1. Note that you define the BEG AT/END AT in the same way as you would for a READNEXT, the READPREV just determines the order in which the designated range of records will be returned. ---++ Comments: _Read what other users have said about this page or add your own comments._ Note that READPREV acts differently than READNEXT when the BEG AT/END AT is less than the full key being used. For example, the following code will return the FIRST line item from the ORDER2 file instead of the LAST line item: <verbatim> SET COE ORDER1 ORDER NO = 12345 BEG AT COE ORDER2 IN COE ORDER1 ORDER NO END AT COE ORDER2 IN COE ORDER1 ORDER NO READPREV COE ORDER2 HOLD 0 FT 0 BY ORDER2 KEY</verbatim> If there are 5 line items in ORDER2 for that order number, one would expect that READPREV would return the 5th one, but instead, it comes back with the first. The only solution, at this time, is to define all parts of the key: <verbatim> SET COE ORDER2 ORDER NO = 12345 SET COE ORDER2 LINE NO = 0 BEG AT COE ORDER2 IN COE ORDER2 KEY SET COE ORDER2 LINE NO = 999 END AT COE ORDER2 IN COE ORDER2 KEY READPREV COE ORDER2 HOLD 0 FT 0 BY ORDER2 KEY</verbatim> This behavior is evident through APPX 5.4.0. A bug report has been submitted. -- %BUBBLESIG{AlKalter - 2015-02-04}% %COMMENT% -- Main.JeanNeron - 2013-10-04
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r5
<
r4
<
r3
<
r2
<
r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r5 - 2015-02-04
-
AlKalter
Home
Site map
Main web
MedicaidBilling web
Sandbox web
TWiki web
Main Web
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
E
dit
A
ttach
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback