Sunday, October 9, 2011

Handling positional/delimited flat files with Oracle B2B 11g


After a long time I am blogging again and this time topic is “Handling positional/delimited flat files with Oracle B2B 11g”. From past couple of weeks, many B2B developers posted question on this topic and hence I thought of posting a blog on the same.

So this is what I will cover in this blog –
  1. Modeling an ecs for a sample positional flat file
  2. Configuring Oracle B2B for a PFF document
  3. Testing the outbound and inbound transaction

Step#1 Modeling an ecs for a sample positional flat file:-
First of all we have to create an ecs for a sample positional flat file (PFF) document. I created below ecs for this blog –



I created this ecs for transferring personal information. I have added two records in this ecs with 5 fields. First record represents the headers and hence can occur once at max in the doc. Second record represents the data and hence can occur infinite times in a doc. 

To uniquely identify the document, I have added a tag value “SERIALNUM” for header field “SERIALNO” –




I will configure the same value in B2B to identify the document uniquely.

Now we need to perform the most important and unique step for PFF doc type – generating the parser schema for the ecs. To generate a parser schema for your ecs, open your ecs in B2B doc editor, go to Tools -> Generate Parser Schema, accept the defaults and provide the file name as well as location to save for ecs parser file –




Once you will click on “Save” it will automatically generate a parser schema for your ecs. Parser schema for my ecs looks like –






Once ecs and parser ecs is created, you need to export XSD (File -> Export -> Oracle B2B 2.0) out of it. Also generate test data out of ecs to test the inbound and outbound flows. This activity is same as what we do for any other type of document.


Step#2 Configuring Oracle B2B for a PFF document:-

Now we will configure Oracle B2B with the files we have generated in previous step. 

First of all copy the parser ecs file in the directory $Oracle_SOA_Home\soa\thirdparty\edifecs\XEngine\config\schema (for eg. - D:\OFMW11g\PS3MWHome\Oracle_SOA1\soa\thirdparty\edifecs\XEngine\config\schema)

And add an entry for this parser ecs in $Oracle_SOA_Home\soa\thirdparty\edifecs\XEngine\config\XERegistry.xml. To add this entry, edit the XERegistry.xml in a text editor and add an entry like below in “Positional flat parser schemas” list –

${XERoot}/config/schema/PARSER_ECS_NAME.ecs





Save the changes after adding entry, close the file XERegistry.xml and restart all the servers.
Now create a Document Protocol Version, Document Type and Document Definition under “PositionalFlatFile” on Oracle B2B console –





Use the XSD and transaction set ecs we created in step#1, while creating document definition.

In Identification tab, we will configure the following values to let B2B uniquely identify this document-

Identification Value = SERIALNUM
Identification Start Position = 1
Identification End Position = 9





Now configure both inbound and outbound agreement for same doc-def –






As you can see, I have kept validation and translation enabled in both the agreements. 

Validation option is used to indicate B2B to validate the incoming/outgoing native format document against the ecs configured in respective document definition. Translation option is used to indicate B2B to translate the incoming flat file to XML or to translate an outgoing XML to flat file.

Save, validate and deploy both the agreements.


Step#3 Testing the outbound and inbound transaction:-

Now first of all we will test an outbound case. Drop the XML file, generated from ecs using Document Editor’s Data Generator tool, into the directory of internal listening channel. Make sure that the XML contains the Internal Properties -




Go to Oracle B2B reports section and make sure that message state is “MSG_COMPLETE”. If transaction completes successfully, you will see a positional flat file on the remote trading partner side –





Similarly, to test an inbound flow, pass the positional flat file to B2B through an external listening channel. Go to Oracle B2B reports section and make sure that message state is “MSG_COMPLETE”. If transaction completes successfully, you will see a corresponding XML file on the host trading partner side (in internal delivery channel). You may check Application Message Report to see the content of translated XML.

Now go ahead and experiment more with it.