3 min read time

AMC Tech Tips: Project COBOL (Part 1 of 2)

by   in Application Modernization

Introduction: Moving to the Visual Studio Project System

In my previous article, I commented on some of the benefits associated with having a project system when using Micro Focus Visual COBOL/Enterprise Developer. This time let's talk about what's actually required to move to the Visual Studio (VS) project system. The general process involves identifying which COBOL sources should be grouped logically together in a project and the compiler directives that are required to compile them.

Note that for people using the Eclipse Integrated Development Environment (IDE), the project system differs from VS, so I would recommend looking at the docs for those interested in Eclipse. The general process for creating a project is very similar between the two IDEs.

Before trying to move a COBOL application into a project, I would recommend creating a simple native COBOL project within VS or looking at the included product samples to get a feel for the structure of the project system.

Project structure and identifying logical groupings for a project

VS uses a solution file (.sln) as the top level element that gets loaded by the IDE. The solution file contains references to one or more projects (.cblproj) which actually contain references to the COBOL sources and configuration. On-disk, the folder structure of a typical VS project structure looks like the following (folders in bold)

  • BankApp
    • BankApp.sln
    • Lending
      • Lending.cblproj
      • LoanCalculator.cbl
      • MortageCalculator.cbl
      • ...
    • CustomerManagement
      • CustomerManagement.cblproj
      • AddCustomer.cbl
      • LookupCustomer.cbl
      • ...

There will be some generated folders (such as bin and obj) in the project directories, which get created during a build, so can be safely ignored for now. When I refer to the project directory, this is the folder that contains the project file; and equally the solution directory is the one containing the solution file.

The first step is to identify which COBOL sources are closely related and try to group them logically. Possible strategies may be to group by functionality, or programs that are used frequently together. In the example above, I've grouped all lending related programs together and all customer management programs together.

Whilst this is not strictly needed, it makes the workflow for the developer simpler. Files are easier to locate since they are ordered logically, and define some structure to the application. Note that project settings are shared by all COBOL sources that are contained within the project, so that may help decide where the project boundaries should be.

Creating a project and adding sources

Once logical boundaries have been decided, a developer then needs to create the solution and projects in VS. For this example, I will be creating a Native COBOL console application. To do so:

  1. Open Visual Studio
  2. Select File -> New -> Project...
  3. Select COBOL -> Native in the left tab
  4. Select Console Application as the project type
  5. Provide a project and solution name, then press OK



Once the solution and project file have been created, the COBOL sources then need to be added.

  1. Right click on the project node in Solution Explorer
  2. Select Add -> Existing Item...
  3. Locate files that should be added and press OK
    • It is possible to select multiple files at once with the shift key
    • Default behaviour is to copy the files into the project directory. If the developer does not want the file to be copied, then Add As Link can be used. This option is present in the Add dropdown.



To create any additional projects once a solution is defined, simply do the following:

  1. Right click on the Solution item in the Solution Explorer
  2. Select Add -> New Project...

Locating copybooks

Once the projects have been created and source files added, the typical next step is to locate any required copybooks. This can be done by setting the copybook paths in the project settings. Once set, the COBOL programs will be able to resolve copybooks with the copy statement.

  1. Double click on the Properties item under the Project node in Solution Explorer to open the project settings
  2. Configure the paths under the Copybooks tab
    • Note that for certain project flavours, this may instead be under the Dependency Paths tab


 It is possible to directly add copybooks to the project itself, though this is not the preferred method. Adding a copybook directly into a project is normally done when it will only be referenced by programs within the same project.


The post has covered how to create the basic project structure, add sources and configure the resolving of copybooks. In my next post I will be covering the configuration of directives.


Visual COBOL