Table definition

By using the ttable snippet, we define the Vendor Quality table as follows:

table 50102 "Vendor Quality_PKT"
{
Caption = 'Vendor Quality';
DataClassification = CustomerContent;

fields
{
field(1; "Vendor No."; Code[20])
{
Caption = 'Vendor No.';
DataClassification = CustomerContent;
TableRelation = Vendor;
}
field(2; "Vendor Name"; Text[50])
{
Caption = 'Vendor Name';
FieldClass = FlowField;
CalcFormula = lookup (Vendor.Name where ("No." = field ("Vendor No.")));
}
field(3; "Vendor Activity Description"; Text[250])
{
Caption = 'Vendor Activity Description';
DataClassification = CustomerContent;
}
field(4; ScoreItemQuality; Integer)
{
Caption = 'Item Quality Score';
DataClassification = CustomerContent;
MinValue = 1;
MaxValue = 10;
trigger OnValidate()
begin
UpdateVendorRate();
end;
}
field(5; ScoreDelivery; Integer)
{
Caption = 'Delivery On Time Score';
DataClassification = CustomerContent;
MinValue = 1;
MaxValue = 10;
trigger OnValidate()
begin
UpdateVendorRate();
end;
}
field(6; ScorePackaging; Integer)
{
Caption = 'Packaging Score';
DataClassification = CustomerContent;
MinValue = 1;
MaxValue = 10;
trigger OnValidate()
begin
UpdateVendorRate();
end;
}
field(7; ScorePricing; Integer)
{
Caption = 'Pricing Score';
DataClassification = CustomerContent;
MinValue = 1;
MaxValue = 10;
trigger OnValidate()
begin
UpdateVendorRate();
end;
}
field(8; Rate; Decimal)
{
Caption = 'Vendor Rate';
DataClassification = CustomerContent;
}
field(10; UpdateDate; DateTime)
{
Caption = 'Update Date';
DataClassification = CustomerContent;
}
field(11; InvoicedYearN; Decimal)
{
Caption = 'Invoiced for current year (N)';
DataClassification = CustomerContent;
}
field(12; InvoicedYearN1; Decimal)
{
Caption = 'Invoiced for year N-1';
DataClassification = CustomerContent;
}
field(13; InvoicedYearN2; Decimal)
{
Caption = 'Invoiced for year N-2';
DataClassification = CustomerContent;
}
field(14; DueAmount; Decimal)
{
Caption = 'Due Amount';
DataClassification = CustomerContent;
}
field(15; AmountNotDue; Decimal)
{
Caption = 'Amount to pay (not due)';
DataClassification = CustomerContent;
}
}

keys
{
key(PK; "Vendor No.")
{
Clustered = true;
}
}

trigger OnInsert()
begin
UpdateDate := CurrentDateTime();
end;
trigger OnModify()
begin
UpdateDate := CurrentDateTime();
end;
local procedure UpdateVendorRate()
var
VendorQualityMgt: Codeunit VendorQualityMgt_PKT;
begin
VendorQualityMgt.CalculateVendorRate(Rec);
end;
}

In this table, we have the definitions of the required score fields (rating) and the required financial fields.

For the score rates, we handle the OnValidate trigger to dynamically update the rate calculation when the user inserts values in the fields (this is done by calling the UpdateVendorRate function defined in the table (as a class method) but implemented in the external codeunit that we'll see later).

We've also handled the table's OnInsert and OnModify triggers to save the insertion or modification date of the record (business requirements).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.175.182