Example: using FROMKEY and TOKEY

 

In this example, the copy command copies records in the file EMP1 to the file EMP1T. EMP1T is a file in a test library. Because you only need a subset of the records, you specify a from-key value and a to-key value. Both are full key values. Note that a 1 specified in the FROMKEY and TOKEY parameters indicates the number of key fields to be used in searching the record keys, starting with the first key field.

CPYF   FROMFILE(PERSONNEL/EMP1) +
  TOFILE(TESTLIB1/EMP1T) MBROPT(*REPLACE) +
  FROMKEY(1 438872) TOKEY(1 810199)

All positions in a key value should be specified. If the value is shorter than the key field length, it will be padded on the right with zeros. Thus, a 5-position key field specified as FROMKEY(1 8) causes a search for a key equal to hex F800000000. If the key value contains blanks or special characters, enclose them in apostrophes.

 

Parent topic:

Selecting records by record keys (FROMKEY and TOKEY parameters)