on 10-19-2004 5:13 PM
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
Answered by internal reading/training/try/error on message mapping contexts.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
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.