Parsing multiple record Flat Files with/without delimiters

Does anyone know how to parse a flat file that has multiple record types and some of the records types have field delimiters and some are fixed length.

For example: A Purchase Order (PO)

Header id = 001 and holds Purchase number & date and each field is fixed length
Shipper id = 002 and holds address information, each address field is delimited by a | character.

Sample data:

0018521252003/04/22
002ShipperNumber|ShipperName|ShipperAddress
0018528882003/04/22
002S852|John Brown Shipping|123 West Drive

My thought is to parse the flat file twice, once with a fixed length schema just pulling out the Headers and then again with a character delimited schema. The only issue I have is matching the data together afterwards.

Any ideas?

I got this to work in one pass by setting up a delimted FF schema with “newline” as the record delimiter, and “|” as the field delimiter.

I set up a schema with “001” as the record Identifer for the fixed length lines, and used a Fixed Position Extractor. Set Max Repeat to unlimited.

The second record was set up with “002” as the record identifer, and was set up as child of the first record, and Max Repeat was left at “1”. Use a Nth field extractor for this.

The problem that occurs is that the 002 records have no delimiter between the record identifier (002) and the first data element, so the first data element must have the “002” stripped off to be usable.

I have a sample .zip file. If you would like to obtain the zip file or discuss this further, contact me at pjewell@webmethods.com

Best Regards,
-Phillip

Has anyone worked with multiple character record delimiters? such as ‘END’ representing the end of a record. I have yet find the documentation within webMethods as it appears that all delimiters are limited to one character position.

Thanks,

Adam

Adam:

I would create a Flat file dictionary with a Record defined for Record definition and field definition.

After that I would create a Flat file schema and point the setting to reference the dictionary you created earlier.

Test the schema.

Generate the document.

You will need to write extensive tokenizer code to performing parsing.

Good luck!

Regards,
Animesh

I appreciate your assistance, but that does not really answer the question. I could tokenize it without the WmFlatFile package.

Hi,
Present iam working in webmethods4.6 version.iam trying to separate fields in flatfile records using string tokenizer but some records have no fields in flafile.So if i excute the service this error is coming “java.lang.NullPointerException”.So tell me where iam going to wrong and how can i solve this problem.
with regards,
venkat

Hello,
Adam: You could use the replaceString service and turn all multi-char delimeters into single-char ones. Then you can use the more common tools.

Venkat: You should use a branch to test if certain fields are $null. You would then set then to some useable default value. I see this a lot when you try to get a numeric value and pass it to the math services. Good day.

Yemi Bedu

No one ever answered the question about multiple character delimiters. I am well versed in using the Flat File adaptor in WM 6.0.1. The delimiter is " <$> ", but the adaptor stops on “<”.

I am using replaceString service, but this is 1000’s of extra executions, and I am trying to make this long running program more efficient.

Help?!?!?