Generally, a file has to be defined before you can write records to it.
Sometimes, you may need a simple "flat" file with no field definitions.
For that, the Create Physical File command without DDS specifications
will work. To create a file named FTPOUT that is 100 characters in length:
CRTPF FILE(MYLIB/FTPOUT) RCDLEN(100)
The AS/400 actually creates a file named FTPOUT, a member named FTPOUT
and a field of length 100 that is named FTPOUT.
To make a database file, you use the DDS specifications. You must start
the Programming Development Manager and create a member with TYPE
of PF (for physical file). Usually, this goes in the object QDDSSRC.
The first line defines the record name. For a simple 3 field file:
Then, you must compile or create the file. In PDM you can do this with
the option 14. When you use option 14, you actually execute the command:
CRTPF FILE(MYLIB/CUS) SRCFILE(MYLIB/QDDSSRC) SRCMBR(CUS)
The AS/400 knows to use this command because you specified that this
member is describing a PF.
If you have wanted a key built on the PHONE field, the DDS would have been:
A R CUSREC
A NAME 20A
A PHONE 10S 0
A STATUS 1A
Name the member in QDDSSRC the same as the desired file. In this
case, I named it CUS.
A R CUSREC
A NAME 20A
A PHONE 10S 0
A STATUS 1A
A K PHONE
Welcome to the AS/400 database--- DB2/400