on 10-06-2009 10:59 AM
Hi,
When there is no inv2 in the first invoice tag of my input xml, the result breaks down. value of the 2. invoice tag moves up under the first item. Is it possible to correct this without addind an empty inv2 tag to the 1. invoice?
My mapping:
inv1-value -> itm1
inv2-value -> itm2
inv3-value -> itm3
input:
<root>
<invoice>
<inv1 value="1"/>
<inv3 value="2"/>
</invoice>
<invoice>
<inv1 value="3"/>
<inv2 value="4"/>
<inv3 value="5"/>
</invoice>
</root>
output:
<root>
<item>
<itm1>1</itm1>
<itm2>4</itm2>
<itm3>2</itm3>
</item>
<item>
<itm1>3</itm1>
<itm3>5</itm3>
</item>
</root>
Hi Ali,
Check the output structure in your question (first post).
You are saying you need an output like
<root>
<item>
<itm1>1</itm1>
<itm2>4</itm2>
<itm3>2</itm3>
</item>
<item>
<itm1>3</itm1>
<itm3>5</itm3>
</item>
</root>
But later you are saying you need an output like
<root>
<item>
<itm1>1</itm1>
<itm2></itm2>
<itm3>2</itm3>
</item>
<item>
<itm1>3</itm1>
<itm2>4</itm2>
<itm3>5</itm3>
</item>
</root>
or
<root>
<item>
<itm1>1</itm1>
<itm3>2</itm3>
</item>
<item>
<itm1>3</itm1>
<itm2>4</itm2>
<itm3>5</itm3>
</item>
</root>
Which is the actual output that you are expecting!!!!
Also tell is it the problem with only inv2 or you have the same issue with inv1 and inv3
Regards
suraj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think you have not red the question properly.. because from very begining he expecting only below mentioned result..
Plz go through once agin with original question... (actually just by looking it seems like that... so what you observed is correct but not true)
<root>
<item>
<itm1>1</itm1>
<itm3>2</itm3>
</item>
<item>
<itm1>3</itm1>
<itm2>4</itm2>
<itm3>5</itm3>
</item>
</root>
In the first post it is the output I get, but I don't want that output.
What I want is:
<root>
<item>
<itm1>1</itm1>
<itm3>2</itm3>
</item>
<item>
<itm1>3</itm1>
<itm2>4</itm2>
<itm3>5</itm3>
</item>
</root>
In my example the problem is with inv2. But if you omit inv1, then you get the same problem with that also (the same with inv3).
Hi Ali,
Map like this:
invoice -> item
value(inv1) ->MapwithDefault-> itm1
value(inv2) -> MapwithDefault->itm2
value(inv3) -> MapwithDefault->itm3
Also please check what MapwithDefault does here http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
Replaces empty contexts in the inbound queue with a default value, which you specify in the function properties.
Example:
If u201CDefaultu201D is the default value and
A|B1,B2| |C| |D
is the inbound queue,
mapWithDefault returns the following outbound queue:
A | B1,B2 | Default | C | Default |D.
So map with default shoudl work for you, now if that doesn't work, provide the input field which you are passing and the output that you are getting. No need to set any property for mapwithdeafult
regards
Suraj
Hi Ali,
Try this once
invoice -> item
value(inv1) ->MapwithDefault->splitbyvalue(each value)->itm1
value(inv2) -> MapwithDefault->splitbyvalue(each value)->itm2
value(inv3) -> MapwithDefault->splitbyvalue(each value)->itm3
Right Click the Mapwithdefault function in the mapping of itm2 and see the display queue. Also make sure the context of inv2 is set to its parent item.
Can you paste here the input and output values which you see in the display queue of mapwithDefault (for output node itm2)
Regards
Suraj
I think if you just do the direct assaignment between Invoice and Item
as
Invoice----->Item
and for the value(Inv1) to Itm1 and respectively for other Inv2 and Inv3 to Itm2 and Itm 3.then you will get the required output.
If you tell the exact mapping requirement then we will help you further.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>
> I think if you just do the direct assaignment between Invoice and Item
> as
>
> Invoice----->Item >
> and for the value(Inv1) to Itm1 and respectively for other Inv2 and Inv3 to Itm2 and Itm 3.then you will get the required output.
> If you tell the exact mapping requirement then we will help you further.
I have already made that mapping. In my input XML some elements may sometimes not exist. In this circumstances that values are shifted from below values. Please check it from the first post.
Add a condition using if else and if inv2 exists then inv2 --> item else default to inv2
Need to check the context if it is used at child levels
HTH
Rajesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>
> Add a condition using if else and if inv2 exists then inv2 --> item else default to inv2
>
> Need to check the context if it is used at child levels
>
> HTH
> Rajesh
<itm2> in the second <item> is still missing.
new output:
<root>
<item>
<itm1>1</itm1>
<itm2/>
<itm3>2</itm3>
</item>
<item>
<itm1>3</itm1>
<itm3>5</itm3>
</item>
</root>
Edited by: Ali Varli on Oct 6, 2009 12:15 PM
>
> MapWithDefault should help you.
>
> I think MapWithDefault should give the output even if field does not exist, if not then add a condition that if field doesn't exist then Map with some constant so that your queue should be maintained.
>
> Regards,
> Sarvesh
Yes MapWithDefault gives the output even if field does not exist, but as stated in my example <itm2> in the 2. <item> gets no value as it should get "4".
My mapping:
invoice -> item
value(inv1) -> itm1
value(inv2) -> mapWithDefault("") -> itm2
value(inv3) -> itm3
what I get:
<root>
<item>
<itm1>1</itm1>
<itm2/>
<itm3>2</itm3>
</item>
<item>
<itm1>3</itm1>
<itm2/>
<itm3>5</itm3>
</item>
</root>
my request:
<root>
<invoice>
<inv1 value="1"/>
<inv3 value="2"/>
</invoice>
<invoice>
<inv1 value="3"/>
<inv2 value="4"/>
<inv3 value="5"/>
</invoice>
</root>
or
<root>
<invoice>
<inv1 value="1"/>
<itm2/>
<inv3 value="2"/>
</invoice>
<invoice>
<inv1 value="3"/>
<inv2 value="4"/>
<inv3 value="5"/>
</invoice>
</root>
User | Count |
---|---|
87 | |
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.