web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to get Actual cost from Landed cost Voyages (Costs inquiry) via SQL

(3) ShareShare
ReportReport
Posted on by 64
Hi,
In Dynamics 365 Finance, I want to retrieve via SQL the "Actual cost" value displayed in the following menu
 
Landed cost > Voyages > All voyages > Costs inquiry
 
This value is shown per item and cost type (Freight, Duty, Handling charges).
Which table and field store this Actual cost,
and how can it be retrieved using SQL?
Thank you.
 
Categories:
I have the same question (0)
  • Martin Dráb Profile Picture
    238,769 Most Valuable Professional on at
    Moved from Integration, Dataverse, and general topics forum to Finance | Project Operations, Human Resources, AX, GP, SL forum.
     
    First of all, find out details of the form control by right-clicking it and clicking on the form name. The Form information dialog can give you details such as which table field the control is bound to.
  • KK-12030320-0 Profile Picture
    64 on at
    Hi Martin,
     
    Thanks for the suggestion.  
    I checked the form information, and I can see that the data is loaded into the ITMTmpCostSum table.  
    However, this table has a table type of InMemory, so the data exists only in memory during runtime and cannot be queried directly via SQL.  
    We are looking for a way to retrieve the Actual cost values displayed on this form from a persistent SQL table, if possible.
     
    Thank you,
     
  • Suggested answer
    Martin Dráb Profile Picture
    238,769 Most Valuable Professional on at
    Check out ITMCostSum.calcActualCost(); it may be what you're looking for:
    protected Amount calcActualCost(ITMCostTrans _shipCostTrans, ITMLine _shipLine)
    {
        ITMCostInvoiceTrans shipCostInvoiceTrans;
        ITMCostAllocateTrans shipCostAllocateTrans;
    
        select sum(AllocatedAmount) from shipCostAllocateTrans
            where shipCostAllocateTrans.PurchLineRefRecId == _shipLine.RefRecId 
                && shipCostAllocateTrans.PurchRefTableId == _shipLine.RefTableId 
                && shipCostAllocateTrans.PurchLineDataArea == _shipLine.ShipDataArea
            exists join shipCostInvoiceTrans
            where shipCostInvoiceTrans.TableId == shipCostAllocateTrans.RefTableId 
                && shipCostInvoiceTrans.RecId == shipCostAllocateTrans.RefRecId 
                && shipCostInvoiceTrans.RefTableId == _shipCostTrans.TableId 
                &&  shipCostInvoiceTrans.RefRecId == _shipCostTrans.RecId;
    
        return shipCostAllocateTrans.AllocatedAmount;
    }
    Note that when you know the field name, you can use Find references in Visual Studio to find out where the field is used.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 509 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 375

#3
Adis Profile Picture

Adis 268 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans