Sie sind auf Seite 1von 36


1. Field Types
2. Field conditions
3. Field Usage
4. Access Path
5. Select/Omit criteria
6. Virtual Fields
7. Hands on - Creating fields and Access Paths

Part 1 -Reference Material

Field Types
Field has a Name and a Field Type
Classification depends on the type of
Broadly classified as alphanumeric,
numeric & special field types

Field Type Name Description Type

Length Example
Stock Code
7,0 Date of birth
Idegraphic text A
20 Kanji name
Narrative text
5.0 # of employees
Percentage P
5.2 Profit margin
Price or tarif P
7.2 Unit Price
5.0 Stock quantity
Field based on
7.0 System Key
6.0 Change Time
Descriptive name A
25 Product name
Monetary value P
11.2Stock value
Valid system name
10 File name

Field Usage
Two types: Database fields and Function

Database fields
Code (CDE) fields:- used for key fields e.g.
Company Code
Data attribute (ATR) fields: used for nonkey fields e.g. Company Name

Function fields
These are used only in EDTTRN, DSPTRN, PRTFIL and
PRTOBJ functions
They allow for common arithmetic operations on a subfile
of records in a transaction, or a group of records in a
report's key level
SUM - Summing a field value throughout a subfile
CNT - Counting the records in the subfile
MAX - Returning the maximum value of a field in the
MIN - Returning the Minimum value of a field in the
DRV Contain any amount of processing. Parameters may
be specified. The result of the user-defined calculation, or
USR - Ofers a simple method of adding a work field to a
device design or action diagram. No default processing

Field Conditions
Specifies the values or set of values a field may take
Condition has a Name, a type and an associated value
The two sets of condition types, VAL and LST for STS
fields, and CMP and RNG for other field types, can be
used in four primary ways:

1. Value (VAL) Condition

Used to specify single values that status field can take
two related values:
internal value - value in the implemented database
external value - value displayed/entered on the

2. List (LST) Condition

Used to specify list of values that status
field can take
Screen functions implement prompt key

3. Compare (CMP) Condition

Defined in terms of a fixed value and an
Valid operators: *EQ, *NE, *GT, *LT, *GE, *LE

4. Range (RNG) Condition

Defines range of values that field can take
Defined in terms of From and To values

Access Path
An access path defines the physical file and/or the logical
views of that file
The order in which you want to retrieve records from a
Which fields will be present ?
Your select/omit criteria for deciding which records from
the file will be retrieved by the access path.
Six types of Access Paths
Physical (PHY)
Update (UPD)
Retrieval (RTV)
Resequence (RSQ)
Query (QRY)
Span (SPN)

Physical (PHY) Access Path

Single format file containing fields derived from
resolution of all relations on the file.
Not keyed.
No virtual fields.
Created automatically for every REF/CPT file.
Not referenced directly by functions.
No additional PHY access paths allowed for a file.

Update (UPD) Access Path

Uniquely keyed, single format access path which
is used by functions for updating database.
Keyed on the fields that identify the file.
No Virtual fields.
Created automatically for every REF/CPT file.
Additional UPD access paths may be created with
the same key but subset of fields.

Retrieval (RTV) Access Path

Uniquely keyed, single format access path used
by functions to retrieve records.
Keyed exactly as the UPD access path.
Allows virtual fields.
Created automatically for every REF/CPT file.
Associated with the UPD access path.
Non-key fields can be dropped.
Can select/omit records.
Possible to define multiple RTV access paths for a
given file, but all should have same key fields.

Resequence (RSQ) Access Path

Uniquely or non-uniquely keyed single format
access path used by functions to retrieve records.
Must be created explicitly.
Defaults to the keys of the based on file.
Allows default keys to be changed which need not
be unique.
Allows virtual fields.
Associated with RTV, which points to a UPD.
Many RSQ access paths possible for single file.

Query (QRY) Access Path

Keyed single format access path used by
functions to retrieve records.
Must be created explicitly.
Display File, Select Record, Retrieve Object, Print
Object, and Print File
Allows virtual fields on key & non-key fields.
Available only for Print Object/Print File functions.
Defaults to the keys of the based on file.
Allows default keys to be changed.
Associated with RTV, which points to a UPD
Many QRY access paths possible for single file
Implemented by OPNQRYF or Dynamic SQL

Span (SPN) Access Path

A SPN access path can only be specified over files with
Owned by or Refers to relationships
A SPN access path must be created over an owning or
referred to file
Press F9 on Edit Access Path Details panel to first
select the primary format and then the secondary
Keyed multi-format access path
Used by Edit & Display transaction functions to
retrieve records from a pair of related files
Must be created explicitly
Used for the transaction-type entry functions EDTTRN
These keys can be changed
Allows virtual fields
Associated with RTV, which points to a UPD

Present a subset of the records from the physical
If more than 1 set is used, the 'Seq' field can be
used to specify the order in which the checks are
carried out, and the lines are logically OR d
The field and conditions names may be selected
using the '?' prompt.
If more than one condition is entered on this
screen, they are logically ANDed together before
including a record for selection.

Virtual Fields
When a file is referenced by another file by
means of a Refers to relation, entries are
automatically created on the referencing
file for the key fields of the referenced file.
To include a non-key field from the
referenced file in the referencing file, you
need to specify it as a virtual field. This
makes the field available for use in the
functions that operate upon the
referencing file.

Part 2 Hands on

Create new fields in the model and edit the default

length of the field

Go to Edit field details by taking Z against the


Add field conditions. For Horse gender add the

following two values

You can type ? in the Check condition field, to view a selection

list of existing conditions from Edit field Details screen
Select *All values from the screen.

Note that a Prompt function field now displays. As a result,

when the end user of the compiled application positions the
cursor on the Horse gender field and either enters ? or
presses F4, a selection list of the conditions you
defined will be displayed.

Create a RTV Access path

Type Z against one of the relations for the Horse file and add the following
retrieval index

Take Z against the Access Path to edit the

parameter of Access Path

Create Select/Omit criteria

Type D in the Allow select/omit field to select Dynamic
OS/400 selection and type S in the Subfile selector to define
the select/omit criteria.

Type Z, S, and the description of the select/omit set.

Horse gender in the Field column to specify the field on

which the condition is to be based.
Mare in the condition column to indicate the value the Horse
gender field must contain for the record to be selected.

Specify a Select criteria for the Stallions Access


Specify the following criteria

Include For Text in the relationship by taking +

against the relationship
Include Virtual fields in the Refers To relationship as

Type + against the fields which have to be

virtualized and press enter to confirm.
Repeat the same for the other Refers To relationship

Now take E against the file relationship to display

the Edit File Entries panel

Note that the virtual fields you just specified are

included as indicated by a V in the Entry type (Et)

Thank You