Extracting COBOL code to a copybook

To help reduce data structure duplication across your COBOL applications you can extract a block of COBOL code to a copybook. To extract the code, perform the following steps:

  1. In the COBOL editor, highlight the lines that you want to extract to a copybook.
  2. Right-click in the COBOL editor, and then click Refactor > Extract to Copybook. Alternatively, from the main menu, click Refactor > Extract to Copybook.

    This opens the Extract to Copybook dialog box where Containing project contains the current project.

  3. In the New file name field, type a copybook file name with either a .cpy or .cbl file extension.
  4. Optionally, click Preview to view the changes to be performed. In the Changes to be performed pane, you are presented with a list of the actions to be taken. By default, all actions are checked. You can uncheck actions to obtain the required results. Clicking on the actions displays the result of the actions in the Original Source and Refactored Source panes.
  5. Click OK.

    By default this extracts the highlighted source code to the specified copybook and refactors the original source, leaving a COPY statement referencing the newly-created copybook.