First let me apologize for my lack of knowledge .. you SAP folks gota have IQ's off the chart ..
in any case .. our firm is migrating to SAP .. I've been asked to investigate the creation of tools to input data that are familiar to the majority of our users eg. Excel.
I've attempted to create a macro that creates and populates a table without success. see code below .. my issue currently is that though I see the table initiated in my IDE, I can't seem to pass actual data, and I don't see the table created in the SAP environment. Though I would surely appreciate any fixes to the code offered, what I would truely appreciate is a resource to better educate me about SAP, RFC's ... ie a SAP for dummies ....
Private Declare Sub CoFreeUnusedLibraries Lib "OLE32.DLL" () ' Cleaning up memory.
Const SapSystem = "NSP"
Const SapSystemNumber = "00"
Const SapApplicationServer = "questserver"
Const SapClientNumber = "00"
Const SapUserName = "BCUSER"
Const SapUserPassword = "minisap"
Const SapLanguage = "EN"
Public sapConn As Object
Public SapFuncCall As Object
Public TableFactoryCtrl As Object
Public OurTable As Object
Public RetVal As Boolean
Public myData() As Variant
If RetVal = False Then GoTo Bye
Set sapConn = CreateObject("SAP.Functions")
sapConn.Connection.System = SapSystem
sapConn.Connection.SystemNumber = SapSystemNumber
sapConn.Connection.ApplicationServer = SapApplicationServer
sapConn.Connection.client = SapClientNumber
sapConn.Connection.user = SapUserName
sapConn.Connection.Password = SapUserPassword
sapConn.Connection.Language = SapLanguage
sapConn.logfilename = "LTSlog.txt"
sapConn.loglevel = 0
RetVal = sapConn.Connection.Logon(0, True)
If RetVal <> True Then
MsgBox ("Logon Failed, program will now exit")
MsgBox ("Logged on to " & SapApplicationServer & "/" & SapSystem & " as " & SapUserName)
Set SapFuncCall = CreateObject("SAP.Functions")
Set TableFactoryCtrl = CreateObject("SAP.TableFactory.1")
SapFuncCall.Connection = sapConn.Connection
Set LTSTable = TableFactoryCtrl.NewTable
Call LTSTable.Create("LTSTests", 100)
Set myRange = ActiveSheet.UsedRange
myRows = myRange.Rows.Count
myColumn = myRange.Columns.Count
For x = 1 To myColumn
LTSTable.Columns.Item(x).Name = myRange.Cells(1, x)
For y = 2 To myRows
Set Row = LTSTable.Rows.Add
For z = 1 To myColumn
myData(z) = myRange.Cells(y, z)
Row.Data = myData