Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create and Export/Import Table from VBA into SAP

Status
Not open for further replies.

Swat76

IS-IT--Management
Oct 22, 2002
7
0
0
AT
how can i export a table into sap to run a funtion call ???
 
The ActiveX, DCOM, and Java technologies all allow you to pass a table of values to any Remote enabled SAP Function that accepts TABLE type parameters.

is a good place to start researching how to do this.
 
thank you for your answer. but i cannot login to this site.
is there any other help you can give me.

i know the functions i want to call in sap but i cannot create a correct table for the function paramaters (in vba).
 
Sorry to delay so long in responding.

If you don't have access to the ABAP developer websites, the ActiveX (COM) objects you will most likely use from VBA are also part of the Visual Studio 6.0 installation. Check your PC for an object named "SAP.Functions". If it's there you most likely have the .dll files you will need.

My standard reference on this subject is "Professional Visual Basic SAP R/3 Programming" (ISBN# 1-861002-7-85), though I understand several others have come out in the past year or so.

These are older technologies, since replaced by the more robust DCOM and Java connectors.
 
I create the table like this. But how can i send this to my SAP-function ???

Set fac = New SAPTableFactory
Set tbl = fac.NewTable

Call tbl.Create("Kreditor", 64)

Set col1 = tbl.Columns.Add(col)
col1.Name = "Position"
col1.IntLength = 10
col1.Type = RfcTypeNum
 
SWAT76 did you get a solution to your problem? I was having the same problem and was able to work it out. I would be interested in exchanging information with about calling SAP RFC's and writting BAPI's from VB.

The simple answer to you problem (please forgive typo's as I am typing this off the top of my head)

Set varSAPfunc1 = SAPFunctions.add("RFC_NAME")
set vartable1 = varSAPFunc1.tables("SAP_TABLE")

vartable1.appendrecord
vartable1. -- set the data here

varSAPFunc1.call

The set vartable1 line creates a pointer to the table as defined in the RFC_NAME which allows you to read and write data to it.

In addition I downloaded a PDF file from the web site that was mentioned earlier in the post. It provides additional information if you would like me to e-mail it to you.
 
in the meantime i found a solution ... see below !!!

BUT NOW I HAVE A NEW PROBLEM: we have a "new" client installation for sap-gui 6.5. this is a complete installation. with our old installation everything worked fine. when i want to create the sap.bapi object (first line of code below) i receive following runtime error: "runtime error 7. not enough memory". has anyone a hint ´what the problem is ?!

Set oBAPICtrl = CreateObject("SAP.BAPI.1")

oBAPICtrl.Connection.user = SAP_Buchhalter_KZ
oBAPICtrl.Connection.Password = Range("ImpExp").Cells(35, 1)
oBAPICtrl.Connection.Client = "001"
oBAPICtrl.Connection.Language = "DE"
If Not oBAPICtrl.Connection.Logon(0, False) Then 'True=SilentLogin
Set oBAPICtrl = Nothing
Fehler = 1
Exit Sub
End If

'*********************************************
'"VendorFind"
'*********************************************

Set oBapiService = oBAPICtrl.GetSAPObject("BapiService")
Set bo1 = oBAPICtrl.GetSAPObject("Vendor")
Set oVendor = oBAPICtrl.DimAs(bo1, "Find", "SELOPTTAB")
Set oResult = oBAPICtrl.DimAs(bo1, "Find", "RESULTTAB")

oVendor.Rows.Add
oVendor.Cell(1, "TABNAME") = "LFA1"
oVendor.Cell(1, "FIELDNAME") = "NAME4"
oVendor.Cell(1, "FIELDVALUE") = String(5 - Len(Range("Pers_Nr").Text), "0") + Range("Pers_Nr").Text

'BAPI Ausführen
bo1.Find SELOPTTAB:=oVendor, RESULTTAB:=oResult, RETURN:=oReturn

'Rückgabewerte auswerten
If oResult(1, "TYPE") = "S" Then ' Beleg in Ordnung
SAP_Kreditor = oResult(1, "VENDOR_NO")
Else
n = oResult.RowCount
For i = 1 To n
Meldung = oResult(i, "MESSAGE") ' Fehlerhinweis
If Meldung <> "" Then
MsgBox "Fehler: " & Meldung
Fehler = 1
End If
Next i
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top