Get Open status from Vendor Ledger Entry

fmhiguefmhigue Member Posts: 290
edited 2005-03-14 in Navision Attain
I am running a report based on Purch. Inv. Header and I want to include the status of each invoice. I got the following code but what else I need to do


VendorLedgerEntry.SETFILTER("Vendor No.","Purch. Inv. Header"."Buy-from Vendor No.");
VendorLedgerEntry.SETFILTER("Document No.","Purch. Inv. Header"."No.");

Comments

  • fbfb Member Posts: 246
    When posting Purch. Invoices, there is a test in Codeunit 12 - Gen. Jnl.-Post Line that goes like this:
    // Test Internal number
          OldVendLedgEntry.RESET;
          OldVendLedgEntry.SETCURRENTKEY("Document No.","Document Type");
          OldVendLedgEntry.SETRANGE("Document No.",CVLedgEntryBuf."Document No.");
          OldVendLedgEntry.SETRANGE("Document Type",CVLedgEntryBuf."Document Type");
          IF OldVendLedgEntry.FIND('-') THEN
            ERROR(...
    
    This test insures that (for certain document types), the Document No. is guaranteed to be unique...

    So, all you need is:
    VendorLedgerEntry.SETCURRENTKEY("Document No.","Document Type");
      VendorLedgerEntry.SETRANGE("Document No.","Purch. Inv. Header".""No.");
      VendorLedgerEntry.SETRANGE("Document Type",VendorLedgerEntry."Document Type"::Invoice);
    
    Note also that Purch. Invoices are posted to the "Pay-to Vendor", not the "Buy-from Vendor"...
  • fmhiguefmhigue Member Posts: 290
    Avon:

    I used the setcurrentkey and setrange as you said but the how do I assign the value from VendorLedgerEntry.Open current record to a variable. The status on each invoice will be printed too.

    Paco
  • fbfb Member Posts: 246
    Place the following code in the 'OnAfterGetRecord' trigger of the "Purch. Inv. Header" dataitem:
    VendorLedgerEntry.SETCURRENTKEY("Document No.","Document Type"); 
    VendorLedgerEntry.SETRANGE("Document No.","Purch. Inv. Header".""No."); 
    VendorLedgerEntry.SETRANGE("Document Type",VendorLedgerEntry."Document Type"::Invoice);
    VendorLedgerEntry.FIND('-');
    
    Then, in the Sections of your report, add a textbox control, and set its SourceExpression to VendorLedgerEntry.Open. I don't think you need to assign the field to some other variable -- just use the field directly off the record.
  • fmhiguefmhigue Member Posts: 290
    It's working now!
Sign In or Register to comment.