%KDS (Search Arguments in Data Structure)

%KDS(data-structure-name{:num-keys})

%KDS is allowed as the search argument for any keyed Input/Output operation (CHAIN, DELETE, READE, READPE, SETGT, SETLL) coded in a free-form group. The search argument is specified by the subfields of the data structure name coded as the first argument of the built-in function. The key data structure may be (but is not limited to), an externally described data structure with keyword EXTNAME(...:*KEY) or LIKEREC(...:*KEY)..

Notes:
  1. The first argument must be the name of a data structure. This includes any subfield defined with keyword LIKEDS or LIKEREC.
  2. The second argument specifies how many of the subfields to use as the search argument.
  3. The individual key values in the compound key are taken from the top level subfields of the data structure. Subfields defined with LIKEDS are considered character data.
  4. Subfields used to form the compound key must not be arrays.
  5. The types of all subfields (up to the number specified by "num-keys") must match the types of the actual keys. Where lengths and formats differ, the value is converted to the proper length and format.
  6. If the data structure is defined as an array data structure (using keyword DIM), an index must be supplied for the data structure.
  7. Opcode extenders H, M, or R specified on the keyed Input/Output operations code affect the moving of the search argument to the corresponding position in the key build area.

Example:

Figure 226. Example of Search on Keyed Input/Output Operations
A..........T.Name++++++RLen++TDpB......Functions++++++++++++++++++
A          R CUSTR            
A            NAME         100A
A            ZIP           10A
A            ADDR         100A
A          K NAME
A          K ZIP
FFilename++IPEASF.....L.....A.Device+.Keywords+++++++++++++++++++++++++
Fcustfile  if   e           k disk    rename(CUSTR:custRec)
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++
D custRecKeys     ds                  likerec(custRec : *key)
 ...
 /free
         // custRecKeys is a qualified data structure
         custRecKeys.name = customer;
         custRecKeys.zip = zipcode;
         // the *KEY data structure is used as the search argument for CHAIN
         chain %kds(custRecKeys) custRec;
 /end-free
 


[ Top of Page | Previous Page | Next Page | Contents | Index ]