You are here: LANSA for i User Guide > 3. Files > 3.15 Virtual Fields > 3.15.3 Virtual Fields Maintenance

3.15.3 Virtual Fields Maintenance

This screen is displayed when:



 DC@P201601     MMMMMMM                     




 Edit virtual field derivation code . . . . . . ___  YES, NO     




   Sequence Name     Description                       Definition  PJF 

                     PJF's before virtuals derived on input


                    Virtual Fields derived after input 


                    PJF's after virtuals derived after input


                    Virtual Fields derived before output 


                    Undefined Virtual Fields




 Fnn=Help Fnn=Exit Fnn=Add/Create Fnn=Cancel Fnn=Change Fnn=Delete  




Note: MMMMMMM on line 2 indicates mode as Display, Add, Change or Delete.

Working from the Virtual Fields in File Definition screen you can:

Remember that virtual field names can be specified in full, partially or chosen from the data dictionary (by entering a "?").

Note: On this screen virtual fields and Predetermined Join Fields are grouped according to when they are retrieved or derived with appropriate headings. It is important to understand this order as you may wish to use Predetermined Join Fields to derive virtual fields or to use virtual fields as keys on access routes to retrieve Predetermined Join Fields. If a virtual field is defined as derived 'after input from file' and 'before output to file', it will only appear once in the list in the 'after input from file' group. The Predetermined Join Fields cannot be added, changed, or deleted from this screen. They can only be maintained via the access route maintenance screens described in the section in this manual on access routes and Predetermined Join Fields.

Input Options

These input options apply when specifying the virtual fields in a file definition:

Edit Virtual Field Derivation Code?

This field is used to indicate that the RPG/400 source code used to derive the virtual fields is to be reviewed or edited.

Enter YES to edit the RPG/400 source code. The resulting display is described in detail in the following sections.

Leave blank or enter NO if you do not wish to review or edit the RPG/400 source code.


Specifies the sequence/order of the virtual field relative to other virtual fields in the file. Use numbers in the range 1 to 99999 to indicate the order that fields should be included into the file definition.

Virtual fields and Predetermined Join Fields are grouped according to when they are retrieved or derived. This is flagged on the virtual field definition and on the access route on which Predetermined Join Fields are defined. The sequence number for virtual fields only applies within the group they are listed. To move virtual fields or Predetermined Join Fields from one group to another, the flags on the virtual field definition or access route definition must be changed.

Note: If a virtual field is flagged as derived both 'after input' and 'before output', it only appears once in the 'after input' group.

When no sequence number is specified, sequence 99999 is assumed. When fields are assigned the same sequence number they are sub- ordered by the order in which they are specified on the screen.

Field Name

Specifies the name of a field that is to be included in the file definition as a virtual field. Any field nominated here must have been already been defined in the LANSA data dictionary. By entering a partial name, '?' or sequence number with a blank field name the multiple field selection screen is displayed. The selection list will be built from the fields in the LANSA data dictionary. A maximum of 30 fields can be selected at a time. Refer to 3.10.1 Select Fields When Working from File Definition Menu for more details.

Review/Change Extended Definition

Provides the option to elect whether the extended definition of a virtual field can be reviewed or changed. This option is only available when "virtual" fields have been selected for change or creation.

If a value has been entered in the extended definition field against a virtual" field and an extended definition type has already been specified for the virtual field then the relevant screen will be displayed, these screens are described in more detail later on in this section.

If no extended definition types exist for the field, the user will be prompted with an "Action Box" from which one of these options can be selected to generate "virtual" code automatically:

The Action Box that will provide these options is as follows:



            /  Virtual Field Extended Definitions   \     

            :                                       :     

            :  Use cursor to select an option       :     

            :   Substringing                        :     

            :   Concatenation                       :     

            :   Mathematical calculations           :     

            :   Date conversion                     :     

            :                                       :     

            :  Then use cursor to initiate action   :     

            :   Perform selected request            :     

            :   Return to previous screen           :     

            : F1=Help   Fnn=Cancel   F14=Messages   :     





If an option has been selected then the relevant screen will be displayed, these screens are described in more detail later in this section.

Note: The mathematical calculation option will only be available if the selected virtual field is numeric.

In addition, any field nominated as a virtual field must not have been defined as a "real" field in this file definition. Refer to elsewhere for details of how "real" fields are defined in a file definition.


This display-only column indicates that the field is a Predetermined Join Field retrieved before (B) virtual fields which are derived after input from file, or after (A) virtual fields which are derived after input from file, or is a virtual field which is undefined (U).

Virtual Field Extended Definitions

The Virtual field extended definition function allows you to derive virtual fields from real fields and vice versa by mapping data using the Substringing, Concatenation and Date conversion options. It also allows you to perform mathematical calculations to derive a resulting virtual field.

This function dramatically reduces the requirement and dependence of RPG/400 programming skills for specifying RPG/400 code to derive virtual fields, the four extended definition options available - substringing, concatenation, mathematical calculation and date conversion are the most common cases used to derive virtual fields and should be used wherever possible to derive the resulting virtual field. It is recommended that you only use RPG/400 code to derive virtual fields where the already defined options cannot produce the desired result.

Each one of the virtual field extended definition options is described in more detail in:

3.15.4 Substringing of a Field/Record

3.15.5 Concatenation of Field(s)

3.15.6 Mathematical Calculation of a Field

3.15.7 Date Conversion of a Field.