Transaction No. error when UnApplying

When unapplying a customer or a vendor ledger entry you sometimes get the error “The latest Transaction No. must be an application in Vendor Ledger Entry No. ######”.  I have found that this can be triggered if “Adjust Exchage Rates” batch has been executed after the prior application posting.

This can be avoided by changing the function FindLastTransactioNo in Codeunit 227.

[code]FindLastTransactionNo(VendLedgEntryNo : Integer) : Integer
"Vendor Ledger Entry No.","Entry Type");
"Vendor Ledger Entry No.",VendLedgEntryNo);
LastTransactionNo := 0;
IF DtldVendLedgEntry.FIND(‘-‘) THEN
//# Changes Start
IF SourceCodeSetup."Exchange Rate Adjmt." = ” THEN
IF DtldVendLedgEntry."Source Code" <>
SourceCodeSetup."Exchange Rate Adjmt."
//# Changes End
IF (DtldVendLedgEntry."Transaction No." > LastTransactionNo) AND
NOT DtldVendLedgEntry.Unapplied
LastTransactionNo := DtldVendLedgEntry."Transaction No.";
UNTIL DtldVendLedgEntry.NEXT = 0;

8 Replies to “Transaction No. error when UnApplying”

  1. Hello there,
    Thanks for this solution – I have just tried it and it seems to address the problem with unapplication of vendor ledger entries after adjustment of exchange rates. I have checked the underlying Detailed Customer Ledger entries, and the exchange rate unrealise gains applied to the transaction have been reversed correctly. Brilliant solution!! Bobby

  2. Hi Gunnar,
    I try to build a code that unapplies customer entries. For that i call the function “PostUnApplyCustomer” from the codeunit 226 (“CustEntry-Apply Posted Entries”). I get the error “Before you can unapply this entry, you must first unapply all application entries that were posted after this entry.”.
    I understand the error but i do not understand why NAV does not permit us to unapply any transaction and what are the consequences if modify the code to permit this. (for example add a condition as you did in your example above).

    Thanks in advance for your help.


  3. Dear Gunnar,

    Than you so much for posting a Blog with solutions.

    I need further clarification in the above mentioned codes as The Code Unit which you have mentioned is 227 For Vendor Entry can you please mention the code for 226 Customer Entry i tried from my end to rename the Vendor to Customer below is the code i added but than i received a syntax error can you please correct me where i did wrong.

    Syntax Error comes in this please
    (//# Changes Start
    IF SourceCodeSetup.”Exchange Rate Adjmt.” = ” THEN)

    “Cust. Ledger Entry No.”,”Entry Type”);
    ” Cust. Ledger Entry No.”,CustLedgEntryNo);
    LastTransactionNo := 0;
    IF DtldCustLedgEntry.FIND(‘-‘) THEN
    //# Changes Start
    IF SourceCodeSetup.”Exchange Rate Adjmt.” = ” THEN
    IF DtldCustLedgEntry.”Source Code”
    SourceCodeSetup.”Exchange Rate Adjmt.”
    //# Changes End
    IF (DtldCustLedgEntry.”Transaction No.” > LastTransactionNo) AND
    NOT DtldCustLedgEntry.Unapplied
    LastTransactionNo := DtldCustLedgEntry.”Transaction No.”;
    UNTIL DtldCustLedgEntry.NEXT = 0;

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.