4.4.5 Input or Output Virtual Fields
When using virtual fields in LANSA it is very important to understand and properly define when the virtual field is derived. For example, you can use virtual fields as output only to display information, such as a date in a different format. Or, you can use virtual fields as input fields which will determine what value is written to the real field in the file. Understanding when a virtual field is derived becomes even more important once predetermined join fields and triggers are introduced. A field can be specified as both on input and before output.
Derive value when record is read = DISPLAY ONLY
The "derive value when record is read" option means that the virtual field is created when you read the information from the file. The information will now be derived and available for display. For example, a date is stored as YYYY/MM/DD so the file can be properly sorted by date, but the information is displayed to the user as DD/MM/YY. This virtual date field would be derived on input, in other words, when you read from the file.
Populate real field when writing to file = UPDATE FILE
The "populate real field when writing to file" option means that information entered in a virtual field will be written out to the file field(s) used to define the real fields. The virtual fields are the user input fields and will write information to a real field in the file. For example, the user enters a date in DD/MM/YY and it is then converted and stored in the file as YY/MM/DD.
To summarize:
- If a virtual field is derived when read, it will be used for display purposes.
- If a virtual field is derived when writing to file, it will be used to update the file.
- If a virtual field is derived for both, it will be used for both display and update purposes.
Also See
Derive value when record is read in the