Best Practice When Upgrading a Legacy Application

There are different ways in which you can start using Visual COBOL to develop your applications created with a legacy Micro Focus product such as Net Express, Server Express, or Mainframe Express.

The quickest approach would be to open individual files in Visual Studio and use the IDE to edit, compile and debug them. The approach that Micro Focus recommends is to create a Visual Studio project and take advantage of the many project-handling features offered by Visual COBOL.

The following sections highlight stages of the development process where Micro Focus has recommendations about the best way to proceed when upgrading large projects.

Create a project for your source code

Regardless of whether you have used a project file before, Micro Focus recommends that you create one or more projects in Visual COBOL for your application files. Using a project file means all of the Visual Studio productivity features will be available to you. See Working with Projects for more information.

If you have a Net Express project for your application, note the following:

  • Visual Studio projects are not direct mappings of existing Net Express projects.
  • A convenient way to import the project into Visual Studio is to use the Net Express Project Import wizard. The wizard analyzes your existing Net Express projects, creates a solution with one or more projects and sets any Compiler directives that were used in the Net Express project.
  • The wizard helps you quickly and easily move your sources from Net Express to Visual Studio. It might not create a perfectly-optimized solution, and you might need to rethink and restructure the initial Visual Studio projects once you have moved your source files to them.

Import your sources into a Visual Studio project

There are a few different ways to create Visual Studio projects and add your source files to them:

  • Use the Net Express Project Import wizard - uses an existing Net Express project. Analyzes the project, creates a Visual Studio solution with a number of projects that use the settings used in Net Express, and adds source files.
  • Create a Visual Studio project, then use Add Existing Item to add your source files. This adds the files to the project without setting any Compiler directives on them.
  • Create a Visual Studio project, then use Add Existing COBOL Items to add your source files. This scans the files to determine which files are programs or copybooks and sets the appropriate build actions on them. It also sets any required COBOL and EXEC SQL directives as specified in Tools > Options > Micro Focus > Directives > COBOL.
  • Use File > New > Project From Existing Code- the wizard walks you through the process of creating a project from files stored in a location. The wizard creates and configures the project, and sets any required Compiler directives on the individual files.

Choosing a project type

Visual COBOL provides the following project types:

Visual Studio project type Description
Native application Choose this type for any existing application that you used to compile in your legacy Micro Focus product or at the command line.
Managed application Choose this project type if you want to take advantage of the functionality of the .NET framework and extend your applications.

Your existing native COBOL applications should compile in a managed (.NET) COBOL project without any changes required.

The benefits of switching to a managed project include:

  • The .NET COBOL dialect makes more COBOL language features adapted for .NET framework available to you.
  • Easier interaction with other managed languages such as C#.
  • The ability to take advantage of a number of widely-used .NET framework features such as Windows Presentation Foundation.
Restriction: Code analysis is not available in managed projects.

Using tabs in your files

Tab size in legacy Micro Focus products (such as Net Express) defaulted to eight spaces while it is four spaces by default in Visual Studio. This means that you might get compiler errors when you try to compile your COBOL sources in Visual COBOL.

If you have your application's Net Express project, you can use the Net Express Project Import wizard in Visual COBOL to upgrade the application. The wizard automatically converts the tabs to four spaces.

If you use another method to import the files into Visual Studio, the tabs will not be converted automatically. In such cases, Micro Focus recommends that you set the SOURCETABSTOP"4" Compiler directive that converts tabs to four spaces.

Do not change the size of the tabs in the Visual Studio preferences, as these preferences apply to all other programming languages you might be working on in the IDE.

Micro Focus recommends that you use spaces instead of tabs in Visual COBOL.

Rename variables that are now reserved words

Micro Focus continues to enhance the COBOL language. New Micro Focus product releases use newer levels of the COBOL language where each level has new words added to the list of reserved COBOL keywords.

When you are upgrading an application from a product that uses an earlier level of the COBOL language, you might find that some of the variable names are now reserved words. See the Upgrade Guide for how you can solve this problem.

To avoid confusion, Micro Focus recommends that you rename the variables whose names that are now reserved words.

Functionality not supported in Visual COBOL

Note that some functionality that was available in older Micro Focus products might work differently or be superseded in Visual COBOL. See Differences between Enterprise Developer and Net Express and Mainframe Express in the Upgrade Guide for more.