Reading cobol datastructures from Java

允我心安 提交于 2019-11-28 17:36:24
Bruce Martin

You could look at JRecord - http://sourceforge.net/projects/jrecord/ or cb2java http://sourceforge.net/projects/cb2java/ both allow you to access cobol files but neither will generate the full classes.


Update Jan 2011

Since the original Answer:

  • JRecord continues be developed. There is now a JRecord Code generator available as either a standalone program or in the Recordeditor. This Code Generator will build JRecord JRecord code from a Cobol Copybook. See RecordEditor Jrecord CodeGen
  • Development on cb2java has stopped
  • cobol2j has been written. There have been no updates for a year.
  • There is also Legstar again nothing published for a few years

Update Aug 2017

The RecordEditor has a Generate option for generating Java / JRecord code from a Cobol Copybook. See RecordEditor Code Generation notes for details.

Update Jan 2018

There is some information on generating Java~JRecord code in this question / answer:

How do you generate java~jrecord code for a Cobol copybook

Yes. I have done that before. I used an ODBC connection to COBOL files, and then with jdbc:odbc bridge, I used metadata information to generate classes, read data and port it all to Oracle.

Here is a nice tutorial on how to access metada information with JDBC. Here is another one.

Keep in mind that you don't need the JDBC:ODBC bridge approach. If you can get a native JDBC driver to connect to your Cobol DataSource, it will be better. In this regard, I also used an IBM native driver. Don't remember the name though. It was a long time ago.

There appear to be some commercial solutions for this. Alternatively you can use cb2xml to convert the copybooks to XML, and then import the XML into Java using whatever mechanism you require.

I have used Bruce's JRecord (from sourceforge) package for my project. It took only couple of days to learn to use it and saved me months of work in rolling out a much less general solution on my own. I recommend it highly.

Microfocus provide a way of calling OO COBOL from Java.

"You can write classes in OO COBOL which can be called from Java programs as though they were Java classes. You do this by providing a Java wrapper class, which provides a function for each method in the OO COBOL class. The Net Express Class and Method Wizards make this easy for you, by generating the Java code at the same time as the COBOL code."

They also provide a tool called Enterprise Server which allows COBOL to interact with web services.

If you have a COBOL program A, the tool allows you to expose A's interface section as a web service.

Of course, because A now has a web service any other type of program (command line, Windows application, Java, ASP etc.) can now also call it and hence pass the COBOL data across to a Java program.

BEA used to have a product named JAM that was used to communicate with mainframe COBOL programs. It included a tool that would read copybooks and generate both corresponding Java POD classes and data conversion code.

I don't know if this is still available, I lost track of it when I left BEA.

Rational Application Developer can read COBOL source code and generate Java classes. The generated classes have methods for accessing the various part of the COBOL data structure. The class that is generated is compatible with the J2EE Connector Architecture. To create a class in your project, select File, New, Other then select the CICS/IMS Java Data Binding wizard under J2C. Click next. Choose COBOL to Java for mapping. Select your COBOL file. Select the structure you wish to generate a Java class for then click Finish and there you go. There are of course a number of options you can select along the way that I didn't mention. For more information search Help for J2C.

Ayman

Have a look at Javolution Struct.

You can then use a macro to convert your COBOL datat into Struct.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!