Previous Topic Next topic Print topic


Compiling the Source Code

By default, the Eclipse IDE is set to build projects automatically. Whenever you add new COBOL or BMS files to the Bankdemo project, the IDE starts an automatic build (compilation).
Important: You need Enterprise Developer or Enterprise Developer for z Systems to create executables. Building projects is not supported in Enterprise Developer Connect.

To turn the automatic build off:

  • Click Project and disable Build Automatically.

To start a build manually:

  • Click Project > Build Project.

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

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

Turn the automatic build on:

  • Click Project and enable Build Automatically.

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 the Team Developer Tree view, right-click ZBNKPRT1.cbl and click Properties.
  2. Click COBOL in the left-hand pane and check Enable file specific settings.
  3. Check Generate listing file and click OK.

During the build, the Compiler produces a source listing file, ZBNKPRT1.lst, in a Listing subfolder in the project directory (C:\MFETDUSER\Bankdemo\Projects\Eclipse\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. You can view this listing from within the IDE: double-click the .lst file in the Listing folder.

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 the Team Developer Tree view, 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
    • Move one of the copybooks from c:\MFETDUSER\Bankdemo\Sources\Copybook to c:\MFETDUSER\Bankdemo\Sources\jcl using the MOVE... action from the context menu of the copybook entry.

    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.

    This triggers a build of the project which will also update the listing file. The messages in the Console view indicate that there are build errors.

  6. Click the Problems tab to view the list of errors.

    If it is hidden you can open it by clicking Window > Show View > Problems.

    Tip: Click the column headings to sort the list into an appropriate order; for example, click the Program heading to order the errors by program.
  7. Double-click an error in the list to position the cursor on the line of code that contains the error.
  8. To fix the copybook error:
    1. Locate the error related to the unknown copybook in the Problems view and double-click that line in the list of errors.

      This positions the cursor on the line that contains the COPY statement for this copybook.

    2. Right-click the COPY statement, then select Quick Fix.

      The Quick Fix window appears.

    3. Double-click Enable copybook path....

      This displays a message that the directory containing the copybook is not on the copybook path for the project.

    4. Click Yes to add the c:\MFETDUSER\Bankdemo\Sources\jcl folder where you moved the copybook to the copybook path of the project.

      This triggers a rebuild of the project which now compiles cleanly as it now locates the copybook.

  9. Check the errors in the listing file, ZBNKPRT.lst as follows:
    1. Double-click the .lst file in the Listing folder.

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

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

    There should be no errors in the build now.

    Note: Move the copybook back to its original directory in case other projects are expecting to locate it there.
Previous Topic Next topic Print topic