C#/Java COBOL interop made easy with SmartLinkage - please give us your feedback
Original Question: C#/Java COBOL interop made easy with SmartLinkage - please give us your feedback by Paula Willis
[Migrated content. Thread originally posted on 19 September 2011]
COBOL has one of the most extensive type systems of any programming language.
Other languages only support a subset of the types COBOL has to offer, which has made it difficult to access data in existing COBOL applications, without code changes or writing wrapper classes.
SmartLinkage is a feature that was added in Visual COBOL R4 as a “Technology Preview”, to offer an instant solution.
This makes COBOL linkage data access easy from other managed languages, such as C#, Java, VB, COBOL.
We’d like your feedback to help us define the way forward. What would you like to see in terms of usability and functionality?
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
Easy configuration steps
• 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
– 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".
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;
Compiling a COBOL program with ilsmartlinkage directive exposes the COBOL data items as the following types on .NET & JVM.
COBOL C# types Java types
PIC X(n) string String
PIC S9(n) n
PIC 9(n) n
PIC 9(n) 2
PIC S9(n) 4
PIC 9(n) 4
PIC S9(n) 9
PIC 9(n) 9
PIC 9(n)V9(m) decimal ScaledInteger
PIC S9(n)V9(m) decimal ScaledInteger
COMP-1 float float
COMP-2 double double
PIC Z9 (any numeric edited) string String
PIC A(n) string String
Group item string String
For more information :
• Free download of Visual COBOL R4
• See the “C# WinBook” sample in Visual COBOL for Visual Studio R4
This 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.
Please download Visual COBOL R4 and let us know if you found SmartLinkage useful and how you’d like to see this feature presented in the next release.
Question: RE: C#/Java COBOL interop made easy with SmartLinkage - please give us your feedback by Joachim BlomeI currently am supporting a client, that is putting a Silverlight frontend to his application. The application is already built out of services. As Silverlight needs some support on the server that Visual COBOL cannot (yet) handle, the server will have C# at the service entry, from here the original service will be called. Smartlinkage will be fun to use there.
The customer already saw the webcast on the NetExpress conversion and found this impressive.
Question: RE: C#/Java COBOL interop made easy with SmartLinkage - please give us your feedback by spgennardHi,
The later is not available today but with the use WebSockets or ajax requests you can interop with a server side COBOL service.
Question: RE: C#/Java COBOL interop made easy with SmartLinkage - please give us your feedback by Joachim BlomeStephen,
I share your view on the way, things will change in the future.
My client (an ISV) has some business, where Silverlight is a requirement today. It will be done in C# - and Smartlinkage is a very nice way to interface with the legacy services. All of the real processing including some neccesary data type changes are done in COBOL, and that did already survive various transitions.
Question: RE: C#/Java COBOL interop made easy with SmartLinkage - please give us your feedback by spgennardI hope the customer understands that our .Net product and more specifically our .Net runtime/support assemblies will not load in a Silverlight environment due to the fact this is not a standard CLR (CoreCLR) and its base class library is different and it will require us to change our runtime and to the best of my knowledge this is not been done.
Question: RE: C#/Java COBOL interop made easy with SmartLinkage - please give us your feedback by Joachim BlomeThe cuatomer has been educated on all the issues on Silverlight. Connection between a Silverlight client (C#) and a server using WCF, another small C# layer and then Visual COBOL is working here.