# Weird flat file mapping to XML

**URL:** <https://techcommunity.softwareag.com/t/weird-flat-file-mapping-to-xml/108289>\
**Category:** Forum\
**Tags:** EDI\
**Created:** [August 15, 2003, 7:32pm UTC](https://techcommunity.softwareag.com/t/weird-flat-file-mapping-to-xml/108289 "2003-08-15T19:32:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mathieu.desmarais.15388](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@mathieu.desmarais.15388](https://techcommunity.softwareag.com/u/mathieu.desmarais.15388)\
**Post date:** [August 15, 2003, 7:32pm UTC](https://techcommunity.softwareag.com/t/weird-flat-file-mapping-to-xml/108289/1 "2003-08-15T19:32:01Z")

</div>

I must map a flat file that has the following format to a XML structure. I have made a template (included in attachment) and the file is loading OK in the record so I have all my data in the pipeline. The file (an invoice) has 1 field per line instead of having many fields on 1 line. So for detail records, it goes like this :  
…  
301 0001  
305 MMM651  
310 Product description  
325 5  
335 2.39  
301 0002  
305 MMM652  
310 Prod desc 2  
325 10  
335 4.35  
…

My goal is to load this to an XML structure like this :  
…  
\<invoiceline\>  
\<linenumber\>  
\<number\>0001\</number\>  
\</linenumber\>  
\<itemquantity\>  
\<quantity\>000005\</quantity\>  
\</itemquantity\>  
\<productid\>  
\<id\>MMM651\</id\>  
\<description\>Prodcut Description\</description\>  
\</productid\>  
\<unitprice\>  
\<amount\>23900\</amount\>  
\</unitprice\>  
\</orderline\>  
\<orderline\>  
\<linenumber\>  
\<number\>0002\</number\>  
\</linenumber\>  
\<itemquantity\>  
\<quantity\>000010\</quantity\>  
\</itemquantity\>  
\<productid\>  
\<id\>MMM652\</id\>  
\<description\>Prod desc 2\</description\>  
\</productid\>  
\<unitprice\>  
\<amount\>43500\</amount\>  
\</unitprice\>  
\</orderline\>  
…

I’ve tried many LOOP, MAP combined with appendToRecordList to a temp records and/or directly to my XML structure but was not able to produce an output that was making sense. The best I could do was having the correct line detail structure but with the same data in each detail line ![](http://www.wmusers.com/wmusers/clipart/sad.gif)

I’m sure somebody in here has done something similar ?  
Thanks for your help !

![](http://www.wmusers.com/wmusers/icons/attachment_icon.gif)flat file invoice template  
[AlphaInvoiceTemplate.xml](http://www.wmusers.com/wmusers/messages/117/AlphaInvoiceTemplate-22027.unk) (14.6 k)

---

<div class="post-metadata">

**Author:** ![CHIRAG](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/chirag/32/7647_2.png) [@CHIRAG](https://techcommunity.softwareag.com/u/CHIRAG)\
**Post date:** [August 15, 2003, 7:37pm UTC](https://techcommunity.softwareag.com/t/weird-flat-file-mapping-to-xml/108289/2 "2003-08-15T19:37:50Z")

</div>

Hi,

Your case is like a VDA format file used in europe. or EDIFACT groups of DTM and SCC. See if you can define… 305,310 325 and 335 as subelements under 301 and if that work, or if you can define them as a group.

---

<div class="post-metadata">

**Author:** ![halsalam](https://avatars.discourse-cdn.com/v4/letter/h/7993a0/32.png) [@halsalam](https://techcommunity.softwareag.com/u/halsalam)\
**Post date:** [August 15, 2003, 9:03pm UTC](https://techcommunity.softwareag.com/t/weird-flat-file-mapping-to-xml/108289/3 "2003-08-15T21:03:19Z")

</div>

Mathieu,

Have you tried using the “out-array” feature of the LOOP.

Your “in-array” is the source record you created from the template. The “out-array” is the target record you will eventually create the XML with" . For example, within the LOOP - map the source record data to the target record data , as a single record (not recordlist) called linenumber. You set “out-array” of the LOOP to be the same name as the target record - so in this case - call it “linenumber”. At the end of the loop, you should have a record list of “linenumber”.

---

<div class="post-metadata">

**Author:** ![halsalam](https://avatars.discourse-cdn.com/v4/letter/h/7993a0/32.png) [@halsalam](https://techcommunity.softwareag.com/u/halsalam)\
**Post date:** [August 15, 2003, 9:12pm UTC](https://techcommunity.softwareag.com/t/weird-flat-file-mapping-to-xml/108289/4 "2003-08-15T21:12:59Z")

</div>

sorry - I just noticed that “linenumber” is not the right example from your XML - should be “invoiceline”.

---

<div class="post-metadata">

**Author:** ![mathieu.desmarais.15388](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@mathieu.desmarais.15388](https://techcommunity.softwareag.com/u/mathieu.desmarais.15388)\
**Post date:** [August 15, 2003, 9:18pm UTC](https://techcommunity.softwareag.com/t/weird-flat-file-mapping-to-xml/108289/5 "2003-08-15T21:18:22Z")

</div>

So I don’t really need to play with templates right ?  
Let me try those suggestions and get back to you…

---

<div class="post-metadata">

**Author:** ![mathieu.desmarais.15388](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@mathieu.desmarais.15388](https://techcommunity.softwareag.com/u/mathieu.desmarais.15388)\
**Post date:** [August 16, 2003, 1:18am UTC](https://techcommunity.softwareag.com/t/weird-flat-file-mapping-to-xml/108289/6 "2003-08-16T01:18:59Z")

</div>

I changed my template (see attachment) to include some subelements under my 300 record but now some data in going into unDefData instead of going into the correct 301/305/… records. I must do something wrong …?

![](http://www.wmusers.com/wmusers/icons/attachment_icon.gif)new flat file with subelements  
[AlphaInvoiceTemplate.xml](http://www.wmusers.com/wmusers/messages/117/AlphaInvoiceTemplate-22036.unk) (14.9 k)

Here’s a screenshot of my record with unDefData  
 ![](http://www.wmusers.com/wmusers/messages/117/22037.jpg)

---

<div class="post-metadata">

**Author:** ![atul\_ahire.43935](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@atul\_ahire.43935](https://techcommunity.softwareag.com/u/atul_ahire.43935)\
**Post date:** [September 19, 2003, 8:25pm UTC](https://techcommunity.softwareag.com/t/weird-flat-file-mapping-to-xml/108289/7 "2003-09-19T20:25:39Z")

</div>

Hi,

Have you found a solution to your problem?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:05pm UTC](https://techcommunity.softwareag.com/t/weird-flat-file-mapping-to-xml/108289/8 "2021-04-02T15:05:09Z")

</div>


