File Management - IBM
File Management - IBM File Management - IBM
96 File Management V4R5 Example: build-key function An example of the build-key function is: Key Field Number Type Length Decimal Precision Value 1 CHAR 6 KEN 2 ZONED 6 2 54.25 3 BINARY 4 1 10.1 You could specify the FROMKEY (or TOKEY) parameter as follows: FROMKEY( 2 x'D2C5D5404040F0F0F5F4F2F50065') Or, you could use the *BLDKEY value and specify the FROMKEY as follows: FROMKEY(*BLDKEY (KEN 54.25 10.1)) Another example using key fields 1 and 2 is: FROMKEY(2 'KEN 005425') Or, you can specify the *BLDKEY value: FROMKEY(*BLDKEY (KEN 54.25)) 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, you must enclose them in apostrophes. Variable-length fields used by record keys (FROMKEY and TOKEY) When the number of key fields and a value are used to specify the FROMKEY or TOKEY parameter, the string should include the 2-byte length field for each variable-length key field. You must pad the variable-length key field with blanks so that keys following the variable-length key field are in the correct position. You can specify the data in hexadecimal format. When you specify *BLDKEY on the FROMKEY or TOKEY parameter for variable-length key fields, specify the character string without the 2-byte length field. Only the amount of data that is entered for the key value is used for key comparisons. You can specify a zero-length string for variable-length key fields.
Date, time, and timestamp fields used by record keys (FROMKEY and TOKEY) When the number of key fields and a value are used to specify the FROMKEY or TOKEY parameter, no conversion of data occurs if the corresponding key field in the from-file is a date, time, or timestamp field. The user input string that you specify (including the separators) must be in the same format as the date, time, or timestamp field. If it is not, a file open error may occur, or the records copied may not be the desired result. If *BLDKEY is specified for the FROMKEY or TOKEY parameter and the corresponding key field in the from-file is a date, time, or timestamp field, the system attempts to convert the user-input key field value to the format (and separators) of the from-file field. The following rules apply to the conversion: v If the from-field is a date key field, the system first determines if the user-input key value is in the same format and has the same separator as specified in the current job under which the copy command is running. This can be *MDY, *DMY, *YMD, or *JUL for the format and slash (/), hyphen (-), period (.), comma (,), or blank ( ) for the separator. If the user-input key value is not in the current job specified format and separator form, it determines if it is in one of the Systems Application Architecture (SAA) formats (*ISO, *USA, *EUR, or *JIS). It also determines if it is in a YYYYDDD form (no separator). If the system can determine the user-input key value is in one of these forms, the input string is converted to the actual format (and separator) of the from-file date field, which is used for the key comparison. If the user-input string format cannot be determined or the length or data value is not valid, the system issues a diagnostic message. You must left-justify the date portion of the user-input key value; it can contain trailing blanks. v If the from-field is a time key field, the system first determines if the user-input key value is in the same format and has the same separator as specified in the current job under which the copy command is running. This may be HHMMSS for the format and colon (:), comma (,), period (.), or blank ( ) for the separator. If the user-input key value is not in the current job specified format and separator form, the system determines if it is in one of the SAA formats (*ISO, *USA, *EUR, or *JIS). If the system can determine the user-input key value is in one of these forms, the input string is converted to the actual format (and separator) of the from-file time field, which is used for the key comparison. If the user-input string format cannot be determined, or the length or data value is not valid, the system issues a diagnostic message. You must left-justify the time portion of the user-input key value; it can contain trailing blanks. v If the from-field is a timestamp key field, the system first determines if the user-input key value is in the SAA format or YYYYMMDDHHMMSS form. If the system determines the user-input key value is in one of these forms, the input string is converted to the actual SAA timestamp format, which is used for the key comparison. If the user-input string format cannot be determined, or the length or data value is not valid, the system issues a diagnostic message. You must left-justify the timestamp portion of the user-input key value; it can contain trailing blanks. Null-capable fields used by record keys (FROMKEY and TOKEY) When you use the number of key fields and a value to specify the FROMKEY or TOKEY parameter, the copy command ignores the null values. The command uses only the buffer default values for values that are actually null for the comparison. Chapter 4. Copying files 97
- Page 56 and 57: 46 File Management V4R5 Override 1
- Page 58 and 59: 48 File Management V4R5 same call l
- Page 60 and 61: 50 File Management V4R5 Program A .
- Page 62 and 63: 52 File Management V4R5 Applying OV
- Page 64 and 65: Deleting overrides 54 File Manageme
- Page 66 and 67: Program A (in user default activati
- Page 68 and 69: 58 File Management V4R5 Displaying
- Page 70 and 71: 60 File Management V4R5 Command 7 d
- Page 72 and 73: 62 File Management V4R5 Display All
- Page 74 and 75: Redirecting files 64 File Managemen
- Page 76 and 77: 66 File Management V4R5 Default act
- Page 78 and 79: 68 File Management V4R5 From Databa
- Page 80 and 81: Copying files: overview 70 File Man
- Page 82 and 83: 72 File Management V4R5 Table 9. Co
- Page 84 and 85: Table 10. Summary of Copy Functions
- Page 86 and 87: 76 File Management V4R5 Copying fil
- Page 88 and 89: Resending copy file completion mess
- Page 90 and 91: 80 File Management V4R5 from-file m
- Page 92 and 93: CPYSRCF command support for CCSIDs
- Page 94 and 95: | | | | | | | | | | | | | | | | | |
- Page 96 and 97: | | | | | | | | | | | | | | | | 86
- Page 98 and 99: | | | | | | | | | | | | | | | | | |
- Page 100 and 101: 90 File Management V4R5 Copying onl
- Page 102 and 103: Selecting the records to copy 92 Fi
- Page 104 and 105: 94 File Management V4R5 Selecting r
- Page 108 and 109: 98 File Management V4R5 When you sp
- Page 110 and 111: 100 File Management V4R5 A field na
- Page 112 and 113: 102 File Management V4R5 v “Null-
- Page 114 and 115: 104 File Management V4R5 - INCCHAR(
- Page 116 and 117: When you specify PRINT(*EXCLD), the
- Page 118 and 119: Note: It is possible for files with
- Page 120 and 121: 110 File Management V4R5 Variable-L
- Page 122 and 123: Table 14 on page 112 outlines the c
- Page 124 and 125: 114 File Management V4R5 in the cur
- Page 126 and 127: 116 File Management V4R5 (including
- Page 128 and 129: | | | | | | | | | | | | | | | | | |
- Page 130 and 131: | | | | | | | | | | | | | | | | | |
- Page 132 and 133: Preventing errors when copying file
- Page 134 and 135: elationship. However, the copy oper
- Page 136 and 137: Preventing allocation errors when c
- Page 138 and 139: 128 File Management V4R5 - A depend
- Page 140 and 141: Year 2000 support: date, time, and
- Page 142 and 143: FLD TYPE DATFMT SPECIFIED FIELD LEN
- Page 144 and 145: Restrictions for Year 2000 support
- Page 146 and 147: | | | | | | | | | | AS/400 supports
- Page 148 and 149: | | | | | | | | | | | | | | | | | |
- Page 150 and 151: Using the Copy From Import File (CP
- Page 152 and 153: externally described database file
- Page 154 and 155: 144 File Management V4R5 v Two adja
Date, time, and timestamp fields used by record keys (FROMKEY<br />
and TOKEY)<br />
When the number of key fields and a value are used to specify the FROMKEY or<br />
TOKEY parameter, no conversion of data occurs if the corresponding key field in<br />
the from-file is a date, time, or timestamp field. The user input string that you<br />
specify (including the separators) must be in the same format as the date, time, or<br />
timestamp field. If it is not, a file open error may occur, or the records copied may<br />
not be the desired result.<br />
If *BLDKEY is specified for the FROMKEY or TOKEY parameter and the<br />
corresponding key field in the from-file is a date, time, or timestamp field, the<br />
system attempts to convert the user-input key field value to the format (and<br />
separators) of the from-file field. The following rules apply to the conversion:<br />
v If the from-field is a date key field, the system first determines if the<br />
user-input key value is in the same format and has the same separator as<br />
specified in the current job under which the copy command is running. This can<br />
be *MDY, *DMY, *YMD, or *JUL for the format and slash (/), hyphen (-), period<br />
(.), comma (,), or blank ( ) for the separator. If the user-input key value is not in<br />
the current job specified format and separator form, it determines if it is in one<br />
of the Systems Application Architecture (SAA) formats (*ISO, *USA, *EUR, or<br />
*JIS). It also determines if it is in a YYYYDDD form (no separator). If the system<br />
can determine the user-input key value is in one of these forms, the input string<br />
is converted to the actual format (and separator) of the from-file date field,<br />
which is used for the key comparison. If the user-input string format cannot be<br />
determined or the length or data value is not valid, the system issues a<br />
diagnostic message. You must left-justify the date portion of the user-input key<br />
value; it can contain trailing blanks.<br />
v If the from-field is a time key field, the system first determines if the<br />
user-input key value is in the same format and has the same separator as<br />
specified in the current job under which the copy command is running. This<br />
may be HHMMSS for the format and colon (:), comma (,), period (.), or blank ( )<br />
for the separator. If the user-input key value is not in the current job specified<br />
format and separator form, the system determines if it is in one of the SAA<br />
formats (*ISO, *USA, *EUR, or *JIS). If the system can determine the user-input<br />
key value is in one of these forms, the input string is converted to the actual<br />
format (and separator) of the from-file time field, which is used for the key<br />
comparison. If the user-input string format cannot be determined, or the length<br />
or data value is not valid, the system issues a diagnostic message. You must<br />
left-justify the time portion of the user-input key value; it can contain trailing<br />
blanks.<br />
v If the from-field is a timestamp key field, the system first determines if the<br />
user-input key value is in the SAA format or YYYYMMDDHHMMSS form. If<br />
the system determines the user-input key value is in one of these forms, the<br />
input string is converted to the actual SAA timestamp format, which is used for<br />
the key comparison. If the user-input string format cannot be determined, or the<br />
length or data value is not valid, the system issues a diagnostic message. You<br />
must left-justify the timestamp portion of the user-input key value; it can contain<br />
trailing blanks.<br />
Null-capable fields used by record keys (FROMKEY and TOKEY)<br />
When you use the number of key fields and a value to specify the FROMKEY or<br />
TOKEY parameter, the copy command ignores the null values. The command uses<br />
only the buffer default values for values that are actually null for the comparison.<br />
Chapter 4. Copying files 97