>>-.---.-.-------ILSMARTLINKAGE---.-------------.--.-------->< +-/-+ | +-"namespace"-+ | +-----NOILSMARTLINKAGE--------------------+
Default: | ILSMARTLINKAGE |
Phase: | Syntax check |
$SET: | Initial |
IDE Equivalent: |
The following COBOL program is compiled with ILSMARTLINKAGE, ILCUTPREFIX(lnk-b-) and ILCUTPREFIX(lnk-):
program-id. BookLegacy. ... linkage section. 01 lnk-function pic x. 01 lnk-b-details. 03 lnk-b-text-details. 05 lnk-b-title pic x(50). 05 lnk-b-type pic x(20). 05 lnk-b-author pic x(50). 03 lnk-b-stockno pic x(4). 03 lnk-b-retail pic 99v99. 03 lnk-b-onhand pic 9(5). 03 lnk-b-sold pic 9(5) comp-3. procedure division using by value lnk-function by reference lnk-b-details.
In Java, you can access the data in BookLegacy program in JVM COBOL as follows:
BookLegacy myBook = new BookLegacy(); //creates an object corresponding to the BookLegacy program Details myDetails = new Details(); //creates an instance corresponding to the group lnk-bdetails . . . myDetails.setStockno("6666"); myDetails.setTitle("Managed COBOL"); myDetails.setAuthor("Mike Focus"); myDetails.setType("Reference"); myDetails.setRetail(new ScaledInteger(155, 5)); myDetails.setOnhand(20);
Comments:
This directive exposes group linkage items to managed code. In addition to the class generated as usual for the COBOL program, this directive effectively generates one class for every 01 level group item in the linkage section. Each data item in the group is exposed as a property of this class, where the property is of a standard managed type.
COBOL group items are exposed as string properties. If the group contains non-DISPLAY data (e.g. numeric COMP items), it will not be possible to use the property associated with the group to populate these non-DISPLAY items. In this case, these non-DISPLAY items must be populated using the individual properties associated with these non-DISPLAY items.
Hyphens are removed from data item names and the letter following a removed hyphen is folded to upper case. For example a data item author-name is renamed to AuthorName.
If a namespace is specified, all classes generated as a result of this directive are grouped under that namespace.
Compiling with ILSMARTLINKAGE generates classes and types that includes an extra method or a property called get_Reference(). If you pass such a class or type as a parameter to a program that receives it “by reference”, you need to use the “by reference” object by specifying the get_Reference() method. This returns an object that encapsulates the SmartLinkage parameter so it is used with a method that is declared "by reference”.
You also need to use get_Reference() with the RunUnit:Call() method – for example: