Finishing the processing code
Next, we will create the C/AL code to calculate a Fan's age (in years) based on his/her Birth Date and the current WORKDATE. The logic is simple: subtract the Birth Date from the WORKDATE. This gives a number of days. So we divide by 365 (not worrying about Leap Years) and round down to integer years (if someone is 25 years, 10 months and 2 days, we will just consider them 25). In the following code, we did the division as though the result were a decimal field. But because our math is integer, we could have used the simpler expression:
FanAge := ((WORKDATE - "Birth Date") DIV 365);
Finally, we'll write the code to check each Fan record data against our selection criteria, determining if we want to include that fan in our output data (SelectThisFan
set to True
). This code will select each fans who fits any of the checked criteria; there is no combination logic here. Following is our commented C/AL code for Report 50002:
After this...