cancel
Showing results for 
Search instead for 
Did you mean: 

IDOC mapping

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

justin_santhanam
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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

justin_santhanam
Active Contributor
0 Kudos

Rajat,

I'm sure it will work. I think you might have directly used the source field with If then else.In that case it will throw an error.

But in my case see the logic, I used exists in conjunction to this, so it won't throw any error. I'm 100% sure on this, plz correct me if i'm wrong.

raj.

Former Member
0 Kudos

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

Former Member
0 Kudos

Hello Raj

Could you send a screenshot if possbile ?

Thanks

justin_santhanam
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

Hello

Thanks for the screenshot.

But my questions is : In your screenshots if "Row" does not come then mapping will fail.

Same situation I have but the Segment:"Row" may or may not come sometimes.

Can you suggest some alternative.

Thanks

justin_santhanam
Active Contributor
0 Kudos

Rajat,

Hence you mean

Row 0..1

Value 0..1

So, if Value won't come no issues, coz I explained in the screenshot. But your question is what happens if Row doesn't come am I right?

raj.

Former Member
0 Kudos

Yes ,you understood it right now.

Thanks

justin_santhanam
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

Thanks Raj

This is what I was asking initially in my first email and you are correct mapwithDefault can be used and not IF -Else-Exists check.

I will award you the points and close the thread.

Regards.

Answers (1)

Answers (1)

Former Member
0 Kudos

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