RPG/400 Help

MOVEA (Move Array)

*---------*---------------*-----------------*----------------*---------------*
|   CODE  |    FACTOR 1   |     FACTOR 2    |     RESULT     |  INDICATORS   |
|         |               |                 |      FIELD     |               |
*---------*---------------*-----------------*----------------*---------------*
| MOVEA   |               | Source field    | Target field   |    + - ZB     |
| (P)     |               |                 |                |               |
*---------*---------------*-----------------*----------------*---------------*

The MOVEA operation transfers character or numeric values from factor 2 to the result field. (Certain restrictions apply when moving numeric values.) Factor 2 or the result field must contain an array. Factor 2 and the result field cannot specify the same array even if the array is indexed.

You can use MOVEA with a packed, binary, zoned, or character array. You can:

Movement of data starts with the first element of an array if the array is not indexed or with the element specified if the array is indexed. The movement of data ends when the last array element is moved or filled. When the result field contains the indicator array, all indicators affected by the MOVEA operation are noted in the cross-reference listing.

The coding for and results of MOVEA operations are shown in Figure "MOVEA Operation". See Character MOVEA Operations and Numeric MOVEA Operations for more information.

Character MOVEA Operations

Both factor 2 and the result field must be defined as character.

On a character MOVEA operation, movement of data ends when the number of characters moved equals the shorter length of the fields specified by factor 2 and the result field; therefore, the character MOVEA operation could end in the middle of an array element.

Numeric MOVEA Operations

Moves are only valid between fields and array elements with the same numeric length defined. Factor 2 and the result field entries can specify numeric fields, numeric array elements, or numeric arrays; at least one must be an array or array element. The numeric types can be binary, packed decimal, or zoned decimal but need not be the same between factor 2 and the result field.

Factor 2 can contain a numeric literal if the result field entry specifies a numeric array or numeric array-element:

Decimal positions are ignored during the move and need not correspond. Numeric values are not converted to account for the differences in the defined number of decimal places.

The figurative constants *BLANK, *ALL, *ON and *OFF are not valid in factor 2 of a MOVEA operation on a numeric array.

General MOVEA Operations

If you need to use a MOVEA operation in your application, but restrictions on numeric MOVEA operations prevent you, you might be able to use character MOVEA operations. If the numeric array is in zoned decimal format:

If a figurative constant is specified with MOVEA, the length of the constant generated is equal to the portion of the array specified. For figurative constants in numeric arrays, the element boundaries are ignored except for the sign that is put in each array element. Examples are:

Note that the results of MOVEA are different from those of the MOVE example above.

For both character and numeric MOVEA operations, you can specify a P in position 53 to pad the result from the right.

For further information on the MOVEA operation, see Move Operations.

Figure 39. MOVEA Operation

