Limitation to COM interface method name

havhav Member Posts: 299
edited 2012-02-27 in NAV Three Tier
Hi,
I am using NAV 2009 NA SP1.

I have created an ATL COM class CWMSalesHeaders using VC++ and it has a method called "UpdateSalesOrderStatusToInDespatch".
I have written a codeunit in which i have declard an Automation var. SALESHEADERS oF type CWMSalesHeaders COM and there is code which calls SALESHEADERS.UpdateSalesOrderStatusToInDespatch().

When i compile the codeunit, the code SALESHEADERS.UpdateSalesOrderStatusToInDespatch() gets replaced with SALESHEADERS.UpdateSalesOrderStatusToInDesp() and it gives error saying UpdateSalesOrderStatusToInDespatch().method cannot be found. Note that the method name is truncated to UpdateSalesOrderStatusToInDesp(),

Is there any limitation in giving the method name for an ATL COM class that is used in NAV?
or ami i missing something?

Regards,
Hemant
Regards,
Hemant
MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)

Answers

  • skullaskulla Member Posts: 140
    Did you use interface when you declared class and method in VC ++. If possible please post that code.
  • havhav Member Posts: 299
    Below is the VC++ code for the ATL COM dll:-
    WMObject.idl - Interface Definiition File
    interface IWMSalesHeaders : IDispatch{
    ..................
    [id(7), helpstring("method UpdateSalesOrderStatusToInDespatch")] HRESULT UpdateSalesOrderStatusToInDespatch([in] BSTR SalesHeaderType, [in] BSTR SalesHeaderNo);
    }
    

    WMSalesHeaders.h - Class Declaration File
    // CWMSalesHeaders
    class ATL_NO_VTABLE CWMSalesHeaders :
    	public CComObjectRootEx<CComSingleThreadModel>,	
    	public IDispatchImpl<IWMSalesHeaders, &IID_IWMSalesHeaders, &LIBID_WMObjectLib, /*wMajor =*/ 1, /*wMinor =*/ 0>
    {
    public:
          ................
          // Interface functions
          STDMETHOD(UpdateSalesOrderStatusToInDespatch)(BSTR SalesHeaderType, BSTR SalesOrderNo);
    }
    

    WMSalesHeaders.cpp - Class Definition File
    //Function to updates the Job status to InDespatch.
    STDMETHODIMP CWMSalesHeaders::UpdateSalesOrderStatusToInDespatch(BSTR SalesHeaderType, BSTR SalesOrderNo)
    {
            ............
            return S_OK;
    }
    

    In NAV, I have created a codeunit "WM Interface" with below definition:
    VAR
    SALESHEADERS Automation IWMSalesHeaders
    SalesHeaderRec Record SalesHeader
    BEGIN
    .................
    SALESHEADERS.UpdateSalesOrderStatusToInDespatch(SalesHeaderRec."Document Type"::Order, SalesHeaderRec."Document No.")
    ..............
    END

    When i open the symbol menu, the SALESHEADERS var shows the method name as UpdateSalesOrderStatusToInDesp(). It does not show the full name of the method UpdateSalesOrderStatusToInDespatch(). See below image

    I have double-checked the class declaration and definition but i don't think i have made any mistake in giving the method name.

    Hope that helps.

    Regards,
    Hemant
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • nhsejthnhsejth Member, Microsoft Employee Posts: 34
    You have unfortunately run into a classic limitation of the AL symbol name length. All symbol names used for functions etc, are limited to 30 characters which is why you see the truncated method name in the editor. To enable your COM object for the AL environment, you will have to ensure that the length of all methods and properties is less than or equal to 30.
    _________________
    Niels-Henrik Sejthen
    Senior Software Developer
    Microsoft Dynamics NAV

    The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
  • havhav Member Posts: 299
    Hi,
    Thanks for your immediate response :D

    I will rename my COM interface method to UpdateOrderStatusToInDespatch() which counts to 29 char's and hopefully this should comply with the symbol size limitation.

    Regards,
    Hemant
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
Sign In or Register to comment.