1

I have a COBOL program which generates a sequential file with this structure:

FD ALUMNOS-FILE.
01 ALUMNOS-DATA.
    88 EOF                 VALUE HIGH-VALUES.
    05 STUDENTID           PIC 9(7).
    05 STUDENTNAME         PIC X(10).
    05 FILLER              PIC X(8).
    05 COURSECODE          PIC X(4).
    05 FOO                 PIC S9(7)V USAGE COMP-3.

If I open the file in Notepad++, I see strange unicode symbols which are difficult to read caused by the COMP-3 variable. Something similar to the image below (the image is from another file):

enter image description here

Is there any way without using COBOL to rewrite this sequential file to be readable? Maybe using a script language like VBS? Any tip or advice will be appreciated, and if you need more info let me know and I'll edit the post.

mllamazares
  • 7,876
  • 17
  • 61
  • 89
  • BTW that's Notepad++, not Notepad. – Lightness Races in Orbit Jul 04 '13 at 14:36
  • @BillWoodger: Since Stack Overflow was created only in 2008 (not 1990), you may safely assume that my comment was a joke, yes. – Lightness Races in Orbit Jul 04 '13 at 16:32
  • The "COMP" bit means "COMPUTATIONAL". "Packed-decimal", which can be COMP-3/COMPUTATIONAL-3/PACKED-DECIMAL, is an "internal" format for a decimal number. It is not about "compacting" or saving space in itself (although that is one way it is used). – Bill Woodger Jul 04 '13 at 16:34
  • Where is your data coming from (compiler/Operating System) and where are you running it? One-long-line means the data you are looking at has no "record separator". Perhaps the COBOL program didn't write separators, perhaps they were deliberately (by accident) dropped in a transfer process to where you see them. – Bill Woodger Jul 04 '13 at 16:37

1 Answers1

4

I would suggest having a look at the Last Cobol Questions

But the RecordEditor will let you view / edit Cobol Files using a Cobol Copybook. In the RecordEditor you can export the file as Csv, Xml if you want.

As mentioned in the Last Cobol Questions there are several solution for Reading Cobol files in Java and probably some in other languages.


To import the Cobol Copybook into the RecordEditor, Select: Record Layout >>> Import Cobol Copybook

Import_Cobol_Copybook

The File-Structure controls how the file is read. Use a File-Structure of Fixed length Binary if all the records are of the same length (no carraige return).

Other Structures supported include

  • Standard Text files File Structures: ** ..Text.. **
  • Cobol Variable Record Length Files. These Typically have a Record-Length followed by the Data. There are versions for Mainframes, Open-Cobol, Fujitsu.
  • The Default File structure will choose the most likely File-Structure based on the Record-Definition. In your case it should choose Fixed length Binary because there is a binary Field in the Definition.

Note: From Record Editor 0.94.4, with a File-Structure of Fixed Length Binary you can edit Fixed Length Text files in a basic Text Editor if you want.

Note: I am the author of RecordEditor

Answer Updates 2017/08/09

Conversion Utilities

For simple Cobol files these conversion utilities (based on JRecord) could be used:

  • [CobolToCsv][5]
  • [CobolToXml][6]
  • [Cobol To Json][7]

RecordEditor

The RecordEditor has a Generate option for generating Java / JRecord code. See [RecordEditor Code Generation notes][8]

enter image description here

Bruce Martin
  • 10,358
  • 1
  • 27
  • 38
  • Really thanks for the answer. Now imagine that the sequential file is all in one line, there is any option in your program to put a line break by the record lenght? – mllamazares Jul 04 '13 at 12:30
  • Yes, there is Field File-Structure which controls how the file is Read. Set the File-Structure to Fixed-Length-Binary. You could also get away with Default because it switch's to Fixed-Length binary when there are binary fields – Bruce Martin Jul 04 '13 at 23:36