class-id MyClass.
working-storage section.
01 volume binary-long private.
property-id Volume binary-long.
getter.
set property-value to volume
setter.
if property-value < 0
set volume to 0
else
set volume to property-value
end-if
end property.
end class.
property-id PropertyReadOnly string.
getter.
set property-value to field-5
end property.
See also the Properties sample, available from Start > All Programs > Micro Focus Studio Enterprise Edition x.x > Samples, under COBOL for .NET .
A property specified using PROPERTY-ID must contain a get or set accessor (or both), using the GETTER and SETTER keywords respectively. The Compiler then generates get_ and set_ methods accordingly.
There are two ways of exposing a field as a property within a COBOL program: