Previous Topic Next topic Print topic


Creating a COBOL Copybook File

In COBOL, a copybook file is used to define data elements that can be referenced by many programs. When the Declaration Generator creates a declaration for a COBOL program, it writes it to a copybook file (.cpy file).

To create a COBOL copybook, start the Declaration Generator utility, then follow the steps below:

  1. In the Language group box, click the COBOL button.
  2. In the Table group box, select the Location, AuthID and Table Name that identifies the table for which you want to create a copybook.
  3. If you want to change the name of the file to which the copybook is written, type a new name in the Output File field (the Declaration Generator automatically places a default name based on the table name in this field).

    If you don't specify a path, the copybook is written to the first directory specified in the COBCPY environment variable. If this variable isn't found, the copybook is written to the current application path (the application path is specified in the PATHS tab in Options).

    If you specify a file that already exists, you are given the choice of appending to it or overwriting it at run time.

  4. If you want to change the name of the record description, type a new name in the Structure field.
  5. If you want to add a prefix to each of the elementary item names, type it in the Field Prefix box. You can end the prefix with a special character such as a dash (-) to set it off from the rest of the name. For example, if a prefix of EMP- were specified, field names would be written as follows:
    EMP-lname PIC X(15) 
    		EMP-fname PIC X(10) 
    		EMP-dept PIC X(12) 
    		.
    		. 
    		.

    Remember the COBOL variable-naming guidelines when assigning a prefix. Do not assign one containing characters that are disallowed by the compiler or one that might make the elementary item name too long.

  6. When you specify a prefix, you can optionally check the Numbered option to assign numbers instead of field names to the elementary items. If Numbered were checked using the EMP- prefix in last example, the declaration would be written as follows:
    EMP-001 PIC X(15) 
    		EMP-002 PIC X(10)
    		EMP-003 PIC X(12) 
    		.
    		. 
    		.
  7. In the Computation box, select the COMP type that you want use for the table's Int and Smallint fields.
  8. Click Options and set the following options as needed:
    For this option... Specify...
    Level The level number you want assigned to the record description. If you leave this field blank, Level 1 is assigned.
    Graphic Type The PIC type you want to use for graphic, vargraphic and long vargraphic fields in the table.
    Page Size The page size you want assigned to long varchar, long vargraphic, and long varbinary fields.
  9. Click OK to close the Declare Options dialog.
  10. If you want to save your specifications, click the Save As button, specify a file name and click OK. The specifications will be saved to a .DGE file, which can be used as input to the Declaration Generator's batch mode. See Running in Batch Mode for more information about .DGE files and batch mode.
  11. Click the Generate button to generate the COBOL copybook file.
Previous Topic Next topic Print topic