cancel
Showing results for 
Search instead for 
Did you mean: 

Value Mapping requirement

Former Member
0 Kudos

Hi Experts, I have a requiremnet to fail the mapping if value mapping lookup (standard valuemapping) fails...

For example

vendor --111 --valuemaplookup to aaa ---target =aaa

if vendor 222 does not have value defined in value map table it has to fail the mapping...I am not sure its not working its outputting 222 in the target , any idea whats the cause.

Regards

Ravikiran

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

you can try this:

add one UDF after value mapping...this UDF will compare the output of value mapping and input source value,
in case if both are same then it will throw a runtime exception

input will be a and b
execution type: single value

if(a.equals(b))
{
throw new RuntimeException();
}
else
return a;

Chk this also:
http://scn.sap.com/people/alessandro.guarneri/blog/2006/01/26/throwing-smart-exceptions-in-xi-graphi...

Former Member
0 Kudos

This is what I was looking for worked like charm...not sure how to give points to you...this new feature and look ,looks like a crystal maze

Answers (3)

Answers (3)

iaki_vila
Active Contributor
0 Kudos

I assume that you are using the standar function Value Mapping to do the value mapping.

You could test this example:

ESR:

ID:

The values are in the configuration part, then it is a better aproximation if you need to change this values in the future.

Regards

Former Member
0 Kudos

Hi Thanks for the answer i donot have "throw exception" option my my value mapping function , I am using 7.0 I guess might be due to patch level

Former Member
0 Kudos

as far as i know, i think in 7.0 this option of throw exception in value mapping properties is not available. so you can create a UDF using if condition to check for your source values, in then map it to target values and in else condition (if no condition satisfies) throw an exception using throws statement.

iaki_vila
Active Contributor
0 Kudos

You could find the code that Rajev suggest in http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/00ee347e-aabb-2a10-b298-d15a1ebf4...

Pages 14 to 16.

Regards.

Former Member
0 Kudos

Hi Rajeev,

Thanks , yeah thats a mess now , do u have any sample UDF ,I guess putting around 3000 values in UDF does not sound good to me ...any simple UDF to raise exception if there is a blank value..then I can build my mapping condition around that

Former Member
0 Kudos

the situation is slightly tough now.........use the below URL to see the class, interface and methods and try to invoke it in your UDF:

http://help.sap.com/saphelp_nwpi711/helpdata/en/f2/dfae3d47afd652e10000000a114084/frameset.htm

the doc provided by inaki above also uses these and has a better detailed description to use these.

use executeMapping function in your UDF. so if it returns null in UDF, then throw exception.

so in graphical msg mapping, the valuemapping node will be replaced by your UDF having all the input parameters as constants except the source value field in your graphical msg mapping for executeMapping function.

iaki_vila
Active Contributor
0 Kudos

If you have a large number of values you should use for example an RFC Lookup function. I don't know if it is available in SAP PI 7.0.

You could use the code from here http://wiki.sdn.sap.com/wiki/display/Snippets/User-defined+Mapping+Function+for+RFC+Lookup

Regards

Former Member
0 Kudos

Check your code in RFC... Check if it returns the input value if output value is not maintained for the input value. Change your RFC code to return null in case target value is not maintained and raise exception in your message mapping accordingly.

-Amol

Former Member
0 Kudos

create a UDF for this lookup and for not required values, throw exception using throws statement.

former_member184681
Active Contributor
0 Kudos

Hi Ravikiran,

@RAJEEV GUPTA: UDF is not required here, standard configuration of Value Mapping function can be used.

The solution is: when you double-click the Value Mapping function, a configuration popup appears. You can choose the expected behavior when the lookup fails: Use Key (which is the default and apparently is used in your case), Use Default Value and Throw Exception. You should use the last one in your case. See below:

Hope this helps,
Greg

Former Member
0 Kudos

Hi , thanks for the update , initially that was i thought , but I donot have "throw exception " option might due to patch level of XI ..using 7.0 ...