Friday, February 5, 2010

OSB and MFL

Recently worked on a new seemingly innocuous POC on OSB for a client.

The requirements were:

1. To pick up a flat data file from an FTP location,

2. Transform the data file into xml tags (MFL - Message Format Language),

3. Do a transformation based on the XML tags from MFL to EDI 93A "ORDERS" format,

4. Make a recursive call to invoke a BPEL web service.

Fairly basic requirement from the looks of it. You could even say, Not worth a mention on any blog to show how its done - and you could not be more wrong.

The point 1 more descriptively specifies the format of the XML tags based on the data till the end of each line. It gets complicated, as the data in each row can represent any of the 7 different sets of data based on a field in the very line of data. Each line of the data file has to be converted into one of the 7 different groups which are seperated only based on length of fields in characters(thats right, no delimiters are used).

For example:

The data file kind of looks like this:

1234576543210012345678901234567890
123457654321101234567890123456
12345765432120123456789012345678
2234576543210012345678901234567890
223457654321101234567890123456
22345765432120123456789012345678
3234576543210012345678901234567890
323457654321101234567890123456
32345765432120123456789012345678

The two digits in bold will decide on the format for the rest of the row.

Now that we have the problem described in detail let me show you how we resolved it.

Mind you, we would not have been troubled but for the fact that there wasnt much of documentation available out there or within. What you are seeing now is my attempt to put more of documentation regarding MFL.

If you are looking for an MFL solution with requirement similar but not as strange, please refer to the article by Edwin Biemond an Oracle ACE on his personal blog -> http://biemond.blogspot.com/2008/12/flat-file-to-xml-with-oracle-service.html

His article pretty much describes how to handle a flat file read, convert and transform in xml.

I felt a little description is needed, which I will try to put in here:

MFL Format Builder is a Java Application which can be used to create MFL files with a comprehensive UI(will not talk more about it, as biemond's blog already has the basic information). Coming to our example, where a certain field has to be observed for identifying and in turn populating the relevant XML tags, a feature of 'Tag' can be used.

Briefly: let us assume the field name which decides the format of the data till the end of the line is "TYPE" and with a length of 2(for '00', '10' etc). Now, when the MFL is to be defined, other than the usual tag description as mentioned in the article refered, for the element "TYPE" a Tag has to be set in the format builder.
As shown in the image.
By doing this, if there is a certain '00' in the row while parsing, the parsing will continue down. But, if the value is '10' the row will break to the next element which will contain the Tag as '10'.
This process can be repeated for as many branches. I've tried till 7. After completing the MFL formatting you can proceed to write the XQuery(process can be found in the referred article) and to ultimately use in the Proxy Service.

No comments:

Post a Comment