Create Physical File

DDS on IBM Power i systems defines physical files.

Physical Files

A physical file is a database file that contains data records. The data records are grouped into physical file members and each member has its own access path to the data. Normally, database files have only one member which, by default, is added to the file when the file is created. If the desired physical file has a record format with only one character field in arrival sequence or if the file is a source file, a DDS source file is not needed. To override attributes of the file after it has been created, use the Override Database File (OVRDBF) command before the file is opened. To change attributes of the file after it has been created, use the Change Physical File (CHGPF) command.

Simple DDS

The example below is simple. The DDS defines a phyiscal file with twelve fields. Only one record format name is allowed for a physical file, in the example, the record format name is RCAWCNF. The are no file level keywords. The only attributes assigned, other than the data type, are the TEXT keyword to describe the field, and the COLHDG keyword to define the default column heading associated with the field.

     A****************************************************************
     A* PHYSICAL FILE- CAWCNFPF                                      *
     A*                                                              *
     A* FUNCTION     - This file maps the fee waiver confirmation    *
     A*                                                              *
     A* PROGRAMMER   - Steve Croy      99/99/9999 iSoftwerks, inc    *
     A****************************************************************
     A****************************************************************
     A*               FILE ATTRIBUTE SECTION                         *
     A*                                                              *
     A*  MAXMBRS   : 1                                               *
     A*                                                              *
     A****************************************************************
     A****************************************************************
     A*                   MODIFICATION LOG                           *
     A*                                                              *
     A*  DATE       PROGRAMMER      DESCRIPTION                      *
     A*                                                              *
     A****************************************************************
     A          R RCAWCNF                   TEXT('WAIVER CONFIRMATION')
     A            CFOWN          6S 0       COLHDG('Own' 'Cde')
     A                                      TEXT('Account owner')
     A            CFPRJ          3S 0       COLHDG('Prj' 'Cde')
     A                                      TEXT('PROJECT')
     A            CFACT          8A         COLHDG('Account')
     A                                      TEXT('Account')
     A            CFCNT          1S 0       COLHDG('Trans' 'Cent')
     A                                      TEXT('Transaction century')
     A            CFREF          4S 0       COLHDG('Ref' 'Code')
     A                                      TEXT('Reference Code')
     A            CFTRN          2A         COLHDG('Trn' 'Code')
     A                                      TEXT('Transaction Code')
     A            CFAMT          7S 2       COLHDG('Amount')
     A                                      TEXT('Transaction Amount')
     A            CFDSC         10A         COLHDG('Description')
     A                                      TEXT('Transaction description')
     A            CFDUE          8P 0       COLHDG('Due' 'Dte')
     A                                      TEXT('Due Date')
     A            CFPCT          4P 3       COLHDG('Bill' 'Pct')
     A                                      TEXT('Bill percent')
     A            CFRSN          3S 0       COLHDG('Rsn' 'Cde')
     A                                      TEXT('Reason Code')
     A            CFDFI          1A         COLHDG('D/I')
     A                                      TEXT('Deferred/Immediate')

Keyed Physical File

