RPG/400 Help

MOVE (Move)

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

The MOVE operation transfers characters from factor 2 to the result field. Moving starts with the rightmost character of factor 2.

If factor 2 is longer than the result field, the excess leftmost characters of factor 2 are not moved. If the result field is longer than factor 2, the excess leftmost characters in the result field are unchanged, unless padding is specified.

You cannot specify resulting indicators if the result field is an array; you can specify them if it is an array element, or a nonarray field.

If factor 2 is shorter than the length of the result field, a P specified in the operation extender position (position 53) causes the result field to be padded on the left after the move occurs.

For further information on the MOVE operation, see Move Operations. It is summarized in Figure "MOVE Operation".

Move Example

Figure 38. MOVE Operation

                   Factor 2 Shorter Than Result Field
 
               Factor 2                         Result Field
                                                                +
               P H 4 S N           Before MOVE  1 2 3 4 5 6 7 8 4
a. Character  *-*-*-*-*-*                      *-*-*-*-*-*-*-*-*-*
      to       P H 4 S N           After MOVE   1 2 3 4 P H 4 S N
   Character  *-*-*-*-*-*                      *-*-*-*-*-*-*-*-*-*
                                                                +
               P H 4 S N           Before MOVE  1 2 3 4 5 6 7 8 4
b. Character  *-*-*-*-*-*                      *-*-*-*-*-*-*-*-*-*
      to                                                        -
   Numeric     P H 4 S N           After MOVE   1 2 3 4 7 8 4 2 5
              *-*-*-*-*-*                      *-*-*-*-*-*-*-*-*-*
 
               1 2 7 8 4 2 5       Before MOVE  1 2 3 4 5 6 7 8 9
c. Numeric    *-*-*-*-*-*-*-*                  *-*-*-*-*-*-*-*-*-*
      to       1 2 7 8 4 2 5       After MOVE   1 2 1 2 7 8 4 2 5
   Numeric    *-*-*-*-*-*-*-*                  *-*-*-*-*-*-*-*-*-*
 
               1 2 7 8 4 2 5       Before Move  A C F G P H 4 S N
d. Numeric    *-*-*-*-*-*-*-*                  *-*-*-*-*-*-*-*-*-*
      to       1 2 7 8 4 2 5       After MOVE   A C 1 2 7 8 4 2 5
   Character  *-*-*-*-*-*-*-*                  *-*-*-*-*-*-*-*-*-*
 
                   Factor 2 Longer Than Result Field
 
               Factor 2                         Result Field
 
               A C E G P H 4 S N   Before MOVE  5 6 7 8 4
a. Character  *-*-*-*-*-*-*-*-*-*              *-*-*-*-*-*
      to       A C E G P H 4 S N   After MOVE   P H 4 S N
   Character  *-*-*-*-*-*-*-*-*-*              *-*-*-*-*-*
                                                        +
               A C E G P H 4 S N   Before MOVE  5 6 7 8 4
b. Character  *-*-*-*-*-*-*-*-*-*              *-*-*-*-*-*
      to                                                -
   Numeric     A C E G P H 4 S N   After MOVE   7 8 4 2 5
              *-*-*-*-*-*-*-*-*-*              *-*-*-*-*-*
 
               1 2 7 8 4 2 5       Before MOVE  5 6 7 4 8
c. Numeric    *-*-*-*-*-*-*-*                  *-*-*-*-*-*
      to       1 2 7 8 4 2 5       After MOVE   7 8 4 2 5
   Numeric    *-*-*-*-*-*-*-*                  *-*-*-*-*-*
 
               1 2 7 8 4 2 5       Before MOVE  P H 4 S N
d. Numeric    *-*-*-*-*-*-*-*                  *-*-*-*-*-*
      to       1 2 7 8 4 2 5       After MOVE   7 8 4 2 5
   Character  *-*-*-*-*-*-*-*                  *-*-*-*-*-*
                   Factor 2 Shorter Than Result Field
                   With P in Operation Extender Field
 
               Factor 2                         Result Field
                                                                +
               P H 4 S N           Before MOVE  1 2 3 4 5 6 7 8 4
a. Character  *-*-*-*-*-*                      *-*-*-*-*-*-*-*-*-*
      to       P H 4 S N           After MOVE           P H 4 S N
   Character  *-*-*-*-*-*                      *-*-*-*-*-*-*-*-*-*
                                                                +
               P H 4 S N           Before MOVE  1 2 3 4 5 6 7 8 4
b. Character  *-*-*-*-*-*                      *-*-*-*-*-*-*-*-*-*
      to                                                        -
   Numeric     P H 4 S N           After MOVE   0 0 0 0 7 8 4 2 5
              *-*-*-*-*-*                      *-*-*-*-*-*-*-*-*-*
 
               1 2 7 8 4 2 5       Before MOVE  1 2 3 4 5 6 7 8 9
c. Numeric    *-*-*-*-*-*-*-*                  *-*-*-*-*-*-*-*-*-*
      to       1 2 7 8 4 2 5       After MOVE   0 0 1 2 7 8 4 2 5
   Numeric    *-*-*-*-*-*-*-*                  *-*-*-*-*-*-*-*-*-*
 
               1 2 7 8 4 2 5       Before Move  A C F G P H 4 S N
d. Numeric    *-*-*-*-*-*-*-*                  *-*-*-*-*-*-*-*-*-*
      to       1 2 7 8 4 2 5       After MOVE       1 2 7 8 4 2 5
   Character  *-*-*-*-*-*-*-*                  *-*-*-*-*-*-*-*-*-*
 
                   Factor 2 and Result Field Same Length
 
               Factor 2                         Result Field
 
               P H 4 S N           Before MOVE  5 6 7 8 4
a. Character  *-*-*-*-*-*                      *-*-*-*-*-*
      to       P H 4 S N           After MOVE   P H 4 S N
   Character  *-*-*-*-*-*                      *-*-*-*-*-*
 
               P H 4 S N           Before MOVE  5 6 7 8 4
b. Character  *-*-*-*-*-*                      *-*-*-*-*-*
      to                                                -
   Numeric     P H 4 S N           After MOVE   7 8 4 2 5
              *-*-*-*-*-*                      *-*-*-*-*-*
                       -
               7 8 4 2 5           Before MOVE  A L T 5 F
c. Numeric    *-*-*-*-*-*                      *-*-*-*-*-*
      to               -                                -
   Numeric     7 8 4 2 5           After MOVE   7 8 4 2 5
              *-*-*-*-*-*                      *-*-*-*-*-*
 
                       -
               7 8 4 2 5           Before MOVE  A L T 5 F
d. Numeric    *-*-*-*-*-*                      *-*-*-*-*-*
      to               -
   Character   7 8 4 2 5           After MOVE   7 8 4 2 N
              *-*-*-*-*-*                      *-*-*-*-*-*
      +                   -
Note: 4 = letter D ,  and 5 = letter N.


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