Friday, 30 November 2018

Job to get average unit cost of item through X++ code in D365

Recently I have encounter a scenario in which I want to get the average unit cost price of the item in D365FO. For that I have created a job to get the cost. Please follow below screenshots.

You can see the average unit cost price for item through this navigation Cost management -> Inventory accounting -> Released products -> Manage Costs (Tab) -> Costing (Section) -> Cost Object (Option).

Source Code Explanation (1.1):
  • Initialize and declare objects.
  • Set Item Id = 'F-001' (in my case).
  • Get invent sum buffer through item id.
  • Check inventory dimension, in case of not found created one.

Source Code Explanation (1.2):
  • Create an object of invent cost price cache class.
  • Get invent table buffer from invent sum.
  • Get from & to unit of measurement.
    • Construct secondary to invent unit converter buffer.
    • Get the convert value.
  • Get the OOTB cost price pieces method from cache class that will return average unit cost price of the item.


1 comment:

Set up Online VM for Dynamics 365 Finance and Operation for Technical and Functional Learning Purposes

In this blog, I will discuss how we set up an online VM for D365F&O for Technical and Functional learning purposes for free. Step: 1 Cl...