1 Reply Latest reply on May 4, 2013 8:21 PM by kiransaravi

    Is there a simple way of finding duplicates in Arrays in BPEL


      Hope you are doing fine.
      I'm working with arrays in BPEL and my case is to find duplicates between 2 arrays(of same type) coming from 2 services and to prepare a list with unique values from both

      I could get the result, but this seems too much code, Just wanted to find out if there is any straight forward way...just like .contains() in Java :)

      Here is the procedure I followed

      Var1 from Service1 - lets say size = len1, RowCounter = i
      Var2 from Service2 - size = len2, RowCounter = j
      Var3 - The final list
      isExistingRec boolean var used to skip if found as duplicate
      int k - dummy counter used to chk if new record

      Note that all are of same types

      while(i <= len1)
      while(j < len2 & ExistingRec = false())
                //WhileLoop for Var2 Start
                          condition : if Var1[i] = Var2[j]
                               isExistingRec = true() // so Next time, this loop wont happen due to the condition in while
                          otherwise :
                //WhileLoop for Var2 End

                condition : if k=j //which means that k is same as size of Var2, i.e. it did not match any of Var2 values
                     append this to Var3
                otherwise :
      //WhileLoop for Var1 End

      Just want to know if there is any straight forward way to find duplicates - coding a while loop with xml Arrays is too hectic