Reference Modification With OF
COBOL Reference Modification With OF
Syntax to use reference modification for a filed, which exists in multiple groups.
01 ww-grp1 03 name1 pic x(10) 03 sal pic 9(4) 01 ww-grp2 03 name1 pic x(10) 03 sal pic 9(4)
name1 exists in both groups. So if we want to use reference modification for ww-grp1
move name1 of ww-grp1(1:4) to var1
move name1(1:4) of ww-grp1 to WW-var1
Above one will not work as it is not correct syntactically.
Basic details of Ref. Modification:
This is used to move a partial value from one variable in to another variable. For example if in a variable declared as a FULL-Name in which first 10 characters are of First-Name and last 10 characters are of Last-Name, then if only first name needs to be moved into another field. it can be done using ref. modification without changing the declaration of the field.
MOVE FUL-NAM(1:10) TO FRST-NAM MOVE FUL-NAM(10:10) TO LST-NAM
2nd statement can also be coded like
MOVE FUL-NAM(10:) TO LAST-NAM.
In this case starting from 10th position remaining part would be moved to destination.
For more details and syntax go thru the official IBM pages @