Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to process a large text file that was created by a cobol dataset definition on a mainframe in a c# or other visual studio language. I don't want to use Cobol. I want to use the Cobol dataset definition of the file from my C# or other visual studio program

A 333 BANKIE BANK FSB -333 PO BOX 1234 CANTON OH 44711 3304445555
B 1111111 JON A SAMSONS 222 MAIN ST DRIVE SUNBERRYS TOWNSHIP PA 16166 4403334444 0 JOHNSTUT@BNTMINTERNET.NET SANDERA A SAMSONSUA 222 MAIN ST DRIVE SOONBERRY TOWNSHIP KZ 16666 724-777-0140 0
D 1111111 222 AFTERNOON DR SOONBERRY TOWNSHIP KZ 16666 USA 19 12 1 07-01-1997 99500 99500 07-01-1997
F 1111111 2 8 FR4421888660729203 00/00/0000 07/11/1997 09/01/1997 07/01/2012 00/00/0000 2 98949.00 6.50000 625.42 360 08/01/2027 2.62500 360 08/01/2027 469.81 308.42 31.31 61368.00 + 778.51 11/01/2014 - 14.02 + + + + 826.08 0 1 15 7 N 2 4.000 00/00/0000 9999.99 10/01/2014 11/01/2014 10/16/2014 10/17/2014 283 0 + + 2121.23 + 2749.67 + 4937.47 + 4875.57 + 582.27 + 5454.05 1 00/00/0000 + + + + N 00/00/0000 00/00/0000 00/00/0000 00/00/0000 N 00/00/0000 00/00/0000 00/00/0000 00/00/0000 N 00/00/0000 00/00/0000 00/00/0000 00/00/0000 N 00/00/0000 00/00/0000 00/00/0000 00/00/0000 C 0 0000000000 0000000000 00/00/0000
G 1111111 120500 GHA 1 YR ADJ 1/5 DAPS A 00/00/0000 00/00/0000 + 2.50000 + 99.99999 10/01/2014 2.62500 08/25/2014 0.11000 0000000000 10/01/2015 11/01/2013 00000469.81 11/01/2015 0000000000 08/01/2027
H 1111111 120500 GHA 1 YR ADJ 1/5 DAPS 7010 1-YEAR US TREASURY HILL FEMERAL DESERVE RTAT BELEASE 12 12 1.00000 1.00000 5.00000 1.00000 1.00000 99.99999 12 12 99.99999 99.99999 99.99999 99.99999 99.99999 99.99999 206 24 30
I 1111111 11 12 1 A MARIANNE JOHNESON 800-333-1777 00/00/0000 0 11/14/2014 C 00/00/0000 05/02/2014 04/11/2014 00/00/0000 00/00/0000
K 1111111 11-10-2014 11 6 6 6 5 4 3 3 2 1 . . . 1 1 2 0 1 2 3 4 5 6 6 5 . . . . . . . . . 2 0 1 00/00/0000
M 1111111 11-14-2014 5027 + + + + + + + + + DM CONTACT WITH CUSTOMER CHANGED TO R
M 1111111 11-14-2014 5027 + + + + + + + + + DM MS CLD SD SHE WILL TAKE TO BRANCH ON MONDAY. GAVE CELL PH # TO CONTACT HER #777-777-4144. BLM 11/14/14
M 1111111 11-14-2014 5027 + + + + + + + + + DM ACTION/RESULT CD CHANGED FROM BRQL TO BOQL
Posted
Updated 12-Feb-15 2:02am
v4
Comments
PIEBALDconsult 13-Jan-15 10:45am    
Do you have any reference material or examples you could add?
Please use Improve question to add detail and context.
CHill60 13-Jan-15 10:50am    
There is an article here on CP where someone has done just that - I'll see if I can find it

The approach we took was to download the dataset definition as an ascii file.

We then parsed it (as text) into a dictionary. From that we created classes to hold the data from the file but an XML schema would do - this is the tricky part or the easy part depending on your specific requirements (and not something I can expand on properly in this forum).

Using the techniques from this CP article - EBCDIC to ASCII Converter[^] we then converted the file into ASCII (and thence to XML)
 
Share this answer
 
Comments
Member 11372314 12-Feb-15 7:19am    
This looks like an ideal solution. I have questions regarding this solution. I am currently working a 'non ideal' solution due to time constraints. I receive the file as a tab deliminated text file converted to ASCII (mainframe LRS VPS to server based LRS ANYQ. I intend to explore this soluution as I think it is ideal.
CHill60 12-Feb-15 7:28am    
You're lucky on that format! In which case all you need from the dataset definition should be the order in which the fields are sent (whereas we had to work out offsets etc and then convert to ascii). If this is the only file that you need to process it might be worth looking at this article Fill a DataSet from delimited text files[^] and doing something similar but using the Cobol definition to create the (C#) datatable schema
Member 11372314 12-Feb-15 7:47am    
Thank you for responding!
Cobol can create different types of files - fix length or variable length or so called VSAM files.
Fields in the file can be defined as Characters (string in C#) or numeric.
Numeric can be different types - signed or unsigned, COMP-3 (signed of unsigned), COMP (signed or unsigned) and some other not often use types.
On the Mainframe files can be created as ASCII or EBCDIC.
If you file has only text field it look pretty simple.
Lets assume in cobol you have:
C++
01 record.
       03 first-name   pic x(20).
       03 last-name    pic x(30).
       03  address     pic x(10).


in C#:
C#
using (StreamReader sr = new StreamReader(filePaths, System.Text.Encoding.ASCII))
{
   String w_line;
   // Read and display lines from the file until the end of
   // the file is reached.
   while ((w_line = sr.ReadLine())!= null)
   {
      string firstName = w_line.Substring(0,20) ;
      string lasttName = w_line.Substring(20,30) ;
      string address = w_line.Substring(50,10) ;



zb
 
Share this answer
 
Comments
Member 11372314 12-Feb-15 7:37am    
Based on the above code, would this code work?

oline = string.Format("{0}", w_line.Substring(0,20); //firstName
+ string.Format("{0}", w_line.Substring(10,30); //lastName
+ string.Format("{0}", w_line.Substring(50,10); //address

The output is a text file that gets passed loaded into LRS ANYQ (report/file distributer)
Member 11372314 12-Feb-15 7:48am    
I need to be able to format each field individually as the output file is build line by line.
Member 11372314 12-Feb-15 7:48am    
Thank you for responding!
This is the solution I am currently working on.
This file is tab delimited. Others are not. These files Solution 2 is ideal.
The input file contains 15 records per loan number with a total of 477 fields.
The goal is to read the tab delimited file, split the records/fields, format the output file with headings, load the file into LRS ANYQ as a 'text file report' to be printed and loaded into an image system for viewing.

Process(line);
cline = builder;
bRec = cline.Substring(0, 1);
if (bRec.Contains"A")) //Rec Type A
{
string oline = "";
string [] RAFields = cline.Split(new char[] {'\t'});
string RAF1 = RAFields[1];
string RAF2 = RAFields[2];
string RAF3 = RAFields[3];
oline =
String.Format("{0}", RAF1 + '\n') //Service Number
+ String.Format("{0}", RAF2 + '\n') //Servicer Name
+ String.Format("{0}", RAF3+ '\n') //Servicer Addr Line 1
builder = oline;
string path2 = @"c:\400\400717to.txt";
string alltext = builder + Environment.NewLine;
File.AppendAllText(path2, (alltext));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900