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 1Factor 2Results Field
Entry(Character)ValueDTZ Type
*MDY11/19/7575/323D(*JUL)
*JUL92/11423/04/92D(*DMY)
*YMD14/1/2801/28/2014D(*USA)
*USA12/31/999931.12.9999D(*EUR)
*ISO2036-05-2121/05/36D(*DMY)
*JUL45/33311/29/1945D(*USA)
*USA1:00 PM13.00.00T(*EUR)
*EUR1.10.0711:10:07T(*JIS)
*JIS14:16:1814.16.18T(*HMS)
*ISO24.00.0012:00 AMT(*USA)
Blank1991-09-14-13.12.56.1234561991-09-14-13.12.56.123456Z(*ISO)
*ISO1991-09-14-13.12.56.1234561991-09-14-13.12.56.123456Z(*ISO)

Moving a Numeric Field to a Date-Time Field

Factor 1Factor 2Results Field
Entry(Character)ValueDTZ Type
*MDY11197575/323D(*JUL)
*JUL9211423/04/92D(*DMY)
*YMD14012801/28/2014D(*USA)
*USA1231999931.12.9999D(*EUR)
*ISO2036052121/05/36D(*DMY)
*JUL4533311/29/1945D(*USA)
*MDY03053303.05.33D(*MDY)
*USA*DATE (092195)1995-09-21D(*JIS)
Blank*DATE (092195)1995-09-21D(*JIS)
*MDYUDATE (092195)21.09.1995D(*EUR)
*HMS23125623.12.56T(*ISO)
*EUR11100711.10.07T(*JIS)
*JIS14161814.16.18T(*HMS)
*ISO24000012:00 AMT(*USA)
Blank199109141312561234561991-09-14-13.12.56.123456Z(*ISO)

Moving a Date-Time Field to a Character Field.

Factor 1Factor 2Results Field
Entry(Character)DTZ Type(Character)
*JUL11/19/75D(*MDY)75/323
*USA15.01.28D(*YMD)01/28/2014
*EUR12/31/9999D(*USA)31.12.9999
*USA45/333D(*JUL)11/29/1945
*ISO24.12.56T(*HMS)24.12.56
*EUR11:00 AMT(*USA)11:00:00
*JIS11:10:07T(*EUR)11:10:07
*USA24:00:00T(*ISO)12:00 AM
Blank2045-10-27-23:34.59.123456T(*ISO)12:00 AM

Moving a Date-Time Field to a Numeric Field.

Factor 1Factor 2Results Field
Entry(Character)DTZ Type(Character)
*JUL11/19/75D(*MDY)75323
*USA15.01.28D(*YMD)01282014
*EUR12/31/9999D(*USA)31129999
*USA45/333D(*JUL)11291945
*ISO24.12.56T(*HMS)241256
*EUR11:00 AMT(*USA)110000
*JIS11.10.07T(*EUR)111007
*USA45/333T(*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” ```

See Also

MOVEL

Moving Date-Time Data