on 06-06-2008 7:41 AM
Hi experts,
We have a received payload like :
Seg1 - header
seg2 - item
seg2 - item
seg2 - item
seg3 - footer
In the seg3 footer filed1 should have the value of number of segments used in payload,
for example in above payload the value of field1 should be 5.
How we can count these segments and place the value in field1 of seg3, in our receiver payload ?
Please help.
Regards,
Study SAP
Hello ,
Use the count function for ITEM node the assign this count value to the receiver field , keep the ITEM context to header!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
your source structure is like:
Seg1 - header
seg2 - item
seg2 - item
seg2 - item
seg3 - footer
So, seg1 and seg3 will occur only once and seg2 can have multiple occurances.
and you are tring to count number of all occuring segments.
So simply you count how many times seg2 is occuring and then add 2 with the result.(add 2 for single occurances of seg1 and seg3).
so your mapping will be:
item>Count>add-->field1
Constant[2]----
|
--Sankar Choudhury
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
if you want you could try this xslt mapping:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="seg3">
<xsl:copy>
<xsl:element name="field1">
<xsl:value-of select="count(//seg2)"/>
</xsl:element>
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
I have try with this similar xml as source:
<?xml version="1.0" encoding="UTF-8"?>
<segments>
<seg1>header</seg1>
<seg2>item1</seg2>
<seg2>item2</seg2>
<seg2>item3</seg2>
<seg3>footer</seg3>
</segments>
And the result was:
<?xml version="1.0" encoding="UTF-8"?>
<segments>
<seg1>header</seg1>
<seg2>item1</seg2>
<seg2>item2</seg2>
<seg2>item3</seg2>
<seg3>
<field1>3</field1>
</seg3>
</segments>
Maybe it could be useful for you.
Regards,
Emiliano
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
do the following
1) this is your source structure
Seg1 - header
seg2 - item
seg2 - item
seg2 - item
seg3 - footer
your target would be
Seg1 - header
seg2 - item
seg2 - item
seg2 - item
seg3 - footer
field 1
No map field with the STANDARD COUNT function from the SEG1 header line
Thanks
sudhir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
At the end before mapping to the field add the additional standard function - 'count' and then map it to the field..
regards
chandra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
when I am doing this for count with Seg2 - Item,
it is giving me only value 1, and in the payload the value of seg2 is 3.
please give me clear idea to solve this problem.
it means your items are under different contexts so add a removeContexts before count function.
so , item>removeContexts>Count
**Reward points if helpful.
--Sankar Choudhury
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.