Hi Guys!
I've looking a long time on the web, i would like some direction on this,
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:
I need to place several numbers on the list, when i type more than 2 number on:
tblOptions.AppendRow
tblOptions(1, "TEXT") = "MATNR IN ('000002840779902100','000009242000074000')"
, it fires an error "system failure".
I need to pull out about 1k data numbers and i wrote a piece of code to add several numbers in a string variable:
Im using MARD table
Dim material as String
Dim eljuntos as String
dim myMaterialNumber(10000) as String
i = 1
j = 0
Do While Worksheets("Sheet1").Range("M2").Cells(i, 1) <> ""
material = Worksheets("Sheet1").Range("M2").Cells(i, 1)
j = j + 1
If Len(material) = 10 Then
myMaterialNumber(j) = "00000000" & Replace(material, "-", "") 'this sets the variable to 18 characters that is the required for the MATNR field
Else
myMaterialNumber(j) = "00000" & Replace(material, "-", "") 'this sets the variable to 18 characters that is the required for the MATNR field
End If
'This is because we have Part Numbers with length of 10 and 13 characters
If j = 1 Then
eljuntos = "'" & myMaterialNumber(j)
Else
eljuntos = eljuntos & "','" & myMaterialNumber(j)
End If
i = i + 1
Loop
eljuntos = eljuntos & "'"
But when i try to use the sentence IN(, it appears a "system failure error", and doing it one by one takes too long.
objOptTab.Rows.Add
objOptTab(objOptTab.RowCount, "TEXT") = "MATNR IN (" & eljuntos & ") and "
objOptTab.Rows.Add
objOptTab(objOptTab.RowCount, "TEXT") = "WERKS EQ '7034'"
'This passes with no error,
'But when the function is called:
If objRfcFunc.call = False Then
MsgBox objRfcFunc.Exception
End If
also tried:
tbloptions(1, "TEXT") = "WERKS EQ '7034' AND MATNR IN (" & ordCollector & ")"
It fires a "System Failure" Error.
I've found that the sentence OR could be helpful but i haven't found how this sentece works.
Please help Gurus!
Many thanks in advance!