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?
Asked
Active
Viewed 176 times
1 Answers
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
- 10,358
- 1
- 27
- 38
-
Hi, the last sentence of your answer is incomplete – Modus Tollens Jun 10 '20 at 04:30
-
Thanks for the advice! I cannot upvote the answer now but I'll try looking into JRecord. – Varut J Jun 10 '20 at 16:40