cancel
Showing results for 
Search instead for 
Did you mean: 

map flat to nested structure by creating a collection

Former Member
0 Kudos

Hi All,

I've got a problem by mapping a flat to a nested structure.

The source structure looks like that:

<b>ISIN</b> = DE00000123450

<b>WKN</b> = 012345

The target structure is build as a collection of identifers:

<i><b>IDENTIFIER (1..unbounded)</b></i>

<b>ID</b> = 01

<b>TYPE</b> = Isin

<b>VALUE</b> = DE00000123450

<b>ID</b> = 02

<b>TYPE</b> = Wkn

<b>VALUE</b> = 012345

Now, it's impossible for me to append a new record to this identifier collection by using the plain mapping functionality without java functions.

Did anybody face and solve this problem?

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

The solution lies in the function "duplicate subtree".

If the target message type "IdentifierCollection" contains a collection, you can append n-records of the basis datatype in the mapping environment.

IdentifierCollection

Identifier (0..unbounded)

Type

Value

Identifier (0..unbounded)

Type

Value

target-XML:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:InvestmentPreCollection xmlns:ns0="http://sap.com/identifier">

<InvestmentIdentifier>

<Type>ISIN</Type>

<Value>DE123456</Value>

</InvestmentIdentifier>

<InvestmentIdentifier>

<Type>WKN</Type>

<Value>123456</Value>

</InvestmentIdentifier>

</ns0:InvestmentPreCollection>

Former Member
0 Kudos

Hi Bhavesh, Marcus,

I'd like to refine the above problem somewhat ..

The main problem here is not to map an element name of a source document to an element value of a destination document, but to construct a collection from a list of source element values (Isin->Value, Wkn->Value):

("." are just for prettyprinting)

Source_1:

<PRICES>

....<Price>

........<Isin>DE0123456</Isin>

........<Wkn>123456</Wkn>

........<Currency>USD</Currency>

........<Amount>123.45</Amount>

....</Price>

....<Price>

........<Isin>DE0123457</Isin>

........<Wkn>123457</Wkn>

........<Currency>EUR</Currency>

........<Amount>987.65</Amount>

....</Price>

</PRICES>

Destination_1:

<PRICES>

....<Price>

........<IDENTIFIERS>

............<Identifier>

................<Key>ISIN</Key>

................<Value>DE0123456</Value>

............</Identifier>

............<Identifier>

................<Key>WKN</Key>

................<Value>123456</Value>

............</Identifier>

........</IDENTIFIERS>

........<Currency>USD</Currency>

........<Amount>123.45</Amount>

....</Price>

....<Price>

........<IDENTIFIERS>

............<Identifier>

................<Key>ISIN</Key>

................<Value>DE0123457</Value>

............</Identifier>

............<Identifier>

................<Key>WKN</Key>

................<Value>123457</Value>

............</Identifier>

........</IDENTIFIERS>

........<Currency>EUR</Currency>

........<Amount>987.65</Amount>

....</Price>

</PRICES>

So the main question for me seems to be: How to do the transpose of Isin and Wkn to the Value elements:

Source_2:

<Price>

....<Isin>DE0123456</Isin>

....<Wkn>123456</Wkn>

....<Currency>USD</Currency>

....<Amount>123.45</Amount>

</Price>

Destination_2:

<Price>

....<IDENTIFIERS>

........<Value>DE0123457</Value>

........<Value>123457</Value>

....</IDENTIFIERS>

....<Currency>EUR</Currency>

....<Amount>987.65</Amount>

</Price>

Since the length of the source list has very few items (comparable to columns in a database table), they could easily be set as constant Key's in the destination. The problem is: how to map element values of different source elements (Isin, Wkn) into a collection of destination elements (comparable to rows in a database table). The mapping from Destination_2 to Destination_1 could be done by a SplitByValue.

I couldn't find a mapping in the GUI which allows to do the latter mapping. More precisely to sort-of reference the destination elements by an index or to simply add more elements to the collection without overwriting the first one.

A Java Mapping doesn't seem to be appropriate, since it seems, that only 1 result value can be returned (or is it possible to modify the destination DOM/XML with a Java Mapping ? Or to return a list of values ?).

An XSLT Mapping seems to be possible, but unfortunately it imposes bigger efforts when additionally conversions or value-mappings are needed.

In the case that XSLT mapping is the only solution to the problem: is it possible, to do a XSLT mapping pipelined with a GUI mapping, such that the structural mapping can be done by XSLT and the conversions / value-mappings can be done via the GUI ?

Best regards,

Marc

bhavesh_kantilal
Active Contributor
0 Kudos

Hi Marcus,

You need to access the name of your element using Graphical Mapping.

I dont think this is possible and you will have to go for either JAVA Mapping or XSLT mapping.

Juct check this thread for info on the same and also for the various methods that can be used in JAVA Mapping,

hope this helps,

Reagards,

Bhavesh