Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CR asking for value in strange place

Status
Not open for further replies.

BBST

Programmer
Jun 20, 2012
6
0
0
US
I am adding values for each customer by month. When the customer changes, the customer values will be added to report totals and then set to 0. The arrays are defined and initialized in a formula in the report header. I am receiving the error "A currency amount is required here."

I have placed an asterisk where CR is asking for a CurrencyVar. This is my formula code in the details section:

Code:
WhilePrintingRecords;
CurrencyVar Array CustTotals;
CurrencyVar Array MonthTotals;
NumberVar Index := Month ({BacklogSumm.DueDate});

If OnFirstRecord Then
    (CustTotals[Index] = {BacklogSumm.Price};)
Else (
    If {BacklogSumm.CustCode} = Previous({BacklogSumm.CustCode}) Then
        (CustTotals[Index] := CustTotals[Index] + {BacklogSumm.Price};)
    Else  *(
        For Index := 1 To 12 Do (
            MonthTotals[Index] := MonthTotals[Index] + CustTotals[Index];
            CustTotals[Index] := 0;
        )
    )
)

This seems very strange to me. It looks like my code is well-formed and there are no 'open' assignments. I can't think of any reason it would expect a certain type of var immediately after an Else. I placed parenthesis around everything to try to narrow down the root of the error, but it stays elusive.
 
Where are you initializing the data in the arrays? Are you using the array variables in another formula? When you declare an array you need to set the size of it otherwise you have to use ReDim or ReDim Preserve to extend the size of the array before putting data in an element of the array.

-Dell

DecisionFirst Technologies - Six-time SAP BusinessObjects Solution Partner of the Year
 
As I said: The arrays are defined and initialized in a formula in the report header. Here's the code I used to do that.
Code:
WhilePrintingRecords;
CurrencyVar Array CustTotals;
CurrencyVar Array MonthTotals;
NumberVar Index := 0;
ReDim CustTotals[12];
ReDim MonthTotals[12];

For Index := 1 To 12 Do (
    MonthTotals[Index] := 0;
    CustTotals[Index] := 0;
)
 
Sorry for missing that...

The one thing that I see is that you're using Index in two different ways in the formula. Do you need to use a separate variable for the For loop?

-Dell

DecisionFirst Technologies - Six-time SAP BusinessObjects Solution Partner of the Year
 
Yes, ultimately I do need to have two indexes. I have been changing/adding/removing things trying to get it to work. Looking at the OP, I had a = where it should have been a :=. In the mean time, I have added a second index to address the bug before it bit me. :)

CR now tells me that "The ) is missing." when I try to save the formula. I have placed an asterisk where it places the cursor:

Code:
WhilePrintingRecords;
CurrencyVar Array CustTotals;
CurrencyVar Array MonthTotals;
NumberVar intMonthIndex := Month ({BacklogSumm.DueDate});
NumberVar intLoopIndex := 0;

If OnFirstRecord Then
    CustTotals[intMonthIndex] := {BacklogSumm.Price}
Else
(
    If {BacklogSumm.CustCode} = Previous({BacklogSumm.CustCode}) Then
        CustTotals[intMonthIndex] := CustTotals[intMonthIndex] + {BacklogSumm.Price}
    Else 
    (
        For intLoopIndex := 1 To 12 Do
        (
            MonthTotals[intLoopIndex] := MonthTotals[intLoopIndex] + CustTotals[intLoopIndex];
            CustTotals[intLoopIndex] := 0;
        )
        *CustTotals[intMonthIndex] := {BacklogSumm.Price};
    )
)
 
Found the issue. I misplaced the ; for ending the loop.
Code:
WhilePrintingRecords;
CurrencyVar Array CustTotals;
CurrencyVar Array MonthTotals;
NumberVar intMonthIndex := Month ({BacklogSumm.DueDate});
NumberVar intLoopIndex := 0;

If OnFirstRecord Then
    CustTotals[intMonthIndex] := {BacklogSumm.Price}
Else
(
    If {BacklogSumm.CustCode} = Previous({BacklogSumm.CustCode}) Then
        CustTotals[intMonthIndex] := CustTotals[intMonthIndex] + {BacklogSumm.Price}
    Else 
    (
        For intLoopIndex := 1 To 12 Do
        (
            MonthTotals[intLoopIndex] := MonthTotals[intLoopIndex] + CustTotals[intLoopIndex];
            CustTotals[intLoopIndex] := 0
        );
        CustTotals[intMonthIndex] := {BacklogSumm.Price};
    )
)

Thank you for your time.
 
I would try changing the "else" code to something like this:
Code:
    (
        For intLoopIndex := 1 To 12 Do
        (
            MonthTotals[intLoopIndex] := MonthTotals[intLoopIndex] + CustTotals[intLoopIndex];
            if intLoopIndex = intMonthIndex then
              CustTotals[intLoopIndex] := {BacklogSumm.Price};
            else
              CustTotals[intLoopIndex] := 0;
        )
    )

-Dell

DecisionFirst Technologies - Six-time SAP BusinessObjects Solution Partner of the Year
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top