cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple IF condition

Former Member
0 Kudos

Hi,

I've 12 fields to check(message mapping using IDoc segments) if anyone of them have value 03 then I want to read the associated field value into target field.

e.g.

if dar01 eq 03

move dat01 to target_dat.

elseif dar02 eq 03

....

elseif dar03 eq 03

....

elseif dar12 eq 03

move dat12 to target_dat

else

do not populate the target segemnt.

endif.

I've tried this using graphical mapping but it looks like a real mess, any idea pls...

cheers

Taj

Accepted Solutions (0)

Answers (1)

Answers (1)

moorthy
Active Contributor
0 Kudos

Hi Taj,

Make use of Gloobal COntainer Object to set the flag. and then based the flag, do the rest of the mapping.

For more on Global COntainer-

http://help.sap.com/saphelp_nw2004s/helpdata/en/e0/7d8e40496f6f1de10000000a1550b0/content.htm

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

Regards,

Moorthy

Message was edited by: Krishna Moorthy P

MichalKrawczyk
Active Contributor
0 Kudos

hi Moorthy,

I believe he wants to put it all into

one field - target_dat (so no need for container)

don't you think?

just <b>if, else if</b> and <b>concat </b>but I don't know where

the problem is...

Regards,

michal

Former Member
0 Kudos

Hi Michal & Moorthy,

I think I didn't explain the problem properly. I only need ONE of the 12 fields which contains value 03, I don't need to concat all fields.

Taj

moorthy
Active Contributor
0 Kudos

Hi Michal,

You are right, but if-else if will look very messy in the mapping editor.. As per my understanding ,his question is mapping is very confusing/messy..

Thats the reason I just given a hint of Container. SO that it will be easily readable..

Regards,

Moorthy

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

I still don't know what he needs - java code for if, else?

Regards,

michal

Former Member
0 Kudos

Hi Michal,

I'm new to XI therefore I wanted to know if there is alternative to ifelse condition of graphical mapping and yes it may be Java but I don't know Java either so any guide line would be greatly appreciated.

cheers

Taj

MichalKrawczyk
Active Contributor
0 Kudos

hi,

now we know what you need:)

>>>>if there is alternative to ifelse condition of graphical mapping and yes it

of course there is - you can connect all nodes to

a simple user function and put some java code inside:

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/if.html

and this will generate your result

(very easy and it will look ok for sure

you can also use <b>equals</b> method (to work with strings)

if you just need this no need to use globalcontainer then

this is simple if else if in a simple user defined function - nothing more

Regards,

michal

MichalKrawczyk
Active Contributor
0 Kudos

hi,

you can try this code in your simple function

with all 12 inputs (I assume that you name the inputs dar01, dar02 etc and not a,b,c..)

String finalResult;

if (dar01.equals("03")) {

finalResult = dar01;

} else if (dar02.equals("03")) {

finalResult = dar02;

} else {

finalResult = " ";

}

return finalResult;

for simple user defined fucntions check out this guide:

https://websmp102.sap-ag.de/~sapdownload/011000358700003604872004E/MappingXI30.pdf

Regards,

michal

-


<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

Former Member
0 Kudos

Michal,

I've tried creating the simple user function but can you explain the argument count should this be equal to no. of fields I need to parse if yes then its max value is 10 and I need to check 12 fields and further 12(24 in total) are the associated fields which contain the actual value that I need to get to.

Taj