Post Reason Code from Purchase Line to G/L

WearAllHatsWearAllHats Member Posts: 11
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. ](*,)

Comments

  • jglathejglathe Member Posts: 639
    Hi,

    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
  • WearAllHatsWearAllHats Member Posts: 11
    The client wants a "Reason Code" to post from the purchase line to the g/l. Not the first client to ask for this.
  • bbrownbbrown Member Posts: 3,268
    Are the purchase lines for items, or just G/L accounts?
    There are no bugs - only undocumented features.
  • WearAllHatsWearAllHats Member Posts: 11
    For this client, it's just g/l accounts.
  • bbrownbbrown Member Posts: 3,268
    For this client, it's just g/l accounts.


    I see. I've done this for items. I would agree, not an odd request.
    There are no bugs - only undocumented features.
  • jglathejglathe Member Posts: 639
    Hi,

    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
  • WearAllHatsWearAllHats Member Posts: 11
    So are you saying to add a new field to the g/l entries and post to that instead of the "Reason Code" field? I don't see where the coding would be any different. Where in the system would the code be added to transfer the value(s) from the purchase line table to the g/l entry table. I know if will need to run through the Gen. Journal table but I wasn't able to make this work. I will try again using the extra field and see if that makes a difference. I need a practical solution.
  • bbrownbbrown Member Posts: 3,268
    So are you saying to add a new field to the g/l entries and post to that instead of the "Reason Code" field? I don't see where the coding would be any different. Where in the system would the code be added to transfer the value(s) from the purchase line table to the g/l entry table. I know if will need to run through the Gen. Journal table but I wasn't able to make this work. I will try again using the extra field and see if that makes a difference. I need a practical solution.


    I noticed you are in the US. See Codeunit 10201 "Transfer Custom Fields"
    There are no bugs - only undocumented features.
  • jglathejglathe Member Posts: 639
    Hi,
    bbrown wrote:
    I noticed you are in the US. See Codeunit 10201 "Transfer Custom Fields"
    This seems to be half of the story. I was also thinking along the lines of adding an extra field in the purchase line, adding it in the invoice posting buffer (T49) too, and change CU90 accordingly. It is important that the new field is part of the primary key of T49, otherwise things could get mixed up. Also, you would need to transfer it from T81 (GenJnlLine) to your G/L Entry. This can be done in CU10201.

    with best regards

    Jens
Sign In or Register to comment.