COBOL Compiler directives are statements that determine how the program is compiled and behaves. To ensure that the program in the tutorial executes as expected, you need to set these. To do this, you need to:
For this tutorial you set a global Compiler directive.
You need to specify the ILNAMESPACE directive to ensure that you put the program in the right folder structure, and use the right package. When you import the program into Java, the namespace will then interact correctly with Java packages.
ilnamespace(com.microfocus.book)
The project is rebuilt.
Checkpoint:
This time, the COBOL program is built in the specified namespace. Observe that the file, BookLegacy.class, is now located in the bin/com/microfocus/book folder.
In addition, you need to specify the ILSMARTLINKAGE directive to ensure that the linkage between the COBOL program and the Java code is handled correctly. The Micro Focus SmartLinkage tool converts between traditional COBOL group item types and Java types. For example, a field defined as PIC X(99) will be exposed as a Java STRING, and a COMP-5 field will become a Java int. This feature makes calling COBOL programs from Java much easier.
Procedure
ilsmartlinkage
The project is rebuilt.
Checkpoint
You will see additional files in bin/com/microfocus/book. These are LnkBDetails.class, LnkFilename.class, and LnkFileStatus.class. These are classes generated to represent the linkage items in the book.cbl program. The BookLegacy.class file will now have an entry point that takes these wrapper classes rather than just taking a generic reference class that gives direct byte access.Micro Focus recommends that you specify the ILCUTPREFIX directive. You use this directive to remove any prefixes that may be present in COBOL linkage section data-names. This feature ensures legibility in the generated code.
If you open book.cbl and press F4, you can see the contents of the copybooks in this program. If you navigate down to the linkage section there are group items lnk-filename, lnk-file-status, and lnk-b-details. These map directly onto the generated classes mentioned above.
Procedure
ilcutprefix(lnk-b-)and
ilcutprefix(lnk-)
The project is rebuilt.
Checkpoint
Observe the class files in bin/com/microfocus/book. These files are now called Details.class, BookLegacy.class, and FileStatus.class. Note that the prefixes LnkB and Lnk are no longer present in the class filenames.You need to specify the JVMDECIMAL directive. You use this directive to ensure that COBOL decimal data type is treated as an integer numeric item. The use of this directive is a result of specifying the ILSMARTLINKAGE directive.
Procedure
jvmdecimal(scaledinteger)
The project is rebuilt.