Data Description Specifications(DDS) defines all attributes of a file and which are coded in a system-defined format. These definitions or specifications can be maintained
externally and independent of programs or other dependent files. These statements are
entered into a system-defined format as a source file which is created or compiled as a file.Data records are then written into or retrieved from this file using certain Application
Development Tools or though use-defined application programs.
DDS are coded and entered into a system-defined format known as ‘A’ specifications.
Each file is coded as a separate source member.’A’ specifications are used to code the following types of files.The positions and entries are unique and may differ for the different files.
Physical files.
Logical files
Display (or workstation) files and
Printer files
Defining Physical Files
The Data Description Specifications(DDS) for Physical Files are defined in data specifications in the following layout:
Positions Name Entry Explanation
1-5 Sequence
number
None This is an optional column and may be used to identify, mark or tag source statements.
6 Form type ‘A’ Denotes ‘A’ Specification
7 Comment ‘*’ Denotes a comment line. Comments may be entered betweenpositions 8 and 80.
8-16 Reserved Blank This position Is not used for physical files and must be blank.
17 Type of Name ‘R’
‘ ‘
‘K’
Record format name.
Field name.
key field name.
19-28 Name Record name or field name or key field name.
29 Reference R Denotes that a definition and attributes of the named field are to be referenced from a previously
Positions Name Entry Explanation
39-44 Location This column is reserved and is not used by physical files.
45-80 Keywords.
Components of DDS
DDS definitions are a serious of statement that are entered as source statements. These statements may be entered in to the following levels of definitions.
File level keywords are entered at the file qualify the named file and are applicable to all the record and field definition that follow.
Record format level keywords are entered at the record format level qualify the named record format and are applicable to all the field definitions contained within the record format.
Join level keywords are used to specify parameters that are used to join one or more files in to a single record format. These keywords are valid only in join logical files.
Field level keywords are used to qualify the named field.
Key field level keywords are used to qualify the key or the access sequence of a file. For example, UNIQUE can be specified to prevent existence of duplicate key values in a file.
Select/Omit level keywords are used to specify rules for the selection of records from a physical file, these keywords are valid only in logical files.
Naming Conventions
The normal rule for naming of files, record formats and fields is a 10 character alphanumeric value which does not contain embedded blanks and does not start with a numeric value.
However, some high level languages like RPG/400 supports only 8 character file and record format names and 6 character field names.
Physical File Keywords
Keywords used in physical files are vided into 4 parts. They are:
File level Keywords Record level Keywords Field level Keywords Key-field level Keywords
There are in all over 35 keywords associated with physical files.These keywords are used to provide further qualification to the file, record format, field or key field.Some of the more commonly used keywords are:
File Level Keywords
FCFO First Changed First Out
When duplicate key exists in a file this keyword is used to specify that the record that was changed earliest is to be retrieved.
FIFO First In First Out
When duplicate key exists in a file this keyword is used to specify that the record that was written earliest is to be retrieved.
LIFO Last In First Out
When duplicate key exists in a file this keyword is used to specify that the record that was written most recently is to be retrieved.
REF Reference
Used to indicate the name of another file from which field references wherever indicated are to be retrieved.
UNIQUE Unique Key
Used to indicate that records with duplicate key values will not be allowed in this file.
Record Level Keywords
TEXT Text
Used to assign descriptive text for the record format.
Field Level Keywords
ALIAS Alias Name
Used to indicate the alias name for the named field.
ALWNULL Allow Null value
CHECK Check values
Used to provide certain validity rules for the named field.The values associated with this keyword are as follows:
Used to provide validation to specify that the named field must contain value specified in this parameter. Example, COMP(*EQ ‘A’)
COLHDG Column Heading
Used to provide descriptive text about the named field. This text is used when the field is used in certain application development tools such as Data File Utility(DFU) and Query. Up to three strings of 20 characters each can be specified.
DATFMT Date Format
Used to define the format (namely one of either, YY/MM/DD or MM/DD/YY or DD/MM/YY) in which date is to be stored in the named field.
DATSEP Date separator
Used to identify the character used to separate the elements of a date.
DFT Default Value
Used to nominate a default value when the record is written.
EDTCDE Edit Code
Used to identify a system-supplied editing rule for the named field. Rules could include zero suppression, zero balance, sign etc.
RANGE Range
Used to specify a range of values that are allowed to be input in to the named field.
REFFLD Referenced Field
Used to reference a field from an earlier referenced file whose length and attributes are to be attached to the named field.
Used to assign descriptive text to the named field to be used in all future references of the named field. Example, TEXT(‘Customer code’).
TIMFMT Time Format
Used to define the format in which time is to be stored in the named field.
TIMSEP Time Separator
Used to identify the character to be used to separate the elements namely hour,minute and second of time.
VALUES Values
Used to assign one or more values that are allowed as valid input in to the named field.
Example, VALUES(‘A’, ‘B’, ‘C’, ‘D’, ‘E’).
Key Field Level Key words
ABSVAL Absolute Value
Used to indicate that when retrieving records from the named file, the sign of the key field is to be ignored and only the absolute value of the field is to be used for purposes of ordering sequences.
DESCEND Descending Sequence
Used to specify an ordering sequencing for the retrieval of records from the named file.when retrieving records from named file, the records would be sequenced in the descending order of the named key field.
SIGNED Signed
Used to specify that the sign of the named key-field is to be considered for purposes of ordering sequence when retrieving records from the named file.
Defining Logical Files
The Data Description Specifications(DDS) for Logical Files are defined in data specification in the following.
8-16 Conditioning Blank This position is not used for logical files and must be blank
18 Reserved Blank This position is not used for logical files and must be blank
19-28 Name Record name or field name or key field
name
29 Reference R Denotes that a definition and attributes of the named filed are to be referenced from a previously defined field.
30-34 Length Length of the field the following are the
valid lengths for various types of fields.
Positions Name Entry Explanation T
Z
Timestamp
36-37 Decimal
Position
Number of decimal positions.
38 Usage ‘B’ Both input and output
Default to B
39-44 Location Blank Thos column is reserved and is not used by logical files.
45-80 Keywords
Logical file Keywords
Keywords used in logical files are divided into four parts, namely , File level keywords
Record level keywords Field level keywords Key-field keywords
There are in all over 45 keywords associated with logical files .These keywords are used to provide further qualification to the file , record format, field or key fields. Some of the more commonly used keywords are explained in the subsequent section.
File Level Keywords
DYNSLT Dynamic Select
Used to instruct that selection of records according to the criteria specified in the file must be maintained dynamically as and when records are written into or retrieved from the database file that is pointed to by the logical file.
FCFO First Changed First out
When duplicate key exists in a file this keyword is used to specify that the record that was changed earliest is to be retrieved.
FIFO First In First Out
When duplicate key exists in a file this keyword is used to specify that the record that was written earliest is to be retrieved.
LIFO Last In First Out
When duplicate key exists in a file this keyword is used to specify that the record that was written most recently is to be retrieved.
UNIQUE Unique Key
Use to indicate that records with duplicate key value will not allowed in this file.
Record Level Keywords
PFILE Physical File
Used to name the physical file that is being pointed to by the named logical file .This keyword is mandatory for every logical file definition.
TEXT Text
Used to assign descriptive text for the record format.
Field Level Keywords
ALIAS Alias Name Used to indicate the alias name for the named field .
CHECK Check Values
Used to provide certain validity for the named field. The value associated with this keyword are as follows:
Used to provide validation to specify that named field must contain value specified in this parameter.Example,COMP(*EQ’A’)
COHDG Column Heading
Used to provide descriptive text about the named field.This text is used when the field is used in a certain application development tools such as Data File Utility(DFU)and QUERY.Upto three strings of 20 characters each can be specified .
DATFMT Date Format
Used to define the format (namely one of either ,YY/MM/DD or MM/DD/YY or DD/MM/YY)in which date is to be stored in the named field.
DATSEP Date Separator
Used to identify the character used to separate the elements of a date.
EDTCDE Edit Code
Used to identify a system-supplied editing rule for the named field.Rules could include zero suppression,zero balance ,sign,etc.
TEXT Text
Used to assign descriptive text to the named filed to be used in all future references of the named filed.Example ,TEXT(‘Customer Code’).
TIMFMT Time Format
Used to define the format in which time is to be stored in the named field.
TIMSEP Time Separator
Used to identify the character to be used to separate the elements namely hour,minute and second of time.
VALUES Values
Used to assign one or more values that are allowed as valid input into the named field.
Example,VALUES(‘A’’B’’C’”D’’E’).
Key Field Level Keywords
ABSVAL Absolute Value
Used to indicate that when retrieving records from the named file the sign of the key-field is to be ignored and only the absolute value of the field is to be used for purpose of ordering sequences.
ALL All
Used in conjunction with Select and Omit criteria specification to indicate that all records not fulfilling the Select or Omit criteria must be selected or omitted as the case may be.
DESCEND Descending Sequence
Used to specify an ordering sequence for the retrieval of records from the named file.When retrieving records from the named file,the records would be sequenced in descending order of the named key-field.
SIGNED Signed
Used to specify that the sign of the named key-field is to be considered for purposes of ordering sequence when retrieving records from the named file.
UNSIGNED Unsigned
Used to specify that the sign of the named key-field is to be ignored for purposes of ordering sequence when retrieving records from the named file.
Join Logical Files
A join logical is a logical file which contains definitions required to join two or more different files based on certain user-defined join conditions.
The first file being joinng is called the ‘Primary file’ while the other are called
‘Secondary files’.The primary file and atleast one of the secondary files must be a physical file.
When accessing a join file record, the system internally reads a record from the primary file and picks up the corresponding record from the secondary file based on the user-defined join criteria and then presents the combined data to the accessing program in one consolidated record.
If required, when specifying the primary file and secondary file ,only certain fields from either file may be selected for join file record format rather than all the fields from both the files. But all the fields indicated in join criteria must be selected .
Special consideration
* You cannot change a physical file using a join logical file.
* You can specify only one record format in join logical file.
* Commitment control cannot be used with join logical files.
Join Level Keywords
The keywords used in join logical files are:
JFILE Join File
Identifies the names of the two files being joined.This keyword is specified at the record level.
JFLD Join Field
Used to name the fields that are to be used for purposes of joining the primary file and secondary file.Join fileds must have the same attributes.This keyword is specified at the record level.
JOIN Join
Identifies the names of the two files being joined.This keyword is specified at the join level.
JREF Join Reference File
Identifies the file from which the named fields is to be retrieved from.This keyword is specified at the field –level.
Examples of database files in DDS:
Example of a field reference file:
This example defines all of the fields used in an application and refers to fields only within the field reference file itself. The following keywords are important in the example:
COLHDG EDTCDE(Z) REFFLD REFSHIFT TEXT
The following field reference file (MLGREFP) describes all fields used by any program in the application. The other files use the fields in this file.
Figure 1. DDS for a Field Reference File
00010A** FLDREF MLGREFP MAILING LIST FIELD REFERENCE FILE
00020A (1)R MLGREFR TEXT('Mailing List Field Reference')
(1) Like all physical files, a field reference file has only one record format. The R in position 17 specifies that MLGREFR is the record format name.
(2) The Rs in position 29 and REFFLD in positions 45 through 80 specify that the fields ADDR and CITY are to have the same attributes as NAME.
(3) Specifying COLHDG for ADDR and CITY overrides the COLHDG attribute for NAME, which otherwise would have been in effect.
(4) Specifying REFSHIFT for NAME will cause the keyboard shift specified (X) to be used when this field (NAME) is referred to in a display file.
Example of a physical file with a new record format:
The REF keyword is important in the following example. This file has one record format. The names of all fields in the record format are specified. This example uses fields in a reference file (REF keyword) and uses a keyed-sequence access path.
The following physical file (called CUSMSTP for customer master physical file) describes the fields physically present in the database.
Figure 2. DDS for a Physical File
00010A*
00020A* SAMPLE PHYSICAL FILE(CUSMSTP) 00030A*
00040A (1) REF(MLGREFP)
00050A (2) R CUSMST TEXT('Customer Master Record') 00060A ACTNUM R (3)
00070A NAME R (3) 00080A ADDR R (3) 00090A CITY R (3) 00100A STATE R (3) 00110A ZIP R (3) 00120A (4) SEARCH 10 0 00130A (4) CRDLMT 8 2 00140A (5) K ACTNUM
Legend:
(1) At the file level, the REF keyword refers the OS/400 program to the physical file MLGREFP, which is a field reference file for this database.
(2) At the record level, R in position 17 specifies that CUSMST is the record format name of the record in this file. (There can only be one record format in a physical file.)
(3) At the field level, Rs in position 29 specify that the attributes of fields of the same name in the REF file are to be used as attributes of these fields.
(4) The fields SEARCH and CRDLMT are not defined in MLGREFP; therefore, their field attributes are specified here.
(5) At the key field level, K in position 17 specifies that ACTNUM is the key field for the file.
Example of a logical file specifying multiple formats and new keys:
The PFILE keyword is important in the following example. The example uses new field
specifications and provides two record formats. Each record format provides a different view of the associated physical file and uses a key different from the associated physical file.
Figure 3. DDS for a Logical File Specifying New Keys
00010A*
00020A* SAMPLE LOGICAL FILE 00030A
00040A R CUSMST1 (1)PFILE(CUSMSTP) 00050A ACTNUM
00060A NAME 00070A STATE
00080A LASTNAME I (3)SST(NAME 8 10) 00090A (2) K ACTNUM
00100A*
00110A R CUSMST2 (1)PFILE(CUSMSTP) 00120A ACTNUM
00130A NAME 00140A ZIP 00150A K *NONE 00160A (2) K NAME
Legend:
(1) The two record formats (CUSMST1 and CUSMST2) in this logical file are based on the same physical file (CUSMSTP).
(2) Record format CUSMST1 has a key different from record format CUSMST2, providing the application program with a different sequence of the same records.
(3) The LASTNAME field is a substring of the field NAME. The usage I in position 38 must be specified since this is not a join logical file.
Example of a logical file specifying a new record format:
The UNIQUE keyword is important in the following example. The example specifies a record format different from the associated physical file.
The following logical file (called CUSMSTL2 for customer master logical file two) uses some of the fields in the physical file CUSMSTP. Another logical file could name all fields, name fields in other physical files as well, concatenate fields, change the order of fields, rename fields, or choose different key fields. In this logical file, the programmer merely omitted some fields from the physical file.
00020A* SAMPLE LOGICAL FILE (CUSMSTL2)
(1) The UNIQUE keyword specifies that records with duplicate keys are not allowed within a member of this logical file.
(2) The keyword PFILE (required for logical files) specifies CUSMSTP.
(3) The field names do not have R specified in position 29 as they would in physical files or in any device file.
(4) As in CUSMSTP, the field ACTNUM is treated as a key field.
Example of a join logical file:
The following join logical file joins three physical files (PF1, PF2, and PF3) so that an
application program can get name, address, and salary information in one input operation, even though the information is stored in three different physical files. The following keywords are important in the example:
(1) R identifies the record format. There can be only one record format in a join logical file.
(2) The JFILE keyword specifies that PF1, PF2, and PF3 are the physical files on which this join logical file is based. Because it is specified first, PF1 is the primary file. There are two secondary files: PF2 and PF3.
(3) J identifies the join specifications. With two secondary files in this join logical file, there must be two join specifications. Each join specification defines how a pair of files is to be joined,
as follows: JOIN is required when more than two physical files are being joined, and it identifies which two files are being joined in this join specification. In the first join specification, PF1 and PF2 are joined. In the second join specification, PF2 and PF3 are joined.
as follows: JOIN is required when more than two physical files are being joined, and it identifies which two files are being joined in this join specification. In the first join specification, PF1 and PF2 are joined. In the second join specification, PF2 and PF3 are joined.