Describing Files Using Data Description Specifications (DDS)

You can use Data Description Specifications (DDS) to describe files at the field level to the operating system. In DDS, each record format in an externally described file is identified by a unique record format name.

The record format specifications describe the fields in a record and the location of the fields in a record. The fields are located in the record in the order specified in DDS. The field description generally includes the field name, the field type (character, binary, external decimal, internal decimal, internal floating-point), and the field length (including the number of decimal positions in a numeric field). Instead of being specified in the record format for a physical or logical file, the field attributes can be defined in a field reference file. (See Figure 1.)

The keys for a record format are specified in DDS. When you use a Format 2 COPY statement, a table of comments is generated in the source program listing showing how the keys for the format are defined in DDS.

In addition, DDS keywords can be used to:
  • Specify edit codes for a field (EDTCDE)
  • Specify that duplicate key values are not allowed for the file (UNIQUE)
  • Specify a text description for a record format or a field (TEXT).
For a complete list of the DDS keywords that are valid for a database file, refer to the Database and File Systems category in the IBM® i Information Center at this Web site -http://www.ibm.com/systems/i/infocenter/.
Figure 1. Example of a Field Reference File
 ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
      A**FLDREF    DSTREF     DISTRIBUTION APPLICATION FIELDS REFERENCE
      A          R DSTREF                    TEXT('DISTRIBUTION FIELD REF')
      A* COMMON FIELDS USED AS REFERENCE
    1 A            BASDAT         6  0       EDTCDE(Y)
      A                                      TEXT('BASE DATE FIELD')
      A* FIELDS USED BY CUSTOMER MASTER FILE
    2 A            CUST           5          CHECK(MF)
      A                                      COLHDG('CUSTOMER' 'NUMBER')
      A            NAME          20          COLHDG('CUSTOMER NAME')
    3 A            ADDR      R               REFFLD(NAME)
      A                                      COLHDG('CUSTOMER ADDRESS')
      A            CITY      R               REFFLD(NAME)
      A                                      COLHDG('CUSTOMER CITY')
    2 A            STATE          2          CHECK(MF)
      A                                      COLHDG('STATE')
      A            SRHCOD         6          CHECK(MF)
      A                                      COLHDG('SEARCH' 'CODE')
      A                                      TEXT('CUSTOMER NUMBER SEARCH CODE')
    2 A            ZIP            5  0       CHECK(MF)
      A                                      COLHDG('ZIP' 'CODE')
    4 A            CUSTYP         1  0       RANGE(1 5)
      A                                      COLHDG('CUST' 'TYPE')
      A                                      TEXT('CUSTOMER TYPE 1=GOV 2=SCH 3=B+
      A                                      US 4=PT 5=OTH')
    5 A            ARBAL          8  2       COLHDG('ACCTS REC' 'BALANCE')
      A                                      EDTCDE(J)
    6 A            ORDBAL    R               REFFLD(ARBAL)
      A                                      COLHDG('A/R AMT IN' 'ORDER FILE')
      A            LSTAMT    R               REFFLD(ARBAL)
      A                                      COLHDG('LAST' 'AMOUNT' 'PAID')
    7 A                                      TEXT('LAST AMOUNT PAID IN A/R')
      A            LSTDAT    R               REFFLD(ARBAL)
      A                                      COLHDG('LAST' 'DATE' 'PAID  ')
      A                                      TEXT('LAST DATE PAID IN A/R')
      A            CRDLMT         8  2       COLHDG('CUSTOMER' 'CREDIT' 'LIMIT')
      A                                      EDTCDE(J)
      A            SLSYR         10  2       COLHDG('CUSTOMER' 'SALES' 'THIS YEAR')
      A                                      EDTCDE(J)
      A            SLSLYR        10  2       COLHDG('CUSTOMER' 'SALES' 'LAST YEAR')
      A                                      EDTCDE(J)
This example of a field reference file (Figure 1) shows the definitions of the fields that are used by the CUSMSTL (customer master logical) file, which is shown in Figure 1. The field reference file normally contains the definitions of fields that are used by other files. The following text describes some of the entries for this field reference file.
 1 
The BASDAT field is edited by the Y edit code, as indicated by the keyword EDTCDE (Y). If this field is used in an externally described output file for a ILE COBOL program, the COBOL-generated field is compatible with the data type specified in the DDS. The field is edited when the record is written. When the field is used in a program-described output file, compatibility with the DDS fields in the file is the user’s responsibility. When DDS is not used to create the file, appropriate editing of the field in the ILE COBOL program is also the user’s responsibility.
 2 
The CHECK(MF) entry specifies that the field is a mandatory fill field when it is entered from a display workstation. Mandatory fill means that all characters for the field must be entered from the display workstation.
 3 
The ADDR and CITY fields share the same attributes that are specified for the NAME field, as indicated by the REFFLD keyword.
 4 
The RANGE keyword, which is specified for the CUSTYP field, ensures that the only valid numbers that can be entered into this field from a display work station are 1 through 5.
 5 
The COLHDG keyword provides a column head for the field if it is used by the Application Development ToolSet tools.
 6 
The ARBAL field is edited by the J edit code, as indicated by the keyword EDTCDE(J).
 7 
A text description (TEXT keyword) is provided for some fields. The TEXT keyword is used for documentation purposes and appears in various listings.