Version 8.2.2 for Mainframes
 —  Statements  —

MOVE ALL

MOVE ALL

SUBSTRING (operand1,operand3,operand4)
operand1

TO

SUBSTRING (operand2,operand5,operand6)
operand2

[UNTIL operand7] *

* The UNTIL option is not allowed when a SUBSTRING clause is used for the target operand.

This document covers the following topics:

For an explanation of the symbols used in the syntax diagrams below, see Syntax Symbols.

Related Statements: ADD | COMPRESS | COMPUTE | DIVIDE | EXAMINE | MOVE | MULTIPLY | RESET | SEPARATE | SUBTRACT

Belongs to Function Group: Arithmetic and Data Movement Operations


Function

The MOVE ALL statement enables you to move repeatedly the content of operand1 to operand2 until the complete target field is full or the UNTIL value (operand7) is reached.

Using a SUBSTRING Clause, you may limit the MOVE ALL operation to just segments of the source and target field.

Top of page

Syntax Description

Operand Definition Table:

Operand Possible Structure Possible Formats Referencing Permitted Dynamic Definition
operand1 C S A     A U N1       B             yes no
operand2   S A     A U         B             yes yes
operand3 C S           N P I   B2             yes no
operand4 C S           N P I   B2             yes no
operand5 C S           N P I   B2             yes no
operand6 C S           N P I   B2             yes no
operand7 C S           N P I                 yes no

1 A numeric format (N) for operand1 is permitted only when used without the SUBSTRING clause.

2 If operand3/operand5 or operand4/operand6 is a binary variable, it may be used only with a length of less than or equal to 4.

Syntax Element Description:

Syntax Element Description
operand1
Source Operand:

The source operand contains the value to be moved.

All digits of a numeric operand including leading zeros are moved

TO operand2
Target Operand:

The target operand is not reset before the execution of the MOVE ALL operation. This is of particular importance when using the UNTIL option since data previously in operand2 is retained if not explicitly overlaid during the MOVE ALL operation.

UNTIL operand7
UNTIL Option:

The UNTIL option can be used to limit the MOVE ALL operation to a given number of positions in operand2. operand3 is used to specify the number of positions. The MOVE ALL operation is terminated when this value is reached.

If operand7 is greater than the length of operand2, the MOVE ALL operation is terminated when operand2 is full.

The UNTIL option may also be used to assign an initial value to a dynamic variable: if operand2 is a dynamic variable, its length after the MOVE ALL operation will correspond to the value of operand7. The current length of a dynamic variable can be ascertained by using the system variable *LENGTH.

For general information on dynamic variables, see Usage of Dynamic Variables.

Note:
The UNTIL option is not allowed when a SUBSTRING clause is used for the target operand.

SUBSTRING
SUBSTRING Clause:

The SUBSTRING clause enables you to select a fixed segment of the source or target variable in a MOVE ALL statement - whereas, without the SUBSTRING clause, the whole content of the source or target variable is processed.

operand3 and operand4 describe the start position and length of the operand1 segment used as source value. operand5 and operand6 describe the start position and length of the operand2 segment which is filled by the operation. If the start position (operand3 or operand5) is omitted, then position 1 is assumed by default. If the substring length (operand4 or operand6) is omitted, then the remaining length of the field is assumed.

If SUBSTRING is used for the source field, the start value and length (operand3 and operand4) must describe a data segment which is completely inside operand1.

If SUBSTRING is used for the target field the following rules apply:

  • If operand2 is a fixed length variable, the range described by the start-value and length (operand5 and operand6) has completely to reside within the field extent.

  • If operand2 is a dynamic length variable, the start value (operand5) can either point into or immediately behind the current field length (*LENGTH + 1). When the end of the SUBSTRING range is within the allocated field data, the operation is processed in the same way as for a fixed length field. When the SUBSTRING end exceeds the current field size, the dynamic variable is expanded to this extent.

See also Examples of SUBSTRING Clause Usage below.

Examples of SUBSTRING Clause Usage

DEFINE DATA LOCAL
1 ALFA (A10) INIT <'AAAAAAAAAA'>
1 DYN (A) DYNAMIC INIT <'1234567890'>
1 #VAL (A4) INIT <'1234'>
END-DEFINE
Statement
Result
Before
After
MOVE ALL SUBSTRING (#VAL,1,2) TO ALFA AAAAAAAAAA 1212121212
MOVE ALL '123' TO SUBSTRING (ALFA,3,5) AAAAAAAAAA AA12312AAA
MOVE ALL 'x' TO SUBSTRING (DYN,7,3) 1234567890 (*LENGTH=10) 123456xxx0 (*LENGTH=10)
MOVE ALL 'xyz' TO SUBSTRING (DYN,7,6) 1234567890 (*LENGTH=10) 123456xyzxyz (*LENGTH=12)
MOVE ALL 'xyz' TO SUBSTRING (DYN,11,4) 1234567890 (*LENGTH=10) 1234567890xyzx (*LENGTH=14)

Top of page

Example

** Example 'MOAEX1': MOVE ALL                                           
************************************************************************
DEFINE DATA LOCAL                                                       
1 EMPLOY-VIEW VIEW OF EMPLOYEES                                         
  2 PERSONNEL-ID                                                        
  2 FIRST-NAME                                                          
  2 NAME                                                                
  2 CITY                                                                
1 VEH-VIEW VIEW OF VEHICLES                                             
  2 PERSONNEL-ID                                                        
  2 MAKE                                                                
END-DEFINE                                                              
*                                                                       
LIMIT 4                                                                 
RD. READ EMPLOY-VIEW BY NAME                                            
  SUSPEND IDENTICAL SUPPRESS                                            
  /*                                                                    
  FD. FIND VEH-VIEW WITH PERSONNEL-ID = PERSONNEL-ID (RD.)              
    IF NO RECORDS FOUND                                                  
      MOVE ALL '*' TO FIRST-NAME (RD.)        
      MOVE ALL '*' TO CITY (RD.)              
      MOVE ALL '*' TO MAKE (FD.)              
    END-NOREC                                 
    /*                                        
    DISPLAY NOTITLE (ES=OFF IS=ON ZP=ON AL=15)
            NAME (RD.) FIRST-NAME (RD.)       
            CITY (RD.)                        
            MAKE (FD.) (IS=OFF)               
    /*                                        
  END-FIND                                    
END-READ                                      
END                                          

Output of Program MOAEX1:

     NAME         FIRST-NAME         CITY            MAKE      
--------------- --------------- --------------- ---------------
                                                               
ABELLAN         *************** *************** ***************
ACHIESON        ROBERT          DERBY           FORD           
ADAM            *************** *************** ***************
ADKINSON        JEFF            BROOKLYN        GENERAL MOTORS

Top of page