34 Comments for this entry

  • Dan James

    Excellent article – Thanks for posting and keep up the great work

  • Wallace Zeng

    So detailed article for AX Costing.
    Thanks.

  • Joakim Persson

    Awesome article and very useful! Thanks…

  • Jeff K

    Extremely helpful, thank you for posting this resource. It is by far the most detailed explanation of inventory closing i have seen thus far. This article has saved me SO MANY TIMES trying to explain AX behavior for auditors and accountants. I have sent this to some people in dev and support at Microsoft as an example of how their documentation needs to be improved.

  • Fatih Kartal

    Hello,

    We use Avarege weightd model in inventory closing.
    When I try to close inventory, I receive an error message that some transactions should not be posted to the GL account without a department dimension value (null)

    I realize that as you write in your beautiful paper, The IC generates some lines in inventTrans table which has transtype = summedup. But these lines does not have a department dimension when I check from InventSettlement Table. Cause the gl accounts should be set as department dimension mandatory, how should I do to make the departments has a value.

    • admin

      Well Fatih bey, Normally this summed-up inventory transactions (dummy transfers) are not posted to GL. You can check that related inventTransPosting record has IsPosted==NoYes::No and related inventSettlements has balanceSheetPosting and OperationsPosting set to None.
      I think, that on earlier stages of system implementation, You forgot to turn on mandatory check of Department dimension for certain account. As a result – You have some InventTransPosting records with EMPTY department dimension and Your GL account in either BalanceSheetAccount or OffsetAccount. Then, during inventory settlement phase, this dimension is copied into inventSettlement and Inventory Closing then chokes on attempt to post inventSettlement to General Ledger. The quick fix for your issue is to write the job which will iterate through inventTransPosting records with incorrect department value and fix them with reasonable default Department. It will look like the following pseudocode:
      ttsbegin;
      while select forupdate inventTransPosting
      where isPosted==NoYes::Yes && (BalanceAccount==’account in question’ || offsetAccount==’account in question’) && !dimension[SysDimensions::Department-1]
      {
      inventTransPosting.Dimension[SysDimensions::Department-1]=InventTable::find(inventTransPosting.itemId).Dimension[SysDimensions::Department-1];
      inventTransPosting.update()
      }

      ttscommit;
      Sure – It is only pseudo-code, It needs, at least a check to prevent update of InventTransPosting for already closed inventory transactions, but I think it is enough to get the whole idea.

  • Fatih Kartal

    Hello Fedetenko,

    Thanks for your perfect document and your answer, We have a problem that we should not update all emty records in department field at inventtransposting. We just will try to enter the line in inventtransposting which is generated by the line in inventrans for a virtual transfer line (transtype::summedup) which is generated bu inventclosing.

    Anyway thanks in advance for your perfect document and sensitive reply.

    Kind Regards
    Fatih

    • admin

      Are you completely sure that problem is actually in this virtual transfer ?
      Because normally, virtual transfer is not posted into GL, has inventTransPosting.isPosted==NoYes::No, and thus does not produce inventSettlement eligible for GL posting, so I believe Your problem is not in this transfers itself.

      But You can actually patch the class for creation of this transfers. You just need t redefine Dimension() method in InventMov_Vir_Transfer_Closing class. This Dimension will be placed into inventTransPosting.Dimension for virtual transfer.

      Since we transfered out discussion in email,I do not expect an answer in this web-forum’s thread. I decided to post the copy here, just to have a complete copy of our initial discussion on forum.

    • admin

      Hello again Fatih !
      You were right, I was wrong :) It just occurred to me that dummy transfer actually CAN create postable inventSettlement record. It happens on rounding settlement creation for dummy transfer. That is – if on propagating cost adjustment to receipt of dummy transfer, system finds that this is last iteration of closing or that adjustment is below threshold, it ALWAYS creates postable inventSettlement record (with balanceSheetPosting and OffsetPosting specified) even if originating InventTransPosting record has IsPoste=false.
      So – You can either set dimension for the whole pair of issue/receipt records of dummy transfer (by overriding Dimension() method in InventMov_Vir_Transfer_closing class) or You can modify InventCostItemDim.initInventSettlement() to initialize unfilled dimensions to some predefined values if (_initLedger == #initLedgerAlways).
      Actually, I think that in a long term prospect, the second method is better, since it would allow You to use dedicated Purpose dimension value, so You can separate rounding postings from normal receipt revaluations.

      Regards,
      Denis

  • ana

    Hello Fedetenko

    When we run recalculation for an item, we are getting the following error ,

    “Cannot create a record in Lot level adjustments (InventCostListTrans). Lot ID: 02335332_087, N110T/1.
    The SQL database has issued an error.”

    can you pls help us in this regard.

    • admin

      Hello Anand !
      First question – what version of DAX do you use ?
      Second – try to look into SQL Error log Administration->Inqueries->Database->SQL Statement Trace log. Exact SQL error message would clarify situation a great deal.
      Third – Do you have any customization for IC made ?

      Regards,
      Denis

  • ana

    Hi admin,

    We are using Ax 4.0 sp2 version and please find below the sql error what we are getting while running recalculation for a specified item -N110T/1.

    Object Server 02: The database reported (session 43 (SIS6)): [Microsoft][ODBC SQL Server Driver]Numeric value out of range. The SQL statement was: “INSERT INTO INVENTCOSTLISTTRANS (ITEMID,INVENTTRANSID,INVENTTRANSIDRETURN,VOUCHERPHYSICAL,ADJUSTMENT,VOUCHER,NUMOFITERATION,DATAAREAID,RECVERSION,RECID) VALUES (?,?,?,?,?,?,?,?,?,?)”

    As we are very well aware that Inventory Closing procedure is a critical function in the standard ax application, we never touch upon any customization.

    Kinldy help us to resolve this issue.

    regards
    ana

    • denisfed

      Hello Ana!

      The only thing,which is clear from SQL error message is that the error is caused by attempt to propagate cost adjustment higher then 9999999999999 currency units.
      I saw something like this on the versions of Axapta PRIOR to version 4.0sp2. In versions 3.0sp5-4.0sp1 Axapta had a serious error which could be triggered by usage of negative inventory together with “include physical value” setting in inventory model. Sometimes, an instant issue cost price went too high (like billions and trillions). In this case, initial inventory transaction was posted, but on attempt to close inventory similar error occurred (IC was summarizing a lot of very high value adjustments, so altogether they were exceeding the Numeric (28,14) value range.)
      This error was fixed in version 4.0sp2, but maybe your installation was upgraded from earlier version ? Please – check: Do you have any unreasonably high costs in your inventory transactions ? (Like several billions of cost price in one inventory transaction).

      If this is the case, try to run inventory recalculation on DAY-BY-DAY basis. Try to recalculate inventory for the period of 01.01.2010-01.01.2010, then 02.01.2010-02.01.2010 and so on. There are good chances that in this case, accumulated adjustment would not exceed numerical range and You will be able to fix the cost prices. After You run all these daily recalculations – try to run normal inventory closing for a month (or whatever accounting period you have).

      If you still have “include physical value” setting checked in your inventory model group – uncheck it. It completely useless in 99% of cases.

      Regards,
      Denis

  • ana

    Hi Denis,

    Thanks for your update.

    For one of our customer, one particular item is causing the issue at the Inventory Closing, This bad item has huge cost figures in Item Transactions. They are facing this issue from the Nov-2009 closing onwards.

    We have escalated the issue to MS also. They have suggested to apply the Hotfix for “Incorrect Cost Figures – KB946804 _40SP1SP2″ and we have done the same.

    As you mentioned in your mail, we are running the recalculation on day-day basis only. Somehow we are now able to close the Inventory till december’09.

    We are now in the process of doing recalculations for the month of January,2010. Till 14-jan-2010, we are able to complete recalculation for this bad item.

    When we run recalculation on 15-jan-2010, we are stuck with this SQL error. In the InventTrans table for this period, there are records showing 15 digit values in Value columns (CostAmountPosted, CostAmountPhysical fields).

    We are sure that this High values are causing the issue while running the recalculation. Can you tell us is there any other possibilities to set right the Numeric range for Adjustment column in InventCostListTrans table.

    Kindly help us to solve this issue.

    • denisfed

      Hi Ana,

      I faced the same problem 6 years ago. I was able to fix it only via usage of non-supported dirty hack. :) I developed a job (full blown class actually) which was running through the list of inventory transactions, setting costAmountPosted to reasonable value (from inventTableModule inventory price), and posting to GL a reversal of difference between old and new cost price. I cannot recreate this class now (and I have no ways to test it), but I think that since in Your case You have a limited number of invalid inventory transactions, You can simply modify costAmountPosted manually (via table browser or SQL Management Studio) and then create and post GL journal for the difference between old and new cost prices. Do not forget three rules:
      If you modify issue transaction of transfer (transfer journal, quarantine journal, WMS transfer journal, transfer order), You MUST also set the corresponding receipt transaction to the same costAmountPosted.
      If you modify issue transaction of production (PO or BOM), you MUST adjust receipt transaction on the difference between old and new costAmountPosted in issue transaction.
      You should only create and post GL journal if InventTransPosted record for your inventory transaction is set to Yes.

      Another approach (but I have never tried it) is to modify REAL definition in SQLSystemVariables table to something like Numeric(38,14). You should modify this table (It can be done ONLY via SQL Management Studio), sync database, close inventory and then MODIFY this value back and sync database again.

      Both ways are very dangerous, so try them SEVERAL times on test environment.
      I should mention also that both approaches also are completely unsupported by Microsoft, so You are on your own…

      Regards,
      Denis
      P.S. If you will try the second way – please inform me on results :) I never tried it, but if it work – it would be great !

  • Vamsi Pranith

    Hi
    I would like you to give me a more crisper scenario for the Negative inventory without marking the Physical Negative Inventory option. We are currently a similar issue, wherein the inventory is going to negative inspite of the Physical Negative Inventory option has been unmarked in the inventory model group.

    • denisfed

      Hi Vamsi !

      Scenario is pretty simple:
      1. Create new inventory item (just to be suer that we do not have any history on this item). Set its inventory model to any model with both negative Physical and Financial inventory flags unchecked.
      2. Create new purchase order for 100 PCS of the item. Post purchase invoice with today’s date (15 May 2010).
      3. Create sales order for 110 PCS. Post sales invoice for 70 PCS with yesterday’s date (14 May 2010). Invoice will be posted without any error messages or warnings.
      4. Post another sales invoice for 30 PCS with the date of 1 May 2010. Invoice will be again posted without any error messages or warnings.
      5. Now post another sales invoice for 10 PCS with ANY date (say – tomorrow – 16 May 2010). This time, attempt to post invoice will fail with error message complaining about negative inventory.

      It is pretty obvious that first and second sales invoice was posted with the dates BEFORE actual arrival of the item into inventory.

      Regards,
      Denis

  • Vamsi Pranith

    Hi Densifed,

    I have tried out this scenario and you were right. But my concern is that, we have a client for whom the inventory itself is going to negative and inspite of clearing the physical negative inventory option. Strange thing is that they are able to sell the items, even if the Physical Inventory is negative. This has been haunting the client for quite sometime and they have no real clue what exactly the stock is. They are using an add-on named Inventory II which has got its own internal costing engine which would maintain the per batch cost using the receipt lot id. We have asked the VAR to give us a clue and they say that the latest patch would fix it. We have tested it on the test environment but does not seem to fix it. Any suggestions?

    • denisfed

      Hi Vamsi !

      Actually, all this ‘negative inventory check’ functionality checks only CURRENT inventory level. So – If your customer has item in stock NOW, they can post sales invoice with ANY date from the past (like with date from 1940s or just 1 May of current year). Somewhere in my article, I wrote that MS (probably) has implemented inventory check this way just to prevent delays on inventory update process. It is just designed this way, you can not fix it without implementing customization.

      I heard about Inventory II module, but I never had any experience in working with it.

      Regards,
      Denis

  • Vamsi Pranith

    To be more specific Denis, is there any real chance for the ‘Physical Inventory’ field in the InventSum table rather the Invent On-Hand form, go negative without marking the Physical Negative Inventory with these kind of transactions?

    • denisfed

      Nope. It should not be this way. If ‘Negative XXX Inventory” is turned off, then physical/financial inventory should not became negative in invent on-hand data.
      Two possibilities came to my mind:
      1. You are looking at inventory on-hand data with incorrect subset of inventory dimensions. Say, You have site+inventory location as physical inventory dimensions, but You try to look at inventory on-hand for site+batch id combination. Physical inventory level can be checked only for subset of physical inventory dimensions, Financial inventory level can be checked only for subset of financial inventory dimensions.
      2. I saw inventory on-hand going negative as a result of incorrect addition of extra inventory dimensions. (Especially – if new field has not been added to inventSumDeltaDim table). Please, check whatever new inventory dimensions has been added.

      Regards,
      Denis

  • Vamsi Pranith

    Thanks a lot denis. I have cross verified and found that the new inventory dimensions have not been added into the InventSumDeltaDim Table.

    • denisfed

      You are welcome ! Actually – if You are adding inventory dimensions, You need to check (and modify as needed) all places in X++ source code which are marked with InventDimDevelop macros. The macros itself is empty, but it is used by logistic module developers in MS to mark the places related to inventory dimensions extension.
      Regards
      Denis

  • Vamsi Pranith

    Hi Denis,

    I’m back to trouble you again :D ! Well I now have a strange requirement. Would we be able to track the cost an item per batch? Let’s say i have an item I with batches B1 and B2. B1 has a cost say, 15 and B2 has 16. When I sell,transfer or issue the items, AX would take the average cost of the item i.e., 15.5. Can we maintain the batch cost through out the system during issues, sale or transfers? If yes how, if no why?

    • denisfed

      Hi Vamsi !
      Simply include batch into financial inventory dimensions in inventory dimensions setup.
      Actually – I have written about this in “Per-Batch costing” and “An inventory lot as a basic unit of cost” sections.
      Denis

  • Vamsi Pranith

    Aight Denis! Would go through it! But I have been trying to figure out how to maintain batch cost, during transfer orders. No matter how many times i juggle with the dimensions, I find the same average cost being transferred!

    • denisfed

      Sorry Vamsi, but this problem is totally unsolvable in standard Axapta. Only VERY heavy customization can do the trick.

  • Vamsi Pranith

    Yea! This is what Inventory II is supposed to do, but does not do it in a fulfilling way either!

    • denisfed

      I have been thinking about possibility of such a customization. Here is the short list of things to implement:
      1. Split normal inventory transfer journal functionality into two different journals. One would only support transfers inside the same financial inventory dims, another one – would support merging/splitting financial inventory dimensions.
      2. Change running average calculation algorithm for instant issue cost price calculation to take into account respective financial inventory dimension values (i.e. calculate costs on lot+financial inventory dimensions principle, not just ‘only lot’ principle).
      3. Change inventory closing functionality to track costs on lot+financial inventory dimension principle.
      All this seems to be feasible, but I would ask for at least 1 month of work to develop and test this customization. (It is not a quote, I am actually fully utilized for the next 5-6 months:))

      Denis

  • Vamsi Pranith

    Hi Denis,

    We have another requirement for our client regarding reservations and picking strategy based on Expiry Dates. Do you have any idea of an add-on which would work on these lines? What do you think about customizing the whole thing in AX?

    • denisfed

      Hello again !

      Well – there is nothing too complex about this customization. You need just modify methods inventUpd_Picked.updatePickMore(Slightly) for picking and InventUpd_Reserved.updateReserveMore(Well – more than slightly:)) for reservation. The idea is – You should add inventBatch table into loops other inventTrans and add order by inventBatch.expDate. It is very yeasy for picking, but for reservation You need to rewrite all inventDim selection logic. (Which normally allows You to automatically fill-in unspecified inventory dimensions during reservation).
      The only drawback of this customization that I could imagin, is slightly increased chances for deadlocks during simoultaneous updates to the same inventory lot. Say, If one user is adding reserve to given sales line, while other user is posting sales invoice for the same line, they will use different order of updates for the same inventory lot. (Same set of inventTrans records). This will definately lead to deadlock. From other side, normally Axapta simply restarts and redos transaction in case of deadlock, so most probably user won’t notice anything, just invoice posting will make more time than usual sometimes. Also, It is not very typicall case, when two users are working on the same inventory lot at the same time. So – I would dare to implement this.

      Denis

  • Vamsi Pranith

    And I also have a doubt regarding the Reference Lot ID.When does this field will hold a value? For most of the transactions it is left as blank and I have only for a few transactions it is filled with some value.

    • denisfed

      Hi Vamsi !
      Reference lot ID typically holds value when:
      1. User just marks inventory transactions directly, via inventory->Mark inventory button.
      2. When user firm planned orders in “Update marking:Standard” mode.
      To be honest, I do not have English version of Axapta handy right now, so maybe I misspelled names of the buttons a little:)

      Denis

  • Yogesh Kasat

    Awesome article!! I haven’t found any article with such detailed information about DAX inventory costing and closing. Details of changes in multiple versions makes it even better. Good job, keep it up.

1 Trackback or Pingback for this entry

Leave a Reply