RPG/400 Help

MOVEL (Move Left)

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

The MOVEL operation transfers characters from factor 2 to the result field. Moving begins with the leftmost character in factor 2. You cannot specify resulting indicators if the result field is an array. You can specify them if the result field is an array element, or a nonarray field.

When data is moved to a numeric field, the sign (+ or -) of the result field is retained except when factor 2 is as long as or longer than the result field. In this case, the sign of factor 2 is used as the sign of the result field.

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

The MOVEL operation is summarized in Figure "MOVEL Operation".

A summary of the rules for MOVEL operation for four conditions based on field lengths:

  1. Factor 2 is the same length as the result field:
    1. If factor 2 and the result field are numeric, the sign is moved with the rightmost position.
    2. If factor 2 is numeric and the result field is character, the sign is moved with the rightmost position.
    3. If factor 2 is character and the result field is numeric, a minus zone is moved into the rightmost position of the result field if the zone from the rightmost position of factor 2 is a hexadecimal D (minus zone). However, if the zone from the rightmost position of factor 2 is not a hexadecimal D, a positive zone is moved into the rightmost position of the result field. Digit portions are converted to their corresponding numeric characters. If the digit portions are not valid digits, a data exception error occurs.
    4. If factor 2 and the result field are character, all characters are moved.
  2. Factor 2 is longer than the result field:
    1. If factor 2 and the result field are numeric, the sign from the rightmost position of factor 2 is moved into the rightmost position of the result field.
    2. If factor 2 is numeric and the result field is character, the result field contains only numeric characters.
    3. If factor 2 is character and the result field is numeric, a minus zone is moved into the rightmost position of the result field if the zone from the rightmost position of factor 2 is a hexadecimal D (minus zone). However, if the zone from the rightmost position of factor 2 is not a hexadecimal D, a positive zone is moved into the rightmost position of the result field. Other result field positions contain only numeric characters.
    4. If factor 2 and the result field are character, only the number of characters needed to fill the result field are moved.
  3. Factor 2 is shorter than the result field:
    1. If factor 2 is either numeric or character and the result field is numeric, the digit portion of factor 2 replaces the contents of the leftmost positions of the result field. The sign in the rightmost position of the result field is not changed.
    2. If factor 2 is either numeric or character and the result field is character data, the characters in factor 2 replace the equivalent number of leftmost positions in the result field. No change is made in the zone of the rightmost position of the result field.
  4. Factor 2 is shorter than the result field and P is specified in the operation extender field:
    1. The move is performed as described above.
    2. The result field is padded from the right. See Move Operations for more information on the rules for padding.

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

MOVEL Example

Figure 40. MOVEL Operation

                   Factor 2 and Result Field Same Length
 
               Factor 2                         Result Field
                       -                                 +
               7 8V4 2 5           Before MOVEL  5 6 7V8 4
a. Numeric    *-*-*-*-*-*                       *-*-*-*-*-*
      to               -                                 -
   Numeric     7 8V4 2 5           After MOVEL   7 8 4V2 5
              *-*-*-*-*-*                       *-*-*-*-*-*
 
 
               7 8V4 2 5           Before MOVEL  A K T 4 D
b. Numeric    *-*-*-*-*-*                       *-*-*-*-*-*
      to               -
   Character   7 8V4 2 5           After MOVEL   7 8 4 2 N
              *-*-*-*-*-*                       *-*-*-*-*-*
                                                         +
               P H 4 S N           Before MOVEL  5 6 7 8 4
c. Character  *-*-*-*-*-*                       *-*-*-*-*-*
      to                                                 -
   Numeric     P H 4 S N           After MOVEL   7 8 4 2 5
              *-*-*-*-*-*                       *-*-*-*-*-*
 
               P H 4 S N           Before MOVEL  A K T 4 D
d. Character  *-*-*-*-*-*                       *-*-*-*-*-*
      to
   Character   P H 4 S N           After MOVEL   P H 4 S N
              *-*-*-*-*-*                       *-*-*-*-*-*
 
                   Factor 2 Longer Than Result Field
 
               Factor 2                         Result Field
                               -                         +
               0 0 0 2 5 8 4 2 5   Before MOVEL  5V6 7 8 4
a. Numeric    *-*-*-*-*-*-*-*-*-*               *-*-*-*-*-*
      to                       -
   Numeric     0 0 0 2 5 8 4 2 5   After MOVEL   0V0 0 2 5
              *-*-*-*-*-*-*-*-*-*               *-*-*-*-*-*
                               -
               9 0 3 1 7 8 4 2 5   Before MOVEL  A K T 4 D
