Post by s***@gmail.comI 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.
Move high values and read prior will start reading from the last
record of the file which is not what I want.
Can someone help me with this?
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.
A READ PRIOR from the intended START key position of [the unsupported
less-than predicate] (KEY<=values) against an ASCENDing key sequence
would be the effective equivalent of a READ NEXT from that same START
key position of [the supported greater-than predicate] (KEY>=values) for
the DESCENDing key sequence. The key-positioning request via START is
just to gain position, and the READ PRIOR or READ NEXT is what gets the
actual data; so by simply accepting the oddity [apparently the ANSI
COBOL] of the capability restricted to EQUAL, GREATER THAN, and GREATER
THAN OR EQUAL, just code the opposite direction for the READ with the
opposite collation [e.g. DESCEND vs ASCEND] while using the same key
values, and the expected results should be achieved.
An example follows, one that I think might elucidate, showing how the
same key value but both the opposite key-sequence and opposite
READ-direction used in two scenarios below will achieve the same results
[ignoring that what I offer seems to contradict the docs for the "START
GREATER", for which a link and a complete quotation are included further
below]:
START key>=1.5 for the following ASCENDing key data gets position for
the value=1.7 so two READ...PRIOR requests get the two /prior/ values of
1.4 and 1.1 and in that order.
1.1
1.4
1.7
2.0
START key>=1.5 for the following DESCENDing key data gets position
for the value=1.7 so two READ...NEXT requests get the /next/ values of
1.4 and 1.1 and in that order.
2.0
1.7
1.4
1.1
[http://www.ibm.com/support/knowledgecenter/api/content/nl/en-us/ssw_ibm_i_72/rzase/cbldbfdesckey.htm]
_Processing Files with Descending Key Sequences_
"Files created with a descending keyed sequence (in DDS) cause the READ
statement NEXT, PRIOR, FIRST, and LAST phrases to work in a fashion
exactly opposite that of a file with an ascending key sequence. You can
specify a descending key sequence in the DDS with the DESCEND keyword in
positions 45 to 80 beside a key field. In descending key sequence, the
data is arranged in order from the highest value of the key field to the
lowest value of the key field.
For example, READ FIRST retrieves the record with the highest key value,
and READ LAST retrieves the record with the lowest key value. READ NEXT
retrieves the record with the next lower key value. Files with a
descending key sequence also cause the START qualifiers to work in the
opposite manner. For example, START GREATER THAN positions the current
record pointer to a record with a key less than the current key.
Parent topic: _File Processing Methods for DISK and DATABASE Files_
[http://www.ibm.com/support/knowledgecenter/api/content/nl/en-us/ssw_ibm_i_72/rzase/cbldbfprocess.htm]"
--
Regards, Chuck