From: Bill Robins To: All
Can someone point me to the reference manual explaining the partial KLISTs?
I am referring to a situation we all have where we need to read all of the detail records for a certain header file record.
EX:
HDR HDORD# 1 6 - Key. DTL DTORD# 1 6 - Key DTLNE# 7 8 0 - Key.
I have seen KLISTs for file DTL where the only KFLD is HDORD#. The program is then coded to READE the detail file using the partial KLIST. I love the flexibility, but don't know where it is explained.
From: Pete Hall To: Bill Robins
Actually, partial KLISTs can be used for any of the RPG record retrieval opcodes. They work not only for SETxx, READE, REDPE, READ, and READP, but also for CHAIN, which can occasionally be very helpful if you need to validate something like a product category or region code, which might not be formally defined in a valid codes file. You could also use SETLL with a result indicator if you didn't actually need to retrieve the data.
The only requirement for a partial KLIST, is that the KFLD definitions must exactly match the data definitions of the first n key fields in the access path. For a file with four key fields reference 9 (page 73).
The only requirement for a partial KLIST, is that the KFLD definitions must exactly match the data definitions of the first n key fields in the access path. For a file with four key fields reference Figure 9 (page 73).
If you wish to retrieve records by order number, regardless of division and customer however, you would need to define a different access path.
As an aside, database management actually will let you retrieve records based on any substring of the entire key, regardless of key field boundaries. This is an unpublished feature, which IBM doesn't exactly say won't work, and in fact it does. If you used a program-described file, you could use SETLL and READE to retrieve records based on the division and the first two bytes of the customer number, for instance. You could not chain directly to a record in the file using this type of a partial key, however. For a program described file, the CHAIN opcode requires a key field for factor one, which matches the length of the entire key. KLISTs can't be used for program-described files.
TechTalK: Partial Key Lists
Figure 9 Using partial key lists
Figure 9: Using Partial Key Lists DIVISION 2 *CHAR CUSTOMER 9.0 *ZONED ORDER 7.0 *DEC LINE 3.0 *DEC Any of the following would be valid key lists: ORDKY1 KLIST KFLD DIV 2 * ORDKY2 KLIST KFLD DIV 2 KFLD CUST 90 * ORDKY3 KLIST KFLD DIV 2 KFLD CUST 90 KFLD ORD# 70 * ORDKY4 KLIST KFLD DIV 2 KFLD CUST 90 KFLD ORD# 70 KFLD LINE# 30
LATEST COMMENTS
MC Press Online