You are on page 1of 16

DDS Programming Exercise Physical File

INDEX

Exercise Number 1 2 3 4 5 6 7

Description Create a physical file EMPMST with key field EMPCDE Create a physical file DEPTMST with key field DEPID, MGRID Create a field description file FLDREF Create a physical file EMPMST1 referring FLDREF Create a physical file EMPMST1.A referring file FLDREF Create a physical file EMPMST2 using the FORMAT keyword Create a physical file using file level keywords (UNIQUE, FIFO, LIFO,FCFO) Create a physical file using key field level keywords (ABSVAL, DESCEND) Create a physical file using field level keywords(CHECK(AB,ME,MF,LC) Create a physical file using field level keywords (RANGE, COMP, VALUES, CHKMSGID) Create a physical file using field level keywords(EDTCDE, 1

Page Number 3 4 5 6 7 8 9

10

11

10

12

11

13

12

13

14 15

EDTWRD) Create a physical file using field level keywords(DATFMT, DATSEP, TIMFMT, TIMSEP) Create a physical file using field level keywords(ALWNULL, ALIAS, DFT, VARLEN) Create a physical file INVHDR, with INVNO has key field. Create a physical INVDTL with INVNO and INVLNO has key field.

14

15

16

1. Create a physical file EMPMST with the following fields and key field empcde. Exercise instructions _____1. In this exercise you are going to write a PF EMPMST in your library that includes all the fields Specify below. Field name EMPCDE EMPNAM EMPDOB EMPDEP EMPSAL EMPAD1 EMPAD2 EMPAD3 EMPHN EMTRDT EMTRTM EMTUSR Length 5, 0 30 2 11, 2 25 25 25 14, 0 10 Data type Zoned Alphanumeric Date(L) Alphanumeric Packed Alphanumeric Alphanumeric Alphanumeric Zoned Date (L) Time(T) Alphanumeric

_____2. _____3.

Create a DDS for the EMPMST with the following record formats specifications of the record formats name is EMPREC. Define employee code as the key field. 2

_____4.

Compile EMPMST and check for no compilation errors.

2. Create a physical file DEPMST with the following fields and key field DEPID & MGRID. Exercise instructions _____1. In this exercise you are going to write a PF DEPMST in your library that includes all the fields Specify below.

Field name DEPID DEPNM MGRID

Length 2 20 5, 0

Data type Alphanumeric Alphanumeric Zoned

_____2.

Create a DDS for the DEPMST with the above fields.

_____3.

Define DEPID and MGRID as the key fields.

_____4.

Compile DEPMST and check for no compilation errors.

Most Common Error: Not specifying Record format

3. Create a field reference file FLDREF in your library and include all the fields which are defined in EMPMST.

Exercise instructions _____1. In this exercise you are going to write a PF FLDREF in your library that includes all the fields which one defined in EMPMST. _____2. Field name EMPCDE EMPNAM EMPDOB EMPDEP EMPSAL EMPAD1 EMPAD2 EMPAD3 EMPHN EMTRDT EMTRTM EMTUSR Create a DDS for the FLDREF with the following fields. Length 5, 0 30 2 11, 2 25 25 25 14, 0 10 Data type Zoned Alphanumeric Date(L) Alphanumeric Packed Alphanumeric Alphanumeric Alphanumeric Zoned Date (L) Time(T) Alphanumeric

_____3.

Compile FLDREF and check for no compilation errors.

Most Common Error: Not specifying Record format

4. Create a PF EMPMST1 by referring all the fields from fields reference file FLDREF. Exercise instructions _____1. In this exercise you are going to write a PF EMPMST1 in your library by referring all fields from FLDREF. _____2. _____3. _____4. Create a DDS for the PF EMPMST1 by referring all fields in the field reference file FLDREF. Define employee Code as the key field. Compile the PF EMPMST1 and check for no compilation errors.

Most Common Error: Not specifying Record format

5. Create a PF EMPMST1.A by referring the fields using REFFLD Exercise instructions _____1. In this exercise you are going to write a PF EMPMST1.A in your library by referring all fields from FLDREF. _____2. Create a DDS for the PF EMPMST1.A by referring all the fields from FLDREF other than EMPDEP and using REFFLD refer to EMPDEP from DEPMST. Define employee code as the key field. Specify COLHDG for all fields in EMPMST1.A Compile the PF EMPMST1.A and check for no compilation errors.

_____3. _____4. _____5.

Errors: * CPD5248 30 1 Message . . . . : File specified on REF or REFFLD keyword not found. * CPD5252 30 1 Message . . . . : Field not found in file specified on REF or REFFLD. Mismatch in File Specified and Field Name specified in EMPMST1.A Reference: REFFLD & REF: http://pic.dhe.ibm.com/infocenter/iseries/v7r1m0/index.jsp?topic=%2Fdds%2Fspecref.htm COLHDG: http://publib.boulder.ibm.com/html/as400/v4r5/ic2979/info/db2/rbafpmst58.htm Question: While recompiling it says Object L_EMPMST1A in PMS243 type *FILE deleted. What is the reason?

6. To create a PF EMPMST2 with the similar format of EMPMST and define EMPNAM as the key.

Exercise instructions _____1. In this exercise you are going to write a PF EMPMST2 in your library that includes all the fields of EMPMST and define EMPNAM as the key. _____2. _____3. Create a DDS for the EMPMST2. Define employee name as the key field. Compile EMPMST2 and check for no compilation errors.

Errors: CPD5246 30 1 Message . . . . : Not allowed to use indicated object. CPD7901 30 1 Message . . . . : Record name not found in file specified on FORMAT keyword Cause: The record name must be the same as a record name in the file specified on the FORMAT keyword. Recovery: Either change the file name specified on the FORMAT keyword, or changes the record name in the file. Then try the request again. Reference: http://publib.boulder.ibm.com/infocenter/iadthelp/v7r0/index.jsp?topic=/com.ibm.etools.iseries.langref2.d oc/rzakb/rzakbmstlfkeyw.htm Note: Used FORMAT Keyword to copy the field level details from EMPMST to EMPMST2 Question: Is UNIQUE Keyword Mandatory when using FORMAT Keyword?

7. Create PFs (EMPMST3, EMPMST4, EMPMST5, EMPMST6) with file level keywords UNIQUE, FIFO, LIFO, FCFO Exercise instructions _____1. In this exercise you are going to include file level keywords UNIQUE, FIFO,LIFO,FCFO UNIQUE Select records of unique key value. FIFO See whether records are arranged in first in first out order when duplicate key values are specified LIFO See whether records are arranged in last in first out order when duplicate key values are specified FCFO See whether records are arranged in first changed first out order when duplicate key values are specified Create a DDS for the file EMPMST3, EMPMST4, EMPMST5, EMPMST6 with file level keywords UNIQUE, FIFO, LIFO, (FCFO Test level is not work properly) with similar format of EMPMST. _____2. Compile EMPMST3, EMPMST4, EMPMST5, EMPMST6 and check for no compilation errors.

Note: Have a KEYFIELD in all the above files to check if the KEYWORDS are working properly Reference: UNIQUE: http://publib.boulder.ibm.com/html/as400/v4r4/ic2924/info/db2/rbafpmst137.htm FCFO: http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=%2Frzakb%2Frzakbmsttdfcfo.htm Note: FCFO not working

8. Create a PF EMPMST7 include key field keywords ABSVAL, DESCEND Exercise instructions _____1. In this exercise you are going to include key field keywords ABSVAL, DESCEND. _____2. _____3. _____4. Create a DDS for the file EMPMST7 which is based on EMPMST3 with the following record formats specifications. In EMPMST7, define employee id as the key field. In EMPMST7, specify EMPSAL as key field and use DESCEND. When you specify DESCEND keyword check whether employee salary are listed in descending order. Specify ABSVAL for the EMPSAL field in PF. When you specify ABSVAL, check whether absolute value is obtained. Specify DESCEND and ABSVAL and see whether records are arranged with ABSVAL and descending order. Compile EMPMST7 and check for no compilation errors.

_____5.

9. Create a PF EMPMST8 with field level keywords CHECK(MF), CHECK(ME), ``CHECK(AB), CHECK(LC).

Exercise instructions _____1. In this exercise you are going to include field level keywords CHECK(AB), CHECK(MF) , CHECK(ME). _____2. _____3. _____4. _____5. Create a DDS for the file EMPMST8 with the fields referring from EMPMST. Specify the following keywords. Check for EMPDEP field for CHECK(ME) Field must be entered mandatorily CHECK(MF) Mandatory fill of the particular field. CHECK(AB) Allow blanks. Check for EMPNAM field for CHECK(LC) This field level is function in display file with dds level. For changing to lower case letters. Compile EMPMST8 and check for no compilation errors.

10. Create a PF EMPMST9 with field level (Validation) keywords (RANGE, COMP, VALUES, CHKMSGID).

10

Exercise instructions _____1. In this exercise you are going to include field level keywords RANGE, COMP, VALUES, CHKMSGID. _____2. _____3. Create a DDS for the file EMPMST9 with the fields referring from EMPMST. Specify the following keywords. Specify RANGE of values ( 2000 5000) Depends on the empsal with datatype it will work accurately. to EMPSAL and select. Specify VALUES keyword for EMPDEP field as IT,AD,HR,QA,QC. Specify COMP keyword for the field EMPCDE to the employee records having EMPCDE greater than 0. Specify CHKMSGID for the field EMPDEP. Specify the first message level text Enter valid department. Check whether the error message works. Compile EMPMST9 and check for no compilation errors.

_____4. _____5. _____6.

11. Create a PF EMPMST10 with field level (Formatting) keywords (EDTCDE, EDTWRD). 11

Exercise instructions _____1. In this exercise you are going to include field level keywords EDTCDE, EDTWRD. _____2. _____3. _____4. _____5. Create a DDS for the file EMPMST10 referring fields from EMPMST. Specify the following keywords. Specify EDTCDE for EMPSAL field. Specify edit code J for suppressing zeros. Specify EDTWRD for EMPPHN field (bbbb-bb-bbbbbbbb). (Country code-Area numberPhone number). Compile EMPMST10 and check for no compilation errors.

12. Create a PF EMPMST11 with field level keywords (DATFMT, DATSEP, TIMFMT, TIMSEP).

12

Exercise instructions _____1. In this exercise you are going to include field level keywords DATFMT, DATSEP, TIMFMT, TIMSEP. _____2. _____3. _____4. Create a DDS for the file EMPMST11 referring field from EMPMST. Specify the following keywords. Specify DATFMT for the field EMPDOB as *DMY and DATSEP as - and TIMFMT for the field EMTRTM as *HMS and TIMSEP as .. Compile EMPMST11 and check for no compilation errors.

13. Create a PF EMPMST12 with field level keywords (ALIAS, DFT, VARLEN).

13

Exercise instructions _____1. In this exercise you are going to include field level keywords ALWNULL It is not work output level., ALIAS, DFT, VARLEN. _____2. _____3. _____4. _____5. _____6. _____7. Create a DDS for the file EMPMST12 referring fields from EMPMST. Specify the following keywords. Set ALWNULL for EMPSAL. When you specify ALWNULL, allows null value in the field. Specify ALIAS name ie EMP_NAM to field EMPNAM.. Specify DFT values for EMPDEP as IT. Specify VARLEN for EMPNAM field. Length must be 10. Compile EMPMST12 and check for no compilation errors.

14. Create a physical file INVHDR with the following fields and key field INVNO. Exercise instructions In this exercise you are going to create a PF INVHDR in your library that includes all the fields given below. Create a DDS code for the file INVHDR with the following specifications. Specify INVNO as keyfield. 14

_____1. _____2.

Field name INVNO INVDT CUSCDE INVAMT

Length 7,0 5,0 13,2

Data type Zoned Date(L) Zoned Packed

_____3.Compile INVHDR and check for no compilation errors.

15. Create a physical file INVDTL with the following fields and key field INVNO, INVLNO. Exercise instructions: _____1.In this exercise you are going to create a PF INVDTL in your library that includes all the fields given below. _____2.Create a DDS code for the file INVHDR with the following specifications. Specify INVNO, INVLNO as key field.

15

Field name INVNO INVLNO INVITMNO INVQTY INVRAT INVAMNT

Length 7,0 3,0 5,0 3,0 11,2 13,2

Data type Zoned Zoned Packed Packed Packed Packed

_____3.Compile INVDTL and check for no compilation errors.

16

You might also like