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.
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, you must enclose them in apostrophes.