Read / Write Text file of Specific Format

Read / Write Text file of Specific Format

  
Dear OS GURUS
Please guide me the way to Read / Write the text file.



Every Line has a Numbering starting with 01A---01B--01C---02A--02D--02Z--03F---O4A--04B
and every field has a specific width and in a specific line  
e.g: First Name and age comes in 03A line and Address Details might be in line 04C
First Name = 35Characters
Age = 3 Characters
Address = 75C
Addess2 = 50C
City = 50C

So the output of the text file might look like this 

03ABW111560456FIRST NAME                                                       35
04A111560456ADDRESS1                                                  ADDRESS 2                                      CITY

We need to write the data in specific format and as per our industry standards.
The challenge here is to read the files and create a record based on the values from the files we might receive from other sources....

Total length of a file  might be close to 200 - 300 Lines with 500-600 Fields

Kindly Suggest a solution
tbh,

it sucks what you have to do. but what solution do you want?
imho it's a big horrible switch statement with some custom StringAppends where you don't forget the spaces as well. (take a ridiculous white-space string which you substr as needed..
will be something like address + substr(whitespacevar, 0, maxlength - length(address) )

perhaps there is some c#/java component on the internet to make it easier.. but doubt it.


J --- That's the Challenge we would like to have
Well they are quite some challenges involved with it practically
1. Size of the file
2. Number of Fields in the File
3. Number of DYnamic Lines available 
4. Number of Looped Sections

I would like to have the solution whereby I can import the file into the system directly and export it the same way..

First we always have to count number of Characters  (e.g: First Name, Middle Name, Last Name) if they were assigned as (25,25,25)characters each 

We would have to count the firstname- 25 MiddleName-25 [which is also the 26th characters from Firstname]+LastName [which is also 51st character from FirstName and 26th from Middle Name] 

Is there a way whereby I can use REPLACE the values.... Here the difficulty is the Number of lines  "As the client file we might receive is not standard. One file might have 50 Lines and another might be 300"

With switch statement to write 20 values in single row I feel I can better land on moon "that sounds much easier than in OS"

HELP HELP HELP plz ... anyone
Hi,

Well ..It would have helped a lot if you had said what type of format that was..
But nothing that google can't fix.
From what I can see that is some kind of format from http://www.mismo.org and it looks that there is a parser for .NET already done here: http://mismo-net.sourceforge.net/

I didn't try it ..just gave a quick look at the project and it has alot of stuff that you don't need (like sql database integration to support the model), but It should let you read from a binary file and access the data parsed.

See if you can add it to and extension and then load the file using:

LoanApplication app = new MISMO.BusinessObjects.AUS.LoanApplication();
app.Load(MISMO.Enums.ExternalFileType.FannieMaeResidentialLoanData, yourBinaryFile);

Then if all went fine the "app" object should have all information already parsed. Get from that what you need.

Regards,
João Rosado
JoaO well this is not what we are looking for...

The format of the file is called .FNMA but everything is in TEXT FORMAT 
I know the link I put said stuff about xml, but did you look or try the program?
I did a quick code read and I'm pretty sure it was reading that wierd text format.

If you upload a file example I can give it a try if I get some time.

Regards,
João Rosado
Joao
Well in the zip file you have some very very small Xmls 
you can give it a try and let me know the ways to go about it ....
Just a note that this isn't an Outsystems issue.  You'd have the same challenges regardless of the platform and programming languages you used.  Since you say this is an industry standard, wouldn't the industry have sample code for parsing and creating this mess?  Even if the example was in a weird language, like COBOL or RPG, it would at least show the logic you need saving you from creating the tough parts from scratch.  Most of my recent work is converting data from mainframes and I deal with this all the time but I haven't seen anything with this strange a layout in a long time.

Curt
Curt 
Well I'm never going to say its a OUTSYSTEMS issue... Well all I'm looking for is a solution to the work done.. As the samples I've uploaded are just the basic files I've uploaded to show the format "ASIS" we receive....

As I'm new to OS I would like to know if they are any ways to read and write like the one I've uploaded.>>

Something like Print @location (1,20) (2,45) something like that...



The reason I wanted to clarify that this is not an Outsystems issue is because you posted in an Outsystems forum and people reading the post, particualrly a year from now, can easily get off track.

I'm not sure why you think there would be an Outsystems unique syntax for something like this.  The goal of most of the application platforms developed these days is to reduce or eliminate code like this.  And no, there is no such built-in code though obviously something could be written to read and write this file but it would be very ugly.

Look at this as a Java or .Net problem.  What code would you write in those languages that would solve this problem for you.  Once you have that working it will be easy to encapsulate that code in an extension that an Outsystems application could call.  Again, I have to believe that if this is really an industry standard file format that there is code that every company in your industry is using.  I strongly recommend pursuing that before starting from scratch. 

Update:  I did a quick Google search and found out that this is a Fanne Mae file format.  I was able to find a lot of information at their web site at https://www.fanniemae.com/singlefamily/technology-integration including a program that deciphers these files. 

Curt
curt... theres is no such convertors except the file checking tool which will you the .fnm file is right or wrong if so where is wrong..

if it was the case I would be the happiest person by now to use  them...

But what I would like to know is the way how can WE Read contents of the text file in specific location...
If you go to the Forge and do a search for 'csv' you will find four components that read and write files.  Obviously those components are written to handle comma separated value (CSV) files but the code they use to open, read and write files would be a good starting place for you if you wanted to do a pure Outsystems solution.  They will also have a lot of the string manipulation code that you will need.

Having said that, I think it would be a huge mistake to use pure Outsystems code to solve this problem.  I strongly believe you'll have much more success using a more traditional programming language to do this and then encapsulate that in an extension, much like these CSV components do.  I would also try and contact Fanne Mae to get some program examples.  There is no way that every business that interfaces with them is writing these programs from scratch.

Hope that helps,
Curt
I kind agree with Curt.... it's sad that at this point in there are still companies that are able to develop "standards" without giving any help on applying them and it reaches to a industry standard....

I also think that doing it in an extension is the way to go, I'll check what you uploaded and see if I can get you started.

Regards,
João Rosado
Hi Curt,

Can you link me what you found in https://www.fanniemae.com/singlefamily/technology-integration ?
It just gives me "404 - Not found" pages everywhere. Just can see the Menu ...

Regards,
João Rosado
Joao ... it seems Fanniemae integration part of the site seems down... 
Thats the same link we have from the FNMA Group as well 

Solution
Hi again,

I played a bit with that library ...and good news is that it can read the format you want.
Bad news is that it only has the option to write the XML Mismo format and not the same that reads.

I implemented just a bit of the api to read Borrowers and respective ContactPoints as proof of concept. If that is usefull to you, you can implement the rest in the extension. Just follow those patterns as example.
Also added a method in the extension to convert to xml, since it was a lot easyer to read and see what to look for.

I'm attaching the Application package.
Here is a demo of it working:
https://my.outsystemscloud.com/FannieMaeReader/

Note: the project in the extension is done using Visual Studio 2015.
Not sure if it will open in older versions of Visual Studio without changes (..and can't test it since I don't have any olders versions at the moment)

Regards,
João Rosado
Solution
I would be interested seeing the application package, how do I open your oap file to look at the files, would it be possable to provide it in a format like a zip file?
João Rosado wrote:
Hi again,

I played a bit with that library ...and good news is that it can read the format you want.
Bad news is that it only has the option to write the XML Mismo format and not the same that reads.

I implemented just a bit of the api to read Borrowers and respective ContactPoints as proof of concept. If that is usefull to you, you can implement the rest in the extension. Just follow those patterns as example.
Also added a method in the extension to convert to xml, since it was a lot easyer to read and see what to look for.

I'm attaching the Application package.
Here is a demo of it working:
https://my.outsystemscloud.com/FannieMaeReader/

Note: the project in the extension is done using Visual Studio 2015.
Not sure if it will open in older versions of Visual Studio without changes (..and can't test it since I don't have any olders versions at the moment)

Regards,
João Rosado
 
 

Hi David,

Sure, here are the 2 components of that application I uploaded:
  - the FannieMaeFormat extension (all the work is done here)
  - the FannieMaeReader eSpace (only a example that calls the extension and shows the information in screens)


Regards,
João Rosado
Second reply for the other module.
Hi Joao,

I am new in creating extensions but I want to extend  FannieMaeFormat.xif extension further to read all the contents of FNMA file and store it in Structure. Can you please guide, from where to start writing new code when I open this extension and what steps to follow? 

For example, if there is information related with the co-borrower, so to get that information in a structure from where I should start changing the code. I see different classes but not getting from where to start.

Thanks,
Suraj Borade