Skip to Content
author's profile photo Former Member
Former Member

Why does CompanyService GetItemPrice allocates so much memory?

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Mar 20, 2014 at 10:45 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.