cancel
Showing results for 
Search instead for 
Did you mean: 

Message Mapping context problem

Former Member
0 Kudos

Hello everybody,

I have a source document like the following:

<Level1>

<Level2>

<Value1>1</Value1>

<Value3>HHGH</Value3>

</Level2>

<Value1>2</Value1>

<Value2>Text2</Value2>

<Level2>

</Level2>

<Value1>3</Value1>

<Value2>Text3</Value2>

<Value3>FGFGFG</Value3>

<Level2>

</Level2>

</Level1>

I want to map to the target document only the <Value2> element where the <Value1> element = "3".

If I try this with the mapping tool, the contexts get out of synch, because the first <Level2> element has no <Value2>.

So I have the <Value1>3</Value1> element connected with the <Value2>Text2</Value2> element, which are in different contexts.

How can I solve this? This is happening often with IDOC mappings.

Thanks,

Hans

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Answered by internal reading/training/try/error on message mapping contexts.

franz_forsthofer
Employee
Employee
0 Kudos

Hello Hans-Jürgen,

hier is the text representation of the mapping definition which solves your problem:

/ns:Level1/Level2=removeContexts([]ifWithoutElse([]equalsS([]Constant() , /ns:Level1/Level2/Value1) , Constant()))

/ns:Level1/Level2/Value2=SplitByValue(removeContexts([]ifWithoutElse([]equalsS([]/ns:Level1/Level2/Value1 , Constant()) , /ns:Level1/Level2/Value2)))

One must be aware that also the Level2 must get the correct number of elements.

Regards Franz

Former Member
0 Kudos

Hans,

I presume your example shoud look be

<Level1>

<Level2>

<Value1>1</Value1>

<Value3>HHGH</Value3>

</Level2>

<Level2>

<Value1>2</Value1>

<Value2>Text2</Value2>

</Level2>

<Level2>

<Value1>3</Value1>

<Value2>Text3</Value2>

<Value3>FGFGFG</Value3>

</Level2>

</Level1>

I ran into similar problem and switched to XSLT. In XSLT, this is VERY easy to solve, e.g. xpath expression

/Level1/Level2/Value2[../Value1='3']

Maybe XSLT is a bit less (?) efficient than the SAP mapping tool, but XSLT is a standard, well documented with 3rd party tooling available. For normally sized documents, it performs well.

Kind regards, Guy Crets