DDS can describe a physical file as a keyed physical file. In DDL the equivalent would be a CREATE TABLE statement, followed by a CREATE INDEX statement. The keyword UNIQUE at the file level means that the key values will be unique to the data record. The record format (RSCOBJS) only has a TEXT attribute attached. The name of the record format can be the same as the file name specified in the Create Physical File (CRTPF) command. However, a warning message appears if the names are not unique. RPG does not allow record format and file names to be the same, so it is best not to use the file name as the record format name. Fields are defined at the record level, followed by key level entries--the fields named as the keys used to order the records.

     A****************************************************************
     A* PHYSICAL FILE- SCOBJSPF                                      *
     A*                                                              *
     A* FUNCTION     - This is object list for the SOFTCODE system   *
     A*                                                              *
     A* PROGRAMMER   - Steve Croy      99/99/9999 iSoftwerks, inc    *
     A****************************************************************
     A****************************************************************
     A*               FILE ATTRIBUTE SECTION                         *
     A*                                                              *
     A*  KEY FIELDS: EXOBNM, EXOBTP                                  *
     A*  MAXMBRS   : 1                                               *
     A*                                                              *
     A****************************************************************
     A****************************************************************
     A*                   MODIFICATION LOG                           *
     A*                                                              *
     A*  DATE       PROGRAMMER      DESCRIPTION                      *
     A*                                                              *
     A****************************************************************
     A                                      UNIQUE
     A          R RSCOBJS                   TEXT('OBJECT DATA')
     A            EXCATS         3S 0       COLHDG('Cat' 'Cde')
     A                                      TEXT('CATEGORY')
     A            EXCSEQ         7S 0       COLHDG('Exec' 'Seq')
     A                                      TEXT('Execution Sequence')
     A            EXOBNM        10          COLHDG('Object' 'Name')
     A                                      TEXT('OBJECT NAME')
     A            EXOBTP        10          COLHDG('Object' 'Type')
     A                                      TEXT('OBJECT TYPE')
     A            EXDESC        50A         COLHDG('Description')
     A                                      TEXT('DESCRIPTION')
     A            EXOBSR        10          COLHDG('Object' 'Source')
     A                                      TEXT('OBJECT SOURCE')
     A            EXOMBR        10          COLHDG('Source' 'Member')
     A                                      TEXT('SOURCE MEMBER')
     A            EXOBSL        10          COLHDG('Source' 'Library')
     A                                      TEXT('SOURCE SOURCE')
     A            EXCOMP         1          COLHDG('Cmp''Y/N')
     A                                      TEXT('COMPILE Y/N')
     A            EXMOVO         1          COLHDG('Mov''Y/N')
     A                                      TEXT('MOVE OBJECT Y/N')
     A            EXMOVS         1          COLHDG('MVS''Y/N')
     A                                      TEXT('MOVE SOURCE Y/N')
     A            EXACMD         1          COLHDG('Alt''Cmd')
     A                                      TEXT('ALTERNATE COMMAND')
     A            EXOBLB        10          COLHDG('Object' 'Library')
     A                                      TEXT('OBJECT LIBRARY')
      *---
      * AUDIT FIELDS
      *---
     A            EXADDT         8S 0       COLHDG('Added' 'Date')
     A                                      TEXT('ADDED DATE')
     A            EXADTM         6S 0       COLHDG('Added' 'Time')
     A                                      TEXT('ADDED TIME')
     A            EXADUS        10A         COLHDG('Added' 'User')
     A                                      TEXT('Added User')
     A            EXCHDT         8S 0       COLHDG('Change' 'Date')
     A                                      TEXT('Change Date')
     A            EXCHTM         6S 0       COLHDG('Change' 'Time')
     A                                      TEXT('Change Time')
     A            EXCHUS        10A         COLHDG('Change' 'User')
     A                                      TEXT('Change User')
      *---
     A            EXPROC         1          COLHDG('Prc''Y/N')
     A                                      TEXT('PROCESSED Y/N')
     A            EXPRDT         8S 0       COLHDG('Processed' 'Date')
     A                                      TEXT('Processed Date')
     A            EXPRTM         6S 0       COLHDG('Processed' 'Time')
     A                                      TEXT('Processed Time')
     A            EXPRUS        10A         COLHDG('Processed' 'by User')
     A                                      TEXT('Processed by User')
      *
     A          K EXOBNM
     A          K EXOBTP

Field Limits

The maximum number of fields in a record format is 8000. If any of the fields in the record format are date, time, timestamp, variable length, or allows the null value, then the actual maximum number of fields can be less than 8000. The maximum number of fields can vary depending on the number of fields and combinations of fields that occur within the record format. The maximum number of bytes in a record format is 32 766 if variable length fields are not included and 32 740 if variable length fields are included.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8

00010A* PHYSICAL FILE CODING EXAMPLE from IBM
00020A                                      REF(INVENCTL/INVENTORY)
00030A                                      UNIQUE
00040A          R ORDFMT                    TEXT(’Format for Purchase Orders’)
00050A            ORDNBR         7  0       COLHDG(’Order’ ’Number’)
00060A            ITMNBR     R  10
00070A            SUPNBR     R  +2          REFFLD(SUPID SUPLIB/SUPMST)
00080A            QTYORD         5B
00090A          K ORDNBR
00100A          K ITMNBR ABSVAL


In this example, the file level REF keyword specifies a special type of file, called a field reference file. This type file is generally used as a field library. Note that the field SUPNBR is not defined in this DDS. The field definition is derived from the field SUPID in a file named SUPMST in the library SUPLIB.

Data Types

Entry Meaning
P Packed decimal
S Zoned decimal
P Packed decimal
S Zoned decimal
P Packed decimal
S Zoned decimal
B Binary
F Floating point
A Character
H Hexidecimal
L Date
T Time
Z Timestamp
5 Binary character