cancel
Showing results for 
Search instead for 
Did you mean: 

Compare two different lengths of queues

Former Member
0 Kudos

Hello All,

Please help to advice on my below query

I'm trying to compare two queues which will have different lengths, I tried to use the "Compare" function but it didn't work.

my Queue A has following Values
4535001

7835334

3439034

8043043

Queue B has the following

7835334

3439034

8043043

Queue A will always have all the values in "B" but "A" will have more no.of values (Both A and B are removed with contexts)

my result should occur in such a way that, so that it should produce 1supress/null + 3 nodes as below.

<null>/Suppress

7835334

3439034

8043043

I tried to compare and result the value but it is only displaying the existing but not the missing once.

can you guys help to provide a UDF.?

ThankYou

George.

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hello George,

You can use this UDF:

Arguments: inpA

inpB

for(int a=0;a<inpA.length;a++){

     int cnt = 0;

     for(int b=0;b<inpB.length;b++){

          if(inpA[a].equals(inpB[b])){

               result.addValue(inpA[a]);

          cnt = 1;

          break;

          }

     }

     if(cnt ==0){

          result.addSuppress();

     }

}

Result:

Hope this helps,

Mark

Answers (1)

Answers (1)

anupam_ghosh2
Active Contributor
0 Kudos

Hi George,

                     I am making little change to Mark's code above as it is checking for matching values only for once. Thus if queue B contains multiple matching values of same value as that of queue A then below UDF takes care of the situation. For example

my Queue A has following Values
4535001

7835334

3439034

8043043

1234567

Queue B has the following

7835334

3439034

8043043

8043043

Result

SUPRESS

7835334

3439034

8043043

8043043

SUPRESS

In case this situation arise then the UDF should be like this

for(int a=0;a<inpA.length;a++){ 

         int cnt = 0; 

         for(int b=0;b<inpB.length;b++){ 

                     if(inpA[a].equals(inpB[b])){ 

                          result.addValue(inpA[a]); 

                          cnt = 1; 

              } 

         } 

         if(cnt ==0){ 

                result.addSuppress(); 

         } 

    } 

Regards

Anupam

Former Member
0 Kudos

Hi Mark and Anupam,

Thank you both for your help, it solved my issue.

George