-4

Currently I've a job to rewrite some library which communicate with COBOL Mainframe via ViewCall (Not sure if this is a universal term or not). The response will be a fixed length string according to the copybook. Are there any solutions or approach for Java to map this fixed length string to model class using copybook as a mapper instead of manually cut the strings and set it to model class?

1 Answers1

1

Some possible Solutions:

  • For small Text Copybooks hand coding is feasible.
  • next step up is to use cb2xml and generate the code. Cb2xml will calculate position and length for you. This answer shows what can be done with cb2xml.
  • Use JRecord ~ CodeGen to generate java classes. See Generating Java Code for details on generating Java code. Java Jrecord is orientated to Files but should be usable. Remember there is a fair overhead in passing the Cobol copybook.

For a one off request with a small record, hand coding is viable option but you run the risk of subsequent requests coming along.

Bruce Martin
  • 9,845
  • 1
  • 24
  • 36