Skip to Content

This blog aims in explaining ResultList object/variable and its behavior/API methods with respect to PI versions and also with respect to some special mapping requirements (I faced one issue as per below thread), wherein ResultList object needs to be handled within same UDF.

Thread discussion: “Is ResultList not compatible with java.util.List?” –  http://scn.sap.com/thread/3255482

As you aware till PI7.0, ResultList variable can be easily typecast to java.util.List and then can be iterated over its values using iterator() / ListIterator() / get(int) methods of java.util.List

List list = (List) result;

However, from PI7.1 onwards the ResultList object API seems to be changed and it is no more accessible via above said methods of PI7.0 or below. In PI projects, there can be typical mapping functionality requirements (e.g., I faced one in my migration project as per above thread discussion), wherein ResultList object needs to be handled within the same UDF. After some deep analysis, now I found another solution other than the one what I mentioned in my thread.

Code snippet and method details in brief

  1. Use ResultListImpl class for typecasting ResultList object
  2. Use get() method to fetch the current value from ResultListImpl variable and then use pop() method to move to the next element.
  3. Note that, pop() method basically removes the value from ResultList object and finally after all iterations the ResultList becomes null (no values)
  4. Hence we need to add each fetched value in previous step into a temporary ArrayList variable for further manipulation as per typical mapping functionality requirement (may be some changes to existing values or addition of new values)
  5. Finally add all the required values from ArrayList to ResultList object
ResultListImpl rlImpl = (ResultListImpl) result;    
String tempStr;
ArrayList<String> arrayList = new ArrayList<String>();
int i = 0;
do
{
                tempStr = (String) rlImpl.get();
                rlImpl.pop();     
                arrayList.add(tempStr);
                i++;
                if (tempStr != null)
                                this.getTrace().addInfo("rlImpl.pop():" + i + " :" + tempStr);
}while (tempStr != null);
List list = arrayList;
Iterator iterator = list.iterator();
while (iterator.hasNext())
{
               //requirement manipulation logic
                result.addValue(iterator.next()); //Populate ResultList finally with required value
}

May be there can be some other easy ways to access ResultList object. Please share your valuable inputs.

Thanks,

Praveen Gujjeti

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply