%SIZE Built-In Functions in rpgle
%SIZE function returns the number of bytes occupied by the element.
The argument may be a literal, a named constant, a data structure, a field, an array etc.
For a null value field %SIZE returns full length.
If *ALL is specified as the second parameter for %SIZE, then the elements or occurrences size is also taken into account for array or multiple occurrence data structure
Below can be the possible format of this function:
%SIZE(variable)
%SIZE(array{:*ALL})
%SIZE(table{:*ALL})
%SIZE(multiple occurrence data structure{:*ALL})
Example –%size built-in function in rpgle
Columns . . . : 6 80
SEU==>
FMT D DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++
0001.00 dvar s 5p 0
0002.00 dnum s 5p 0
0003.00 dds1 ds occurs(5)
0004.00 dname 10a
0005.00 daddr 20a
0006.00 c eval num=%size(var)
0007.00 c num dsply
0008.00 c eval num=%size(name)
0009.00 c num dsply
0010.00 c eval num=%size(addr)
0011.00 c num dsply
0012.00 c eval num=%size(ds1)
0013.00 c num dsply
0014.00 c eval num=%size(ds1:*all)
0015.00 c num dsply
0016.00 c seton lr
****************** End of data ********************************************
Output
DSPLY 3
DSPLY 10
DSPLY 20
DSPLY 30
DSPLY 150