Parsing of Flat File

Hi,

I am facing problem in parsing a flat file.
I have two kind of records in one Flat file.
One type of records is a continous string without any space or delimiter and where as the other type of records are seperated by a seperator ~(tilda)

I am not getting the way how to parse this file using schema.

As said above,can you upload your flatfile sample,so that users here will take a look and respond.

HTH,
RMG

There are two type of records in file

first one is like

1004200811042008ABCDEF123456
Second record is like
10042008~11042008~ABCDEF~123456

First record is without any seperator and the second record is with the ~ separator.

Let me know if any other info required.

You cannot create schema/parse this kind of file…one record with out segment delimiter and second record with segment delimiter etc…all in one file…In FlatFileDefinition itself you can’t specify record parsers with 2 various delimiters,it should be the same parsing criteria for all the records.

So talk to your source people who created this file and let them know to give file the way webMethods can parse it.

HTH,
RMG

Thanks a lot for your response…
can i use two different schema to parse one file?

First thing …u need to follow what RMG said , to make sure source system is ready to change the file layout , to make it easy on your part ( i dont know how much effort is required on their part to do that)

I dont think u could do 2 schemas and work on same fiel, i dont know if the first line and the second line are related or are those completly different records.

if they are completly different records , then what u can do is u need to split the incoming file into two files one which contains all the records with no delimeter and one with delimeters( u may need to write a java service which works on the file :- as a preprocessing step).

once the 2 files are created , u can then use your processing to work on 2 files( create 2 schemas and the reguar stuff).

Note :- the above solution should be used only when the source system is not ready to change the way they are sending the file ( As RMG mentioned)

HTH
sri

If you cant get your source to give you a consistent string, can you employ some Perl or java code that monkeys with the first record, adding ~ where needed?

If you note an ISA record, it is a set length, and your translator/ediModule gets the expected delimiters from that. You could use that same logic to recognize a string of a specific bite size and insert ~ where needed. Then let the convert to values take it from there.

Its bad Mojo to try to clean up a source systems data and then process within WM. From a business clarity point of view, your source should be specific and consistent.

My suggestion if you can’t have the source file modified is to create a couple
of java services, one for each record (line) type you have in the file.
Then, you read the line in a standard non-delimited way. Then, pass it to
which ever service is appropriate. You could even have a java service that examines the line for a ‘~’ char to help determine which service will process the line. This way, you can just go around the file schema and you’d be done a lot faster.

_brett.

Thanks a lot guys for your valuable comments

As you said :
first one is like
1004200811042008ABCDEF123456
Second record is like
10042008~11042008~ABCDEF~123456

You may replace ‘~’ with empty, and try to use one schema to solve this issue.