cancel
Showing results for 
Search instead for 
Did you mean: 

UDF has 2 different results with the same input

Former Member
0 Kudos

Hello,

I have two mappings of the ORDERS idoc. In both mappings I use the following UDF function to create a long string output:



public void matConfig(String[] CHAR, String[] CHARTXT, String[] VALUE, String[] VALUETXT, String[] POSEX, String[] LINE, ResultList result, Container container) throws StreamTransformationException{

int i, j;
String crlf = "\r\n";
StringBuffer matConfig;

j = 0;
for (i = 0; i < POSEX.length; i++) {
  matConfig = new StringBuffer();
  while (LINE.length > j && Integer.parseInt(POSEX<i>) == Integer.parseInt(LINE[j])) {
    if (matConfig.length() > 0)
      matConfig.append(crlf);
    if ((CHARTXT[j].length() > 0) || (CHAR[j].length() > 0)) {
      if (CHARTXT[j].length() > 0)
        matConfig.append(CHARTXT[j]);
      else
        matConfig.append(CHAR[j]);
      matConfig.append(" : ");
      if (VALUETXT<i>.length() > 0)
        matConfig.append(VALUETXT[j]);
      else
        matConfig.append(VALUE[j]);
      }
      j++;         
  }
  result.addValue(matConfig.toString());      
  result.addContextChange();
}

I have checked the queues of all the inbound fields and the values match exactly but in one mapping the output in the queue for this UDF looks like this:

Correct Result:

Thickness of Glass: 20 Height: 10 Width: 5 Length: 18

Thickness of Glass: 10 Height: 15 Width: 8 Length: 14

Bad Result:

Thickness of Glass: 20

Width: 5

How can the same input using the same java code (cut and pasted to make sure it matched) return 2 different values. I have verified that they both use the same Imports as well. The bad one is part of a function library while the good one is a local function.

Any ideas?

Thanks,

Matt

Edited by: Matthew Herbert on May 29, 2010 12:09 AM

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

Just the code of the UDF can give no solution but wild guessing.

So my first guess: You have 6 input fields, which makes it hard to assign a source to the UDF.

Maybe you did not assign the source fields correctly to the UDF.

Answers (3)

Answers (3)

Former Member
0 Kudos

Stefan - Thank you for the responses. It was probably not <null> but empty fields (< >). Also, I believe the counter using i and j is correct.

Rather than continue to try to solve this problem, I gave up and built the mapping the way I had been intending to. So this function was no longer needed.

Thanks,

Matt

stefan_grube
Active Contributor
0 Kudos
       if (VALUETXT<i>.length() > 0)
        matConfig.append(VALUETXT[j]);

here you check for counter i but in next line you use counter j

Is this correct?

Former Member
0 Kudos

You make a good point Stefan but unfortunately I already checked that. I have even copied the mapping (right click copy) and pasted it from the working Mapping to the bad Map (Paste) to make sure the context values were all the same.

I also opened all the queues and compared the values in each. All values match exactly except for the result(out) queue.

In both tests I am using the same IDOC XML file.

These are the only differences I see.

1. The IDOC is exactly the same as far as I can tell but they come from two different source SWCV. SAP APPL 4.7 and Steelcase_Procurement (ECC 6.0).

2. The working map uses a local UDF. The bad map calls the UDF from a Function Group. Is there a Java version difference between the two?

A better sample of the result queues look like this:

Correct Result:

Thickness of Glass: 20

Height: 10

Width: 5

Length: 18

Thickness of Glass: 10

Height: 15

Width: 8

Length: 14

Bad Result:

Thickness of Glass: 20

<null>

<null>

<null>

Width: 5

<null>

<null>

<null>

I took this chance to redesign my Variant Config output to separate the characteristics/values, but I'm still bothered that I was unable to determine what would cause the differing values.

Any ideas?

Thanks,

Matt

Former Member
0 Kudos

> I have even copied the mapping (right click copy) and pasted it from the working Mapping to the bad Map (Paste) to make sure the context values were all the same.

If my assumption is correct then here you have made the mistake.

The thing is, you have two different mappings and you have copied the mapping and pasted in other mapping. So in your bad mapping under mapping editor double click on the source fields and see if the cursor goes to the corresponding source in the mapping structure. If it doesn't go then your mapping is not correct (even though it looks ok).

So do the re-mapping of source fields again without copying from other mapping.

stefan_grube
Active Contributor
0 Kudos

> Any ideas?

A lot

Guess no. 2:

The type if the UDF is different.

Are you really having "null" in the output?

null cannot happen in a UDF.

Have you activated the function group with the global UDF?