cancel
Showing results for 
Search instead for 
Did you mean: 

PI v7.3 Process ResultList from UDF in another UDF

Former Member
0 Kudos

I am in need of some help.  We are writing a UDF to gather data from multiple sources.  Several of those sources are already built UDF functions in another library.  We can call the UDF functions from the other library, but we are having issues with parsing the data that is returned.

As an example:

UDF A->genAddressText(String[] inXML, String[] inQualifier, ResultList result);

     This function will parse the XML and return formatted address lines for the XML given.

UDF B->genInstructions(String[] inXML, ResultList result);

     This is the new function that will call the UDF A->genAddress();

In the genInstructions - we call the UDF A->genAddress as such:

String[] inQualifier = {"ZC"};

String[] inDestEurope = { "true" };

//Calling genAddressText UDF to get Final Destination Address

ResultListImpl address = new ResultListImpl();

_Forms_test_.genAddressText(inxml,inQualifier, inDestEurope, (ResultList) address,container);

container.getTrace().addWarning ("address is empty? " + (address.isEmpty()? " true": " false"));

String[] finalDestination = null;

if (address != null) {

container.getTrace().addWarning ("address is not null");

  finalDestination = (String[]) address.get();

}

address.clear();

However, we get a null pointer exception when there is any data.  It seems the "get" is not returning a String[] or Object[] but just an Object.  Is there a way to parse the records in the ResultList returned?

I have reviewed and tried the example shown in this thread, but it doesn't work either:

Accepted Solutions (1)

Accepted Solutions (1)

engswee
Active Contributor
0 Kudos

Hi Brian

In order to parse the content in the ResultList, you need to iterate through it using the get() method one at a time, and then use pop() to move to the next value. ResultList can accept different content, so not necessarily everything is stored as String.

Refer below an example of one UDF calling another and the result.

First UDF which stores two values, one String and one integer.

Second UDF calls first UDF, then iterate through the ResultList

Output when second UDF is used in mapping.

Hope this helps.

Regards

Eng Swee

Former Member
0 Kudos

I was thinking about the pop/get routines last night but I wasn't sure about the isEmpty and how it worked.

Thanks!  This code is exactly what I needed.

Answers (0)