I have a Report develop on a Purchase Inv. LIne DataItem.
I must get the Vendor Ledger Entry’s for a Vendor Number on a FilterDate user range:
I Tried this but is not OK, variable Ded cames empty and the VendorLedgerEntry.Posting Date does not respect the user FilterDate
I Create a new Function, and put ONAfterGetRecord
CalcDed(VendLedgerEntry);
CalcDed(VendorLedgerEntry : Record “Vendor Ledger Entry”)
CLEAR(VendLedgerEntry);
IF “Purch. Inv. Line”.“Buy-from Vendor No.”<> ‘’ THEN BEGIN
“Purch. Inv. Line”.SETRANGE(“Buy-from Vendor No.”,“Purch. Inv. Line”.“Buy-from Vendor No.”);
“Purch. Inv. Line”.SETFILTER(“Purch. Inv. Line”.“Posting Date”,DateFilter);
VendLedgerEntry.INIT;
VendLedgerEntry.SETFILTER(VendLedgerEntry.“Vendor No.”, “Purch. Inv. Line”.“Buy-from Vendor No.”);
IF VendLedgerEntry.FINDSET THEN BEGIN
IF VendLedgerEntry.“Vendor No.” = “Purch. Inv. Line”.“Buy-from Vendor No.” THEN
Ded := VendLedgerEntry.Amount;
In Report Dataitem below Purch .Inv Line add one more dataitem Vendor Ledger Entry and set relationship with Document No.
Remol
In my report I have only one section, Purch.Inv.Line GroupFooter. Where all my variables fields are printed.
That solution does not feet on my report
The ‘awfull truth’ to Ded being empty is that you are asigning an empty value to it with this statement:
VendLedgerEntry.Amount is a FlowField which by default is not stored in the database but has to be calculated using the C/AL function CALCFIELDS. So before being able to use its value you have to program this statement:
VendLedgerEntry.CALCFIELDS(Amount);
Then:
- I wonder what the full extend of your code is as I see you using BEGIN in your code which (in your code snippet above) is not balanced by END
- Why setting filters on “Purch. Inv. Line” when you are not asking the database to give you any data for it (see 2nd and 3rd code lines above)?
- Why using an INIT as FINDSET will fill all fields of the record?