Kednos PL/I for OpenVMS Systems
User Manual


Previous Contents Index

E.2 Creating CDD Structure Declarations

CDD source files must be written in the Common Data Dictionary Language (CDDL). You enter them into your file directory using a VMS editor utility, just as you would enter any other file into your directory. CDD source files should have a file type of DDL, which is the file type recognized by CDD compiler.

Once you have created a CDD source file, you can invoke the CDDL compiler to insert your record definitions in the CDD. First, however, you can define CDDL as a global symbol by issuing the following command line or including it in your login command procedure:


$ CDDL:==$SYS$SYSTEM:CDDL

After you have done so, you need only enter CDDL to invoke CDD compiler. For example, to compile your FILE.DDL and insert it into the CDD, enter the following:


$ CDDL FILE.DDL
The CDD compiler compiles the structure declaration and issues messages, if necessary. To correct errors in your structure declaration, invoke an editor and change the data definition text as needed, and then recompile. The CDD enters only the highest version of a file; if you attempt to compile another file with the same name, CDD compiler issues an error message. However, the Dictionary Management Utility (DMU) permits updates. For further information see your CDD documentation.

E.3 Using the CDD

The %DICTIONARY statement incorporates CDD data definitions into the current PL/I source file during compilation. The %DICTIONARY statement can occur anywhere in a PL/I source file. It has the following format:

%DICTIONARY cdd-path; 

cdd-path

Is any preprocessor expression. The preprocessor expression is evaluated and converted to a character string, if necessary. The resulting character string is then interpreted as the full or relative path name of a CDD object. The resultant path name must conform to the rules for forming CDD path names.

There are two types of CDD path name: full and relative. A full path name begins with CDD$TOP and specifies the given names of all its descendants; it is a complete path to the record definition. Descendant names are separated from each other by a period.

A relative path name begins with any generation name other than CDD$TOP, and specifies the given names of the descendants after that point. You can create a relative path by establishing a default directory with a logical name. For example:


$ DEFINE CDD$DEFAULT CDD$TOP.PLI

This logical name definition specifies the beginning of the CDD path name; thus, a relative path name specifies the remainder of the path to the record definition. Note also that a CDD path name beginning with CDD$TOP overrides the default CDD path name. For example, if you have a record with the following path name:


CDD$TOP.SALES.JONES.SALARY 
You can specify a relative path name as follows:


%DICTIONARY 'SALARY'; 

Or you can specify an absolute path name as follows:


%DICTIONARY '_CDD$TOP.SALES.JONES.SALARY'; 

The compiler extracts the record definition from CDD and inserts the PL/I structure declaration corresponding to the record description in the PL/I program.

A %DICTIONARY statement can appear as a statement by itself, or it can appear within a regular PL/I structure declaration. However, the resulting structures appear somewhat different, depending on the way %DICTIONARY is included.

If the %DICTIONARY statement is not embedded in a PL/I language statement (that is, if %DICTIONARY immediately follows a nonpreprocessor semicolon or is the first statement in the program), then the resulting structure is declared with the logical level 1, and the BASED storage attribute is furnished. The logical member levels increment from 2. For example:


DECLARE PRICE FIXED BINARY(31); 
%DICTIONARY 'ACCOUNTS'; 
would result in a declaration of the form:


DECLARE PRICE FIXED BINARY(31); 
DECLARE 1 ACCOUNTS BASED, 
          2 NUMBER, 
            3 LEDGER CHARACTER(3), 
            3 SUBACCOUNT CHARACTER(5), 
          2 DATE CHARACTER(12), 
           .
           .
           .

Notice that in the previous example, ACCOUNTS is a relative dictionary path name.

If the %DICTIONARY statement is embedded in a PL/I language statement, as in a structure declaration, then the resulting structure is declared with no logical level and no storage attribute. Logical member numbers are supplied and incremented from 100. For example:


DECLARE 1 COMMON_INTERFACES STATIC EXTERNAL, 
          %DICTIONARY 'ACCOUNTS';   , 
          %DICTIONARY 'ADDRESSES';  ; 
Notice the syntax in this example: the %DICTIONARY statement is terminated with the usual preprocessor terminator semicolon before the normal PL/I punctuation. The normal PL/I punctuation must also be included so that the final structure declaration will contain proper PL/I punctuation. At compile time, this declaration would result in a declaration of the following form:


DECLARE 1 COMMON_INTERFACES STATIC EXTERNAL, 
          100 ACCOUNTS, 
            101 NUMBER, 
               102 LEDGER CHARACTER(3), 
               102 SUBACCOUNT CHARACTER (5), 
            101 DATE CHARACTER(12), 
            .
            .
            .
          100 ADDRESSES, 
           .
           .
           .

When you extract a record definition from the CDD, you can choose to include this translated record in the program's listing by using the /LIST/SHOW=DICTIONARY qualifiers on the PLI command line.

CDD data definitions can contain explanatory text in the CDDL DESCRIPTION IS clause. If you specify /SHOW=DICTIONARY, this text is included in the PL/I listing comments. You can use these comments to indicate the data type of each structure and member. The punctuation for CDDL comments is the same as for other PL/I programs.

Even if you choose not to list the extracted record, the names, data types, and offsets of CDD record definition are displayed in the program listing's allocation map.


Index Contents