Hi everyone,
I have a problem in a report...
The structure of my report is :
DataItem Name
Employee <Employee>
Bull1 <Bulletin1>
Bull2 <Bulletin2>
There are two fields to calculate in my report.I used the following code:
Bul1RESET;
Bul1.SETRANGE("Codebull",Employee."Bulletin");
Salary:=Employee."Base Salary";
REPEAT
Salary:=Salary+Bul1."DefaultAmount";
UNTIL (Bul1NEXT = 0);
Bul2.RESET;
Bul2.SETRANGE("Codebull",Employee."Bulletin");
SalaryN := Salary;
REPEAT
SalaryN :=SalaryN-Bul2."Taux";
UNTIL (Bul2.NEXT = 0);
The code works just fine when I print a single report...but when I print many reports(for different employees) at the same time, the code gives correct values for only the first report, and
no calculation is performed for the rest...
The report just prints the value of Base Salary for both fields Salary and SalaryN...
What shall I do???
Answers
1. Try to debug your code. Being able to see how variables are populated step after step is a great help.
2. Regarding your report... It is dificult to tell you what is happening there without seeing whole report.
a. In attached code I see that you are missing FINDSET/FIND('-') before each loop. Thus your will get wrong values if you will re-use that record. This is what is happening when you print this report for more than one Employee. Please review this code. b. Why those records are defined in the Report hierarchy tree? You are lopping through them under the Employee dataitem, are you? I am assuming this is what you do. If I am wrong why don't you make any calculations on the OnAfterGetRecord trigger for Bull1, Bull2 dataitems, instead of looping through them under the Employee dataitem? Based on your description I am assuming that you pull the same data twice. Firstly you are taking them to make calculations and then they are retaken under each data item for print purposes... Am I right?
Good luck
KB