1

I am trying to convert excel to COBOL data file which has variable length format. I am able to convert excel into tab formatted text file. This data file involves around 400 fields. Instead of trying to set the block length for each block of data, I like to utilize copybook file within my code to convert data to variable length. I am wondering is there any framework or recommendation to achieve this.

Part of Copybook Format

 05 EXTR-PRI-APPLICANT-DATA.
          10 EXTR-PRI-SOC-SEC-TAX-ID-NUM           PIC X(09).
          10 EXTR-PRI-FIRST-NAME                   PIC X(15).
          10 EXTR-PRI-MIDDLE-INITIAL               PIC X(01).
          10 EXTR-PRI-LAST-NAME                    PIC X(25).
          continues for 400 fields.   
SamK
  • 377
  • 9
  • 27
  • Have you looked at Record Editor http://record-editor.sourceforge.net/? I used cb2xml, which the project is based on, and it worked quite well. – michaelok Feb 27 '15 at 21:36
  • Is there a reason you cannot use COBOL's UNSTRING verb to parse the tab-delimited data? – cschneid Feb 27 '15 at 21:39
  • @michaelok-In my project I can't use any built in tools. – SamK Feb 27 '15 at 21:39
  • To select the records vertically, UltraEdit can do that. If you can specify the block sizes, you can use substring method in java. – zawhtut Feb 27 '15 at 21:59
  • There is no such things as a COBOL data file. "Trying to set the block length" means nothing. You want to give a COBOL copybook to Excel and let Excel get on with it? There is nothing remotely variable about the example you have shown. Do you mean you want to write fixed-width columns which will give you a fixed-length record? If you want to set 400 column-widths correctly, use your macro-language. What do you mean by "built-in tools" in your comment? Your question is unclear, requires opinion to answer, and is off-topic as a tool-recommendation except you also say No to tools. – Bill Woodger Feb 28 '15 at 00:37
  • @Bill- I referred copybook format sample above, it shows the length of each block in flat file. It is not a fixed length, it is variable length depends on copybook format. To convert from Excel into flat file is a part of my project. Record Editor commented above is a dedicated tool for my requirement. I changed built-in-tool to tool in my comment, sorry for the confusion. – SamK Feb 28 '15 at 00:47
  • Your title mentions *Java*. Where does that come into play? – lurker Feb 28 '15 at 01:27
  • @Lurker - This is a Java based project and want to add the above requirement on this project. – SamK Feb 28 '15 at 01:29
  • Hm, that doesn't help my understanding. I see a lot of discussion about using COBOL to read a variable length field data file exported from Excel. At what point are you using Java? – lurker Feb 28 '15 at 01:32
  • @Luker - I need to convert data from Excel to flat file (based on copybook format). This is a part of a project based on Java and I like to know is there any frameworks available in java to do this job or any other guidance to get this done. – SamK Feb 28 '15 at 01:37
  • Still confused by "variable". Do you have more than one record type? – Bill Woodger Feb 28 '15 at 10:38

1 Answers1

4

Which Cobol Dialect ????. The format of Numeric data is different for different Cobol compilers. There are also related question or another question

Anyway have a look at these java projects:

  • JRecord it based on the code for RecordEditor. This project can read and write files using a Cobol Copybook. It can also handle multiple record formats in the same file. If it is just a single record format, there is also Csv2Cobol utility. JRecord is well suited for Generic utilities based on Cobol Copybooks
  • Cobol2J - might have problems if there are multiple record formats in the file.
  • Cb2xml - This package will read a Cobol copybook and convert it to Xml. The Xml holds all the Cobol fields with there Starting position, length Picture definition. The latest version has JaXB example code for processing the Xml. Cb2xml is used by JRecord, Cobol2J plus some Commercial packages e.g. Stirling Map editor, CA DevTest Solutions
  • legstar
  • There are other Open Source projects out there but most need more work than the above.
  • There are several commercial packages available that can convert to/from Mainframe Cobol files. e.g. IBM has packages that can generate Java classes for Cobol files. Most are expensive though.

Of the above, all will handle IBM Mainframe Cobol; JRecord offers limited support for other Cobol compilers.

Bill will no doubt mention that if you choose any of the above, you will need to satisfy the auditors of there use. That said, JRecord, Cb2Xml and Legstar are used in either Commercial packages or Large Open Source Transformation projects. Also Legstar looks to be becoming semi commercial, so check the license.


Disclosure: I wrote JRecord, RecordEditor and helped in the writing of Cb2Xml with Peter and Jean-Francois

Community
  • 1
  • 1
Bruce Martin
  • 10,358
  • 1
  • 27
  • 38
  • The task sounds odd anyway. 400 unverified user-entered fields? It is either un-auditable as designed or unimportant. – Bill Woodger Feb 28 '15 at 12:35