2011 Jul 20 1:34 PM
Hi together,
hope this is the right forum. We have a central service, written in C++ which gather information's from several systems, and from our SAP ECC system. The service use the RFC libraries from the SAP GUI (7.20 Unicode). Before we upgrade, I can get the collection of all import parameters when I call func.Inports(NULL). Now I'll get a null pointer from this function. I try to test this in VB, because it's easier to debug. Here is the code:
Dim SAPLogon As New SAPLogonCtrl.SAPLogonControl
Dim SAPCon As SAPLogonCtrl.Connection
Dim SAPFuncs As New SAPFunctionsOCX.SAPFunctions
Dim SAPFunc As SAPFunctionsOCX.Function
Dim SAPExpSubrc As SAPFunctionsOCX.Parameter
Dim SAPExpCnt As SAPFunctionsOCX.Parameter
Dim SAPTblData As SAPTableFactoryCtrl.Table
Dim SAPExports As SAPFunctionsOCX.Exports
Dim SAPImports As Variant
Set SAPCon = SAPLogon.NewConnection
SAPCon.ApplicationServer = "xxx.xxx.xxx.xxx"
SAPCon.System = "R/3"
SAPCon.SystemNumber = 0
SAPCon.Client = "xxx"
SAPCon.User = "xxxxx"
SAPCon.Password = "xxxx"
SAPCon.Language = "DE"
If SAPCon.Logon(0, True) = True Then
Set SAPFuncs.Connection = SAPCon
Set SAPFunc = SAPFuncs.Add("ZTEST_RFC")
If SAPFunc.Call = False Then
MsgBox SAPFunc.Name & vbCrLf & SAPFunc.Exception, vbCritical, "Fehler"
Else
' in the past, I'll get here the whole import parameter collection, now Nothing
Set SAPImports = SAPFunc.Imports(Null)
End If
Set SAPFunc = Nothing
Set SAPFuncs = Nothing
SAPCon.Logoff
Else
MsgBox "Anmeldung fehlgeschlagen !!!", vbCritical, "Fehler"
End If
Set SAPCon = Nothing
Set SAPLogon = Nothing
Any idea?
BTW: During our upgrade from 4.6C to ECC 6.0, we get also a new GUI version (6.20 to 7.20), so I'm not sure is the problem the system or the GUI.
Thanks in advance, Thomas
2011 Aug 17 12:47 PM
Hi all,
I found a solution by myself, if anyone is interrested, here the VB code
Dim SAPLogon As New SAPLogonCtrl.SAPLogonControl
Dim SAPCon As SAPLogonCtrl.Connection
Dim SAPFuncs As New SAPFunctionsOCX.SAPFunctions
Dim SAPFunc As SAPFunctionsOCX.Function
Dim SAPExpSubrc As SAPFunctionsOCX.Parameter
Dim SAPExpCnt As SAPFunctionsOCX.Parameter
Dim SAPTblData As SAPTableFactoryCtrl.Table
Dim SAPExports As SAPFunctionsOCX.Exports
Dim SAPImports As Variant
Dim var As Variant
Set SAPCon = SAPLogon.NewConnection
SAPCon.ApplicationServer = "xxx.xxx.xxx.xxx"
SAPCon.System = "R/3"
SAPCon.SystemNumber = 0
SAPCon.Client = "xxx"
SAPCon.User = "xxxxx"
SAPCon.Password = "xxxx"
SAPCon.Language = "DE"
If SAPCon.Logon(0, True) = True Then
Set SAPFuncs.Connection = SAPCon
Set SAPFunc = SAPFuncs.Add("ZTEST_RFC")
If SAPFunc.Call = False Then
MsgBox SAPFunc.Name & vbCrLf & SAPFunc.Exception, vbCritical, "Fehler"
Else
var = Empty
Set SAPImports = SAPFunc.Imports(var)
MsgBox CStr(SAPImports.Count)
End If
Set SAPFunc = Nothing
Set SAPFuncs = Nothing
SAPCon.Logoff
Else
MsgBox "Anmeldung fehlgeschlagen !!!", vbCritical, "Fehler"
End If
Set SAPCon = Nothing
Set SAPLogon = Nothing
Unfortunately, it's impossible to declare the collection as SAPFunctionsOCX.Imports. In VB it's no problem, because VB convert the object automatically. In C++ it's a bit more tricky, here the "cast" to the right object
_variant_t varNULL;
varNULL.vt = VT_EMPTY;
IUnknownPtr pUnk(func->GetImports(varNULL));
IImportsPtr imps;
pUnk->QueryInterface(IID_IDispatch, (void**)&imps);
By Thomas