SAP Search with multiple records

bconforto

New Member
Joined
Nov 17, 2016
Messages
30
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:
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
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
I found a way to do it, but I discovered that variable length for the query in SAP is 72 characters, so I could concatenate two records but it will not work with more records.

Regards,
Brian
 
Upvote 0

Forum statistics

Threads
1,215,220
Messages
6,123,693
Members
449,117
Latest member
Aaagu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top