on 08-07-2007 5:11 PM
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
Sub Main()
SapLogon
If RetVal = False Then GoTo Bye
SapBuildObjs
SapCreateTable
SapLogOff
Bye: CleanUp
End Sub
Sub SapLogon()
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")
Exit Sub
Else
MsgBox ("Logged on to " & SapApplicationServer & "/" & SapSystem & " as " & SapUserName)
End If
End Sub
Sub SapBuildObjs()
Set SapFuncCall = CreateObject("SAP.Functions")
Set TableFactoryCtrl = CreateObject("SAP.TableFactory.1")
SapFuncCall.Connection = sapConn.Connection
End Sub
Sub SapCreateTable()
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.Add
LTSTable.Columns.Item(x).Name = myRange.Cells(1, x)
Next x
ReDim myData(myColumn)
For y = 2 To myRows
Set Row = LTSTable.Rows.Add
For z = 1 To myColumn
myData(z) = myRange.Cells(y, z)
Next z
Row.Data = myData
Next y
LTSTable.Refresh
End Sub
Sub SapLogOff()
sapConn.Connection.Logoff
End Sub
Hi David,
Read these. Very helpful articles-
/people/kathirvel.balakrishnan2/blog/2006/05/08/data-upload-into-sap-from-microsoft-excel-150-abap-part
/people/kathirvel.balakrishnan2/blog/2006/05/09/data-upload-into-sap-from-microsoft-excel-150-vba-part
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndcom/html/sapintegration.asp
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
THANKS Jitesh
Not seen that blog as of yet ..
So if I understand this method correctly .. I must first write a RFC to call .. and
this RFC creates the table structure. Is this the only method ? I had hoped to create a utility a bit more dynamic at the client end as Excel column count/headings and created table name etc will be different for users dependant upon their content. Hate to have to write a unique RFC for each.
If I were to follow this course ..
How do I migrate the RFC from my developmental platform to the actual SAP system ? I'm on a network isolated from the SAP box.
THANKS Again
Hi David,
If I understood the requirement correctly then you do not need to create RFCs for each user.
You need to develope only one RFC. You pass the information of the table structure etc through the parameters to the RFC. And write the logic to create table is inside the RFC.
Regarding your second question- You either would have to use transport system provided by SAP (in this case the source and target system has to be part of same system landscape) or you can do the system copy.
If some system admin is watching this thread, please validate second part of my answer (above)
Regards.
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.