Elementary move rules
Any necessary conversion of data from one form of internal representation to another takes place during the move, along with any specified editing in, or de-editing implied by, the receiving item. The code page used for conversion to or from alphanumeric characters is the one in effect for the CODEPAGE compiler option when the source code was compiled.
The following rules outline the execution of valid elementary moves. When the receiving field is:
Alphabetic:
- Alignment and any necessary space filling or truncation occur as described under Alignment rules.
- If the size of the sending item is greater than the size of the receiving item, excess characters on the right are truncated after the receiving item is filled.
Alphanumeric or alphanumeric-edited:
- If the sending item is a national decimal integer item, the sending data is converted to usage DISPLAY and treated as though it were moved to a temporary data item of category alphanumeric with the same number of character positions as the sending item. The resulting alphanumeric data item is treated as the sending item.
- Alignment and any necessary space filling or truncation take place, as described under Alignment rules.
- If the receiving item is a dynamic-length elementary item, the length of the receiver is set to the minimum of the length of the sender or the specified or implied value of the LIMIT phrase. If the length of the sending item is greater than the length of the receiving item, then excess characters on the right are truncated after the receiving item is filled.
- For items that are not dynamic-length elementary items, if the size of the sending item is greater than the size of the receiving item, excess characters on the right are truncated after the receiving item is filled.
- If the initial sending item has an operational sign, the unsigned value is used. If the operational sign occupies a separate character, that character is not moved, and the size of the sending item is considered to be one less character than the actual size.
DBCS:
- If the sending and receiving items are not the same size, the sending data is either truncated on the right or padded with DBCS spaces on the right.
External floating-point:
- For a floating-point sending item, the floating-point value is converted to the usage of the receiving external floating-point item (if different from the sending item's representation).
- For other sending items, the numeric value is treated as though that value were converted to internal floating-point and then converted to the usage of the receiving external floating-point item.
Internal floating-point:
- When the category of the sending operand is not internal floating-point, the numeric value of the sending item is converted to internal floating-point format.
National or national-edited:
- If the representation of the sending item is not national characters, the sending data is converted to national characters and treated as though it were moved to a temporary data item of category national of a length not to cause truncation or padding. The resulting category national data item is treated as the sending data item.
- If the representation of the sending item is national characters, the sending data is used without conversion.
- Alignment and any necessary space filling or truncation take place as described under Alignment rules. The programmer is responsible for ensuring that multiple encoding units that together form a graphic character are not split by truncation.
- If the sending item has an operational sign, the unsigned value is used. If the operational sign occupies a separate character, that character is not moved, and the size of the sending item is considered to be one less character than the actual size.
UTF-8:
- If the representation of the sending item is not UTF-8 characters, the sending data is converted to UTF-8 characters and treated as though it were moved to a temporary data item of category UTF-8 of a length not to cause truncation or padding. The resulting category UTF-8 data item is treated as the sending data item.
- If the representation of the sending item is UTF-8 characters, the sending data is used without conversion.
- Alignment and any necessary space filling or truncation take place as described under Alignment rules. The programmer is responsible for ensuring that multiple encoding units that together form a graphic character are not split by truncation.
- If the sending item has an operational sign, the unsigned value is used. If the operational sign occupies a separate character, that character is not moved, and the size of the sending item is considered to be one less character than the actual size.
Numeric or numeric-edited:
- Except when zeros are replaced because of editing requirements, alignment by decimal point and any necessary zero filling take place, as described under Alignment rules.
- If the receiving item is signed, the sign of the sending item is placed in the receiving item, with any necessary sign conversion. If the sending item is unsigned, a positive operational sign is generated for the receiving item.
- If the receiving item is unsigned, no operational sign is generated for the receiving item and the absolute value of the sending item is used in the move.
- When the category of the sending item is alphanumeric, alphanumeric-edited, national, or national-edited, the data is moved as if the sending item were described as an unsigned integer.
- When the sending item is floating-point, the data is first converted to either a binary or internal decimal representation and is then moved.
- When the receiving item is numeric-edited, editing takes place as defined by the picture character string or BLANK WHEN ZERO clause associated with the receiving item.
- When the sending item is numeric-edited, the compiler de-edits the sending data to establish the unedited value of the numeric-edited item (this value can be signed). The unedited numeric value is used in the move to the receiving numeric or numeric-edited data item.
Usage notes:
- If the receiving item is of category alphanumeric, alphanumeric-edited, numeric-edited, national, or national-edited and the sending field is numeric, any digit positions described with picture symbol P in the sending item are considered to have the value zero. Each P is counted in the size of the sending item.
- If the receiving item is numeric and the sending field is an alphanumeric literal, a national literal, or an ALL literal, all characters of the literal must be numeric characters.