on 12-12-2008 1:33 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.