MOVE
Estimated reading time: 5 minutes
Transfers characters from Source to the Target , right-adjusted with optional blanks padded on the left side of the Target .
MOVE
Source (Character Expression)
Target (Character Expression)
Fill (<u>*NOPAD</u> | *PAD)
Pos (Indicator Variable)
Neg (Indicator Variable)
Boz (Indicator Variable)
Type (<u>*NONE</u> | *BINARY | *BOOLEAN | *BYTE | *CHAR | *DECIMAL | *FLOAT | *FLOAT4 | *FLOAT8 | *IND |
*INTEGER | *INTEGER2 | *INTEGER4 | *INTEGER8 | *ONECHAR | *PACKED | *ZONED)
Len (Length Integer, [Decimal Integer])
TimFmt (<u>*NONE</u> | *DMY | *EUR | *HMS | *ISO | *JIS | *JUL | *MDY | *USA | *YMD)
Parameters
Source
Required. If the Source parameter is longer than the Target , the excess leftmost characters of Source are not moved. If the Target is longer than Source , the excess leftmost characters are left untouched, unless padding is specified.
Target
Required. Resulting indicators cannot be specified if the Target is an array. They can be specified if the Target is a non-array field or array element.
Fill
Optional. Specifies if you want to fill, or pad the Target (Target) with blanks. The default is *NOPAD.
- *NOPAD indicates that the Target will not be padded with blanks.
- *PAD indicates that the Target will be padded with blanks.
Pos
Optional only if Target is numeric. Turned on if the value of Target is a positive number.
Neg
Optional only if Target is numeric. Turned on if the value of Target is a negative number.
Boz [Blank or Zero]
Optional. Turned on if the value of Target is blank or zero.
Type
Optional. Can be any of the Types listed. *NONE is the default. See Type Parameter for further information.
Len
Optional. Defines the length of the field. If Len is decimal (3,1) *ZONED is assigned as the default. If Len is character (3), *CHAR is assigned as the default.
Depending upon the Type specified, the Len parameter may be required. For instance, Type *CHAR, *PACKED, and *ZONED will require a Len . A compiler message will display if the Len parameter is needed.
TimFmt
Optional. TimFmt specifies the format for time, date, and timestamp variables. If the TimFmt parameter is not specified, the format specified by the program is assumed.
Remarks
Moving Text from a Control to a Field
When moving text from a control into a field, be aware that the contents is a null-terminated string and does not assume the field length. MOVE and MOVEL operations will move only the number of characters in the string into the field, which may result in extraneous data remaining in the field. Be sure to use Fill(*Pad) in the operation to prevent this.
Moving Date, Time or Timestamp fields
TimFmt must be blank unless either the source or the target is a character or numeric field. Otherwise, TimFmt contains the date or time format compatible with the character or numeric field that is the source or target of the operation.
If Source is *DATE and the result is a Date field, TimFmt is not required. If TimFmt contains a date format it must be compatible with the format of *DATE. See Moving Date-Time Data for more information.
Moving a Character Field to a Date-Time Field
Factor 1 | Factor 2 | Results Field | |
---|---|---|---|
Entry | (Character) | Value | DTZ Type |
*MDY | 11/19/75 | 75/323 | D(*JUL) |
*JUL | 92/114 | 23/04/92 | D(*DMY) |
*YMD | 14/1/28 | 01/28/2014 | D(*USA) |
*USA | 12/31/9999 | 31.12.9999 | D(*EUR) |
*ISO | 2036-05-21 | 21/05/36 | D(*DMY) |
*JUL | 45/333 | 11/29/1945 | D(*USA) |
*USA | 1:00 PM | 13.00.00 | T(*EUR) |
*EUR | 1.10.07 | 11:10:07 | T(*JIS) |
*JIS | 14:16:18 | 14.16.18 | T(*HMS) |
*ISO | 24.00.00 | 12:00 AM | T(*USA) |
Blank | 1991-09-14-13.12.56.123456 | 1991-09-14-13.12.56.123456 | Z(*ISO) |
*ISO | 1991-09-14-13.12.56.123456 | 1991-09-14-13.12.56.123456 | Z(*ISO) |
Moving a Numeric Field to a Date-Time Field
Factor 1 | Factor 2 | Results Field | |
---|---|---|---|
Entry | (Character) | Value | DTZ Type |
*MDY | 111975 | 75/323 | D(*JUL) |
*JUL | 92114 | 23/04/92 | D(*DMY) |
*YMD | 140128 | 01/28/2014 | D(*USA) |
*USA | 12319999 | 31.12.9999 | D(*EUR) |
*ISO | 20360521 | 21/05/36 | D(*DMY) |
*JUL | 45333 | 11/29/1945 | D(*USA) |
*MDY | 030533 | 03.05.33 | D(*MDY) |
*USA | *DATE (092195) | 1995-09-21 | D(*JIS) |
Blank | *DATE (092195) | 1995-09-21 | D(*JIS) |
*MDY | UDATE (092195) | 21.09.1995 | D(*EUR) |
*HMS | 231256 | 23.12.56 | T(*ISO) |
*EUR | 111007 | 11.10.07 | T(*JIS) |
*JIS | 141618 | 14.16.18 | T(*HMS) |
*ISO | 240000 | 12:00 AM | T(*USA) |
Blank | 19910914131256123456 | 1991-09-14-13.12.56.123456 | Z(*ISO) |
Moving a Date-Time Field to a Character Field.
Factor 1 | Factor 2 | Results Field | |
---|---|---|---|
Entry | (Character) | DTZ Type | (Character) |
*JUL | 11/19/75 | D(*MDY) | 75/323 |
*USA | 15.01.28 | D(*YMD) | 01/28/2014 |
*EUR | 12/31/9999 | D(*USA) | 31.12.9999 |
*USA | 45/333 | D(*JUL) | 11/29/1945 |
*ISO | 24.12.56 | T(*HMS) | 24.12.56 |
*EUR | 11:00 AM | T(*USA) | 11:00:00 |
*JIS | 11:10:07 | T(*EUR) | 11:10:07 |
*USA | 24:00:00 | T(*ISO) | 12:00 AM |
Blank | 2045-10-27-23:34.59.123456 | T(*ISO) | 12:00 AM |
Moving a Date-Time Field to a Numeric Field.
Factor 1 | Factor 2 | Results Field | |
---|---|---|---|
Entry | (Character) | DTZ Type | (Character) |
*JUL | 11/19/75 | D(*MDY) | 75323 |
*USA | 15.01.28 | D(*YMD) | 01282014 |
*EUR | 12/31/9999 | D(*USA) | 31129999 |
*USA | 45/333 | D(*JUL) | 11291945 |
*ISO | 24.12.56 | T(*HMS) | 241256 |
*EUR | 11:00 AM | T(*USA) | 110000 |
*JIS | 11.10.07 | T(*EUR) | 111007 |
*USA | 45/333 | T(*JUL) | 11291945 |
Example
** Source is shorter than Result. **
Character to Character
Value1 = "ASNA4ME"
Value2 = "123456784"
Move Value1 Value2
Value2 now = "12ASNA4ME".
**Character to Numeric**
Value1 = "ASNA4ME"
Value2 = 123456784
Move Value1 Value2
Value2 now contains invalid Data for a numeric field.
**Numeric to Numeric**
Value1 = 1278425
Value2 = 123456789
Move Value1 Value2
Value2 now = 121278425.
**Numeric to Character**
Value1 = 1278425
Value2 = "ACFGPH4SN"
Move Value1 Value2
Value2 now = "AC1278425"
``` <br />
**<u>Source is longer than Result.</u>**
Character to Character
Value1 = “ASNA4ME” Value2 = “PH4SN” Move Value1 Value2
Value2 now = “NA4ME”.
Character to Numeric
Value1 = “ASNA4ME” Value2 = 56784 Move Value1 Value2
Value2 now contains invalid Data for a numeric field.
Numeric to Numeric
Value1 = 1278425 Value2 = 56748 Move Value1 Value2
Value2 now = 78425.
Numeric to Character
Value1 = 1278425 Value2 = “ASNA4” Move Value1 Value2
Value2 now = “78425”.
<br /> **<u> Source is shorter than Result with *Pad extension. </u>**
Character to Character
Value1 = “ASNA4ME” Value2 = “123456784” Move Value1 Value2 Fill(*Pad)
Value2 now = // ASNA4ME’.
Character to Numeric
Value1 = “ASNA4ME” Value2 = 123456784 Move Value1 Value2 Fill(*Pad)
Value2 now contains invalid Data for a numeric field.
Numeric to Numeric
Value1 = 1278425 Value2 = 123456789 Move Value1 Value2 Fill(*Pad)
Value2 is now = 1278425.
Numeric to Character
Value1 = 1278425 Value2 = “ACFGPH4SN” Move Value1 Value2 Fill(*Pad)
Value2 now = // 1278425’.
<u>Source and Result are the same length.</u>
Character to Character
Value1 = “ASNA4ME” Value2 = “1234567” Move Value1 Value2
Value2 now = “ASNA4ME”.
Character to Numeric
Value1 = “ASNA4ME” Value2 = 1234567 Move Value1 Value2
Value2 now contains invalid Data for a numeric field.
Numeric to Numeric
Value1 = 1278425 Value2 = 1234567 Move Value1 Value2
Value2 now = 1278425.
Numeric to Character
Value1 = 1278425 Value2 = “ACFGPH4” Move Value1 Value2
Value2 now = “1278425” ```