6.4.3 Virtual Fields

Virtual fields allow you to significantly reduce your application code by centralizing the manipulation of data that is repeated in many applications.

A virtual field does not physically exist in the file. If you were to display the contents of the file, you would not see the virtual fields. To a program, whether a client or IBM i program, the field appears to be part of the file, however, the value is derived when the record is input or output from the file. With virtual fields, you could:

In each case, code is removed from the application. Maintenance is only required in one place. A calculation is always the same, regardless of where it is used.

A virtual field must be defined in the Repository and may have field and file level validations associated with it. Validation rules for the fields used in defining the virtual field are still enforced.

Virtual fields can be used like any other Repository field, except that:

For more information, refer to Virtual Fields the LANSA for i User Guide.