on 03-10-2008 3:47 PM
Hello
A quick question : Will both the below(1 and 2) behave in same way or differ.
There is an IDOC and a segment within that IDOC may or may not come every time the IDOC is triggered.I am mapping a field in that segment which may or may not come.
1) Use an IF then else clause in conjunction with an EXISTs check on that field. If that field does not exist then else clause will map to a constant.
2) MapwithDefault: If that field does not come it still maps.
Thanks
Rajat,
Both are same. But depending on your usage, for example
Set1
Source
<Test>
<Field1>It's there</Field1>
</Test>
Target -1
<Test>
<Result>True </Result>
</Test>
Target -2
<Test>
<Result>It's there</Result>
</Test>
Set 2
Source
<Test>
</Test>
Target -1
<Test>
<Result>False</Result>
</Test>
Target -2
<Test>
<Result>It's not there</Result>
</Test>
If you want to achieve Target -1
Then
Field1 -
>exists -
>If then else -
>Result
Then Branch Map -
> Constant(True)
Else Branch Map -
> Constant(False)
Here, you can't use MapWithDefault
But in the following case you can use Map With Default
Field1 -
>exists -
>If then else -
>Result
Then Branch Map -
> Field1
Else Branch Map -
> Constant("Its not there")
Field1 -
>MapWithDefault("Its not there") -
>Result.
I hope it clears a bit, if not reply back.
raj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello
With the option 1) If else exists check:when I checked last time
If the segment does not come then the mapping is not executed as the segment node is absent.
So the segment node needs to be present for that exists check to work but I am not sure if mapwithdefault will serve the purpose.
I am not having access to server right now ,else I could have checked.
Thanks
Hello,
i think it will make no difference, because they are doing the same.
So if it's not working with if-condition it will also not working with mapWithDefault.
But you say that your field is part of an optional segment. In that case you have to do the existence check for your Segment too.
Regards
Patrick
Rajat,
See the below snapshots.
Case 1 - In this scenario, we can't use Map With Default.
http://www.flickr.com/photos/23855877@N07/2324042795/sizes/o/
Case2 - In this scenario, we can use both If then else and Map With Default.
http://www.flickr.com/photos/23855877@N07/2324042799/sizes/o/
I hope you will believe me now, ... Juz kidding.
If it doesn't helps let me know.
raj.
Rajat,
I got you. First of all thanks, new learning from you! For this case, you need to use only MapWithDefault , you can't use If then else function if you don't have parent node.
Refer - http://www.flickr.com/photos/23855877@N07/2325019126/sizes/o/
Good learning from you!
Thanks,
Raj.
Hello,
they behave the same way.
If you look in SAP Help :
http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/frameset.htm
There is written about 'mapWithDefault:
>The function corresponds to the following combination of standard functions:
>If(
> \[\]field,
> exists([]field),
> Constant(\[value=default\]))
Regards
Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.