on 06-02-2009 12:45 PM
Hi all,
I am adding new records to UDT using userTable.UserFields
After I add the first record to a table, I add another one, but for the second one, I do not supply values for some of the fields.
For some reason, the userTable object "remembers" the values I used for the previoues record and inserts them to the fields of the new record.
Anyone has any idea? Workaround?
Asher
Hi
If i'm not wrong then the problem can be that memory may not be released.....
try to release the memory after addition...
System.Runtime.InteropServices.Marshal.ReleaseComObject(your variable used for adding the values)
Hope it solves your problem
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Here is the code recreating the problem:
Table AAA has fields U_A and U_I - string and int
firstRun is a class variable:
the function is called twice and creates two records.
the value of U_A is 'A' in both records and the value of U_I is 3 in both records
=================================================================
Company company = Utilities.SAPApplication.GetRunningCompany();
UserTables tables = company.UserTables;
UserTable tableObjcet = tables.Item("AAA");
if (firstRun)
{
tableObjcet.Code = "00000024";
tableObjcet.Name = tableObjcet.Code;
tableObjcet.UserFields.Fields.Item("U_A").Value = "A";
tableObjcet.UserFields.Fields.Item("U_I").Value = 3;
firstRun = false;
}
else
{
tables = company.UserTables;
tableObjcet = tables.Item("AAA");
tableObjcet.Code = "00000025";
tableObjcet.Name = tableObjcet.Code;
}
int i = tableObjcet.Add();
System.Runtime.InteropServices.Marshal.ReleaseComObject(tableObjcet);
System.Runtime.InteropServices.Marshal.ReleaseComObject(tables);
==============================================================
Asher
User | Count |
---|---|
93 | |
11 | |
10 | |
6 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.