'
' some more stuff
'
Option Explicit
Const ForReading = 1, ForWriting = 2
'--main r3 object
Dim ObjR3
'--parameter to abap object
Dim ObjPrm1
Dim ObjPrm2
Dim ObjPrm3
Dim ObjPrm4
Dim ObjPrm5
Dim ObjPrm6
Dim ObjPrm7
Dim ObjPrm8
Dim ObjPrm9
Dim ObjPrm10
Dim ObjPrm11
Dim ObjPrm12
'--parameter from abap (return) object
Dim ObjParmin
'--abap function to use object
Dim ObjR3Func
'--return code for abap call
Dim result
'--abap table returned object
Dim Objudextab
Dim Strout, intidx
logon_to_sap
read_data
strout = ""
Do
intidx = intidx + 1
on error resume next
if ObjUdextab(intidx, 1) = "" then
exit do
end if
'-----gav whatever U want goes ere
strout = strout & ObjUdextab(intidx, 1) & _
" - " & _
ObjUdextab(intidx, 2) & _
" - " & _
ObjUdextab(intidx, 3) & _
vbcrlf
Loop
on error goto 0
set Objudextab = nothing
Wscript.Echo strout
sub read_data
'--address the set abap function
Set ObjR3Func = ObjR3.Add("BAPI_COSTCENTER_GETLIST")
'--and the paramters we will send
Set ObjPrm1 = ObjR3Func.exports("CONTROLLINGAREA")
Set ObjPrm2 = ObjR3Func.exports("CONTROLLINGAREA_TO")
Set ObjPrm3 = ObjR3Func.exports("COMPANYCODE")
Set ObjPrm4 = ObjR3Func.exports("COMPANYCODE_TO")
Set ObjPrm5 = ObjR3Func.exports("COSTCENTER")
Set ObjPrm6 = ObjR3Func.exports("COSTCENTER_TO")
Set ObjPrm7 = ObjR3Func.exports("PERSON_IN_CHARGE")
Set ObjPrm8 = ObjR3Func.exports("PERSON_IN_CHARGE_TO")
Set ObjPrm9 = ObjR3Func.exports("DATE")
Set ObjPrm10 = ObjR3Func.exports("DATE_TO")
Set ObjPrm11 = ObjR3Func.exports("COSTCENTERGROUP")
'--and values
ObjPrm1.Value = "GB01"
'--do it
result = ObjR3Func.call
'--if ok then process - else exit
If result = False Then
'-----if it was stuffed the exit
Wscript.Echo "Error reading sap - " & ObjR3.connection.User & " - " & ObjR3.connection.System
ObjR3.connection.LOGOFF
WScript.Quit
else
Set ObjUdextab = ObjR3Func.Tables("COSTCENTER_LIST")
End If
'--drop objects
Set ObjR3Func = Nothing
Set ObjPrm1 = Nothing
Set ObjPrm2 = Nothing
Set ObjPrm3 = Nothing
Set ObjPrm4 = Nothing
Set ObjPrm5 = Nothing
Set ObjPrm6 = Nothing
Set ObjPrm7 = Nothing
Set ObjPrm8 = Nothing
Set ObjPrm9 = Nothing
Set ObjPrm10 = Nothing
Set ObjPrm11 = Nothing
end sub
sub logon_to_sap
Set ObjR3 = CreateObject("SAP.Functions")
'--get this info from your logon pad..
ObjR3.connection.System = "Kxx"
ObjR3.connection.Client = "172"
ObjR3.connection.User = "myid"
ObjR3.connection.Password = "mypassword*"
ObjR3.connection.Language = "EN"
ObjR3.connection.ApplicationServer = "appservernamehere"
ObjR3.connection.SystemNumber = "61"
'--if no logon then exit
If ObjR3.connection.logon(0, True) <> True Then
Wscript.Echo "Sap connection error - " & ObjR3.connection.User & " - " & ObjR3.connection.System
WScript.Quit
End If
end sub