0

So I'm attempting to work with files that are created as COBOL fixed length records. I was given the raw data files (.GCUS file extension) and a "file layout" document that has specifications which include a table with the following columns "Position, Picture, Type, Description" (it has two sections, a "header" record and a "Detail Record A".

I have never worked with any COBOL file types before and I'm trying to find a way to parse and read these files for use in an internal application and ideally I need them to be re-exported in either CSV or XML so I can import them in the application we're building.

So far the only software I've found that can read these files is this one: https://www.fundmanagersoftware.com/

But I haven't found the option within it to actually export to a CSV or XML.

Any suggestions would be greatly appreciated.

2 Answers2

0

This open source project should do the trick

http://cb2xml.sourceforge.net/

Given a COBOL copybook it generates a java program to convert the data.

James Anderson
  • 27,109
  • 7
  • 50
  • 78
  • Could you please post a link to the project you're referencing? Also I don't have a COBOL copybook but I do have the "Header Record", "Detail Record", & "Trailer Record" details in a PDF file. – user3062109 Sep 20 '19 at 17:35
  • Google "cobol copybook convert java" and take your pick. – NicC Sep 21 '19 at 19:51
  • Oops missed the link somehow. – James Anderson Sep 22 '19 at 08:36
  • **cb2xml** converts a Cobol-Copybook to Xml / Java objects not much use here. https://sourceforge.net/projects/jrecord/ could be used. The File Definition can be Cobol, Xml or defined in Java. – Bruce Martin Sep 23 '19 at 23:21
0

If you have documentation of the fields in each type of record, you can put a comma between each field and voila you have a CSV.

You already have the starting offset (and implied length) for each. The picture clause along with the type should give the format.

If there are any binary or packed decimal fields (COMP or COMP-3) you may have to convert the byte values to numerics. Information about this should be available elsewhere on the internet, in COBOL primers, and here on SO. Search for "COBOL PIC CLAUSE" for relevant information such as at http://www.3480-3590-data-conversion.com/article-reading-cobol-layouts-1.html

If you want more specific help, post sample data and file layout details.

Turophile
  • 3,367
  • 1
  • 13
  • 21