Trouble summing amount from G/L

Pls could anyone help is there any where have gone wrong
I := 0;

FOR I := 1 TO DIMNO DO BEGIN
GLENTRY2.RESET;
GLENTRY2.SETCURRENTKEY(“Posting Date”,“Global Dimension 1 Code”,Amount);
GLENTRY2.SETRANGE(GLENTRY2.“Global Dimension 1 Code”,DIM[I]);
GLENTRY2.SETFILTER(GLENTRY2.“Posting Date”,’%1…%2’,STARTDATE,ENDDATE);
GLENTRY2.SETFILTER(GLENTRY2.Amount,’>%1’,0);
IF GLENTRY2.FIND(’-’) THEN BEGIN
REPEAT
IF GLENTRY2.Amount = 2000 THEN BEGIN
GLENTRY2.CALCSUMS(GLENTRY2.Amount);
AMOUNTFREQ[I] := GLENTRY2.Amount;
END
ELSE
IF (GLENTRY2.Amount > 2000) AND (GLENTRY2.Amount < 5000) THEN BEGIN
GLENTRY2.CALCSUMS(GLENTRY2.Amount);
AMOUNTFREQ1[I] := GLENTRY2.Amount;
END
ELSE
IF (GLENTRY2.Amount > 5000) AND (GLENTRY2.Amount < 10000) THEN BEGIN
GLENTRY2.CALCSUMS(GLENTRY2.Amount);
AMOUNTFREQ2[I] := GLENTRY2.Amount;
END
ELSE
IF (GLENTRY2.Amount > 10000) AND (GLENTRY2.Amount < 50000) THEN BEGIN
GLENTRY2.CALCSUMS(GLENTRY2.Amount);
AMOUNTFREQ3[I] := GLENTRY2.Amount;
END
ELSE
IF (GLENTRY2.Amount > 50000) AND (GLENTRY2.Amount < 100000) THEN BEGIN
GLENTRY2.CALCSUMS(GLENTRY2.Amount);
AMOUNTFREQ4[I] := GLENTRY2.Amount
END

UNTIL GLENTRY2.NEXT = 0;

thanks all

Perhaps this will point you in the right direction, but you should easily be able to use the debugger for most of this.

Which of your conditionals applies when you have an amount < 2000?
Exactly equal to 5000?
Exactly equal to 10000?
And so on.

Also, you are only assigning an amount to your frequency variables. Try using += instead of +. In fact you don’t have a + or sum in the entire function. And you can take out the CALCSUMS.

As a second option, if you are trying to use CALCSUMS for this you need to set your filters on the Amount field instead of using IF statements. And then you don’t need a REPEAT…UNTIL either. The := assignment would be appropriate in this case and not the += operator.

Try doing it both ways, then you’ll understand the differences.

Thanks Mart,

I have try both ways still not getting the require result. Anything else u think i could do.

Gbenga

What do you want us to do, guess what the required result should be? We’re not mind readers you know.

You need to turn on the debugger and step through the code. Before you take the next step, think to yourself what it’s going to be before actually taking the next step. If it’s the same then the code is doing what you thought it was going to do. If it is different, then your expectation is different from reality, and that is where you will need to modify your code.

DenStar,

I want the code to read through G/L entry to sum up amount entry between the range of condition given in the code but am not getting the entry sum up as required. Am setting filter on Dimension code,posting date and amount. Any assistance will be greatly appreciated.

Gbenga

Dear Nav Team,

I have been able to get through using the G/L entry as the dataitem for the report since i have to hard code the value range i need to change the dimension value code am using as the dataitem before to G/L entry.

Thanks Guys