Sunteți pe pagina 1din 3

|********************************* TOP OF DATA ********************************|

|
*** MOVE STATEMENT ***
|
|
|
| The MOVE statement is a PROCEDURE DIVISION statement which transfers
|
| data from one area of storage to one or more other areas of storage.
|
|
|
|
Format 1
|
|
-------|
|
MOVE identifier1/literal1 TO identifier2
|
|
|
|
Format 2
|
|
-------|
|
MOVE CORRESPONDING/CORR identifier1 TO identifier2
|
|
|
|
|
| Identifier1/literal1 is the sending area.
|
|
|
| Identifier2 is the receiving area. It may specified as multiple data|
| items in Format 1 in order to specify multiple receiving areas.
|
|
|
| When Format 1 is used, all identifiers may be either elementary or
|
| group items. The data in identifier1/literal1 is moved into each
|
| receiving data item specified by identifier2 (in the order in which the
|
| receiving items are specified).
|
|
|
| When CORRESPONDING is specified (in Format 2), both identifier1 and
|
| identifier2 must be group items. In this case, selected items (i.e.,
|
| those with the same name) in identifier1 are moved to identifier2
|
| (i.e., according to the rules for the CORRESPONDING phrase).
|
|
|
| In Format 2 and in Format 1 when multiple receiving areas are
|
| specified, the results are the same as if multiple MOVE statements had
|
| been coded (i.e., one MOVE statement for each individual receiving data
|
| item).
|
|
|
| Evaluation of the length and evaluation of any subscripting associated
|
| with identifier1 is done only once, immediately before data is moved to
|
| the first of the receiving data items. Length and subscript evaluation
|
| for data items associated with identifier2 are done immediately before
|
| data is moved to the respective receiving data item.
|
|
|
| Evaluation of the length of sending or receiving area may be affected
|
| by the DEPENDING ON phrase of the OCCURS clause.
|
|
|
| A MOVE statement cannot reference an index data item, a pointer data
|
| item, or, for COBOL/370, a procedure-pointer data item.
|
|
|
|
ELEMENTARY MOVES
|
|
|
| An elementary move is one in which both the sending and receiving items
|
| are elementary items. In an elementary move, any necessary conversion
|
| of data from one internal form to another as well as any specified
|
| editing implied by the receiving item is done as part of the execution
|
| of the MOVE statement.
|
|
|
| Special considerations for elementary moves are outlined below. When
|
| the data category of the receiving field is:
|
|
|
|
ALPHABETIC
|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

The data is aligned at the leftmost character position. If the size of


the sending item is less than the size of the receiving item, the
receiving item is padded on the right with blanks. If the size of the
sending item is greater than the size of the receiving item, excess
characters on the right are truncated. (If specified, the JUSTIFIED
clause overrides this rule.)
ALPHANUMERIC or ALPHNUMERIC-EDITED
The data is aligned at the leftmost character position. If the size of
the sending item is less than the size of the receiving item, the
receiving item is padded on the right with blanks. If the size of the
sending item is greater than the size of the receiving item, excess
characters on the right are truncated. (If specified, the JUSTIFIED
clause overrides this rule.)
If the sending item has an operational sign, the unsigned value is
used. If the operational sign occupies a separate character, that
character is not moved and the size of the sending item is considered
to be one less character than the actual size.
NUMERIC or NUMERIC-EDITED
The data is aligned on the decimal point and, if necessary, truncated
or padded with zeros at either end. If no decimal point is specified,
the receiving item is treated as though an assumed decimal point is
specified immediately to the right of the field.
If both the sending and receiving items are signed, then the sign of
the sending item is moved (and converted in format if necessary) to the
receiving item.
If the receiving item is signed but the sending item is not, then a
positive operational sign is generated for the receiving item.
If the receiving item is unsigned, the absolute value of the sending
item is moved and no operational sign is generated for the receiving
item.
When the sending item is alphanumeric, the data is moved as if the
sending item is an unsigned integer.
If the sending field is a non-numeric literal or ALL literal, then all
characters of the literal must be numeric characters.
The table below shows which elementary moves are valid for each
category of data. (YES = Move is valid. NO= Move is not valid.)
RECEIVING CATEGORY
-------------------------------------------------Alpha- Alpha- Alpha- Numeric Numeric Float- DBCS
SENDING CATEGORY betic numeric numeric
Edited ing
-------------------Edited
Point
Alphabetic and SPACE YES

YES

YES

NO

NO

NO

NO

Alphanumeric and
Non-numeric
Literals

YES

YES

YES

YES

YES

NO

YES

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

| Alphanumeric-edited YES
YES
YES
NO
NO
NO
NO
|
|
|
| Numeric integer and NO
YES
YES
YES
YES
YES NO
|
| ZERO
|
|
|
| Numeric Non-integer NO
NO
NO
YES
YES
YES NO
|
| and numeric literals
|
|
|
| Numeric-Edited
NO
YES
YES
YES
YES
YES NO
|
|
|
| Floating-Point
NO
NO
NO
YES
YES
YES NO
|
|
|
| DBCS
NO
NO
NO
NO
NO
NO
YES
|
|
|
|
|
|
GROUP MOVES
|
|
|
| A group move is a move in which either the sending area, the receiving
|
| area, or both areas are group items.
|
|
|
| All group moves are valid. A group move is treated as though it were
|
| an alphanumeric elementary move except that no conversion of data takes
|
| place.
|
|
|
| For more information, see CORRESPONDING PHRASE, OCCURS CLAUSE, DATA
|
| CATEGORIES, JUSTIFIED CLAUSE, and WHEN-COMPILED.
|
|
|
| For the items defined below:
|
|
|
|
05 WS-ITEMA
PIC X(5)
VALUE 'ABCDE'.
|
|
05 WS-ITEMB
PIC X(3)
VALUE SPACES.
|
|
05 WS-ITEMC
PIC X(7)
VALUE 'XXXXXXX'.
|
|
05 WS-ITEMD
PIC 9(5)
VALUE 50.
|
|
05 WS-ITEME
PIC S9(5)V99 VALUE ZERO.
|
|
05 WS-ITEMF
PIC S9(5)V99 VALUE +100.
|
|
05 WS-ITEMG
PIC ZZ,ZZ9.99.
|
|
|
| The results of the following MOVE statements are shown to the right of
|
| the statement:
|
|
New Value In
|
|
Receiving Field
|
|
--------------|
|
|
|
MOVE WS-ITEMA TO WS-ITEMB.
'ABC'
|
|
|
|
MOVE WS-ITEMA TO WS-ITEMC.
'ABCDEbb' (b=space)
|
|
|
|
MOVE WS-ITEMD TO WS-ITEMA.
'00050'
|
|
|
|
MOVE WS-ITEMD TO WS-ITEME.
+50.00
|
|
|
|
MOVE WS-ITEMF TO WS-ITEMG.
'bbb100.00' (b=space)
|
|******************************* BOTTOM OF DATA *******************************|

S-ar putea să vă placă și