By creating nested classes, programs within the same compilation unit can have linkage records with the same name.
The following COBOL program is compiled with ILSMARTLINKAGE, ILSMARTNEST, 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). 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 BookLegacy.Details myDetails = new BookLegacy.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