Sage MAS 90 and 200 Sage MAS 500 blogs Product Feedback Support Training
Reply
Sage MAS 90 Customer
fredalyea
Posts: 13
Registered: 01-18-2010
0

Working with Parameters as Arrays

I have a parameter that allows the user to select the months they wish the report of include.  They can select any calendar month(s) from 1 to 12.  The parameter is numeric.  The parameter is called SalesMonths.  I have created a Formula called DispMonth.  The code for this formula is as follows:

 

Global SalesMonths(12) as number
Global DispMonth as string
Dim i as number
DispMonth=""
for i=salesmonths(1) to salesmonths(12) step 1
    if i >0 then
        DispMonth=DispMonth & ", " & monthname(i)
    end if
next i
formula=DispMonth

 

I wish to display in the page header DispMonth which would be a string expression of the months selected for the report.

 

Somewhere I seem to be missing an important concept as I can't seem to get anything to display.  Appreciate assistance in solving what I'm doing incorrectly.

 

Thanks

Fred

 

Super Contributor
connex
Posts: 796
Registered: 10-29-2008
0

Re: Working with Parameters as Arrays

Why not just use a string parameter and the Join function would be available.

formula = Join({?SalesMonths},",")

 Your record selection logic for whether a record would be included would become:

ToText(Month({AR_InvoiceHistoryHeader.InvoiceDate}),"0") in Join({?Multiples},",")

 

Dan Burleson
Sage Authorized Consultant - Ask me about advanced scripting!
e-mail me here
Sage MAS 90 Customer
fredalyea
Posts: 13
Registered: 01-18-2010
0

Re: Working with Parameters as Arrays


connex wrote:

Why not just use a string parameter and the Join function would be available.

formula = Join({?SalesMonths},",")

 Your record selection logic for whether a record would be included would become:

ToText(Month({AR_InvoiceHistoryHeader.InvoiceDate}),"0") in Join({?Multiples},",")

 


 

When the user selects the months they want to be included in the report the parameter asks for a month number, i.e. 1 is january, 7 is july etc.  What I want to display in the page header is the monthname for each of their selections.  Where the user is making multiple selections for the parameter does not the force the parameter to be an array?  The parameter is numeric which will be used in record selection withing the detail of the report.   I'm new to Crystal Dan so not sure about the "join" and "?Multiples.

 

Fred 

 

Super Contributor
connex
Posts: 796
Registered: 10-29-2008
0

Re: Working with Parameters as Arrays

Fred,

 

What I am telling you is that life is much easier if you change your report to use a string type array parameter instead of numberic one.  I probably confused you because in my example "?Multiples" should have been "?SalesMonths" (same parameter as in the 1st snippet) in the second code snippet. 

 

Yes, you should use arrays and that's what I'm doing in the example. The Join function takes a set of values and strings them together with the second argument (comma in this case).

 

It's just easier to deal with string type parameters and if you need to compare them to numbers - convert what ever you are comparing them to a string as I show in the second snippet.

Dan Burleson
Sage Authorized Consultant - Ask me about advanced scripting!
e-mail me here
Sage MAS 90 Customer
fredalyea
Posts: 13
Registered: 01-18-2010
0

Re: Working with Parameters as Arrays


connex wrote:

Fred,

 

What I am telling you is that life is much easier if you change your report to use a string type array parameter instead of numberic one.  I probably confused you because in my example "?Multiples" should have been "?SalesMonths" (same parameter as in the 1st snippet) in the second code snippet. 

 

Yes, you should use arrays and that's what I'm doing in the example. The Join function takes a set of values and strings them together with the second argument (comma in this case).

 

It's just easier to deal with string type parameters and if you need to compare them to numbers - convert what ever you are comparing them to a string as I show in the second snippet.


 

Dan:

 

The Join works fine when I make the parameter a string.  Is there a function that converts "January" to 1, February to 2 etc.? 

It might be academic but why does not my code snipit I originally attempted to use not work?

 

Super Contributor
connex
Posts: 796
Registered: 10-29-2008
0

Re: Working with Parameters as Arrays

Usually people convert 1 to "January" and not the other way around with this Crystal language technique:

 

MonthName (Month({AR_InvoiceHistoryHeader.InvoiceDate}))

 

Regarding your failing code: I don't do much Basic syntax off the cuff.  Maybe someone else will chime in.  I figure why learn two syntaxes due to the REQUIREMENT that all selection criteria must use Crystal syntax. I usually just stick with the one - Crystal.

 

Dan Burleson
Sage Authorized Consultant - Ask me about advanced scripting!
e-mail me here