COBOL Corresponding MoveCOBOL Group Move COBOL Move Reference Modification
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.
MOVE CORRESPONDING will not affect the elementary items in the sending or receiving records which are not matching.
MOVE CORRESPONDING will automatically searches for the corresponding elementary items to move the data from sending item to receiving item.
In MOVE CORRESPONDING, 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 CORRESPONDING, 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 CORRESPONDING, if the sending data item has numeric then the receiving data item should be numeric and alphanumeric in the particular positions.
In MOVE CORRESPONDING, if the sending data item has alphabetic/alpha-numeric then the receiving data item should be alphabetic/alpha-numeric in the particular positions.
MOVE CORRESPONDING sending-field TO receiving-field.
In the above example, FULL-NAME declared as of length 30 with three elementary items FIRST-NAME, MIDDLE-NAME and LAST-NAME of length 10 each.
Similarly FULL-NAME-REV is declared with same length 30 with three elementary items in the order LAST-NAME, MIDDLE-NAME and FIRST-NAME of length 10 which are the reverse order of FIRST-NAME.
The input is accepted from SYSIN for the three elementary items.
After all ACCEPT statements executed, the values of elementary items will be
FIRST-NAME will have MAINFRAMES MIDDLE-NAME will have TECH LAST-NAME will have HELP
To move the elementary items to another group item, we need three simple move statements.
This one can be accomplished by using a CORRESPONDING MOVE likes below.
MOVE CORRESPONDING FULL-NAME TO FULL-NAME-REV.
The above move statement will do the below tasks
- Moving FIRST-NAME of FULL-NAME to FIRST-NAME of FULL-NAME-REV
- Moving MIDDLE-NAME of FULL-NAME to MIDDLE-NAME of FULL-NAME-REV
- Moving LAST-NAME of FULL-NAME to LAST-NAME of FULL-NAME-REV
COBOL Group Move COBOL Move Reference Modification