GET Function

supp85supp85 Member Posts: 76
Hello all,

I am trying to add vendor bank details to the remittance advice report, however i keep getting an error when i enter the following code within the onaftergetrecord of the Vendor Ledger Entry data item

Vend: Vendor table
VendBankAcc: Vendoor bank account table
IF Vend."BACS Account No." <>'' THEN BEGIN
   VendBankAcc.GET("Vendor No.",Code) THEN BEGIN
   BankSC := VendBankAcc."Bank Branch No.";
   BankAcc := VendBankAcc."Bank Account No.";
END;

Can anyone help please?

Answers

  • FlowerBizFlowerBiz Member Posts: 34
    You are missing a second IF statement (and corresponding END statement):

    IF Vend."BACS Account No." <>'' THEN BEGIN
    IF VendBankAcc.GET("Vendor No.",Code) THEN BEGIN
    BankSC := VendBankAcc."Bank Branch No.";
    BankAcc := VendBankAcc."Bank Account No.";
    END;
    END;
  • supp85supp85 Member Posts: 76
    Sorry my mistake there shouldn't be a second IF statement, even so it still does not work?

    IF Vend."BACS Account No." <>'' THEN BEGIN
    VendBankAcc.GET("Vendor No.",Code);
    BankSC := VendBankAcc."Bank Branch No.";
    BankAcc := VendBankAcc."Bank Account No.";
    END;
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    What is the error message?
    Code is not a field specified in the table Vendor Ledger Entry. Where do you set it?
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • bhalpinbhalpin Member Posts: 309
    I think your trouble is here:

    VendBankAcc.GET("Vendor No.",Code);

    1st, GET operates on a record's primary key, and assuming VendBankAcc is a "Bank Account" the key is "No.". If Code is a var that contains a bank acocunt No., then the line to get the bank account record would be:

    VendBankAcc.GET(Code);

    Wrap that in an IF/THEN to cach any error that may occur.

    (Others jump in if I'm wrong here.)
  • FlowerBizFlowerBiz Member Posts: 34
    If you don't test for a successful GET, and the GET fails during runtime, you will receive an error. It is better to test the GET function with either an assignment to a boolean variable or by using an IF statement directly:

    OK := TableRecord.GET("key 1 value","key 2 value");

    IF TableRecord.GET("key 1 value","key 2 value") THEN BEGIN
    // do some processing
    END;
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    Vendor Bank Account Primary Key is "Vendor No.,Code". So the code seems to be right. But I think he didn't even define any variable named "Code".
    And it doesn't make sense to get a Bank Account out of a Vendor Ledger Entry. So I assume he doesn't understand the business logic of that part of NAV.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • supp85supp85 Member Posts: 76
    thank you all for your reply, yes this is the primary key within the VendBankAcc hence "Vendor No.",Code i have defined code as a variable. I understand that it is not within the Vend Ledg Entry what i am trying to do is get the vendor record from the vendLegEntry then from the Vendor get the BankAcc, which i am not entirely sure is possible?

    I have also tried this:

    Vend.GET("Vendor No.");
    IF Vend."BACS Account No." <>'' THEN BEGIN
    VendBankAcc.GET(Vend."No.",Vend."BACS Account No.");
    BankSC := VendBankAcc."Bank Branch No.";
    BankAcc := VendBankAcc."Bank Account No.";
    END;
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    I don't know "BACS Account No.", but if it contains the Code of a Bank Account of that Vendor, then it seems to be right.
    Could you post your error message?
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • supp85supp85 Member Posts: 76
    'BACS Account No.' does contain the Code of a Bank Account of that Vendor. The report is running fine without error message now when i use the code above but it just doesn't seem to show the bank details?
  • supp85supp85 Member Posts: 76
    Its ok i placed the code in the wrong place I moved it over to the OnPreSection of the group header, Thank You all for you in put
Sign In or Register to comment.