>>-.---.-.-------ILSMARTLINKAGE---.-------------.--.-------->< +-/-+ | +-"namespace"-+ | +-----NOILSMARTLINKAGE--------------------+
Default: | ILSMARTLINKAGE |
Phase: | Syntax check |
$SET: | Initial |
IDE Equivalent: | Check Expose group linkage items to managed code on the COBOL tab in the project's properties. |
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 C#, you can access the data in BookLegacy program in .NET 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-b-details . . . myDetails.Stockno = "6666"; myDetails.Title = "Managed COBOL"; myDetails.Author = "Mike Focus"; myDetails.Type = "Reference"; myDetails.Retail = 15.50M; myDetails.Onhand = 20; myDetails.Sold = 5; myBook.BookLegacy("2", myDetails); // calls the BookLegacy method with myDetails, // which corresponds to the group item lnk-b-details
See the C# WinBook demonstration in the Enterprise Developer samples for more.
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 .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 .Reference property. 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 .Reference with the RunUnit:Call() method – for example: