These examples apply to specifying virtual fields in a file definition. They do not demonstrate how the associated RPG derivation code would be specified.
Refer to the Examples of Virtual Fields & Derivation Code for more comprehensive examples of the virtual field facility.
Define three virtual fields called COMPNO, DIVNUM and COSTCT:
Seq
Field
Description
1
COMPNO
Company number
2
DIVNUM
Division number
3
COSTCT
Cost center
Define two virtual fields called YYMMDD and MONTH:
Seq
Field
Description
10
YYMMDD
Date in format YYMMDD
20
MONTH
Month of the year