Announcement:
wanna exchange links? contact me at sapchatroom@gmail.com.
Posted by
Admin at
Reply from pietro_cantoni on Aug 3 at 10:03 AM The strangest part of this story is that I've used exactly the same code to download data from AFVC table and I can access AFVV table through SE16 transaction viewing all the table contents.
| | | ---------------Original Message--------------- From: pietro_cantoni Sent: Friday, August 03, 2012 9:13 AM Subject: RFC Call VBA Excel AFVV Table Problems Hi to Everyone. I'm trying to download to Excel some data from AFVV table usign RFC via VBA. Hereafter my code. Can you help me to catch the possible issues within my code? Thanks in advance Dim LogonControl Dim conn Dim funcControl Dim TableFactoryCtrl Dim RFC_READ_TABLE Dim eQUERY_TAB Dim TOPTIONS Dim TDATA Dim TFIELDS Private Sub command1_CLICK() Set LogonControl = CreateObject("SAP.LogonControl.1") Set funcControl = CreateObject("SAP.Functions") Set conn = LogonControl.NewConnection conn.System = "010" conn.Client = "02 - PAP - [R/3 PRODUCTION SYSTEM] - HP" conn.Language = "IT" conn.User = "user" conn.Password = "pwd" retcd = conn.LOGON(0, False) If retcd <> True Then MsgBox " Cannot log on! " MsgBox retcd Stop Else End If funcControl.Connection = conn command3_click End Sub Private Sub command3_click() Const attachpath = "C:\Query.CSV" Set objFileSystemObject = CreateObject("Scripting.FileSystemObject" ;) Set filOutput = objFileSystemObject.CreateTextFile(attachpath, True) Set RFC_READ_TABLE = funcControl.Add("RFC_READ_TABLE") Set strExport1 = RFC_READ_TABLE.Exports("QUERY_TABLE") Set strExport2 = RFC_READ_TABLE.Exports("DELIMITER") Set tbloptions = RFC_READ_TABLE.Tables("OPTIONS") Set tblData = RFC_READ_TABLE.Tables("DATA") Set tblFields = RFC_READ_TABLE.Tables("FIELDS") strExport1.Value = "AFVV" strExport2.Value = "," tbloptions.Rows.Add tbloptions.Value(1, "TEXT") = "AUFPL EQ '0000168029'" tblFields.AppendRow tblFields(1, "FIELDNAME") = "AUFPL" If RFC_READ_TABLE.Call = True Then If tblData.RowCount > 0 Then For intRow = 1 To tblData.RowCount filOutput.WriteLine tblData(intRow, "WA") Next Else MsgBox "No records returned" End If Else MsgBox "ERROR CALLING SAP REMOTE FUNCTION CALL" End If End Sub | | Reply to this email to post your response. __.____._ | _.____.__ |