I need to re-write an old .ASP application in a C# webservice. No problem,
right? Well, I also need to use a DCom object to connect to our SAP system.
Unfortunately, I'm unable to make that work.
It seems that, even though SAP requires an ADODB.Recordset object passed,
the DCom specification says it requires an object. So .Net won't let me use
anything but an object while SAP bombs out when it received anything but a
Recordset. Here is the code I currently have:
------------------------------------------------------------------------------------------
//Declare a set of objects and recordsets used for local and remote (SAP)
systems
Object oProEMat, oReturn;
ADODB.Recordset rsProEMat, rsReturn;
rsProEMat = new ADODB.Recordset();
rsReturn = new ADODB.Recordset();
oProEMat = new ADODB.Recordset();
oReturn = new ADODB.Recordset();
//This defines the record set(s) with field names, data types, etc... based
on the SAP function reference via DCOM
oSAPMaterial.DimAs("BapiGetMaterialBasic", "MaterialBasic", ref oProEMat);
oSAPMaterial.DimAs("BapiGetMaterialBasic", "Return", ref oReturn);
//Use the returned structure from the definition statement (DimAs) to create
a new recordset
rsProEMat = (ADODB.Recordset)oProEMat;
//Add a new record assigning field 'Matnr' to the value strMatnr
rsProEMat.AddNew("Matnr", strMatnr);
//Reassign the recordset back to the generic object
oProEMat = new ADODB.Recordset();
oProEMat = (ADODB.Recordset)rsProEMat;
//Using the generic objects, call SAP function via DCOM
oSAPMaterial.BapiGetMaterialBasic(ref oProEMat, ref oReturn);
------------------------------------------------------------------------------------------
The last statement returns error
'System.Runtime.InteropServices.COMException: Exception from HRESULT:
0x80040E21'. When I check SAP, it gives an error stating an unhandled
variable type was passed.
Anyone have any ideas?
Bruce
|