This example shows how to describe a physical a file using DDS.
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 A* ORDER HEADER FILE (ORDHDRP) A 5 A 1 UNIQUE A 2 R ORDHDR TEXT('Order header record') A 3 CUST 5 0 TEXT('Customer number') A ORDER 5 0 TEXT('Order number') A . A . A . A K CUST A 4 K ORDER
The following example shows a physical file ORDHDRP (an order header file), with an arrival sequence access path without key fields specified, and the DDS necessary to describe that file.
Customer number (CUST) — Packed decimal length 5, No decimals |
Order number (ORDER) — Packed Decimal Length 5, No decimals |
Order date (ORDATE) — Packed decimal length 6, No decimals |
Purchase order number (CUSORD) — Packed decimal length 15, No decimals |
Shipping instructions (SHPVIA) — Character length 15 |
Order status (ORDSTS) — Character length 1 |
... |
State (STATE) — Character length 2 |
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 A* ORDER HEADER FILE (ORDHDRP) A R ORDHDR TEXT('Order header record') A CUST 5 0 TEXT('Customer Number') A ORDER 5 0 TEXT('Order Number') A ORDATE 6 0 TEXT('Order Date') A CUSORD 15 0 TEXT('Customer Order No.') A SHPVIA 15 TEXT('Shipping Instr') A ORDSTS 1 TEXT('Order Status') A OPRNME 10 TEXT('Operator Name') A ORDAMT 9 2 TEXT('Order Amount') A CUTYPE 1 TEXT('Customer Type') A INVNBR 5 0 TEXT('Invoice Number') A PRTDAT 6 0 TEXT('Printed Date') A SEQNBR 5 0 TEXT('Sequence Number') A OPNSTS 1 TEXT('Open Status') A LINES 3 0 TEXT('Order Lines') A ACTMTH 2 0 TEXT('Accounting Month') A ACTYR 2 0 TEXT('Accounting Year') A STATE 2 TEXT('State') A
The R in position 17 indicates that a record format is being defined. The record format name ORDHDR is specified in positions 19 through 28.
You make no entry in position 17 when you are describing a field; a blank in position 17 along with a name in positions 19 through 28 indicates a field name.
If the data type (position 35) is not specified, the decimal positions entry is used to determine the data type. If the decimal positions (positions 36 through 37) are blank, the data type is assumed to be character (A); if these positions contain a number 0 through 31, the data type is assumed to be packed decimal (P).
The length of the field is specified in positions 30 through 34, and the number of decimal positions (for numeric fields) is specified in positions 36 and 37. If a packed or zoned decimal field is to be used in a high-level language program, the field length must be limited to the length allowed by the high-level language you are using. The length is not the length of the field in storage but the number of digits or characters specified externally from storage. For example, a 5-digit packed decimal field has a length of 5 specified in DDS, but it uses only 3 bytes of storage.
Character or hexadecimal data can be defined as variable length by specifying the VARLEN field-level keyword. Generally you would use variable length fields, for example, as an employee name within a database. Names usually can be stored in a 30-byte field; however, there are times when you need 100 bytes to store a very long name. If you always define the field as 100 bytes, you waste storage. If you always define the field as 30 bytes, some names are truncated.