RFC_READ_TABLE where IN - VBA
I'm using RFC_READ_TABLE transaction to parse some data from a table in SAP.
The problem is that I want to get the data for more than one order therefore I use the IN in the query as bellow:
tbloptions(1, "TEXT") = Chr(34) & "WERKS EQ '0012' AND AUFNR IN" & "(" & ordCollector & ")" & Chr(34)
ordCollector is a string variable where I add the order numbers respecting the syntax.
Dim Rand As Long
Dim LRand As Long
LRand = ws.Cells(Rows.Count, 1).End(xlUp).Row
Rand = 2
If LRand = 2 Then
ordCollector = "'" & ws.Cells(Rand, 1).Value & "'"
Do While ws.Cells(Rand, 1).Value <> "" And Rand < LRand
ordCollector = ordCollector + "'" & ws.Cells(Rand, 1).Value & "', "
Rand = Rand + 1
ordCollector = ordCollector + "'" & ws.Cells(Rand, 1).Value & "'"
with these two pieces of code I wanted to have something like:
tbloptions(1, "TEXT") = "WERKS EQ '0012' AND AUFNR IN ('1234567', '8910111', '2131415')"
I don't know if it' something wrong with the syntax I'm using (if I use chr(24) the workbook stops responding and if I'm not the RFC_READ_TABLE gives me an error.
Any ideas? If you want more details please ask.