COBOL Move Statement

COBOL Unstring COBOL Simple Move

Advertisements


MOVE statement is used to assign a value to a variable from another variable or literal.

MOVE statement actually transfers the data from one memory location to one or more memory location.

In MOVE statement, sending data item should be only one.

In MOVE statement, receiving data item can be more than one.

The sending data item, receiving data item can be a group item or elementary item.

During the MOVE statement execution, the receiving field data completely replaced by sending field data.

During the MOVE statement execution, the sending field length is greater than the receiving field the data will be moved to receiving data field based on the data type.

During the MOVE statement execution, the sending field length is less than the receiving field the remaining length of the receiving field will be filled with ZEROES or SPACES based on the data type declaration.

Mainly MOVE statements are classified into based on its usage in the program.

  1. Simple move.
  2. Group move.
  3. Corresponding move.
  4. MOVE referencing modification.

Simple MOVE:

MOVE statement used to move the data from source to receiving field without any conditions.

In simple MOVE, sending field must be a constant/variable.

The simple MOVE topic explained in detail here

GROUP MOVE:

Group MOVE used to move one group item to another group of similar kind.

Group MOVE also similar to simple MOVE, but used for group variables.

The GROUP MOVE topic explained in detail here

CORRESPONDING MOVE:

The corresponding move also like group move but the values should move corresponding elementary items which are matching.

MOVE CORRESPONDING only affects data-items that have identical names.

The CORRESPONDING MOVE topic explained in detail here

MOVE reference modification:

MOVE reference modification is special purpose and used to move part of data from source field to target field.

MOVE reference modification defines the below two items to move the partial data to target field.

The MOVE reference modification topic explained in detail here

MOVE Combinations:

The below table represents the eligible data types in MOVE statement.

The left side data types represent the source data item type and the top row represents the destination data item.

DATA TYPES

  • NUMERIC
  • NUMERIC EDITED
  • ALPHABETIC
  • ALPHA-NUMERIC
  • ALPHA-NUMERIC EDITED

NUMERIC

  • Y

  • N
  • N
  • Y
  • N

NUMERIC EDITED

  • Y
  • N
  • N
  • Y
  • N

ALPHABETIC

  • N
  • N
  • Y
  • Y
  • Y

ALPHA-NUMERIC

  • Y
  • Y
  • Y
  • Y
  • Y

ALPHA-NUMERIC EDITED

  • Y
  • Y
  • Y
  • Y
  • Y

If any questions on the above, post your queries on Cobol Discussion forum


COBOL Unstring COBOL Simple Move

Advertisements