Hello guys,
I am using below code to make a RFC to SAP and find specific data from tables, but always passing ONLY one value at the time.
I would like to see if it could be faster to make one call for multiple values at the time, but I am having problem in how to write it.
Technically it is a call to table V_EQUI passing Serial Number(SERNR) and retriving Equipment number (EQUNR).
For one record it works fine like this:
So I tried with two records in this way:
This is not working as it is passing only the first record.
I will have a dynamic list of values to pass, but may be if I can solve it for two values, I could extend it to be dynamically.
Regards,
Brian
I am using below code to make a RFC to SAP and find specific data from tables, but always passing ONLY one value at the time.
I would like to see if it could be faster to make one call for multiple values at the time, but I am having problem in how to write it.
Technically it is a call to table V_EQUI passing Serial Number(SERNR) and retriving Equipment number (EQUNR).
For one record it works fine like this:
Rich (BB code):
tblOptions(1, "TEXT") = "SERNR EQ 'F1353276' "
So I tried with two records in this way:
Rich (BB code):
tblOptions(1, "TEXT") = "SERNR EQ 'F1353276' or SERNR EQ '3510022122' "
This is not working as it is passing only the first record.
I will have a dynamic list of values to pass, but may be if I can solve it for two values, I could extend it to be dynamically.
Regards,
Brian
Rich (BB code):
'RFC to get Replacement order
Dim Functions As Object
Dim RfcCallTransaction As Object
Dim Messages As Object
Dim BdcTable As Object
Dim tblOptions
Dim tblData
Dim tblFields
Dim strExport1
Dim strExport2
Dim intRow As Integer
Dim conn As Object
Dim sap As Object
'sorg = Sheets("Sheet1").Cells(2, 1).Value
'StartTime = Timer
user = Sheet3.Cells(1, 2)
pass = Sheet3.Cells(2, 2)
syst = Sheet3.Cells(3, 2)
Set Functions = CreateObject("SAP.Functions")
Functions.Connection.System = syst
Functions.Connection.client = "010"
Functions.Connection.user = user
Functions.Connection.Password = pass
Functions.Connection.Language = "EN"
If Functions.Connection.logon(0, True) <> True Then
Exit Sub
End If
Set RfcCallTransaction = Functions.Add("RFC_READ_TABLE")
Set strExport1 = RfcCallTransaction.exports("QUERY_TABLE")
Set strExport2 = RfcCallTransaction.exports("DELIMITER")
Set tblOptions = RfcCallTransaction.Tables("OPTIONS")
Set tblData = RfcCallTransaction.Tables("DATA")
Set tblFields = RfcCallTransaction.Tables("FIELDS")
strExport1.Value = "V_EQUI"
strExport2.Value = ";"
tblOptions.AppendRow
'tblOptions(1, "TEXT") = "SERNR EQ'" & returnorder & "' and VBTYP_N EQ 'I' "
'tblOptions(1, "TEXT") = "SERNR EQ '" & returnorder & "' "
tblOptions(1, "TEXT") = "SERNR EQ 'F1353276' " & " and SERNR EQ '3510022122' "
tblOptions.AppendRow
tblFields.AppendRow
tblFields(1, "FIELDNAME") = "EQUNR"
If RfcCallTransaction.Call = True Then
If tblData.RowCount > 0 Then
For intRow = 1 To tblData.RowCount
Equip = tblData(intRow, "WA")
Next
Else
'MsgBox "No records returned"
Application.StatusBar = "Waiting: " & a
End If
Else
MsgBox "Error"
End If
Functions.Connection.Logoff