on 05-21-2012 7:16 PM
Hi,
I am trying to extract data out of SAP using VBScript. I remember this worked earlier, but ever since we upgraded to VB7, I am getting an error. Can you please look into this?
code:
Dim R3, MyFunc, App, objFileSystemObject, filOutput, objmessage As Object
Dim nTotalRecords As Long
' Define the objects to hold IMPORT parameters
Dim QUERY_TABLE As Object
Dim DELIMITER As Object
Dim NO_DATA As Object
Dim ROWSKIPS As Object
Dim ROWCOUNT As Object
' Define the objects to hold the EXPORT parameters
' None for RFC_TABLE_READ
' Define the objects to hold the TABLES parameters
' Where clause
Dim OPTIONS As Object
' Fill with fields to return. After function call will hold
' detailed information about the columns of data (start position
' of each field, length, etc.
Dim FIELDS As Object
' Holds the data returned by the function
Dim tDATA As Object
' Use to write out results
Dim ROW As Object
Dim Result As Boolean
Dim iRow, iColumn, iStart, iStartRow, iField, iLength As Integer
Dim var_return As String
Public Function RFC_READ_TABLE_MARA()
'**********************************************
'Create Server object and Setup the connection
'**********************************************
Set objFileSystemObject = CreateObject("Scripting.FileSystemObject"
attachpath1 = "C:\Extracts\MARA.rtf"
Set R3 = CreateObject("SAP.Functions")
R3.Connection.system = "xxx"
R3.Connection.SystemNumber = "xxx"
R3.Connection.client = "xxx"
R3.Connection.User = "xxx"
R3.Connection.Password = "XXX"
R3.Connection.language = "EN"
R3.Connection.applicationserver = "XXX"
If R3.Connection.logon(0, True) <> True Then
MsgBox "No connection to R3!"
var_return = " has Failed"
sendmessage (var_return)
Exit Function
End If
'*****************************************************
'Call RFC function RFC_READ_TABLE
'*****************************************************
Set MyFunc = R3.Add("RFC_READ_TABLE")
ERROR RECEIVED IS:
Run-time error '-2147352568'
Bad variant type
Thank you
Hi Sheetal,
Good evening. I am not sure if you have succeeded in extracting the data or gave up.
The key thing is on the code above:
If you have a VBscript with the code - that is standalone - then you cannot define the variables
as follows:
Dim R3Logon As object
Dim MyFunc As object
which should be just:
Dim R3
Dim MyFunc
then when you actually want to instantiate them as objects then:
Set MyFunc = CreateObject("SAP.Functions")
Set R3Logon = CreateObject("SAP.LogonControl.1")
etc.
Check out my video - where i have extracted the SAP table headers and SAP table data
and also bypassed the limit of 512 byte, which exist in the RFC function.
Let me know if you need any help?
Thanks
Ram.S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi sheetal,
First of all: your Declarations right at the Beginning:
Example:
Dim R3, MyFunc, App, objFileSystemObject, filOutput, objmessage As Object
This only "Dims" objmessage as an object not the other ones:
better like that:
Dim R3 as Object
Dim Myfunc as Object
Dim App as Object
'and so on ...
and so on ...
But General- on which line does the Error appear ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.