MOVE
copies data from source to one or more destination.
MOVE
{data-item or msg.} to {destination data-item}
Source
and destination data item can be single or elementary group of item.
The
source and Destination variable must match or destination bytes must be more
than source bytes so it will occupy source data easily else truncation will
happen.
So
here we have to take precaution for truncation i.e original data will not be
lost it will copies as it is.
By MOVE operation
the OLD value gets erased.
MOVE verb for Numeric MOVE.
In
numeric move your Source and destination variables must declared to handle
numeric data so it must be PIC 9(n) or PIC X(n).
Ex:
01
var1 PIC X(8).
01
Var2 PIC 9(4)
01
Var2 PIC 9(4)v99.
Program:
Now
I am going to compile and RUN above job.
Output:
CONCLUSION:
In numeric move the data movement is
from Right to left so while moving 121 to variable data item which is of 2
bytes the left most data i.e. 1 will be lost.
If the data item has only one byte
i.e 1 but the destination is of 2 bytes so blank byte is zeroed out so output
is 01.
Moving a Numeric data with decimal
point
OUTPUT:
Alphanumeric move:
Here
data is alphanumeric i.e. it contains both Alphabets and numbers as well.
EX:
Avi123
Avinash
PROGRAM:
OUTPUT:
If i want to stores data at RIGHTMOST
side means i have to change the default movement then i will use JUSTIFIED
RIGHT
i.e. BBBBBAVI.
Program:
Output:
MOVE CORRESPONDING
How to move a group data item into
another group data item?
Suppose
i have to group data-item student record
and Department record which has a
common fields so whenever some data is stored in Student record i will move all
to Department record.
MOVE CORRESPONDING option is used for this.
Working-storage section:
PROCEDURE DIVISION:
OUTPUT:
How can i move only elementary data
item from the group?
See
below procedure division i have written for this purpose here i will move only
DOB to DEPT-RECORD.
PROCEDURE DIVISION:
OUTPUT:
No comments:
Post a Comment