|
COBOL VERBS - MOVE
MOVE Verb
MOVE literal-1/sending-data-item-1 TO receiving-data-item-1.
MOVE is a Cobol verb, when there is a need for transfering value from
one dataitem to another data item, using MOVE verb we can achieve that
task.
In above syntax, value from sending-field-1 will be moved to
receiving-field-1. Sending-filed-1 can a data item OR a literal (string).
Example for move a literal to a numeric data item.
01 WS-A PIC 999 VALUE 000.
....
MOVE 345 TO WS-A.
Before execution of above statement WS-A contains 000 as a value. After
execution of above statement WS-A contains 345.
Example - Move a alphanumeric literal to alpha numeric data item.
01 WS-NAME PIC X(4) VALUE 'JOHN'.
...
MOVE 'JACOB' TO WS-NAME.
Before execution WS-NAME contains value JOHN
Afer execution of MOVE statement, WS-NAME contains JACO.
If you observe only 4 letters from the string JACOB got transfered to WS-NAME
because WS-NAME defined with length of 4 bytes.In alphabetic OR alphanumeric
moves, Receiving fields receive the letters from left to right as shown below.
That is the reason WS-NAME contains JACO
If the receiving field is a numeric data item, data transfer happens from
right to left.
01 WS-A PIC 999 VALUE 890.
01 WS-B PIC 99 VALUE 22.
...
MOVE WS-A TO WS-B.
If numeric data item has any decimal part in it. numeric value after the decimal
will be moved to receiving field from left right. i.e, 1st digist after decimal
movement happens first, then 2nd byte, etc...
|
|