Microfocus Cobol datafiles
RicardoPortilho
created: 2006-02-03 08:26:00
How can I open this files?
I believe it is possble someway, maybe with the DBI way.


Thanks in advance.
Re: Microfocus Cobol datafiles
created: 2006-02-03 08:57:34

Open? With open, maybe?

Have you tried searching CPAN for a specific module, hoping that one exists?

Re: Microfocus Cobol datafiles
created: 2006-02-03 08:58:15

Ricardo:

We'll need a lot more information than that.

1) Where were the files created?

2) Are you trying to read them on the same system or a different one?

3) Any error messages?

4) Sample code would be nice.

5) What have you tried so far?

PerlMonks is the most helpful place on the 'net. But, you have to do your fair share by asking good questions. Read this: node 172086

Re^2: Microfocus Cobol datafiles
created: 2006-02-03 09:23:58
CPAN doensn´t show anything about Microfocus or Cobol, od .CAD in DBI.
This files are already created, and each one is like a table, with fields and records. their names are like CLIENTS.CAD and CITY.CAD.
People where I work open, read and write in them, with Cobol. I amsure Perl would be faster to code on these.
Re^3: Microfocus Cobol datafiles
created: 2006-02-03 10:02:22
Can you post sample data files for us to look at? (No actual customer or employee information please.)
Re: Microfocus Cobol datafiles
created: 2006-02-03 10:01:21
A search on Google yielded http://www.wotsit.org/search.asp?page=8&s=ALLFILES. There is a link to a file that describes the Microfocus COBOL format. This may help.
Re^2: Microfocus Cobol datafiles
created: 2006-02-03 11:35:10

I'm not willing to read the whole document about COBOL format, but for registries with fixed size you will probably want to use pack and unpack. For variable size, you can use split, regular expressions and subtr to do the job.

Once you have the abstraction to make the code smart enough to figure out which kind of format it uses, maybe you will want to write a module that reads the file and parses it in an easier way

Alceu Rodrigues de Freitas Junior
---------------------------------
"You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill
Re: Microfocus Cobol datafiles
created: 2006-02-03 12:08:23

The first link returned searching for Cobol on search.cpan is [mod://Convert::IBM390] which includes an example for reading a Cobol datafile (not sure what a .cad is though). If you want to read the data printed by the datafile simply set the fd with a filler (see below) then set the filler as a comma or pipe (or other delimiter) and [super search] for reading from a comma delimited file.

       fd data-file
          LABEL RECORDS ARE STANDARD
          DATA RECORD IS data-rec.
       01 data-rec.
          05 data-foo                  pic 9(05).
          05 data-filler1              pic X(01).
          05 data-bar                  pic X(15).
          05 ee-filler2                pic X(01).
      *   etc....

perlmonks.org content © perlmonks.org and blazar, glasswalk3r, inman, kutsu, pboin, RicardoPortilho, socketdave

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03