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?
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.
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.
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.
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...
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.