You are here: LANSA for i User Guide > Appendix A. Virtual Fields > Examples of Virtual Fields & Derivation Code > Example 3: Converting a Date of Birth to an Age

Example 3: Converting a Date of Birth to an Age

An employee master file contains field EMPDOB (date of birth). Using existing program GETAGE (convert date to age) derive virtual fields AGEYER (age in years) and AGEMON (age in months).

Step 1 - Define the Virtual Fields

 

 

     Seq    Name_________ Description______________________

      10    AGEYER        Age in years

      20    AGEMTH        Age in months

 

 

Step 2 - Input RPG Section "Calculations After Input from File"

C*

C* VC_USING FIELDS(EMPDOB AGEYER AGEMTH)

C*

C                     CALL 'GETAGE'

C                     PARM           EMPDOB

C                     PARM           AGEYER

C                     PARM           AGEMTH