On 14-Oct-2015 22:58 -0600, Jonathan Ball wrote:
> On 10/13/2015 8:29 PM, CRPence wrote:
>> On 31-Aug-2015 20:18 -0600,
sunilm...@gmail.com wrote:
>>>
>>> I am planning to place the pointer in the file to the key values
>>> passed from CICS screen and read previous 15 records i.e (key<=
>>> values) for the display to the user screen.
>>>
>>> I tried with START but it doesn't allow a 'less than' keyword.
>>>
>>> <<SNIP>>
>>
>> The IBM i ILE COBOL apparently lives in /Bizzaro-World/ per use of
>> some effective inverse-logic to accomplish the task. Essentially
>> the effect is available, but depends on the ASCEND versus DESCEND
>> attribute of the key, from which the READ requests are directed.
>>
>
> With an ascending key file, using START <file-name> KEY IS >=
> <key-value> followed by READ PRIOR [up to] 15 times will do exactly
> what is needed.
>
> Suppose you have a numeric key and there are 15 rows with key values
> 1-15, then the next key value is 21. The user enters a value of 20
> in the display screen. START <file-name> KEY IS >= <key-value>
> where the value is 20 will position the file at the row with a value
> of 21. The program then does READ PRIOR 15 times, reading rows with
> key values of 15, 14, 13, ... , 1 - exactly the desired result.
> <<SNIP>>
>
>> <<SNIP>>
>>
Yet the OP seems to have requested that a read previous would start
from *less than* the-key-value [though in pseudo-code, was instead
expressed as *less than or equal to* the-key-value]. So it seems that
if the input was 20 with that same data-example, then a row positioning
request for start-key<=20 presumably should yield the row having the
key-value 15, and therefore only the prior 14 rows could be read
previous through the ascending key until an effective EOF, thus reading
rows with key values of 14, 13, ... , 1 as the intended output.?
And FWiW, I tested with the DESCEND key using *greater than* and READ
NEXT [on v5r3], and seemingly according to the results noted, if the
input was 20 with that same data-example, then a row-positioning request
for start-key>=20 apparently yielded the row having the key-value 21,
and the next 15 rows could be read forward\next through the descending
key, reading rows with key values of 15, 14, 13, ... , 1 as _a
contradiction to_ the intended output.?
Yet FWiW, the docs [snipped from quoted reply] seem to suggest that
with the DESCEND key using *greater than* and READ NEXT, if the input
was 20 with that same data-example, then a row-positioning request for
start-key>=20 should yield the row having the key-value 15, and
therefore only the next 14 rows could be read forward\next through the
descending key until an effective EOF, thus reading rows with key values
of 14, 13, ... , 1 as the intended output.? Note: that the
start-key>=20 should yield the row with value 15 instead of the row with
value 21 is that for which I expressed as a /bizarro world/ effect,
because while I recognize that value of 15 is _further beyond_ as in the
_next_ key value from the key-value of 20, at least according to the
DESCEND attribute, that the logical expression (15>=20) is clearly false
is difficult to overlook [knowing that the logical expression (21>=20)
is clearly true], so the [as-expressed by the docs to be a valid] result
seems bizarre.
--
Regards, Chuck