b. Numeric    *-*-*-*-*-*-*-*-*-*               *-*-*-*-*-*
      to                       -
   Character   9 0 3 1 7 8 4 2 5   After MOVEL   9 0 3 1 7
              *-*-*-*-*-*-*-*-*-*               *-*-*-*-*-*
                                                         +
               B R W C X H 4 S N   Before MOVEL  5 6 7 8V4
c. Character  *-*-*-*-*-*-*-*-*-*               *-*-*-*-*-*
      to                                                 -
   Numeric     B R W C X H 4 S N   After MOVEL   2 9 6 3V7
              *-*-*-*-*-*-*-*-*-*               *-*-*-*-*-*
 
               B R W C X H 4 S N   Before MOVEL  A K T 4 D
d. Character  *-*-*-*-*-*-*-*-*-*               *-*-*-*-*-*
      to
   Character   B R W C X H 4 S N   After MOVEL   B R W C X
              *-*-*-*-*-*-*-*-*-*               *-*-*-*-*-*
 
                   Factor 2 Shorter Than Result Field
 
               Factor 2                         Result Field
                       -                                         +
   *-          7 8 4 2 5           Before MOVEL  1V3 0 9 4 3 2 1 0
   |Numeric   *-*-*-*-*-*                       *-*-*-*-*-*-*-*-*-*
   |   to              -                                         +
   |Numeric    7 8 4 2 5           After MOVEL   7V8 4 2 5 3 2 1 0
a.|*          *-*-*-*-*-*                       *-*-*-*-*-*-*-*-*-*
   |                                                             +
   |           C P T 5 N           Before MOVEL  1 3 0 9 4 3 2 1 0
   |Character *-*-*-*-*-*                       *-*-*-*-*-*-*-*-*-*
   *-  to                                                        +
    Numeric    C P T 5 N           After MOVEL   3 7 3 5 5 3 2 1 0
              *-*-*-*-*-*                       *-*-*-*-*-*-*-*-*-*
                       -
   *-          7 8 4 2 5           Before MOVEL  B R W C X H 4 S A
   |Numeric   *-*-*-*-*-*                       *-*-*-*-*-*-*-*-*-*
   |   to              -
   |Character  7 8 4 2 5           After MOVEL   7 8 4 2 N H 4 S A
b.|*          *-*-*-*-*-*                       *-*-*-*-*-*-*-*-*-*
   |
   |           C P T 5 N           Before MOVEL  B R W C X H 4 S A
   |Character *-*-*-*-*-*                       *-*-*-*-*-*-*-*-*-*
   *-  to
    Character  C P T 5 N           After MOVEL   C P T 5 N H 4 S A
              *-*-*-*-*-*                       *-*-*-*-*-*-*-*-*-*
      +                 -
Note: 4 = letter D, and 5 = letter N; arrow V is decimal point.
                   Factor 2 Shorter Than Result Field
                   With P in Operation Extender Field
 
               Factor 2                         Result Field
                       -                                         +
   *-          7 8 4 2 5           Before MOVEL  1V3 0 9 4 3 2 1 0
   |Numeric   *-*-*-*-*-*                       *-*-*-*-*-*-*-*-*-*
   |   to              -                                         +
   |Numeric    7 8 4 2 5           After MOVEL   7V8 4 2 5 0 0 0 0
a.|*          *-*-*-*-*-*                       *-*-*-*-*-*-*-*-*-*
   |                                                             +
   |           C P T 5 N           Before MOVEL  1 3 0 9 4 3 2 1 0
   |Character *-*-*-*-*-*                       *-*-*-*-*-*-*-*-*-*
   *-  to                                                        +
    Numeric    C P T 5 N           After MOVEL   3 7 3 5 5 0 0 0 0
              *-*-*-*-*-*                       *-*-*-*-*-*-*-*-*-*
                       -
   *-          7 8 4 2 5           Before MOVEL  B R W C X H 4 S A
   |Numeric   *-*-*-*-*-*                       *-*-*-*-*-*-*-*-*-*
   |   to              -
   |Character  7 8 4 2 5           After MOVEL   7 8 4 2 N
b.|*          *-*-*-*-*-*                       *-*-*-*-*-*-*-*-*-*
   |
   |           C P T 5 N           Before MOVEL  B R W C X H 4 S A
   |Character *-*-*-*-*-*                       *-*-*-*-*-*-*-*-*-*
   *-  to
    Character  C P T 5 N           After MOVEL   C P T 5 N
              *-*-*-*-*-*                       *-*-*-*-*-*-*-*-*-*
      +                 -
Note: 4 = letter D, and 5 = letter N; arrow V is decimal point.


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