cancel
Showing results for 
Search instead for 
Did you mean: 

unsorted Flat File into IDoc with multiple use of nodes

Former Member
0 Kudos

Hi Experts!

I am facing a little problem. I have a source flat file for a classification where some fields appear several times.

My source flat file looks like this:

item1; field1a

item2; fieldA

item3; fieldxa

item1; field1b

as you can see the item1 exists twice (further appearances are also possible).

Now i have to map the flat file into an IDoc structure

My target IDoc looks like this

Header

-- node1

-


attribute1

-- node2

the "field1a" and "field1b" has to be mapped into the "attribute1" in "node1". "node1" has to be duplicated for each time an "item1" appears (.. and if item2, item3 etc. appears twice, three ... four times...).

So how can i reach it that the node1 will be duplicated automatically when an item appears twice or more times? I know that it could be possible to work with "SplitByValue"... but for this i need all item1 in an straight order.... but i dont have them in a correct order.

I am looking forward to your suggestions.

Thank you in advance.

Udo

Accepted Solutions (0)

Answers (2)

Answers (2)

stefan_grube
Active Contributor
0 Kudos

Complex sorting is not or not easy possible with the grafical mapping tool.

Use a sequence mapping. The first mapping is a simple XSLT which does the sort. The second mapping works as usual.

I have an example XSLT which I used for a different purpose:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <ORDERLIST>
      <xsl:for-each select="ORDERLIST/ITEM">
        <xsl:sort select="ID"/>
        <xsl:copy-of select="."/>
      </xsl:for-each>
    </ORDERLIST>
  </xsl:template>
</xsl:stylesheet>

Regards

Stefan

Former Member
0 Kudos

Hi Stefan...

Thank you for you answer...

Can you give me a little introduction in your XSLT Statements?

Does your scenario:

1. Load the whole Flat File in the XI

2. Sort the whole content

3. starts the mapping?

SudhirT
Active Contributor
0 Kudos

Hi,

Try like this you can use one UDF with three arguments item1,item2,item3

int len = item1.length + item2.length + item3.length;

for(int i = 0; i<len;i++)
{
  result.addValue("");
}

Use this UDF and use item1,item2,item3 as input and output of the UDF to node1.

Thanks!

Former Member
0 Kudos

Thank you for your fast answer. It looks like i gave you some mistakable information.

there are more than 3 items... there are several 10 000 so there is now chance to write a program for all.

And i need for every Item an own IDoc....except the item (item1, item2, item3 .... item341234234) already exists, then i need a new node1 in the existing IDoc for e.g. item1.

So that i have

item1

- note1

- note1

- note1

Edited by: Udo Buchter on Dec 12, 2008 3:04 PM