COBOL applications often consist of COBOL source files and of copybooks - files that include code that is copied into other programs. Copybooks might not be stored in the same location as the source files. This tutorial demonstrates how to configure a project to locate any copybooks that are not in the project directory.
You are going to modify and configure the Hello COBOL World application which you created in the tutorial Hello COBOL World Application to use a copybook which is external to the project. This is what you are going to do as part of this tutorial:
The changes you make to your project will cause some build issues.
This creates the project in the same solution alongside the HelloCOBOLWorld project.
This project will only store a copybook file.
This creates the file in your project and opens it in the editor. You are now going to add some code to the file from the HelloCOBOLWorld project.
display 'Hello COBOL World!'.
COPY Hello.cpy.
Note that the line for the COPY statement in helloworld.cbl is now underlined with a red wavy line in the editor.
helloworld.cbl now has a red error icon in Solution Explorer. Open the Error List window (click View > Error List) to see the error about the specified copybook not being known. The same error message is displayed when you hover the line for the COPY statement.
Note that the help preferences must be set to Launch in Help Viewer from Help > Set Help Preference.
The cause for this issue is that Hello.cpy is not known to the HelloCOBOLWorld project because it is not in the project directory. To resolve this, you need to add the path to the location of the copybook to the project's properties to enable the project to use the copybook.
You are going to look at exactly where the copybook file is located.
This opens Windows Explorer and shows the contents of the project on the hard disk.
This opens the solution folder and you can see that both project folders,CopybookProj and HelloCOBOLWorld, are subfolders within the solution folder.
In order for the HelloCOBOLWorld project to locate the copybook file, the project needs to be configured with the path to the location of the copybook. To do this:
This opens the tabbed pages with the project's properties inside the IDE.
The build should be successful.
Preserve these projects because you are going to use them for a demonstration of how to debug an application.
Continue with the next tutorial, Debugging the Hello COBOL World Application, which shows some of the debugging techniques in Visual Studio.