cancel
Showing results for 
Search instead for 
Did you mean: 

Zeilenindex in Sammlungen finden

MariettaChristo
Level 3
Hallo zusammen,

aktuell habe ich die Aufgabe einen Datenabgleich über BluePrism zu machen.

Hierfür habe ich zwei Excellisten. Die erste Liste (Liste 1) ist ein Datenabzug aus dem Bestandssystem mit 3 Spalten und 500 Zeilen. Diese Liste ändert sich eher selten. Die zweite Liste bekommen wir täglich von einem Dienstleister geliefert und enthält Kundendaten (Liste 2).

Im ersten Schritt soll geschaut werden, ob die PLZ des Kunden (Liste 2) in Liste 1 (Spalte A) enthalten ist. Ergibt das einen Treffer, dann soll aus dieser Zeile die beiden anderen Werte (Spalte B und C) zurückgegeben werden.

Bisher habe ich die Liste 1 in eine Sammlung eingelesen und den ersten Schritt mit der Funktion "Utility - Collection Manipulation" -> "Collection Contains Value" abgebildet. Jetzt komme ich aber an dieser Stelle nicht weiter und habe keine Ahnung wie ich mir den Zeilenindex aus der Sammlung zurückgeben lassen kann um dann die beiden anderen Werte zu erhalten.

Hat einer von euch eine Lösung bzw. bin ich vielleicht falsch ran gegangen und käme mit einen direkten Excel auslesen besser?

Vielen Dank im Voraus und Grüße
Marietta

------------------------------
Marietta Christoph
Sachbearbeiterin
LM
Europe/Dresden
------------------------------
3 REPLIES 3

Hi 
There are a couple of options here to do this, if you want to use a collection to just return the other 2 column values if the post code value exists then you can do this using a loop. Continue using the action Utility - Collection Manipulation -> Collection Contains Value to determine the post code already exists if it doesn't then mark it as an exception or whatever you need to do there. If the value does exist the do a loop through the collection using a decision to determine when you have found the value in the collection InStr([Collection.Postcode], [Postcode])>0 when the decision is true then you just need to get the values from the current row and you can do that with a calculation stage to 2 data items for the calulcation you just need to set the collection and column and set the data item to be saved to e.g. [Collection.SecondColumn] or [Collection.ThirdColumn]. 

5355.png
The other option is to use excel to find the value then find the corresponding cell values but for this you will need to create a code stage to find the address of the postcode value and then a calculation stage to modify the cell address to include the column e.g. "B"&Mid([CellAddress],2,10000). I've included the code for this type of search below if you wanted to use it. Hope this helps 🙂
Dim wb, ws As Object 
Dim excel, sheet, range As Object 
Dim startcell as Object
Dim newCell as object
Dim xlformulas as integer = -4123
Dim xlRows as Integer = 1
Dim xlNext as Integer = 1
Dim xlPart as Integer = 2
Try 
wb = GetWorkbook(Handle, Workbook) 
ws = GetWorksheet(Handle, Workbook, Worksheet)
 
wb.Activate() 
ws.Activate() 
Excel = WS. Application
Sheet = Excel. ActiveSheet.Range(StartingCell). Activate()
startcell = Excel. ActiveCell
 
Ws. Cells.Find(What:=SearchText, After:=startcell, LookIn:=xlformulas, _
        LookAt:=xlPart, SearchOrder:=xlRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False). Activate()
newCell = excel. ActiveCell
        Success = True 
Result = newCell.Address(False,False)
Catch e As Exception  
Success = False  
Message = e.Message 
Finally  
wb = Nothing  
ws = Nothing  
excel = Nothing  
sheet = Nothing  
range = Nothing 
End Try



------------------------------
Michael ONeil
Technical Lead developer
NTTData
Europe/London
------------------------------

Hi, 

vielen, vielen lieben Dank für die schnelle Antwort! Es hat sehr geholfen. Jetzt hat es funktioniert und ich kann den Rest fertig machen. Wieder was neues gelernt. 😉

------------------------------
Marietta Christoph
Sachbearbeiterin
LM
Europe/Dresden
------------------------------

johan.m
Level 4
Hallo Marietta,

Ich benutze gerne Sammelungen

Wenn du einfach "Utility - Collection Manipulation::Filter Collection" benutzt bekommst du eine neue Sammelung mit 

0 Zeilen  = Wert nicht gefunden
1 Zeile = Wert gefunden und du kannst mit ein "Loop" einfach an die Werten kommen
>1 Zeile = Mehr als 1 Resultat ==> Exception ?

Dein "Filter" sieht ungefahr so aus : "[Liste1.SpalteA] = '"&  [PLZ des Kunden (Liste 2)]  &"' "

Eine andere Lösung :
* Utility - Collection Manipulation::Get Row Number
* Utility - Collection Manipulation::Get Value by RowNumber and ColumnName - 0 Based 

Utility - Collection Manipulation::Get Value by RowNumber and ColumnName - 0 Based ==> hat Restrictionen !!

------------------------------
Johan Michiels
------------------------------