Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Create Positional Flat File
- This topic has 9 replies, 1 voice, and was last updated 9 years, 1 month ago by
community-content.
-
AuthorPosts
-
-
July 30, 2010 at 10:44 AM #25455
I have a situation where I am trying to generate a positional flat file from a complex (but relatively simple) XML document. Each and every record should be 15 bytes in length (in reality these are 1300 bytes in length – I shortened for demonstration purpose). The Header and trailer records appear to be generated fine, whereas the member and benefit records are combined into one record 30 bytes in length. I think I need to somehow define the benefit records as delimited with {CRLF} but since they are a part a member record which is positional, I cannot seem to do so. I tried defining Member as delimited but then I ended up with all of its data elements (NameFirst, NameLast, etc) on their own separate lines – not what I want. Any help on how to accomplish this would be greatly appreciated.
Here are the properties of the schema:
Container: Structure: Delimited; Child Delimiter Type: Hex; Child Order: Postfix; ChildDelimiter: 0xD 0xA
Header: Structure: Positional
Members: Structure:Positional
Member: Structure:Positional
Benefits:Structure:Positional
Benefit:Structure:Postitional
Trailer: Structure:Positional
Here is what the incoming XML looks like:
<Container>
<Header>
<H1>Header<H1>
<H2>1300<H2>
</Header>
<Members>
<Member>
<NameFirst>Jon<NameFirst>
<NameLast>Doe<NameLast>
<Benefits>
<Benefit>
<B1>b1</B1>
<B2>b2</B2>
</Benefit>
<Benefits>
</Member>
<Members>
<Trailer>
<T1>trailer<T1>
<Trailer />
</Container>
Here is the output I want (each record 15 chars in length):
Header 1300
Jon Doe
b1 b2
trailer
Here are the schema positional lengths:
H1 – length 10
H2 – length 5
NameFirst – length 7
NameLast – length 8
B1 – length 7
B2 – length 8
T1 – length 15
-
August 2, 2010 at 8:54 AM #25475
Hi sbrown63,
I have created a BizTalk sample project for you, just click on my avatar on BizTalkGurus website, go to the section My Files on my profile page on the right hand side, click on the link View All Files, and look for the zipped file sbrown63.zip and download it to your local machine. When you unzip the file, it will create a project location with all the BizTalk artifacts. You only need to provide your own assembly key file (containing both public and private keys) to strongly name your assembly before deploying it.
To test this application (a message routing-only scenario), in BizTalk Server Administration console, create a one-way Receive Port with a Receive location (of Transport Type equal to FILE and Receive Pipeline equal to Xml Receive) and a static one-way Send Port with the following settings:
1. Send Pipeline will be assigned the custom send pipeline containing the flat file assembler component (deployed from the project).
2. Outbound Maps tab will have one entry which is the custom map (mapping the XML schema to the Positional Flat file schema) deployed from the project.
3. A destination folder with a valid path where your positional flat file will be output.
Once your Send Port and Receive Location are enabled in the administration console, you can use the provided InputXml.xml file (from the project) and drop it into your receive folder location and see the output positional flat file as a result.
Hopefully, this approximates what you are looking for…
Daniel.
-
August 2, 2010 at 10:37 AM #25477
This is very close to what I need – Thanks a bunch!
The only issue remaining is getting it to generate multiple Member and Benefit rows in the flat file. For some reason it only spits out the first one of each. I’ve tried a number of property changes to include:
Set the Max Occurs property to unbounded for both the Member and Benefit nodes in the PositionalFF schema.
Set the Group Max Occurs to unbounded on the Group Node in the PositionalFF schema.
I’m wondering if I need to have a looping functoid to the map on these nodes.
-
August 2, 2010 at 10:58 AM #25478
Hi sbrown63,
Don’t forget to change the XML schema if you want to generate more than one instance of member/benefits record:
1. Set the Members node’s Max Occurs property to the unbounded value.
2. Optionally, set the Benefits node’s Max Occurs property to the unbounded value, if you have more than one occurrence of the Benefit record per member.
As for the Positional schema, you can just set the Max Occurs property of the Group node to the unbounded value, and optionally, set the Max Occurs property of the Benefit node to the unbounded value, if you did the same in item 2 above.
Then, in your map, you would use a looping functoid connecting the Members node (in the Xml Schema) to the Group node (in the Positional schema), and map the remaining fields. Additionally, if you used item 2 above, you would use a second-level looping functoid to connect the Benefits node (in the Xml Schema) to the Benefit node (in the Positional schema).
I hope this all makes sense to you…
Daniel.
-
August 2, 2010 at 2:48 PM #25479
Hi again, its fours hour later and still no luck. With the above settings I still cannot get the output to include multiple members/benefits in the correct format. I’m starting to get the urge to throw things at my PC. If you could take one more look to see if there is anything obvious I’d greatly appreciate it.
Flat file results:
H2_0 H2_0
Frank Farmer
B1_0 B2_0
B5_0 B6_0
T1_0Flat file expected results:
H2_0 H2_0
Frank Farmer
B1_0 B2_0
B3_0 B4_0
Jim Beam
B5_0 B6_0
B7_0 B8_0
T1_0Incoming xml:
<ns0:Container xmlns:ns0=”http://sbrown63.XmlSchema“>
<Header>
<H1>H2_0</H1>
<H2>H2_0</H2>
</Header>
<Members>
<Member>
<NameFirst>Frank</NameFirst>
<NameLast>Farmer</NameLast>
<Benefits>
<Benefit>
<B1>B1_0</B1>
<B2>B2_0</B2>
</Benefit>
<Benefit>
<B1>B3_0</B1>
<B2>B4_0</B2>
</Benefit>
</Benefits>
</Member>
<Member>
<NameFirst>Jim</NameFirst>
<NameLast>Beam</NameLast>
<Benefits>
<Benefit>
<B1>B5_0</B1>
<B2>B6_0</B2>
</Benefit>
<Benefit>
<B1>B7_0</B1>
<B2>B8_0</B2>
</Benefit>
</Benefits>
</Member>
</Members>
<Trailer>
<T1>T1_0</T1>
</Trailer>
</ns0:Container>-
August 2, 2010 at 2:59 PM #25480
I also had to set the Ma Occurs on the Member and Benefit nodes of the XmlSchema in order to successfully validate it against the sample instance of xml.
-
August 3, 2010 at 9:22 AM #25487
Hi sbrown63,
I got the sample working now… You can download the updated version from the same area, under My Files section, and the zipped file is sbrown63.zip.
It involved more work than I anticipated: I had to change the Positional Flat File schema setting the Max Occurs to unbounded on the Group node, and I modified the map to also use a Table Looping functoid (with table extractors) linking the Benefit node of the Xml Schema to the Benefit node in the Positional schema.
Hope this works for you,
Daniel.
-
August 3, 2010 at 1:57 PM #25496
It works! Fantastic! Thanks a lot for you help. I wish I could find a good book on these advanced functoids.
Thanks again.
-
March 6, 2013 at 9:50 AM #26010
Man…. this just made my day!! Thanks for the tip on setting the Unbounded on the Group Node….
-
August 28, 2013 at 1:29 AM #26131
I do need the same but just want to know the properties you set at root and chile root and record level…Quick reply will help me ..thank you.
-
-
-
-
-
-
-
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.