Adding Existing Code to an AcuBench Program

To preserve the greatest amount of flexibility and ensure the greatest long-term ease of maintenance, the best option is adding your existing source code to a new AcuBench program. This option provides you with access to all of the AcuBench code generation and automation tools, and after the initial investment of time, requires the least amount of manual intervention to maintain and add to your code going forward. If you are using AcuBench as part of a legacy modernization process that involves increased use of graphical user interfaces and/or graphical reports, the ease with which you can add and update graphical features to an AcuBench program will likely render this initial investment well worthwhile.

In preparation for this process, the first thing to understand is how AcuBench generates code, and specifically how AcuBench uses program tags (discussed in section Program Tag Options) to determine where to generate code. These program tags act as cues, telling AcuBench where to place different sections of a COBOL program. They are also used to indicate insertion points, at which the code that you define in the AcuBench graphical designers is placed. To understand how to bring your existing code into a new AcuBench program, you must understand where to place your code, so that it can be integrated into the generated program.

Step 1: Define your data

As with every method of working with AcuBench, the process starts with data. When you bring your FD and SELECT statements into the File Designer, the IO Handling interface provides a central repository for storing the file handling code associated with a specific data file.

Specific methods for bringing your data definitions into AcuBench are discussed in Working with Data at the Project Level.

Step 2: Create the program

Before creating the AcuBench program, think about how code will be generated for the program. Do you want code to be generated into a single source file or split into multiple COPY files (the default)? Which program tags will you need? Study the Code Generator section of the Tools > Options interface, as described in Customize Your Working Environment, and set the code generation rules that best apply to your practices.

Chapter Working with Programs provides an overview of the program creation process, including information about the program properties that you can customize and control.

Step 3: Define your data sets

Data sets are used to specify how the data defined in project-level data layout files are used by an individual program. When you define a data set, you determine what file handling code is generated (OPEN, READ, DELETE, CLOSE), which key (if applicable) is used to start the file, and so on. In addition, data defined in data sets is exposed to the various AcuBench graphical designers, making it easier to create screens and reports, for example.

The process of defining data sets is described in Working with Data at the Program Level.

Step 4: Add your Working-Storage data

By default, once a program contains screens and reports, AcuBench performs an automatic check to verify that the variables used by those screens and reports have been defined within the program. If AcuBench cannot locate those data definitions, it adds them to the graphical Working-Storage Designer. To correct problems with duplicate names, it is a good idea to bring your existing Working-Storage data definitions into the graphical designer before adding screens or other code.

You can use either of the following methods to bring your Working-Storage code into AcuBench:

  • Copy and paste the code in from your existing source.
  • Place the Working-Storage code in a COPY file and use the Link COPY File or Import COPY File commands from within the designer.

The Working-Storage Designer interface is described in Working with Data at the Program Level and Using the Working-Storage and Linkage Editors.

Note that, by default, AcuBench generates Key-Status definitions for all generated programs. If your Working-Storage section contains Key-Status definitions, you can either disable the automatic generation of Key-Status code or add your definitions to the AcuBench interface used to generate this code. These Key-Status options are discussed in section Key-Status.

Step 5: Import or re-create your screens

The last two sections of this chapter discuss the process of importing existing character-based and graphical screens into AcuBench. These import utilities provide a starting point for working with existing screens in the graphical Screen Designer.

As you begin to work in the Screen Designer, keep in mind the following points:

  • Although the Property window contains long lists of screen and control properties, most of these settings shown here are defaults that you will have no need to change.
  • In most cases, when the Property sheet provides a way to associate a fixed value (Value property) with an item, it also provides a way to associate a variable (Value Variable property) with the item.
  • The Event tab of the Property sheet serves two purposes. It helps you associate codes with screen events and exceptions, and provides access to insertion points in the generated source (Before Routine, After Routine, Before Initdata, After Initdata) where you can add your own code.
  • The Event Editor provides additional insertion points for adding program code (Before Program, After Program) and file handling code (Declaratives, Before DeleteFile), accessed by selecting a program or data set from the Control drop-down list, then selecting an insertion point from the Message drop-down list.

The Screen Designer and Event Editor discussed in chapter Working with Screens.

Step 6: Add your code

As discussed in Step 5, the Event Editor is both used for event, exception, and termination procedures, and to access insertion points in the generated code. Each of these insertion points is associated with a program tag, making them relatively easy to identify when stepping through the code in the debugger.

It is difficult to offer general rules for how to determine which pieces of code go where. The better you understand AcuBench’s code generation rules, and the program tags that the code generator uses to identify and place code within the code skeleton, the more straightforward the process will be.