NOTICE: Our Community is moving. Get more information. Updated information on a New Login Process
SmartLinkage – what does it do?
Prior to R4, if you wanted to call a COBOL program from another language, you had to create wrapper functions to convert the COBOL data items to managed types. SmartLinkage does that for you, so you can access COBOL linkage data from other managed languages transparently.– No hand-written wrapper classes needed– No changes required to the original code– COBOL data shown in C#/Java/COBOL intellisense
• Project1 (COBOL)
– Create a managed project and add COBOL code– Compile with the ilsmartlinkage directive• Project2 (eg C#)– Create a C# project in the same solution– Add a project reference to Project1– Add a reference to MicroFocus.COBOL.Runtime (unless Project2 is COBOL)– Now you can access Project1’s linkage data directly
• Default– hyphens are removed from COBOL data names and the following letter upper-cased eg lnk-details is accessed from C# as lnkDetails • ilcutprefix(x) directive– Allows you to configure data item names– Strips the text x from the front of the COBOL name eg ilcutprefix(lnk) lnk-details is accessed from C# as Details
Each 01 group linkage item is exposed as a class with subordinate fields exposed as properties.For example, in the following COBOL program, compiled with the ilsmartlinkage directive, a class is created for the lnk1 linkage item that contains 2 properties, a string and an int. program-id program1 as "program1". linkage section. 01 lnk1. 03 sub-lnk1 pic x(20). 03 sub-lnk2 pic 9(5). procedure division using by reference lnk1.My calling C# program: program1 myProg = new program1(); lnk1 myLinkage = new lnk1(); myLinkage.subLnk1 = “myString”; myLinkage.subLnk2 = 1234; myProg.program1(myLinkage);Type Mapping
program-id program1 as "program1". linkage section. 01 lnk1. 03 sub-lnk1 pic x(20). 03 sub-lnk2 pic 9(5). procedure division using by reference lnk1.
program1 myProg = new program1(); lnk1 myLinkage = new lnk1(); myLinkage.subLnk1 = “myString”; myLinkage.subLnk2 = 1234; myProg.program1(myLinkage);
Compiling a COBOL program with ilsmartlinkage directive exposes the COBOL data items as the following types on .NET & JVM.COBOL C# types Java typesPIC X(n) string StringPIC S9(n) n <= 2 sbyte bytePIC 9(n) n <= 2 byte bytePIC S9(n)2 < n <= 4 short shortPIC 9(n) 2 < n <= 4 ushort shortPIC S9(n) 4 < n <= 9 int intPIC 9(n) 4 < n <= 9 uint intPIC S9(n) 9 < n <= 19 long longPIC 9(n) 9 < n <= 19 ulong longPIC 9(n)V9(m) decimal ScaledIntegerPIC S9(n)V9(m) decimal ScaledIntegerCOMP-1 float floatCOMP-2 double doublePIC Z9 (any numeric edited) string StringPIC A(n) string StringGroup item string String
COBOL C# types Java typesPIC X(n) string StringPIC S9(n) n <= 2 sbyte bytePIC 9(n) n <= 2 byte bytePIC S9(n)2 < n <= 4 short shortPIC 9(n) 2 < n <= 4 ushort shortPIC S9(n) 4 < n <= 9 int intPIC 9(n) 4 < n <= 9 uint intPIC S9(n) 9 < n <= 19 long longPIC 9(n) 9 < n <= 19 ulong longPIC 9(n)V9(m) decimal ScaledIntegerPIC S9(n)V9(m) decimal ScaledIntegerCOMP-1 float floatCOMP-2 double doublePIC Z9 (any numeric edited) string StringPIC A(n) string StringGroup item string String
• Free download of Visual COBOL R4• See the “C# WinBook” sample in Visual COBOL for Visual Studio R4This shows a C# WinForm using SmartLinkage to access COBOL legacy program data directly. • You can see a demo of this technology in a recent webinar - “Visual COBOL for Visual Studio R4 – Migrating from Net Express”.The demo takes a Net Express application, moves it to Visual COBOL for Visual Studio. Then modernizes the front–end with a COBOL WinForm using SmartLinkage.