Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Help with RFC_Read_Table

Former Member
0 Kudos

Hi, I'm ussing a similar script like this, but I want to know how can I use the same connection to others Querys

Public Sub RFC_Read_Table()

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 filOutput

Dim intRow As Integer

Set Functions = CreateObject("SAP.Functions")

Functions.Connection.System = "PDS"

Functions.Connection.client = "240"

Functions.Connection.user = "S0110028"

Functions.Connection.Password = "0603cacc"

Functions.Connection.Language = "EN"

If Functions.Connection.Logon(0, False) <> 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 = "LFBK"

strExport2.Value = ";"

tblOptions.AppendRow

tblOptions(1, "TEXT") = "LIFNR EQ '41'" ' Suppose I want to bank data from vendor number 41.

tblFields.AppendRow

tblFields(1, "FIELDNAME") = "LIFNR"

tblFields.AppendRow

tblFields(2, "FIELDNAME") = "BANKS"

tblFields.AppendRow

tblFields(3, "FIELDNAME") = "BANKL"

tblFields.AppendRow

tblFields(4, "FIELDNAME") = "BANKN"

tblFields.AppendRow

tblFields(5, "FIELDNAME") = "BUTYP"

If RfcCallTransaction.Call = True Then

If tblData.RowCount > 0 Then

Dim DatTxt, OutputTxt As String

OutputTxt = "Vendor, Bank Country, Bank Key, Book No., Run No."

DatTxt = "c:\bankdata.txt"

Open DatTxt For Output As #1

Print #1, OutputTxt

For intRow = 1 To tblData.RowCount

OutputTxt = tblData(intRow, "WA")

Print #1, OutputTxt

Next

Close #1

Else

MsgBox "No records returned"

End If

Else

MsgBox "Error"

End If

Set filOutput = Nothing

Functions.Connection.Logoff

End Sub

I don't know if there's something like Functions.Connection.Back or Functions.Connection.exit

1 REPLY 1

Jean_Sagi
Participant
0 Kudos

The same connection to other querys? I dont't know what you mean...

Are you asking how to use the procedure to get information from other tables?

BTW : SAP recommends to not use RFC_READ_TABLE, because it has some serious limitations, but for simple querys it works fine.

J.