Creating Copybooks from Selected Lines of Code

Within the editor, you can select one or more lines in a COBOL program or copybook and move them to a new copybook file. The selected lines are replaced in the original program with a COPY statement that references the new copybook.

To create a copybook from lines selected in the editor:

  1. In the editor, select the lines of code you want to move into a copybook.
  2. Right-click the selection and click Extract to Copybook. This opens the Save As dialog box, prompting you to create a copybook. By default, this offers to create the file in the directory that stores the program in which you made a selection.
  3. Specify a filename and location for the copybook and click Save. This creates a copybook file in the specified location. The file includes the entire lines of code for your selection in the editor.

    In the editor, the selected code is replaced by a COPY statement that refers to the new copybook and shows it in expanded copybook view. The case of the statement is as defined on the Formatting page in Tools > Options > Text Editor > Micro Focus COBOL.

    If you chose to save the copybook in a directory other than the default, this also adds that directory to the list of copybook locations on the Copybooks tab in the project’s properties.

Tip: When you make a selection in the code, the editor shows a quick action (and the light bulbs feature) offering to extract the selected code into a copybook. See Using Light Bulbs with COBOL.