Using Account Schedules to report from Jobs

Problem:
I am having difficulty getting the “Expression” variable to refresh and populate correctly with a new report where I am using the EvaluateExpression logic from Codeunit 8. If a range is entered in the Formula field, it calculates fine; if I only have 2 fields to add together, that also works, but where the formula is longer than this, it iterates the right number of times but gets stuck with the RightOperand as the same each time, so continues to add the result of that line.

I have gone through this again and again, and it is the transfer of the “Formula” back to the “Expression” at the end of the first EvaluateExpression for RightOperand that seems to be the issue.

I would really appreciate some help with this. The code is fairly long, so won’t post it here for now, but can provide if someone can assist. Thanks.

Background:

I am using an Account Schedule to set up the reporting for a client where they want to extract information from Job Budgets, Job Ledger, Posted and UnPosted Orders/Invoices/Credit Notes, by GL.

Global Dimension 2 has been programmed to have a new Dim Value automatically added when new Jobs are created, and Shortcut Dim Value’s are set up to duplicate the Phase, Task and Step Code Values (to allow Job Budgets to be entered to this detail level, and other records to use the Dimensions that match to carry through for the Ledger Entries). This is to allow reporting to be done for Job Budget vs Actual where the Actual is a combination of Posted and UnPosted Orders/Invoices/Credit Notes.

An Analysis View has been set up to use these 4 Dimensions as filtering on the Account Schedule Setup.

All Invoices are posted with a Job No. attached, and the Jobs have been setup to have the 4 Dimensions above as mandatory.

The calculations for the values to display are done as a single call as the totals come from various records and need to be added together to calculate the result.

I’m feeding these into temp tables, 1 for LeftResult and another for RightResult, then calculating the result from the temp tables.

When I follow through the code in Codeunit 8, running report 25 it appears to do the steps correctly, it just doesn’t refresh the Expression, LeftOperand, RightOperand and Operator correctly.

I’m happy to send you all or some of the code that I have put together if that would help with debugging.

Any help you can give will be most appreciated as I’ve spent heaps of time on this and am getting really frustrated.