Hallo zusammen,
ich rufe aus Excel einen Funktionsbaustein aus SAP auf, muss allerdings eine Tabellen als Importparameter liefern.
Ich erhalte beim "Call" des FBSt die Exception: SYSTEM_FAILURE.
Baue ich die Struktur falsch auf, oder wer hat was für ein Problem?
Hier der Code:
[code]Public functionCtrl As Object
Public sapConnection As Object
Public theFunc As Object
Public strFilename As String
Public strException As String
Public TFILE As SAPFunctionsOCX.Structure
Public TDRAW As SAPFunctionsOCX.Structure
Public TPHIO As SAPFunctionsOCX.Structure
Public TFRONTEND As SAPFunctionsOCX.Structure
Public TCOUT As SAPFunctionsOCX.Structure
Public bLogon As Boolean
Public bReturn As Boolean
Public Sub GetPicture()
Set functionCtrl = CreateObject("Sap.Functions")
TakeConnection
If bLogon = True Then
OpenFunction
End If
End Sub
Private Sub TakeConnection()
Set sapConnection = functionCtrl.Connection
bLogon = False
'
'Logon mit Startwerten
'
sapConnection.Client = "***"
sapConnection.User = "********"
sapConnection.Language = "DE"
sapConnection.ApplicationServer = "*******"
sapConnection.SAPRouter = "*******"
sapConnection.Destination = "***"
sapConnection.SystemNumber = "**"
If sapConnection.Logon(0, False) <> True Then
MsgBox "Keine Verbindung"
CloseProgram
Else
bLogon = True
End If
End Sub
Private Sub OpenFunction()
On Error GoTo ErrorHandler
'Referenz auf Funktionsobjekt
Set theFunc = functionCtrl.Add("CV120_DOC_CHECKOUT_VIEW")
Set TFILE = theFunc.Exports("PS_DOC_FILE")
Set TDRAW = theFunc.Exports("PS_DRAW")
Set TPHIO = theFunc.Exports("PS_PHIO")
Set TFRONTEND = theFunc.Exports("PS_FRONTEND")
Set TCOUT = theFunc.Exports("PS_COUT_DEF")
With TFILE
.Value("LANGU") = "DE"
.Value("REVISION") = 0
.Value("FILENAME") = "C:\TEMP\TEST.GIF"
.Value("DAPPL") = "GIF"
End With
With TDRAW
.Value("MANDT") = "***"
.Value("DOKAR") = "AHA"
.Value("DOKNR") = "10000000256"
.Value("DOKVR") = "00"
.Value("DOKTL") = "000"
.Value("DWNAM") = "TEST_DMS"
.Value("DOKST") = "AA"
.Value("VPRIOR") = 0
.Value("FILELEN") = "000000000000"
.Value("FILELEN1") = "000000000000"
End With
With TPHIO
.Value("LO_INDEX") = 0
.Value("PH_OBJID") = "4369FEEFF7FE0E18E1000000A4147F19"
.Value("PH_INDEX") = 1
.Value("LANGU") = "DE"
.Value("STATUS_NR") = "0000"
.Value("ACTIVE_VERSION") = "X"
.Value("DELETE_FLAG") = "X"
.Value("PROTECTED") = "X"
.Value("DEFAULT_LANGU") = "X"
.Value("FILE_ID") = "4369FEEFF7FE0E18E1000000A4147F19"
End With
TFRONTEND.Value("PLATFORM") = 0
TCOUT.Value("KPRO_USE") = "X"
TCOUT.Value("COMP_GET") = "X"
bReturn = theFunc.Call
If bReturn = True Then
strFilename = theFunc.Imports("PFX_FILE")
Worksheets(1).Select
MsgBox "Ergebnis: " & strFilename
Else
strException = theFunc.Exception
If strException <> " " Then
MsgBox strException
Exit Sub
End If
End If
CloseProgram
Exit Sub
ErrorHandler:
If Err <> 0 Then
MsgBox Err.Source & "--> " & Err.Description
End If
End Sub
Private Sub CloseProgram()
'Verbindung trennen
functionCtrl.Connection.Logoff
'Objekte freigeben
Set sapConnection = Nothing
Set functionCtrl = Nothing
MsgBox "Programm beendet!", vbInformation
End Sub[/code]
Danke für Eure Bemühungen!
Kati