Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting Database of RM COBOL DOS Version to Text file

Status
Not open for further replies.

wawanz

Programmer
Aug 29, 2002
62
ID
I have some RM COBOL data (*.dat), I want to convert it to delimeted text file ! Anyone can help ?
 
Hi,
This is easy to do. Just read the file as line sequential and string the fields with tabs or possibly commas (if there are no commas in the file) into a new line sequential file. Do you have the file definitions?
 
Hi Wawanz

Yes it is simple as Mrregan has said. But there is no necessary to string.

Define the line sequential file with the same vaiables name as those of in the original file. Only 01 will be differnt for both file. Add ur delimiter as a filler between all variable names. Then after reading the input record, use a MOVE CORRESPONDING statement. eg.


DATA DIVISION.

FD INFILE.
01 INPUT-REC.
05 FIRSTNAME PIC X(10).
05 LASTNAME PIC X(10).
05 DEPT-CODE PIC X
05 JOIN-DATE PIC 9(8).
05 SALARY PIC 9(5)V99.

FD OUTFILE.
01 OUT-REC.
05 FIRSTNAME PIC X(10).
05 FILLER1 PIC X.
05 LASTNAME PIC X(10).
05 FILLER2 PIC X.
05 DEPT-CODE PIC X
05 FILLER3 PIC X.
05 JOIN-DATE PIC 9(8).
05 FILLER4 PIC X.
05 SALARY PIC 9(5)V99.
05 FILLER5 PIC X.

WORKING-STORAGE SECTION
01 EOF-SWITCH PIC X VALUE 'N'.
05 EOF-INFILE VALUE 'Y'.
05 NOT-EOF-INFILE VALUE 'N'.
01 DELIMITER-VALUE PIC X VALUE '|'.

PROCEDURE DIVISION.
MAIN-PARA.
OPEN INPUT INFILE
OUTPUT OUTFILE.
READ INFILE AT END SET EOF-INFILE TO TRUE.
PERFORM UNTIL EOF-INFILE
MOVE SPACES TO OUT-REC
MOVE CORRESPONDING INPUT-REC TO OUT-REC
MOVE DELIMITER-VALUE TO FILLER1,FILLER2, FILLER3,
FILLER4, FILLER5
WRITE OUT-REC
READ INFILE AT END SET EOF-INFILE TO TRUE
END PERFORM
CLOSE INFILE OUTFILE
STOP RUN.

PS.
If u dont have a comp/binary field in the input and if u know the length of variables then u can open it in excel also using the the fix length option and then saving it as a CSV file.
 
Both previous posts are most likely wrong.

First things first:

You say you have data. But do you have any source code so that you know the record layouts? Tom Morrison
 
Tom is right. The prior two posts will probably work OK IF you know the record layouts and IF none of your fields contain the delimiter. You may need to surround some text fields with quotes to deal with delimiters or enclosed quotes. You may also need to strip leading or trailing spaces and deal appropriately with date fields. Some applications want field names in the first data record, so you might want to plan for that.

There is no true standard for delimited text files, so you should be careful that what you produce is acceptable to those programs you're most likely to read the data with.

Good luck!

Glenn
 
Thanks guys for your replies but, I'm sorry maybe I didn't give a detailed question...
The fact is, I'm a VB programmer.I have a future client who wants me to build an application with VB and the database holder is either Access or SQL Server..They already have data created from RM COBOL (DOS version), and they want me to bring along those data into the new application.

The problem is,I'm not familiar (at all) with COBOL. So I was wondering if I can convert those data into a (.txt) file. I also DON'T have the COBOL software. So I have no idea how to convert those files...

Help...
 
wawa -

You may be in trouble. The data files are likely in a proprietary format and not easily accessed without using RM/COBOL tools. See thread209-437606

Good luck!

Glenn
 
As other contributors have pointed out it is impossible to convert data directly if you don't have a record layout and the means to read that file. However it is nearly always possible to convert data by an indirect method.

For example, ask your client if they are able (using their existing software) to get a print-out of all information in their database. If so have them redirect the print output to a line sequential file. Since the file will have a consistent format it is usually quite easy to write a program to read that data and manipulate it into any format you choose. Clive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top