G'day All,
I have a problem, I'm wondering if anyone has come across something similar.
In Cod 22, Item Jnl Post Line, I have a mod that under certain circumstances needs to build a Gen Jnl Line and Post it running GenJnlPostLine.RunWithCheck.
I am getting an error saying "G/L Entry No. %1 already exists" as Inventory Posting to G/L has already inserted G/L Entries and the instance of GenJnlPostLine in Cod 22 does not know about them. Therefore when the InitCodeunit function runs to determine the NextEntryNo it returns an Entry Number taken in Inventory Posting to G/L.
What I'm curious about is how this works in a standard sales post, where Inventory Posting to G/L inserts G/L Entries, yet when Sales Post calls GenJnlPostLine and the InitCodeunit function is run, the GLEntry.FIND('+') picks up the entries inserted.
Thanks
Dave
0
Comments
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
In codeunit 80 all inventory postings (and related GL postings) are completed before codeunit 80 start to post to GL directly. The last GL Entry No. read by GenJnlPostLine in codeunit 80 is the last Entry No. created by the item related GL posting (from C22 - > C5802).
The issue you have with GL postings from codeunit 22 is that you are posting in between item related GL posting from codeunit 80 and the GL postings posted directly from codeunit 80.
Regards
Claus
http://www.AcumenConsulting.co.nz
I hope this helps.
Claus
http://www.AcumenConsulting.co.nz
ClausHammann, I see what you're saying, however the problem occurs even when I'm posting an Item Journal. In this case the theory is similar to a standard sales post, ie. two different codeunits posting to G/L through their own instances of GenJnlPostLine one after the other.
What is it that allows the instance in Cod80 to see the lines posted in Cod5802, where if I'm just posting an Item Jnl the instance in Cod22 can't find the lines created by Cod5802.
Dave
I think I may have to do that, I have created a new ledger which is posted to through Cod22, and I think to be technically correct I should have the G/L impact posted through Cod5802 which would allow for switching Automatic Cost Posting on/off. Unfortunately I am upgrading the mod from V2.60 this would mean a major re-write.
I may end up going that way but I am still interested in the reasons behind the problem as I'm sure they will be relevant to other things I do.
Dave
Are you getting the issue when you only post one line from an Item Journal or do you only get the issue when you post more than one line from an Item Journal?
I don’t think your issue is that you code in C22 can’t see GL lines created from C5802. I think you issue is that you code in C22 is posting in between the C5802 postings and since the GL posting from you code and C5802 only reads the GL Entry No. once, the two GL postings will eventual use the same GL entry No.
The reason it work for C80 is that C80 finished all C22 (C5802) GL postings first and then starts to post GL Entries directly from C80.
I hope this makes sense.
Regards
Claus
http://www.AcumenConsulting.co.nz
It all makes sense now. Thanks mate.
Dave
http://www.AcumenConsulting.co.nz
It may be possible to structure your code so that you create an instance of codeunit 12 in codeunit 22. You can use this instance to to do your G/L postings in codeunit 22 and change the calls to codeunit 5802 in codeunit 22 so that this same instance of codeunit 12 is passed into the functions of codeunit 5802. Then when codeunt 5802 does its G/L postings it is using the same instance of codeunit 12 that you used.
You can use single instance property of a codeunit, but this won't work and defintely not the solution. He could write them to a different single instace codeunit and then post them later.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n