ADELIA |
VADELIA |
SADELIA |
WADELIA |
EADELIA |
(I/B) |
(I/B) (S) |
(B) (S) |
(I/B) (S) |
(B) (S) |
Section for use
All
Syntax
POSITION_AFTER ViewName
Description
This instruction places the file associate with the view ViewName BEHIND the record whose key is EQUAL TO, or failing this immediately smaller than the key stated in the variables comprising the view's key.
At this point, the record has not been read. The reading is the user responsibility.
Testing the success of the positioning is done with the EXISTS and DOES_NOT_EXIST instructions.
If the positioning is unsuccessful, the pointer will be at the end of the file.
Example
Example for SALES file (file keys are customer code and line number);
SALES view is used with only W_CUST_CODE as key.
SALES_CUST_CODE |
SALES_LINE_NBR |
0002 |
01 |
0002 |
02 |
0002 |
03 |
0002 |
04 |
0006 |
01 |
0006 |
02 |
0011 |
01 |
W_CUST_CODE = '0002'
POSITION_AFTER SALES
* This will position the pointer in the file after line 04 of customer 0002
*
IF SALES EXISTS
READ_PREVIOUS SALES
LAST_LINE_NBR = SALES_LINE_NBR
END
*
* This reads the record of customer 0002 / line 04 and therefore line number = 04
*
* if W_CUST_CODE = '0003' or '0004' or '0005', the result is the same
* if W_CUST_CODE < '0002', the pointer is before the first record
* if W_CUST_CODE > '0010', the pointer is after the last record