cancel
Showing results for 
Search instead for 
Did you mean: 

Attn: Prakash (Message Mapping)

Former Member
0 Kudos

Hi Prakash,

In continuation to our conversation yesterday in regards to message mapping, I tried the solution you provided but when i test the mapping in gives a error.

Mapping scenario:

Source Target

Name >>> Name1

First >>> First1

Last >>> Last1

Address >>> Address1

Now is it possible that if I don't pass any value to a particular element say 'Last' in source then 'Last1' should not be present in the resulted mapping. I.e the result of the mapping should have only Name1, First1 and Address1. and if 'Last' is passed some value then all the four should appear in the result.

Solution you adviced is:

First make sure the ocurance of the Last1 is 0..1

Last

\

Equals>Not>IfWithoutElse -->Last1

/ /

Constant("") Last (then)

The issue is how do i represent empty or null in constant box.

If i represent it as "" or " " or NUll i get a error when i test the mapping.

Regards,

Ashish

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Prakash,

After applying the new mapping i am still getting the same error:

RuntimeException in Message-Mapping transformation: Runtime exception during processing target field mapping /ns0:Message2/E. The message is: Exception:[java.lang.IllegalArgumentException: Cannot cast to boolean] in class com.sap.aii.mappingtool.flib3.Bool method equals[, "", com.sap.aii.mappingtool.tf3.rt.Context@264c60]

the error is generated at the first equals step. Probably because Last is string and Constant "" is of some other data type.

Also in my scenario I have hundred elements that i need to apply this mapping. If i go with the UDF mapping, then is there a way to copy this mapping and apply it to other elements at one go.

Regards,

Ashish

former_member206604
Active Contributor
0 Kudos

Hi Ashish,

Are you sure you tried the same what I have given there above. <b>1st Equals</b> is string equals which you will find under the section <b>Text</b>. <b>2nd Equals</b> is boolean equals which you will find under the section <b>Boolean</b>.

If you want to do it for many fields then better to go for UDF. But its ultemately left to your comfort, but for copying I can give you some idea try this...

1. Right click you mouse on last function in your mapping (In your case it is IFWithoutElse) and select <b>Copy</b> from the menu. Then double click the next node in the target to be mapped and it will appear in the editor. Now right click the mouse and <b>Paste</b> it. Now you can see all the functions starting from the benining to the IFWithoutElse function will be pasted. Now you will have Last node as source, just delete it and map with the otehr source node. Give the output of IFWithoutElse to the Target node.

2. You can Export the mapping by CtrlShiftRight click select Export. You will be able to export the mapping that you have done. Now you can edit that file snd see what is the pattern and copy paste for the nodes you need. Then import the same.

Thanks,

Prakash

Answers (1)

Answers (1)

agasthuri_doss
Active Contributor
0 Kudos

Dear Ashish,

This is my Guess try taking away the quotes.

Page 67 will help you

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/9202d890-0201-0010-1588-adb...

Regards

Agasthuri Doss

former_member206604
Active Contributor
0 Kudos

Hi,

The above solution would work if you have Last node in the source with a Empty value.

If you would like to check both that is "" and NULL as well you can always go for a UDF

if (a.equals(null) || a.equals(""))
 return false;
else
 return true;

Assuming <b>a</b> is the paramter while defining the UDF

               
Last-->UDF-->IFWithOutElse-->Last1
               /
             Last

Thanks,

Prakash

Former Member
0 Kudos

Hi guys,

I just want that when no value is passed to last, then last1 should not appear in the result. But how do i represent nothing or empty in constant box. Is it NULL, or "", because if i use NULL or "" both of them generate error.

when i keep the constant value empty, i get the error below. Same for "", NULL and " ".

"RuntimeException in Message-Mapping transformation: Exception:[java.lang.IllegalArgumentException: Cannot cast to boolean] in class com.sap.aii.mappingtool.flib3.Bool method equals[, , com.sap.aii.mappingtool.tf3.rt.Context@c6ac36]"

Regards,

Ashish

former_member206604
Active Contributor
0 Kudos

Hi,

Did you try with the User Defined function. I have given you the code of the user defined funtion as well. Can you please try that and let me know. You need not pas a constant to the UDF.

Thanks,

Prakash

Former Member
0 Kudos

Hi prakash,

I created a UDF with no import parameter and one argument 'a' of string type and following code:

if (a.equals(null) || a.equals(""))

return false;

else

return true;

I get the error when i test the mapping:

Source code has syntax error: D:/usr/sap/X7A/DVEBMGS09/j2ee/cluster/server0/./temp/classpath_resolver/Map2bd71e3259e611dba361000f206d294f/source/com/sap/xi/tf/_Mapp_.java:59: <b>incompatible types found : boolean required: java.lang.String return false;</b> ^ D:/usr/sap/X7A/DVEBMGS09/j2ee/cluster/server0/./temp/classpath_resolver/Map2bd71e3259e611dba361000f206d294f/source/com/sap/xi/tf/_Mapp_.java:61: <b>incompatible types found : boolean required: java.lang.String return true;</b> ^ 2 errors

Regards,

Ashish

bhavesh_kantilal
Active Contributor
0 Kudos

Ashish,

Am not aware of the actual requirement of the UDF, but the reason for this error is because an UDF can return only <b>Strings.</b> You need to embed false and true with ".

if (a.equals(null) || a.equals(""))
return "false";
else
return "true";

Regards,

Bhavesh

former_member184619
Active Contributor
0 Kudos

Try this 1 to get rid of error

if (a.equals(null) || a.equals(""))

return "OK";

else

return "NOT";

Regards

Sachin

Former Member
0 Kudos

Thanks Guys,

The UDF is finally working after putting true and false in "". However could you guys pls suggest me a way to use this functionality without using UDF as suggested by Prakash.

Last

\

Equals>Not>IfWithoutElse -->Last1

/<b> </b> /

Constant("") <b> </b> Last (then)

Regards,

Ashish

former_member206604
Active Contributor
0 Kudos

Hi,

    
     Last
        
         Equals-->Not
        /             
Constant("")           EqualsB-->IFWithoutElse-->Last1
                      /            /
         Last-->exists           Last

The EqualsB is nothing but the equals that comes under Boolean section.

Thanks,

Prakash