*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C                     MOVEAARRX      ARRY
C*  Array-to-array move.  No indexing; different length array,
C*  same element length.
            ARRX                              ARRY
    |1|2|3|4|5|6|7|8|9|0|  Before |A|A|B|B|C|C|D|D|E|E|F|F|
    *-*-*-*-*-*-*-*-*-*-*  MOVEA  *-*-*-*-*-*-*-*-*-*-*-*-*
     | |                           | |
     ***                           ***
      |                             |
     One Element                   One Element
      |                             |
     ***                           ***
     | |                           | |
    |1|2|3|4|5|6|7|8|9|0|  After  |1|2|3|4|5|6|7|8|9|0|F|F|
    *-*-*-*-*-*-*-*-*-*-*  MOVEA  *-*-*-*-*-*-*-*-*-*-*-*-*
    |                   |         |                   |
    *-------------------*         *-------------------*
              |                             ^
              *-----------------------------*
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C                     MOVEAARRX      ARRY,3
C*  Array-to-array move with index result field.
            ARRX                              ARRY
    |1|2|3|4|5|6|7|8|9|0|  Before |A|A|B|B|C|C|D|D|E|E|
    *-*-*-*-*-*-*-*-*-*-*  MOVEA  *-*-*-*-*-*-*-*-*-*-*
     | |                           | |
     ***                           ***
      |                             |
     One Element                   One Element
      |                             |
     ***                           ***
     | |                           | |
    |1|2|3|4|5|6|7|8|9|0|  After  |A|A|B|B|1|2|3|4|5|6|
    *-*-*-*-*-*-*-*-*-*-*  MOVEA  *-*-*-*-*-*-*-*-*-*-*
    |           |                         |           |
    *-----------*                         *-----------*
          |                                     ^
          *-------------------------------------*
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C                     MOVEAARRX      ARRY
C*  Array-to-array move, no indexing and different length array
C*  elements.
            ARRX                              ARRY
    |1|2|3|4|5|6|7|8|9|0|  Before |A|A|A|B|B|B|C|C|C|D|D|D|
    *-*-*-*-*-*-*-*-*-*-*  MOVEA  *-*-*-*-*-*-*-*-*-*-*-*-*
     | |                           |   |
     ***                           *-*-*
      |                              |
     One Element                   One Element
      |                              |
     ***                           *-*-*
     | |                           |   |
    |1|2|3|4|5|6|7|8|9|0|  After  |1|2|3|4|5|6|7|8|9|0|D|D|
    *-*-*-*-*-*-*-*-*-*-*  MOVEA  *-*-*-*-*-*-*-*-*-*-*-*-*
    |                   |         |                   |
    *-------------------*         *-------------------*
              |                             ^
              *-----------------------------*
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C                     MOVEAARRX,4    ARRY
C*  Array-to-array move, index factor 2 with different length array
C*  elements.
            ARRX                              ARRY
    |1|2|3|4|5|6|7|8|9|0|  Before |A|A|A|B|B|B|C|C|C|D|D|D|
    *-*-*-*-*-*-*-*-*-*-*  MOVEA  *-*-*-*-*-*-*-*-*-*-*-*-*
     | |                           |   |
     ***                           *-*-*
      |                              |
     One Element                   One Element
      |                              |
     ***                           *-*-*
     | |                           |   |
    |1|2|3|4|5|6|7|8|9|0|  After  |7|8|9|0|B|B|C|C|C|D|D|D|
    *-*-*-*-*-*-*-*-*-*-*  MOVEA  *-*-*-*-*-*-*-*-*-*-*-*-*
                |       |         |       |
                *-------*         *-------*
                    |                 ^
                    *-----------------*
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C                     MOVEAFIELDA    ARRY
C*  Field-to-array move, no indexing on array.
            FIELDA                            ARRY
    |1|2|3|4|5|6|7|        Before |9|8|6|5|4|3|2|1|0|A|B|C|
    *-*-*-*-*-*-*-*        MOVEA  *-*-*-*-*-*-*-*-*-*-*-*-*
                                   |   |
                                   *-*-*
                                     |
                                   One Element
                                     |
                                   *-*-*
                                   |   |
    |1|2|3|4|5|6|7|        After  |1|2|3|4|5|6|7|1|0|A|B|C|
    *-*-*-*-*-*-*-*        MOVEA  *-*-*-*-*-*-*-*-*-*-*-*-*
    |             |               |             |
    *-------------*               *-------------*
           |                             ^
           *-----------------------------*
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C* In the following example, N=3.  Array-to-field move with variable
C* indexing.
C                     MOVEAARRX,N    FIELD
C*
            ARRX                                FIELD
    |0|1|0|A|0|2|0|B|0|3|0|C|   Before    |0|1|0|A|
    *-*-*-*-*-*-*-*-*-*-*-*-*   MOVEA     *-*-*-*-*
     | |
     ***
      |
     One Element
      |
     ***
     | |
    |0|1|0|A|0|2|0|B|0|3|0|C|   After      |0|2|0|B|
    *-*-*-*-*-*-*-*-*-*-*-*-*   MOVEA      *-*-*-*-*
            |       |                      |       |
            *-------*                      *-------*
                |                              ^
                *------------------------------*
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C                     MOVEAARRB      ARRZ
C*
C* An array-to-array move showing numeric elements.
      |1.0 |1.1 |1.2 |1.3|  Before MOVEA  |2.0 |3.0 |4.0 |5.0 |6.0|
      *-*--*----*----*---*                *-*--*----*----*----*---*
        One Element                         One Element
        |                                   |
        |                                   |
      |1.0 |1.1 |1.2 |1.3|  After MOVEA   |1.0 |1.1 |1.2 |1.3 |6.0|
      *----*----*----*---*                *----*----*----*----*---*
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C                     MOVEAARRX      ARRY      P
C*  Array-to-array move.  No indexing; different length array with
C*  same element length.
            ARRX                              ARRY
    |1|2|3|4|5|6|7|8|9|0|  Before |A|A|B|B|C|C|D|D|E|E|F|F|
    *-*-*-*-*-*-*-*-*-*-*  MOVEA  *-*-*-*-*-*-*-*-*-*-*-*-*
     | |                           | |
     ***                           ***
      |                             |
     One Element                   One Element
      |                             |
     ***                           ***
     | |                           | |
    |1|2|3|4|5|6|7|8|9|0|  After  |1|2|3|4|5|6|7|8|9|0| | |
    *-*-*-*-*-*-*-*-*-*-*  MOVEA  *-*-*-*-*-*-*-*-*-*-*-*-*
    |                   |         |                   |
    *-------------------*         *-------------------*
              |                             ^
              *-----------------------------*
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C                     MOVEAARRB      ARRZ      P
C*
C* An array-to-array move showing numeric elements with padding.
      |1.0 |1.1 |1.2 |1.3|  Before MOVEA  |2.0 |3.0 |4.0 |5.0 |6.0|
      *-*--*----*----*---*                *-*--*----*----*----*---*
        One Element                         One Element
        |                                   |
        |                                   |
      |1.0 |1.1 |1.2 |1.3|  After MOVEA   |1.0 |1.1 |1.2 |1.3 |0.0|
      *----*----*----*---*                *----*----*----*----*---*
*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C                     MOVEAARRX,3    ARRY      P
C*  Array-to-array move.  No indexing; different length array with
C*  same element length.
            ARRX                              ARRY
    |P|P|P|Q|Q|Q|R|R|R|       Before |A|A|B|B|C|C|D|D|E|E|F|F|
    *-*-*-*-*-*-*-*-*-*       MOVEA  *-*-*-*-*-*-*-*-*-*-*-*-*
     |   |                            | |
     *-*-*                            ***
       |                               |
     One Element                   One Element
       |                               |
     *-*-*                            ***
     |   |                            | |
    |P|P|P|Q|Q|Q|R|R|R|       After  |R|R|R| | | | | | | | | |
    *-*-*-*-*-*-*-*-*-*       MOVEA  *-*-*-*-*-*-*-*-*-*-*-*-*
    |                 |              |                   |
    *-----------------*              *-------------------*
             |                                ^
             *--------------------------------*


[ Top of Page | Previous Page | Next Page | Table of Contents ]