Posting: Transfer fields salesline=>journal

Hi guys I am trying to transfer a field(A new one) from saleslines to Item jnl Line and Gen. jnl line through the posting routine. I have read the code in the codunit Sales- Post and some of the codeunits that this uses, trying to figure this out… But I can’t say that I understand how the sales lines get copied and posted. [xx(] Is this throug som buffer of some sort? Any idea how to do this? I appreciate any response!! TiA,

Hi, G/L Posting: Navision uses a posting buffer where all lines with the same characteristics are summed. This is the InvPostingBuffer Navision works with an array to create the summed values. If a record with the characteristics already exists a modify is done. This happens in UpdInvPostingBuffer() You probably need to add a field to the buffer table (49) and fill this field. Then you can pass it to the genjnlln. This is started with IF InvPostingBuffer[1].FIND(’+’) THEN ----------------------- Item Posting: Done in the function PostItemJnlLine Regards, Mark

Thanks for your response Mark! :slight_smile: I really don’t know how to do this… Now I have added a new field in the buffer table49 and I have tried to fill the field by adding code in the UpdInvPostingBuffer(). Is this what you ment? I have tried quite a few things now but there is no changes what so ever… Can you please be more spesific about what I need to do?

Hi, The FillInvPostingBuffer function is used for filling the buffer Add your code: InvPostingBuffer[1].“VAT Difference” := “VAT Difference”; InvPostingBuffer[1].“VAT %” := “VAT %”; IF Type = Type::“Fixed Asset” THEN BEGIN InvPostingBuffer[1].“FA Posting Date” := “FA Posting Date”; InvPostingBuffer[1].“Depreciation Book Code” := “Depreciation Book Code”; InvPostingBuffer[1].“Depr. until FA Posting Date” := “Depr. until FA Posting Date”; InvPostingBuffer[1].“Duplicate in Depreciation Book” := “Duplicate in Depreciation Book”; InvPostingBuffer[1].“Use Duplication List” := “Use Duplication List”; END; HERE InvPostingBuffer[1].NEWFIELD := NEWFIELD; IF “VAT Calculation Type” = “VAT Calculation Type”::“Sales Tax” THEN BEGIN InvPostingBuffer[1].“Tax Area Code” := “Tax Area Code”; The UpdInvPostingBuffer function is used to calculate the summed values. This is only necessary when you have a decimal or integer field. -------------------------------------- If the posting buffer is updated modify this code GenJnlLine.INIT; GenJnlLine.“Posting Date” := “Posting Date”; GenJnlLine.“Document Date” := “Document Date”; GenJnlLine.Description := “Posting Description”; GenJnlLine.“Reason Code” := “Reason Code”; GenJnlLine.“Document Type” := GenJnlLineDocType; GenJnlLine.“Document No.” := GenJnlLineDocNo; E.g. HERE GenJnlLine.NEWFIELD:= InvPostingBuffer[1].NEWFIELD; GenJnlLine.“External Document No.” := GenJnlLineExtDocNo; GenJnlLine.“Account No.” := InvPostingBuffer[1].“G/L Account”; GenJnlLine.“System-Created Entry” := InvPostingBuffer[1].“System-Created Entry”; GenJnlLine.Amount := InvPostingBuffer[1].Amount; GenJnlLine.“Source Currency Code” := “Currency Code”; GenJnlLine.“Source Currency Amount” := InvPostingBuffer[1].“Amount (ACY)”; GenJnlLine.Correction := Correction; GenJnlLine.“Gen. Posting Type” := GenJnlLine.“Gen. Posting Type”::Sale; GenJnlLine.“Gen. Bus. Posting Group” := InvPostingBuffer[1].“Gen. Bus. Posting Group”; GenJnlLine.“Gen. Prod. Posting Group” := InvPostingBuffer[1].“Gen. Prod. Posting Group”; GenJnlLine.“VAT Bus. Posting Group” := InvPostingBuffer[1].“VAT Bus. Posting Group”; GenJnlLine.“VAT Prod. Posting Group” := InvPostingBuffer[1].“VAT Prod. Posting Group”; GenJnlLine.“Tax Area Code” := InvPostingBuffer[1].“Tax Area Code”; GenJnlLine.“Tax Liable” := InvPostingBuffer[1].“Tax Liable”; GenJnlLine.“Tax Group Code” := InvPostingBuffer[1].“Tax Group Code”; GenJnlLine.“Use Tax” := InvPostingBuffer[1].“Use Tax”; GenJnlLine.Quantity := InvPostingBuffer[1].Quantity; GenJnlLine.“VAT Calculation Type” := InvPostingBuffer[1].“VAT Calculation Type”; GenJnlLine.“VAT Base Amount” := InvPostingBuffer[1].“VAT Base Amount”; GenJnlLine.“VAT Base Discount %” := “VAT Base Discount %”; GenJnlLine.“Source Curr. VAT Base Amount” := InvPostingBuffer[1].“VAT Base Amount (ACY)”; GenJnlLine.“VAT Amount” := InvPostingBuffer[1].“VAT Amount”; GenJnlLine.“Source Curr. VAT Amount” := InvPostingBuffer[1].“VAT Amount (ACY)”; GenJnlLine.“VAT Difference” := InvPostingBuffer[1].“VAT Difference”; GenJnlLine.“VAT Posting” := GenJnlLine.“VAT Posting”::“Manual VAT Entry”; GenJnlLine.“Shortcut Dimension 1 Code” := InvPostingBuffer[1].“Global Dimension 1 Code”; GenJnlLine.“Shortcut Dimension 2 Code” := InvPostingBuffer[1].“Global Dimension 2 Code”; GenJnlLine.“Job No.” := InvPostingBuffer[1].“Job No.”; GenJnlLine.“Source Code” := SrcCode; GenJnlLine.“EU 3-Party Trade” := “EU 3-Party Trade”; GenJnlLine.“Bill-to/Pay-to No.” := “Bill-to Customer No.”; GenJnlLine.“Source Type” := GenJnlLine.“Source Type”::Customer; GenJnlLine.“Source No.” := “Bill-to Customer No.”; GenJnlLine.“Posting No. Series” := “Posting No. Series”; IF InvPostingBuffer[1].Type = InvPostingBuffer[1].Type::“Fixed Asset” THEN BEGIN GenJnlLine.“Account Type” := GenJnlLine.“Account Type”::“Fixed Asset”; GenJnlLine.“FA Posting Type” := GenJnlLine.“FA Posting Type”::Disposal; GenJnlLine.“FA Posting Date” := InvPostingBuffer[1].“FA Posting Date”; GenJnlLine.“Depreciation Book Code” := InvPostingBuffer[1].“Depreciation Book Code”; GenJnlLine.“Depr. until FA Posting Date” := InvPostingBuffer[1].“Depr. until FA Posting Date”; GenJnlLine.“Duplicate in Depreciation Book” := InvPostingBuffer[1].“Duplicate in Depreciation Book”; GenJnlLine.“Use Duplication List” := InvPostingBuffer[1].“Use Duplication List”; END;

This is what I did, but it does not work… it is a code field

Actually it depends on the “type” of field you want to pass on to the GenJnlLine if you need to go through the InvPostingBuffer table… this buffer table is mainly used to group several sales lines into a single general journal line, if account, posting codes, etc. are equal. The buffer table is then used to sum up the amounts, discounts and tax amounts. If you are passing on an informative field, e.g. a identification code or text, you could simply add that line in the section where the general journal lines gets filled. Saludos Nils

It should work, only thing that might be important is that, if the code field you added is different for same items or g/l accounts the new field in table 49 should be added to the primary key of that table. (This is a very long key).