Previous Topic Next topic Print topic


Compiling the Source Code

Important: You need Enterprise Developer or Enterprise Developer for IBM zEnterprise to create executables. Building projects is not supported in Enterprise Developer Connect.

To compile the application:

  1. Click Build > Build Solution.

    The Output window displays information about the progress of the build result

  2. If there are any problems, check the Error List window. Double-click on a line for an error number to position the cursor on it.

The build checks for any files that have changed and does two things:

  • Compiles any files affected by the changes
  • Relinks the built files if necessary

COBOL Compiler control

The Micro Focus COBOL Compiler can compile many different COBOL dialect variations. It can also compile COBOL code that contains EXEC CICS or EXEC SQL statements. The Compiler is controlled through a series of "directives" which are passed to the Compiler at build time. You can set directives at either a project or component level.

Often the directives can be set only at the project level, which means that all component files in the project use them. Sometimes, you have a component which you need to compile with different directives. In this case, you can set the directives at the component level which overrides the project settings.

For example, most of the programs in your project could be using Enterprise COBOL for z/OS and only a few could use VS COBOL II. In this case, you would set directives for Enterprise COBOL for z/OS at the project level, and VS COBOL II at the respective COBOL programs.

The Bankdemo application already has the required Compiler directives set on the files. At build time, the IDE invokes the COBOL compiler to compile the sources and create a number of files. These "built" files can vary, but each COBOL program in the Bankdemo application compiles to produce the following three types of file:

File type Function
.dll - dynamic link library Effectively the executable module the Compiler creates for each program.
.idy - debugger information The file created by the Compiler which allows debugging of the module.
.obj - object file A temporary file the Compiler creates while producing the .dll. You can delete these files.

BMS Compiler control

In the same way as for COBOL, the BMS compilation is controlled both at project and at component level.

The BMS Compiler produces the following two types of file:

File type Function
.mod - BMS executable A file created by the BMS compiler which is the executable module relating to the BMS source.
.cpy - copybook A copybook that contains the BMS mapping for use in a COBOL program.

Producing a Compiler listing

You can configure the IDE to create a fully expanded Compiler listing file during the build. The following is also an example of setting a directive at component level:

  1. In Solution Explorer, right-click ZBNKPRT1.cbl and click Properties.
  2. Set Generate listing file to Yes, and click OK.
  3. Click Build > Build Solution.

During the build, the Compiler produces a source listing file, ZBNKPRT1.lst, in a Listing subfolder in the project directory (C:\MFETDUSER\Bankdemo\Projects\Studio\Bankdemo\Listing in this case). The listing file includes a fully expanded source file together with some Compiler system information at the start and with any Compiler errors highlighted with asterisks. From Windows Explorer, you can open the file in a text editor such as Microsoft's Notepad and view its contents.

Example of compiling a COBOL program with errors

You can introduce some Compiler errors into one of the programs to see how the Compiler handles them:

  1. In Solution Explorer, double-click ZBNKPRT1.cbl.
  2. Page down the program a few pages to the start of the Procedure Division around line 021600.
  3. Introduce a few syntax errors as follows:
    • On line 21800 change RUN-TIME to RUN-TME
    • On line 22100 change SPACES to SPOCES
    • On line 22900 place a period after the END-IF

    The errors are underlined with red wavy lines and a colored bar is added to the left of each line that includes an error.

  4. Hover over an underlined item to view a pop-up with an explanation of what the error is.
  5. Save the program and build your solution.
  6. Check the Error List window to view the list of errors.
  7. Double-click an error in the list to position the cursor on the line of code that contains the error.
  8. Check the errors in the listing file, ZBNKPRT.lst as follows:
    1. In Windows Explorer, navigate to C:\MFETDUSER\Bankdemo\Projects\Studio\Bankdemo\Listing and open the file in a text editor.

    The lines that include syntax errors are marked with asterisks (**).

  9. In the IDE, fix the errors and save the file.

    There should be no errors in the build now.

Previous Topic Next topic Print topic