Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3353

Extract data from SAP using VBScript

$
0
0

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


Viewing all articles
Browse latest Browse all 3353