cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple IF scenarios in Mapping

Former Member
0 Kudos

hi,

i have 5 suppliers. Source is IDOC.

I have to generate an xml. There are is a field in the header tag in the xml that vary from supplier to supplier.

I have to determine what needs to go into the <identity> tag based on the idoc supplier.

<header>

<identity>123</identity>

</header>

Supplier 2:

<header>

<identity>444</identity>

The only option i think is in the Graphical mapping we can check for PARVW and determine the Supplier and map the corresponding identity value.

What options do i have to generate the <identity>?

I can achieve the above using Graphical Mapping.

Other than Java and XSLT what other options do i have?

Thanks,

Tirumal

PS: If tomorrow more suppliers are added i should not be in a situation to change the whole mapping.

Message was edited by: Tirumal Kumar Pappu

Accepted Solutions (0)

Answers (1)

Answers (1)

moorthy
Active Contributor
0 Kudos

Hi Tirumal,

You can write one simple User Defined Function and set the incoming value into a Global Container. And use this COntainer Value whenever you required in the Mapping. Atter this, put just if then inbuilt function and go forward.

http://help.sap.com/saphelp_nw2004s/helpdata/en/22/e127f28b572243b4324879c6bf05a0/frameset.htm

Hope this helps,

Regards,

Moorthy

Former Member
0 Kudos

Moorthy -

do you have a sample program that shows how to capture value in Global container?

Thanks,

Tirumal

Former Member
0 Kudos

Tirumal

The below url shows how to use global container in Graphical Mapping. Go through it and configure your scenario:

/people/michal.krawczyk2/blog/2005/03/04/globalcontainer--in-graphical-mapping-xi

---Mohan

Former Member
0 Kudos

Mohan -

This example has output split into multiple lines.

This is not my requirement.

I want to map one-to-one value in source and target but based on the values in PARVW.

I am able to map this but the mapping has become too complicated(Graphical). So just wanted to know if there is any other way.

The example that you pointed me to is splitting the messages into multiple lines.

Thanks,

Tirumal

moorthy
Active Contributor
0 Kudos

Hi Tirumal,

<i>I am able to map this but the mapping has become too complicated(Graphical). So just wanted to know if there is any other way.</i>

I know that , it is more lengthy, unreadable rather than complex. That the reason I have given the idea of Global Container.

The blog shows the example, how to write Global Container. You are requested the same right ? ANd blog is not talking baout your scenario.

Thanks,

Moorthy

Former Member
0 Kudos

hi,

Ok. Agree with you.

Let me try this and get back to you.

Thanks,

Tirumal

Former Member
0 Kudos

hi,

I created a User defined function and i have the mapping as shown below:

String[] a = new String[100];

int i,j ;

j = 0;

for(i=0; i<parvw.length; i++)

if (! parvw<i>.equals(ResultList.CC) &&

! parvw<i>.equals(ResultList.SUPPRESS) )

a[j++] = parvw<i>;

for(i=0; i<a.length; i++)

if (a<i> != null && a<i>.equals("LF"))

<b>if (partn<i>.equals("0000010283"))

result.addValue("123123123");

else if (partn<i>.equals("0000011239"))

result.addValue("170368430");</b>

If you look at the highlighted statements i am hardcoding the values that i need to map to the header in the addValue.

Is there a dynamic way to do it instead of hardcoding the values inside the UDF ?

If i have add a new supplier and addValue then i have to change it in UDF.

Thanks,

Tirumal

Message was edited by: Tirumal Kumar Pappu

former_member187339
Active Contributor
0 Kudos

Hi,

>><b>if (partn.equals("0000010283"))

result.addValue("123123123");

else if (partn.equals("0000011239"))

result.addValue("170368430");</b>

You can try this aproach, use <b>FixValues</b>. So that if any new supplier is there then you can add the needed value in FixValue.

Give the output of FixValue (say <i>fa</i>) as the input of the UDF.

So the above highlited code can be changed as

<b>result.addValue(<i>fa</i>);</b>

Regards

Suraj<b></b>