cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Question

Former Member
0 Kudos

Small question,

IS it posiible and how to interprate a single line in a message and repeat that line 3 times

Please see below.

<item>

<No>10</No>

<Currency>EUR</Currency>

<PriceInVAT>119,00</PriceInVAT>

<PriceExVAT>100,00</PriceExVAT>

<VATamount>19,00</VATamount>

</item>

I want to convert this to 3 different lines in the output

1:

No: 10

PriceInclVat 119,00

2:

No: 10

PriceExclVat 100,00

2:

No: 10

VatAmount 19,00

Can someone help me with this.

Thanks,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Patrick,

Can you please confirm me that whether do you have the following the target structure

No

Value -- Here it can store any value 3 values of the source

If this is the case then just duplicate the target strucutre 2 times and map the

no-no 3 times and

PriceInVAT->Value,

PriceExVAT->Value,

VATamount>->Value for each occurence of target node

So then your requirement will fulfill

If this is the not satisfy the answer give me some more details about your target structure.

Warm Regards,

Vijay

Message was edited by:

Gangisetty Vijaya Bhaskarudu

Former Member
0 Kudos

Hi Vijaya,

This is not quite what i mean.

I have a 1..n source message element and also a target 1..n element.

so we have

Source

header 1..1

item 1..n

target

header 1..n

item 1..n

BUT: i need to have PER each item 3 referring target items.

Does this makes sense.

Thanks

henrique_pinto
Active Contributor
0 Kudos

Please provide exact source and target desired message definitions (or it will just become a game of guessing here...).

Regards,

Henrique.

Former Member
0 Kudos

Sorry for that, here is the example of how it should look like in the end

Source

<head>

<ordNO>0001</ordNO>

<date>12122007</date>

</head>

<item>

<No>10</No>

<Currency>EUR</Currency>

<PriceInVAT>119,00</PriceInVAT>

<PriceExVAT>100,00</PriceExVAT>

<VATamount>19,00</VATamount>

</item>

<item>

<No>20</No>

<Currency>EUR</Currency>

<PriceInVAT>238,00</PriceInVAT>

<PriceExVAT>200,00</PriceExVAT>

<VATamount>38,00</VATamount>

</item>

Target

<head>

<ordNO>0001</ordNO>

<date>12122007</date>

</head>

<item>

<No>10</No>

<Currency>EUR</Currency>

<PriceInVAT>119,00</PriceInVAT>

</item>

<item>

<No>10</No>

<Currency>EUR</Currency>

<PriceExVAT>100,00</PriceExVAT>

</item>

<item>

<No>10</No>

<Currency>EUR</Currency>

<VATamount>19,00</VATamount>

</item>

<item>

<No>20</No>

<Currency>EUR</Currency>

<PriceInVAT>238,00</PriceInVAT>

</item>

<item>

<No>20</No>

<Currency>EUR</Currency>

<PriceExVAT>200,00</PriceExVAT>

</item>

<item>

<No>20</No>

<Currency>EUR</Currency><VATamount>38,00</VATamount>

</item>

So for each item which is send in i need to conver it to 2 or 3 different itemlines. This has to do with wholesale and consumer orders.

Greets

Former Member
Former Member
0 Kudos

Thanks for this reply but isn't it so that this function looks at identical element names.

and in our requirement the only thing reused is the lineItem number. OK and the Currency at the moment but this also can be put in the header.

as i can remember correctly the function useOneAsMany only works if you have repeating element names which are identical

<no>10</no>

<Price>119</Price>

<Price>100</Price>

<Price>19</Price>

My element names differ from each other, i'll try but i don't think this is it.

GReets

Former Member
0 Kudos

Hi Patrick,

You first duplicate your Item 2 times in Target side so you will have 3 items in the target. According to your target strucutre , you have 3 fields in the Item <PriceInVAT>, <PriceExVAT>, <VATamount>. Right??

In the first target item map like as below

<item>

<No>10</No>

<Currency>EUR</Currency>

<PriceInVAT>119,00</PriceInVAT>

</item>

In the Second target item map like as below

<item>

<No>10</No>

<Currency>EUR</Currency>

<PriceExVAT>100,00</PriceExVAT>

</item>

<item>

In the third target item map like as below

<No>10</No>

<Currency>EUR</Currency>

<VATamount>19,00</VATamount>

</item>

<item>

I hope this is clearn for you.

Warm Regards,

Vijay

Warm Regards,

Vijay

Former Member
0 Kudos

If possible i can also do this

<b>Source</b>

<item>

<No>10</No>

<Currency>EUR</Currency>

<PriceInVAT>119,00</PriceInVAT>

<PriceExVAT>100,00</PriceExVAT>

<VATamount>19,00</VATamount>

</item>

<b>Target</b>

<item>

<No>10</No>

<OrderType>0001</OrderType>

<Price>119,00</Price>

</Item>

<item>

<No>10</No>

<OrderType>0002</OrderType>

<Price>119,00</Price>

</Item>

<item>

<No>10</No>

<OrderType>0003</OrderType>

<Price>119,00</Price>

</Item>

And the <b>OrderType </b>Element may be hardCoded (0001 inclVAT, 0002 exclVAT, 0003 VAT).

Former Member
0 Kudos

Vijaya,

That makes sense yes BUT i see an issue here. WE make use of a BAPI in the end, and this means i have to make at minimum 2 message mappings. Because if the end structure only provides 1 item element node (1..n) i have to duplicate these which will ensure to interfear with SAP Standard correct ?

Former Member
0 Kudos

Hi Patrick,

If you duplicate the tree , then there is no problem because it will consider as one occurence of item only. So you don't have the problem with BAPI end.

U r just producing the 3 items for each item in the source. Nothing is changing. I hope there is no problem whie duplicating the subtree.

Warm Regards,

Vijay

Former Member
0 Kudos

I'll try this one out,

Thanks.

Former Member
0 Kudos

Thanks Vijaya this works.

I didn't really expect that this could be solved like this. in other middleware solutions the solution would be totally different.

Thanks and Greets

henrique_pinto
Active Contributor
0 Kudos

If order is not an issue, message mapping with duplicate subtrees will do alright.

If order is an issue (and since message mapping will generate target not in order), use XSLT if your scenario allows (not too many source items), since handling order in message mapping can be a real pain in the @$$.

Simple XSLT to solve it:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
	<xsl:template match="@*|node()">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:template>
	<xsl:template match="item">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()[not(self::PriceExVAT) and not(self::VATamount)]"/>
		</xsl:copy>
		<xsl:copy>
			<xsl:apply-templates select="@*|node()[not(self::PriceInVAT) and not(self::VATamount)]"/>
		</xsl:copy>
		<xsl:copy>
			<xsl:apply-templates select="@*|node()[not(self::PriceInVAT) and not(self::PriceExVAT)]"/>
		</xsl:copy>
	</xsl:template>
</xsl:stylesheet>

Regards,

Henrique.

Answers (0)