COBOL Move Reference Modification

COBOL Move Corresponding COBOL Selective Program Construction

Advertisements


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.


  1. In move reference modification first position indicates the starting position.
  2. Second position indicates the length of the variable.

MOVE reference modification must not refer the Boolean items.

In MOVE reference modification, 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.

In MOVE reference modification, the sending field length is greater than the receiving field the data will be moved to receiving data field based on the data type.

In MOVE reference modification; if the sending data item has numeric then the receiving data item should be numeric and alphanumeric in the particular positions.

In MOVE reference modification; if the sending data item has alphabetic/alpha-numeric then the receiving data item should be alphabetic/alpha-numeric in the particular positions.


Syntax:

MOVE sending-field TO receiving-field (starting-position: length).

In MOVE reference modification, starting position and length should be numeric values.


Practical Example:


Code:



In the above example, COUNTRY-CODE, STATE-CODE and PHN-NUMBER is declared as elementary items and those will be combined together to get full phone number in a single data item.

COUNTRY-CODE, STATE-CODE and PHN-NUMBER initialized during the declaration.

We can combine the above inputs by using move reference modification like below.


MOVE COUNTRY-CODE	TO FULL-PHN-NBR (1:2)

The above statement will move COUNTRY-CODE to first two bytes of FULL-PHN-NBR.


MOVE STATE-CODE		TO FULL-PHN-NBR (3:2)

The above statement will move STATE-CODE to FULL-PHN-NBR from 3rd byte to 5th byte.


MOVE PHN-NUMBER		TO FULL-PHN-NBR (5:8)

The above statement will move PHN-NUMBER to FULL-PHN-NBR from 5th byte to 12th byte.


Output:



COBOL Move Corresponding COBOL Selective Program Construction

Advertisements