var
salStructure: Record "Salary Structure";
empSalary: Record "Employee Salary";
counter: Integer;
begin
If empSalary.Get(Rec."No.") then begin
salStructure.ID := 10000;
If (salStructure.Find('=')) then begin
repeat
counter := 1;
empSalary.Init();
empSalary.ID := counter;
empSalary."Emp. Name" := Rec.FullName();
empSalary."Employee No." := Rec."No.";
empSalary."Salary Name" := salStructure.Name;
empSalary."Salary Description" := salStructure.Description;
empSalary.Percentage := salStructure.Percentage;
empSalary.Amount := (Rec."Gross Salary" / 100.0) * salStructure.Percentage;
empSalary.Insert(true);
Message('ID: %1, Name: %2, Percentage: %3, Amount: %4', counter, salStructure.Name, salStructure.Percentage, (Rec."Gross Salary" / 100 * salStructure.Percentage));
counter := counter + 1;
until (salStructure.Next() = 0);
end;
end;
NOTE: The Message Dialog part works fine, shows all records and does the calculation correctly but the record is not getting inserted into table pass the first line in salStructure and then it throws error.
This is the Salary Structure list
Sample Expected Result but should have shown everything corresponding to Salary Structure
Error Screen.