on 01-16-2006 5:13 PM
I want to create a file with various headers and details:
Example:
50000 AAAAA <- header
50000 1 a1 <- details
50000 2 a2
50000 3 a3
50001 BBBBB <- header
50001 1 b1 <- details
50001 2 b2
50001 3 b3
50002 CCCCC <- header
50002 1 c1 <- details
50002 2 c2
50002 3 c3
But, I need to get the values using a RFC (Sender). This values are in two tables: header and detail
...
<header>
<item>
<id></id>
<text></text>
</item>
</header>
<detail>
<item>
<id></id>
<id_item></id_item>
</text>
</item>
</detail>
...
How I create this file doing a relation between "id" fields?
Message was edited by: Evandro Klen Stephen de Azeredo
Hi Evandro,
When you are sure, that for every entry in header, there is an entry in item and vice verca, then it is very easy.
First you need a structure, you can use for content conversion for the file adapter.
Create a data type like this:
Target
row (1..unbounded)
header (1..1)
id
text
item (1..unbounded)
id
id_item
text
The trick is, that the content conversion does not care, how often the <row> is available. It needs to be there at least one time, but it does not matter, if it appears more often.
The elements are just mapped one by one, the nodes are mapped like this:
item(header) - row
constant - header
id(item) - removeContexts - SplitByValue(valueChanged) - item
The output of the mapping is:
<Target>
<b><row></b>
<header>
<id>50000</id>
<text>AAAAA</text>
</header>
<item>
<id>50000</id>
<id_item>1</id_item>
<text>a1</text>
</item>
<item>
<id>50000</id>
<id_item>2</id_item>
<text>a2</text>
</item>
<item>
<id>50000</id>
<id_item>3</id_item>
<text>a3</text>
</item>
<b></row></b>
<b><row></b>
<header>
<id>50001</id>
<text>BBBBB</text>
</header>
<item>
<id>50001</id>
<id_item>1</id_item>
<text>b1</text>
</item>
...
which can easily be converted with the content conversion of the file adapter.
Regards
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Stefan,
I has this Data Type:
SourceList
header
item
id
text
itens
item
id
id_item
text
And I created this Data Type:
TargetList
row (1..unbounded)
header (1..1)
id
text
item (1..unbounded)
id
id_item
text
Mapping:
SourceList -> TargetList
header <None>
item -> row
[Constant] -> header
id -> header/id
text -> header/text
itens <None>
item <None>
id removeContext -> splitByValue -> item
id -> item/id
id_item -> item/id_item
text -> item/text
In test, I entry with the folowing data:
<?xml version="1.0" encoding="UTF-8"?>
<p2:SourceList xmlns:p2="urn:spasa_edi.edi">
<cabecalho>
<item>
<id>1</id>
<texto>A</texto>
</item>
<item>
<id>2</id>
<texto>B</texto>
</item>
</cabecalho>
<itens>
<item>
<id>1</id>
<id_item>1</id_item>
<texto>AAA</texto>
</item>
<item>
<id>1</id>
<id_item>2</id_item>
<texto>AAA</texto>
</item>
<item>
<id>2</id>
<id_item>1</id_item>
<texto>BBB</texto>
</item>
</itens>
</p2:SourceList>
And the result was:
<?xml version="1.0" encoding="UTF-8"?>
<p2:TargetList xmlns:p2="urn:spasa_edi.edi">
<row>
<header>
<id>1</id>
<text>A</text>
</header>
<item>
<id>1</id>
<id_item>1</id_item>
<text>AAA</text>
</item>
</row>
<row>
<header>
<id>2</id>
<text>B</text>
</header>
<item>
<id>1</id>
<id_item>2</id_item>
<text>AAA</text>
</item>
</row>
</p2:TargetList>
But It's doing a mapping "1 to 1"
The result must be:
<?xml version="1.0" encoding="UTF-8"?>
<p2:TargetList xmlns:p2="urn:spasa_edi.edi">
<row>
<header>
<id>1</id>
<text>A</text>
</header>
<item>
<id>1</id>
<id_item>1</id_item>
<text>AAA</text>
</item>
<item>
<id>1</id>
<id_item>2</id_item>
<text>AAA</text>
</item>
</row>
<row>
<header>
<id>2</id>
<text>B</text>
</header>
<item>
<id>2</id>
<id_item>1</id_item>
<text>BBB</text>
</item>
</row>
</p2:TargetList>
Thank you.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.