cobol MOVE statement Some MOVE details, there are many


Example

01 a PIC 9.
01 b PIC 99.
01 c PIC 999.

01 s PIC X(4).

01 record-group.
   05 field-a PIC 9.
   05 field-b PIC 99.
   05 field-c PIC 999.
01 display-record.
   05 field-a PIC Z.
   05 field-b PIC ZZ.
   05 field-c PIC $Z9.

*> numeric fields are moved left to right
*> a set to 3, b set to 23, c set to 123
MOVE 123 TO a b c

*> moves can also be by matching names within groups
MOVE a TO field-a OF record-group
MOVE b TO field-b OF record-group
MOVE c TO field-c OF record-group
MOVE CORRESPONDING record-group TO display-record

*> character data is moved right to left
*> s will be set to xyzz
MOVE "xyzzy" TO s