Report Issue

I created a new field (X) in Vendor table. This Field refers to customer nº table. I have a Vendor that has a customer nº too.

I created a report based on Purch. Inv. Header and Purch. Inv.Line.

On Purch. Inv. Line - OnAfterGetRecord()

CLEAR(VendLedgerEntry);

IF “Buy-from Vendor No.”<> ‘’ THEN BEGIN
VendLedgerEntry.INIT;

VendLedgerEntry.SETFILTER(VendLedgerEntry.“Buy-from Vendor No.”,“Buy-from Vendor No.”);
VendLedgerEntry.SETFILTER(VendLedgerEntry.“Posting Date”,DateFilter);
IF VendLedgerEntry.FINDSET THEN BEGIN
VendLedgerEntry.CALCFIELDS(Amount);
CLEAR(Vendor);
IF “Buy-from Vendor No.”<> ‘’ THEN BEGIN
Vendor.INIT;
Vendor.SETFILTER(Vendor.“No.”,“Buy-from Vendor No.”);
IF Vendor.FINDSET THEN BEGIN
CLEAR(CustLedgerEntry);

IF Vendor.X <> ‘’ THEN BEGIN
CustLedgerEntry.INIT;
CustLedgerEntry.SETFILTER(CustLedgerEntry.“Customer No.”,Vendor.X);
MESSAGE(‘Vendor = %1’,Vendor.X // I can Get Vendor Nº

MESSAGE(‘Customer = %1’,CustLedgerEntry.“Customer No.”); // I can not Get Customer Nº
IF CustLedgerEntry.FINDSET THEN BEGIN
CustLedgerEntry.CALCFIELDS(Amount);
IF(VendLedgerEntry.Amount >= CustLedgerEntry.Amount) THEN BEGIN
Ded := (CustLedgerEntry.Amount);
SalDiv :=0;

END ELSE
IF (VendLedgerEntry.Amount < CustLedgerEntry.Amount) THEN BEGIN
// MESSAGE(‘Saldo Cliente = %1’,Amount );
Ded:=VendLedgerEntry.Amount;
SalDiv := CustLedgerEntry.Amount - VendLedgerEntry.Amount;

What is worong in this CAL? Why I can Not Get my Customer Nº? In CustomerledgerEntry

Did you try by adding MESSAGE(‘Customer = %1’,CustLedgerEntry.“Customer No.”);

after IF CustLedgerEntry.FINDSET THEN BEGIN?

Also you will get first record of IF VendLedgerEntry…I am not sure why you are not repeating it…

Use XXX.RESET; instead of XXX.INIT; in all places…