The Payment Code is a normal field. but it has a table relation with Payment Code Table.
Here's my code:
VLE.RESET;
VLE.SETRANGE("External Document No.",TransferLine."Transport Vendor Invoice No.");
VLE.SETRANGE(Open,FALSE);
IF VLE.FINDSET THEN
GetStatus := 'Paid'
ELSE
BEGIN
GetStatus := 'Not Paid';
VLE.SETRANGE(Open,TRUE);
IF VLE.FINDSET THEN
BEGIN
VLE.CALCFIELDS(Amount);
GetAmount := FORMAT(ABS(VLE.Amount),0,'<Precision,2><Standard Format,1>');
//now, get the payment Terms Code
PurchInvHdr.RESET;
PurchInvHdr.SETCURRENTKEY("No.");
PurchInvHdr.SETRANGE("No.",VLE."Document No.");
IF PurchInvHdr.FINDSET THEN
BEGIN
MESSAGE('payment =%1 and no is %2',PurchInvHdr."Payment Method Code",PurchInvHdr."No.");
GetTerms := PurchInvHdr."Payment Method Code";
END;
MESSAGE('Amount=%1 for extdoc no %2 and vle amount=%3, extdecno=%4,Open=%5 and terms=%6',GetAmount,TransferLine."Transport Vendor Invoice No.",ABS(VLE.Amount),VLE."External Document No.",VLE.Open,GetTerms); //mbr test
END;
END;
Note: The problem is in the PurchInvHdr."Payment Method Code". It gives me blank. I feel like I have to do something before I get the actual value?