cancel
Showing results for 
Search instead for 
Did you mean: 

Is ResultList not compatible with java.util.List?

former_member181985
Active Contributor
0 Kudos

Hi,

We are in the process of migrating some interfaces to new PI7.3 from PI7.0. One of the interface has a UDF code as below and when migrated it is not working saying List is NULL

List list = (List) result;

String temp1 = list .get(0).toString();

String temp2 = list .get(1).toString();

Error:

Runtime exception when processing target-field mapping /COND_A04/IDOC/E1KOMG/VAKEY; root message: Exception:[java.lang.ClassCastException: class com.sap.aii.mappingtool.tf7.rt.ResultListImpl:library:com.sap.xi.mapping.tool.lib@com.sap.engine.boot.loader.ResourceMultiParentClassLoader@37e15160@alive incompatible with interface java.util.List:null] in class com.sap.xi.tf.XXXXXXXXXXXXXXXXXXXXXXXXXXX

Has any one faced this issue before? What is the alternate APIs/methods I can use??

Regards,

Praveen Gujjeti

Accepted Solutions (1)

Accepted Solutions (1)

former_member181985
Active Contributor
0 Kudos

Hi All,

Any ideas on this. Your help much appreciated. Thanks in advance

- Praveen

anupam_ghosh2
Active Contributor
0 Kudos

Hi Praveen,

                     You have uploaded only a portion of the code. Could you please upload the section of the code prior to these lines and also the name of the function along with its parameters. Its difficult to comment on the problem without details (and specially because I know from your blogs and posts that you are an excellent coder in java yourself).  

Regards

Anupam

former_member181985
Active Contributor
0 Kudos

Hi Anupam,

Thanks for your reply. The UDF code is little big, that is the reason I provided only partial code where the problem lies.

Can you please assume the below points for testing.

1) The UDF signature is at queue/context level.

2) The UDF has one input with array of values.

3) using for loop all values are being added to ResultList variable result using addValue() method.

4) Try to fetch result values using List variable as below.

  • List list = (List) result;  
  • String temp1 = list .get(0).toString();  
  • String temp2 = list .get(1).toString(); 

5) The above code is working fine in PI7.0 but not in PI7.3 and I am getting incompatible null exception as I explained before.

  Note: in my original requirement, I have a lookup functionality which will add lookup values to result variable based on input values.

Regards,

Praveen Gujjeti

anupam_ghosh2
Active Contributor
0 Kudos

Hi Praveen,

                    Try changing the first statement to this form

List <String>list      = (List<String>) result; 

Hope this resolves the problem.

Regards

Anupam

former_member181985
Active Contributor
0 Kudos

Hi Anupam,

No Luck. Still the same error.

- Praveen Gujjeti

anupam_ghosh2
Active Contributor
0 Kudos

Hi Praveen,

                     Is it necessary to obtain the strings temp1 and temp2 from result object? The result object is getting its values from the input array say a[] as I can infer from your previous post. Thus is it possible to use statements like

temp1=a[0];

temp2=a[1];

In case the input strings are being altered in the code before adding them to result object then you can declare another array in UDF and add same objects to the array whenever there is a result.addValue() statement in the UDF. Thus at first

String b[]=new String[a.length];

------------------------------------------

--------------------------------------------

result.addValue(str);

b[j]=str;

j++;

-------------------------

------------------------

temp1=b[0];

temp2=b[1];

-----------------------------

-------------------------------

Regards

Anupam

former_member181985
Active Contributor
0 Kudos

Hello Anupam,

Fully understand but let me explain what and why I am looking at

1. First thing, You might have missed my statement in my previous reply " Note: in my original requirement, I have a lookup functionality which will add lookup values to result variable based on input values." The lookup is a custom java core  functionality being used in atleast 80% of migration interfaces(500 interfaces) which we are not willing to change under any circumstance, since we have this issue only for one interface.

2. in migration project, we prefer simple lift and shift without any major change.

3. As a PI consultant, I still look why it (ResultList <--> java.util.List) is not compatible in PI7.3 version. The same is compatible in PI7.1 (Bhaskar confirmed in his reply) and lower versions.

