on 03-19-2014 4:18 PM
Hi everyone,
assuming I am trying to retrieve the special price for 1000 items. I have a similar code snippet like the following one:
string cardCode = "";
foreach (KeyValuePair<string, int> kvp in itemCodes)
{
String itemCode = kvp.Key;
SAPbobsCOM.ItemPriceParams param = companyService.GetDataInterface(SAPbobsCOM.CompanyServiceDataInterfaces.csdiItemPriceParams) as SAPbobsCOM.ItemPriceParams;
param.FromXMLString(@"<?xml version='1.0' encoding='UTF-16'?>
<ItemPriceParams>
<Date>" + DateTime.Now.Date.ToString("YYYY-MM-DD") + @"</Date>
<UoMEntry nil='true'></UoMEntry>
<BlanketAgreementNumber nil='true'></BlanketAgreementNumber>
<BlanketAgreementLine nil='true'></BlanketAgreementLine>
<UoMQuantity nil='true'></UoMQuantity>
<InventoryQuantity>1.000000</InventoryQuantity>
<Currency nil='true'></Currency>
<ItemCode>" + itemCode + @"</ItemCode>
<CardCode>" + cardCode + @"</CardCode>
<PriceList nil='true'></PriceList>
</ItemPriceParams>");
SAPbobsCOM.ItemPriceReturnParams rtnParams = companyService.GetItemPrice(param);
}
So, basically I am doing not much in this loop. But the memory is increasing by about 40 MB for these 1000 items. 1000 items is not quite a lot, because I am trying to receive way more item prices.
If I try to run my approach for about 30'000 items, at a certain point I get the following exception at the line 19:
System.Runtime.InteropServices.COMException (0x80028019): Old format or invalid type library. (Exception from HRESULT: 0x80028019 (TYPE_E_UNSUPFORMAT))
I am not sure why. By looping over all these items the memory is increasing up to 1.5 GB for this process and I believe that the DI connection gets affected of the "memory ressources left" in the system ...
Did someone else experience this using the new method GetItemPrice? Is there any other approach to get special prices for a big amount of items? I would like to avoid to write the sql queries by myself as there are so many tables involved for the special prices (OEDG, EDG1, OSPP, SPP1, SPP2, ...?).
Thanks in advance for any recommendation / help.
Regards
Beat
Hi Beat,
Is this the complete code ? It looks like you call the method, but do not actually do anything with the return value ?
Regards,
Johan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Johan,
thanks for your response. No, its not the complete code, my goal is to retrieve the price and the discount and save the result in a file. I removed all additional code and wanted to find out, where my memory is going. So by just running my above code (without doing anything with the actual result), it is already allocation the amount of memory I mentioned.
Regards
Beat
Hi Owen,
if you're suggesting the following code, unfortunately it doesn't help, the same amount of memory is allocated:
foreach (KeyValuePair<string, int> kvp in SyncedItemCodes)
{
SAPbobsCOM.CompanyService companyService = b1connector.Company.GetCompanyService();
SAPbobsCOM.ItemPriceParams param = companyService.GetDataInterface(SAPbobsCOM.CompanyServiceDataInterfaces.csdiItemPriceParams) as SAPbobsCOM.ItemPriceParams;
String itemCode = kvp.Key;
param.FromXMLString(@"<?xml version='1.0' encoding='UTF-16'?>
<ItemPriceParams>
<Date>" + DateTime.Now.Date.ToString("YYYY-MM-DD") + @"</Date>
<UoMEntry nil='true'></UoMEntry>
<BlanketAgreementNumber nil='true'></BlanketAgreementNumber>
<BlanketAgreementLine nil='true'></BlanketAgreementLine>
<UoMQuantity nil='true'></UoMQuantity>
<InventoryQuantity>1.000000</InventoryQuantity>
<Currency nil='true'></Currency>
<ItemCode>" + itemCode + @"</ItemCode>
<CardCode>" + cardCode + @"</CardCode>
<PriceList nil='true'></PriceList>
</ItemPriceParams>");
SAPbobsCOM.ItemPriceReturnParams rtnParams = companyService.GetItemPrice(param);
System.Runtime.InteropServices.Marshal.ReleaseComObject(rtnParams);
System.Runtime.InteropServices.Marshal.ReleaseComObject(param);
System.Runtime.InteropServices.Marshal.ReleaseComObject(companyService);
}
I run the code out from Visual Studio 2012, the underlying SAP is SAP 9.0 PL9 HF 1. Maybe that has something to do with it.
Regards
Beat
Hi Beat,
I am almost certain it is not your code. At the moment I encounter a lot of memory leaks in the last patchlevels ( 9, 9HF, 10,10HF ). So a lot of memory is allocated and not released ( at least the most ). I stepped over that when mass updating items -> it is about 0.3 mb per item. Since then I made some tests and could reproduce the behaviour for many business objects. Also SBO client seems to be affected -> within half a minute of just opening forms from main menu the memory usage is going up like crazy and even after closing most is still allocated.
In result : it is not your fault and you are not alone...
Hi Maik,
thank you for your reply. At least I am certain it's not because of my code and others are affected as well. 😕
I found these Notes, which might be related:
- 1952977
- 1922351
Do you know anything from SAP's side, if there is an active issue related or is it worth I am creating a message with SAP?
Thanks
Beat
Hi Beat,
we have a message pending ( medium priority ). But the problem doesn't seem to occur in all databases. There must be a specific preference,setup or amount of data ( or all together ) that is triggering the high memory consumption.
The first note seems to show the same problem. But in general I would suggest to create a new message, so that the issue gets in focus.
regards,
Maik
Hi Beat,
the note is http://service.sap.com/sap/support/notes/2004662 and is supposed to be fixed in next PL. The note is very specific since support was not able ( ?! ) to reproduce the problem and I had to write a proof of concept.
Meanwhile my customer went live with PL 8 cause apart from DI and UI memory leaks DI server is not working proberly ( longer than 20 min ) in later versions and support can't reproduce again.
Long story short : hands off API for current PL in complex ( larger ) business cases.
regards,
Maik
User | Count |
---|---|
102 | |
12 | |
11 | |
6 | |
5 | |
4 | |
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.