We have added search box. Key in SAP issue keyword to search
TopBottom

Announcement: wanna exchange links? contact me at sapchatroom@gmail.com.

RE:[sap-dev] RFC Call VBA Excel AFVV Table Problems

Posted by Admin at
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

Reply from sapwes on Aug 3 at 9:52 AM
The only thing I see as odd is how you are adding the row to the options table. I've never used the method rows.add, not saying that is what is wrong, just I've never seen it before. Try using appendrow like you do for fields.

Looks like you are on the right path to debug. I usually do the same to find my errors in setting up the inputs to RFC_READ_TABLE.

wes

---------------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.
 
__.____._
Manage Settings | Unsubscribe | Create FAQ | Send Feedback
  
Copyright © 2012 Toolbox.com and message author.
Toolbox.com 4343 N. Scottsdale Road Suite 280, Scottsdale, AZ 85251
sapwes  
Jack
achievements
 
Mark as helpful
View this online
Ask a new question
 
In the Spotlight
Become a blogger at Toolbox.com and share your expertise with the community. Start today.

_.____.__

0 comments:

Post a Comment

T r a n s l a t e to your language