TechTalK: Partial Key Lists

RPG
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: