You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
96 <strong>File</strong> <strong>Management</strong> V4R5<br />
Example: build-key function<br />
An example of the build-key function is:<br />
Key Field<br />
Number Type Length Decimal Precision Value<br />
1 CHAR 6 KEN<br />
2 ZONED 6 2 54.25<br />
3 BINARY 4 1 10.1<br />
You could specify the FROMKEY (or TOKEY) parameter as follows:<br />
FROMKEY( 2 x'D2C5D5404040F0F0F5F4F2F50065')<br />
Or, you could use the *BLDKEY value and specify the FROMKEY as follows:<br />
FROMKEY(*BLDKEY (KEN 54.25 10.1))<br />
Another example using key fields 1 and 2 is:<br />
FROMKEY(2 'KEN 005425')<br />
Or, you can specify the *BLDKEY value:<br />
FROMKEY(*BLDKEY (KEN 54.25))<br />
Example: using FROMKEY and TOKEY<br />
In this example, the copy command copies records in the file EMP1 to the file<br />
EMP1T. EMP1T is a file in a test library. Because you only need a subset of the<br />
records, you specify a from-key value and a to-key value. Both are full key values.<br />
Note that a 1 specified in the FROMKEY and TOKEY parameters indicates the<br />
number of key fields to be used in searching the record keys, starting with the first<br />
key field.<br />
CPYF FROMFILE(PERSONNEL/EMP1) +<br />
TOFILE(TESTLIB1/EMP1T) MBROPT(*REPLACE) +<br />
FROMKEY(1 438872) TOKEY(1 810199)<br />
All positions in a key value should be specified. If the value is shorter than the key<br />
field length, it will be padded on the right with zeros. Thus, a 5-position key field<br />
specified as FROMKEY(1 8) causes a search for a key equal to hex F800000000. If<br />
the key value contains blanks or special characters, you must enclose them in<br />
apostrophes.<br />
Variable-length fields used by record keys (FROMKEY and<br />
TOKEY)<br />
When the number of key fields and a value are used to specify the FROMKEY or<br />
TOKEY parameter, the string should include the 2-byte length field for each<br />
variable-length key field. You must pad the variable-length key field with blanks<br />
so that keys following the variable-length key field are in the correct position. You<br />
can specify the data in hexadecimal format.<br />
When you specify *BLDKEY on the FROMKEY or TOKEY parameter for<br />
variable-length key fields, specify the character string without the 2-byte length<br />
field. Only the amount of data that is entered for the key value is used for key<br />
comparisons. You can specify a zero-length string for variable-length key fields.