-
VBA Excel and SAP
Hi,
I have a sample VBA code for a connction to Sap usin a macro Excel.
I find this kind of VB Object:
Dim objTable As Object ' Sap Table retrieved
I wish to know more exackty about this object for retrieving field information and filling Excel cells or List Box.
Any help will be well appreciated.
Thanks in advance
-
Re: VBA Excel and SAP
Welcome to the Forums.
Dim objTable As Object is an example of Late Binding. What it does it decalre a variable as a generic Object.
Then when the code tries to CreateObject as a particular type the system determines if the type is available on
the system. What type of program is SAP? And could you post more code to see if someone could be able
to determine it?
-
Re: VBA Excel and SAP
Hi RobDog888,
and thanks for the reply!
I need to write a macro Excel for receiving info from a SAP Table.
I have this example but I need explanation about the object Table.
More exactly I find the definition of the table
Dim objTable As Object
then a function return a table ...
Set objTable = MyFunction.Tables("TABLE NAME")
where Dim MyFunction as Object
Dim oSapFunctions As Object
Set MyFunction = oSapFunctions.Add("Function Name")
etc ... call the function
Then I found
(case one)
For Each Customer In objTable.Rows
cells(i,1) = Customer("NAME1")
cells(i,2) = Customer("NAME2")
...
i=i+1
Next
(case two)
For longColIndex = 1 to objTable.ColumnCount
msgbox objTable.Columns(longColIndex).ColumnInfo.TypeName
Next
The result of the case two????
I need to store all data of my table, row after row in a strucure type and I'll find a date format. In VB how can I handle this situation avoiding errors in variables with type not correct?
If this SAP Table is considered as a normal table, where can I find methods end attributes? Where can I find a documentation?
Thanks in advance for your kind support.
-
Re: VBA Excel and SAP
So SAP is some kind of database? If it is then it should have some kind of database or table schema.
Schema is the design and definition of the structure which makes up the table. You may be able to then loop
through the table schema recording its data.
HTH