on 01-31-2006 8:08 AM
Hi anyone,
I'm using SAP .NET Connector version 2.0 to access user tables and modify profile or group memberships with generated "USER" proxy object (i.e. RFC call to BAPI "USER") .
After calling the "USER.GetDetail" method I got a table with all activity group memberships of referenced user (type "SAP.Connector.SAPTable").
Then I try to convert this table into ADO datatable object using method "ToADODataTable". This works fine.
I add a new row to this table and have to save it into SAP.
myADOTable = myTable.ToADODataTable ();
currRow = myADOTable.NewRow ();
currRow["Agr_name"] = newMemberValue;
myADOTable.Rows.Add (currRow);
myTable.FromADODataTable (myADOTable);
If I try to convert ADO datatable back to corresponding SAPTable I get an exception like this "Der Objekttyp kann nicht zum Zieltyp konvertiert werden.".
Where is the mistake?
Thanks in advance for any ideas,
Tino
ADO.NET tables are not typesafe, in contrast to SAPTables.
It can easily happen that you add something to ADO.NET table that cannot be casted to the type in the SAPTable.
Please check the new row with a debugger and check that all columns contain values with the type of the SAPStructure.
Another typical problem are colums that contain DBNull. This can never be casted to any target type (e.g. string).
BTW: Generally I would recommend to work directly with SAPTables instead of converting to and from DataTables.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Reiner,
thank you for posting this helpful information. If I initialze all fields of new row my code works fine.
One question about your notice at the end of your posting.
How do I add a new membership to a SAP.Connector.SAPTable (e.g. BAPIAGRTable) without using the path ToADO()..Add()..FromADO() ? SAPTable doesn't have an Add() method.
Thanks in advance,
Tino
One more remark (maybe usefull for somebody): Perhaps you haven't found the Add (and Delete, indexer and so on) method of the SAPTables, because they don't appear in the Documentation - but the do appear in Intellisense.
Why?
Because they are not implemented in the base class
SAPTAble
, but in each table class as part of your proxy. This is because we want these methods to be strongly typed.
AddNew is different, because it belongs to IBindingList, so it appears in the docu.
All in all SAPTables should have all features you need, including sorting, filtering, databinding, indexed access and so forth.
Hi,
probably you have left some new fields empty. Specially numeric fields (e.g. decimal) have to be filled.
Gerhard Rausch
P.S.: Reiner was a little bit faster
Message was edited by: Gerhard Rausch
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.