3.15.3 Virtual Fields Maintenance
This screen is displayed when:
- Reviewing the virtual fields in a file definition for possible change.
- Defining the virtual fields in a new file definition.
|
Note: MMMMMMM on line 2 indicates mode as Display, Add, Change or Delete.
Working from the Virtual Fields in File Definition screen you can:
- Review the virtual fields already in the file definition.
- Specify details of new virtual fields to be included into the file definition. Use the Add/Create function key to indicate that new fields are to be added to the file definition, then specify details of the new fields.
- Change the sequence of virtual fields already in the file definition. To do this use the Change function key and make all desired changes.
- Delete virtual fields from the file definition. To do this use the Delete function key. The resulting display will request that the virtual field(s) to be deleted should be selected. A final display will then request confirmation that the selected virtual field(s) be deleted. The delete request must be confirmed by entering YES. If YES is not entered no virtual fields will be deleted from the file definition.
- Choose to review/change the extended definition of a virtual field. To do this use the Change function key to enable this option and then select the virtual fields you want to work with.
- Choose to review or edit the RPG/400 source code that is used to derive the virtual fields. To do this enter YES in the request field. The resulting display is described in more detail in the following sections.
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.
Seq
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:
- Substringing
- Concatenation
- Mathematical calculations
- Date conversion
The Action Box that will provide these options is as follows:
|
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.
PJF
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)