I added "Reason Code" to the purchase lines for a client. I need the "Reason Code" to post from the Purchase Line to the G/L "Reason Code". Has anyone done this? I tried to do it in codeunit 90 but it won't seem to work. My client is in NAV 2009 Classic Version. I did a search on "Reason Code" and at each place tried to get it to use the purchase line "Reason Code". Example Code after my change:
IF InvPostingBuffer[1]."Reason Code" <> '' THEN BEGIN //Code I added
GenJnlLine."Reason Code" := InvPostingBuffer[1]."Reason Code"; //Code I added
END ELSE BEGIN //Code I added
GenJnlLine."Reason Code" := "Reason Code"; //Original Code
END;
Another place:
IF PurchLine."Reason Code" <> '' THEN BEGIN
GenJnlLine."Reason Code" := PurchLine."Reason Code";
END ELSE BEGIN
GenJnlLine."Reason Code" := "Reason Code";
END;
I thought this would be easy. Any help is appreciated. ](*,)
0
Comments
Reason Code must be added to the Invoice Posting Buffer and to the primary key of this table. Sounds like kinda strange customization, though. As Reason Code is part of the Gen. Jnl. Batch, I would expect the code to be the same for the whole transaction.
With best regards
Jens
I see. I've done this for items. I would agree, not an odd request.
let me explain why I find it a "strange" customization. Not using an extra qualifier to distinguish between postings, but using Reason Code for it.
Reason Code is part of the Gen. Jnl. Template, and Gen. Jnl. Batch tables. Fields in these tables are copied into the Gen. Jnl. Line when you enter new lines. All other posting routines fill in Gen. Jnl. Lines directly, but use their own Source Code, and no Reason Code. The result is (barring that you don't change the value of this field on one line) that the Reason Code is valid for the whole transaction. So, whenever you use it in these template tables, your resulting postings will be balanced by Reason Code, too. There is no extra check in the code to ensure this, though. However it is useful to have a feature like this under some circumstances. You can filter by Reason Code, and get a balanced "slice" of the company.
When you change the code to use Reason Code in Sales/Purchase/Service documents, the resulting postings won't be balanced by Reason Code. Using something else for it (like dimensions, or the good old extra field/table) would give you the disctinction, and keep the Reason Code "slices" intact.
with best regards
Jens
I noticed you are in the US. See Codeunit 10201 "Transfer Custom Fields"
with best regards
Jens