cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Header / Item

Former Member
0 Kudos

Hi,

In a mapping I want to do that:

--> Inbound (Idoc):

Segment<b>1</b>-fieldA

Segment<b>1</b>-fieldB

Segment<b>2</b>-field<b>C</b>

Segment<b>2</b>-field<b>D</b>

<i>Segment1 and Segment2 are at the same hierarchical level.</i>

--> Outbound (row for a file):

row1: Segment<b>1</b>-fieldA Segment<b>1</b>-fieldB Segment<b>2</b>-field<b>C</b>

row2: Segment<b>1</b>-fieldA Segment<b>1</b>-fieldB Segment<b>2</b>-field<b>D</b>

(it seems that I'll need only ONE Segment1)

But by using "Splitbyvalue", "removecontext", I have only this:

--> Outbound:

row1: Segment<b>1</b>-fieldA Segment<b>1</b>-fieldB Segment<b>2</b>-field<b>C</b>

row2: Segment<b>2</b>-field<b>D</b>

==> pb: Segment1 is missing for my second line.

Anybody have an idea?

Regards.

Mickael.

Message was edited by: Mickael Huchet

Message was edited by: Mickael Huchet

Accepted Solutions (1)

Accepted Solutions (1)

cdumont69
Contributor
0 Kudos

Hello,

If you create your own XSLT, it could be easy to do !

Regards,

Chris

Former Member
0 Kudos

Else a solution is to create a Java Function (advanced one)like it's explained by SAP inside its doc "Mapping - Functionality" (page 101).

Source code is:

for (int i=0; i<a.length; i++){
   result.addValue(b[0]);
}

Former Member
0 Kudos

Hi,

if my example is not an assistance, you can post the XML Files as they to look are.

One Messages before mapping and the message as like it to look after mapping.

So i can post a XSLT Mapping for this Problem.

Regards,

Robin

Former Member
0 Kudos

Hi Robin,

I don't really know XSLT... But I'm interrested by it.

In your example, could I have a number of rows which is not limited?

Example:

<row1>

<row2>

...

<rown>

Regards.

Mickael.

Former Member
0 Kudos

Hi Mickael,

I don't know whether it is possible to become unlimited rows like:


<row1>
<row2>
...
<rown>

i think it is difficult to become the numbers automatically in mapping, but XSLT is very Powerful so maybe there is a solution.

I also Know that is Possible to Map the row like:


<data>
<row></row>
<row></row>
<row></row>
<row></row>
</data>

Regards,

Robin

Former Member
0 Kudos

ok, I'll test your solution after my work.

Thanks.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Mickael,

If you want unlimmited number of rows, don't number them.

You can loop over the source data using the xsl:for-each command.

<xsl:for-each select="//Segment">

<row>

<xsl:value-of select="."/>

</row>

</xsl:for-each>

You can find more information on XSLT on www.zvon.org.

Hopes this helps,

Christiaan Schaake

Former Member
0 Kudos

Hi Mickael,

You can use a XSLT Mapping.

For Example:

Message before Mapping execute:

<?xml version="1.0" encoding="UTF-8"?>
<DATA>
	<SEGMENT1>
		<FIELD_A>DataA</FIELD_A>>
		<FIELD_B>DataB</FIELD_B>
	</SEGMENT1>
	<SEGMENT2>
		<FIELD_C>DataC</FIELD_C>
		<FIELD_D>DataD</FIELD_D>
	</SEGMENT2>
</DATA>

After Mapping:

<?xml version="1.0" encoding="UTF-8"?>
<DATA>
	<row1>DataADataBDataC</row1>
	<row2>DataADataBDataD</row2>
</DATA>

If this is the result you want, you have to use a XSLT Mapping like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:template match="/">
		<DATA>
			<row1>
				<xsl:value-of select="//SEGMENT1/FIELD_A"/>
				<xsl:value-of select="//SEGMENT1/FIELD_B"/>
				<xsl:value-of select="//SEGMENT2/FIELD_C"/>
			</row1>
			<row2>
				<xsl:value-of select="//SEGMENT1/FIELD_A"/>
				<xsl:value-of select="//SEGMENT1/FIELD_B"/>
				<xsl:value-of select="//SEGMENT2/FIELD_D"/>
			</row2>
		</DATA>
	</xsl:template>
</xsl:stylesheet>

Regards,

Robin