Note:- My PI version is 7.3 and SP7

- Praveen Gujjeti

anupam_ghosh2
Active Contributor
0 Kudos

Hi Praveen,

                  Hope you have managed to resolve the problem by now. In migration project it is our motto not to change anything as much as possible. There are cases where you need changes and there is no alternative. One such case I want to bring to your notice where the team followed my suggestion of change and the problem was resolved. You can check this thread http://scn.sap.com/thread/3235341

.  Thus in case if the problem still persists try rewriting the code,but a proper backup of old code is kept so that you can restore the old code if necessary .

When you do changes there are couple of things you need to ensure

1. Interface of the UDF must not change. The input variables and expected output remains same.

2. Extensive testing.

3. Logic of UDF never changes.  

4. Old code is kept safely stored.

All I want to say is please don't  completely stick to the idea that you should not change the code under any circumstances. Sometimes this can be a better, optimal solution than any other solution. This is just my thinking, since I regard all members of this forum as part of my family.I feel I can open my feelings my family members.

Regards

Anupam 

former_member181985
Active Contributor
0 Kudos

Hi Anupam,

Due to strick migration timelines, I am forced to use change the UDF code. Fortunately I am able to manage a solution without having to change the Lookup method wrapper. Code snippet below. Might be useful for someone facing similar issue.

CustomUKMSLookupWrapper(String, String, String,String, String, ResultList result);//result gets populated here

ResultListImpl rlImpl = null;

rlImpl = (ResultListImpl) result;

String tempStr = (String) rlImpl.get(); // This way I am able to store value into a string variable. I need to do this for each lookup functionality

result.clear();//clear result

But I am still wondering why Array type e.g., List is not supported for a type cast of ResultList. May be SAP should have an answer for this.

Regards,
Praveen Gujjeti

anupam_ghosh2
Active Contributor
0 Kudos

Hi Praveen,

                     Thank you so much for sharing the solution.

Regards

Anupam

former_member181985
Active Contributor
0 Kudos

Cheers

Answers (1)

Answers (1)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You might want to try this way....

 

List<String> list = new ArrayList<String>(result);

String temp1 = list.get(0).toString();

String temp2 = list.get(1).toString();

former_member181985
Active Contributor
0 Kudos

Hello Bhaskar,

I can not use yours as it is leading to syntax errors.

new ArrayList<String>(result);

- Praveen

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Please provide more details about the error. 

Are you doing import statement as follows...

import java.util.ArrayList;  or

import java.util.*;

former_member181985
Active Contributor
0 Kudos

The Mapping program has already import java.util.* statement. I do not remember the error as this is more on syntax side. May be you can test this in your PI system using some available mapping program.

- Praveen

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Yes tested with my mapping program in PI 7.1.  Yes I see there is no compatible between java ArrayList type and ResultList.  So I see syntax errors. Please ignore that solution.

I'm sure you might have done more research on this. But here is the findings.  As you know jdk 1.5 works both in PI 7.1 and 7.3, I dont see any difference in java compatiblity between 7.1 and 7.3.  Your original version code works without any issues in PI 7.1(tested in my machine). Unfortunately I dont have access to 7.3 temporarily now.  I would say you can stick with the original version code and see whether you updated com.sap jars for the mapping that works for 7.1 correctly. I suspect your mapping api is still older version that might be causing this issue. You might want to see this link and also I dont see ResultListImpl class (error)  in this...

http://help.sap.com/javadocs/pi/SP3/xpi/overview-summary.html

former_member181985
Active Contributor
0 Kudos

Thanks Bhaskar for investing your time. Now we are on same page.

>>see whether you updated com.sap jars for the mapping that works for 7.1 correctly.

In PI7.3 the standard libraries as imports are implicit in UDF and they are obviously latest ones.

The link you have provided is standard SAP help, this I already checked before. It does not even mentioned in help if ResultList type can be typecasted to java.util.List for PI7.3 (even for lower versions help)

- Praveen