Focal Point
Multiple Parameter Values

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4441067331

September 24, 2003, 07:47 PM
<mhuber>
Multiple Parameter Values
I'd like to run a report using multiple values for a single parameter. For instance:
TABLE FILE CAR
PRINT CAR
BY COUNTRY
WHERE COUNTRY EQ '&Parm';
END

I'd like to enter both ENGLAND and FRANCE in a single request, rather than running a separate request for each.

Thanks,
Michael
September 25, 2003, 05:37 PM
Jen
Try this:

TABLE FILE CAR
PRINT CAR
BY COUNTRY
WHERE (COUNTRY EQ &COUNTRY.(OR(ENGLAND,FRANCE,ITALY,JAPAN,W GERMANY)).CHOOSE COUNTRY.);
END

Good luck!
September 26, 2003, 01:07 PM
<mhuber>
That actually didn't do anything different for me.

Also, I don't want to hard-code all the possible values into the report. We add new values to the database relatively often, and we don't want to have to modify all the reports every time.

We came up with a Dialogue Manager solution that seems to get the job done.
If the user's input is:
'ENGLAND, FRANCE'
the DM code translates it to:
'''ENGLAND'' OR ''FRANCE'''
and the resulting WHERE clause is:
WHERE COUNTRY EQ 'ENGLAND' OR 'FRANCE'

Is there a simpler way to do this than using a whole lot of Dialogue Manager?

Thanks,
Michael
September 26, 2003, 03:19 PM
<NIVAS>
Hi michel
I have a similar kind of problem,would you post that solution please
thanks
September 26, 2003, 07:56 PM
Jen
Michael,
Are you using Dev Studio, or manually coding your focexecs? Have you tried using the Resource Layout Painter tool? You can create dynamic multi-select drop down boxes using the tool, relatively easily. What happened when you ran the above code? Did you hold down CTRL to multi-select the countries?
September 29, 2003, 02:05 PM
GCohen
In WebFocus 5.2.3 the way to do this is either
in the Report Painter in the WHERE clause follow the directions, or in language ..
WHERE COUNTRY EQ &CTY.( OR ('ENGLAND', 'FRANCE','DENMARK)).

The text after the first parenthesis is the 'join' value for the items in the multiple select list. The JavaScript is put in automatically by WebFocus.
October 01, 2003, 02:06 PM
<mhuber>
Gerald: Again, I DON'T WANT TO HARD-CODE ANYTHING!

Jen: Yes, we're using DevStudio. Unfortunately, the dynamic drop-downs/multi-selects in Resource Layout Painter don't work in our environment. I believe we have a case open with IBI, and they'll fix it in a future release. Once that's working, we'll certainly go that route. We're trying to stay away from "Publishing" the custom HTML pages for each report until everything is working as expected. Consequently, manual JavaScript coding is out as well.

Nivas: Here's the DM code. I haven't tested it to make sure it's bullet-proof, but it seems to work quite well. You can do View Source to see the FOCUS code generated in the WHERE clause. NOTE: As you may have guessed, all the quotes below are 'single' quotes.

-SET &ECHO = ALL;
-DEFAULT &INVAL = '';
-DEFAULT &MYWHERE =' ';
-SET &MYLEN = &MYWHERE.LENGTH;
-SET &OUTVAR = '''' | 'A' | &MYLEN | '''';
-SET &CTR = 1;
-SET &VARST ='A';
-REPEAT ENDLP WHILE &VARST NE ' ';
-SET &VARST = GETTOK(&MYWHERE, &MYLEN, &CTR, ',X' , &MYLEN, &OUTVAR.EVAL);
-IF &VARST EQ ' ' GOTO STOPIT;
-IF &CTR GT 1 GOTO ONEMORE;
-SET &INVAL = &INVAL | '''' | &VARST.EVAL | '''' | ' ';
-GOTO SKIPMORE
-ONEMORE
-SET &INVAL = &INVAL | 'OR ' | '''' | &VARST.EVAL | '''' | ' ';
-SKIPMORE
-TYPE &INVAL.EVAL
-SET &CTR = &CTR + 1;
-ENDLP
-STOPIT
TABLE FILE CAR
PRINT CAR MODEL
BY COUNTRY
WHERE COUNTRY EQ &INVAL
END
October 07, 2003, 07:35 PM
<mhuber>
There's a slight logic error in the code. If any of the parameter values contains a space, it blows up. This is probably due to &VARST.EVAL in the code.

I'll post a more complete solution once my coworker & I hash it out. I have more pressing issues at the moment, so I won't be able to devote too much time to it right now.

In the mean time, if anyone has any ideas about how to approach this differently, we're open to suggestions!

Thanks,
Michael
October 09, 2003, 03:05 PM
Tewy
Michael,

This may do what you want, it is quite similar to your code (I dont use -REPEAT as my version of 4.3.6 doesn't support it, and I haven't installed the new service pack).

The code prompts for &VALUES the total number of selections the user wants to input and uses that to create the selection criteria. The user is prompted for each selection one at a time, and so doesn't have to remember to put in commas or anything, and it doesn't mind spaces. Try it and see if its any good

-PROMPT &VALUES
-RUN
TABLE FILE CAR
PRINT CAR
BY COUNTRY
-SET &COUNTER =0;
WHERE COUNTRY IN
(
-HERE1
-IF &COUNTER LT &VALUES GOTO 1 ELSE GOTO END1;
-1
-PROMPT &TEST.&COUNTER
'&TEST.&COUNTER'
-SET &COUNTER=&COUNTER+1;
-IF &COUNTER LE &VALUES GOTO HERE1;
-END1
)
END

Tewy
October 13, 2003, 01:32 PM
<mhuber>
Tewy,
Is it supposed to prompt for both TEST and VALUES when you run the fex?? We've had a bit of a problem with unnecessary prompts in our environment, so maybe this is another case of that.

Anyway, here's the modified code. It accepts spaces inside the string, and ignores spaces before/after the string. You can put as many or as few spaces as you want before/after the commas.

There are only a few real modifications to the original code. I also changed variable names around a bit, just to make it more intuitive.



-SET &ECHO = ALL;
-DEFAULT &INVAL = ' ';
-SET &MYWHERE = '';
-SET &MYLEN = &INVAL.LENGTH;
-SET &OUTVAR = 'A' | &MYLEN;
-SET &CTR = 1;
-SET &VARSTR ='A';
-REPEAT ENDLP WHILE &VARSTR NE ' ';
-SET &VARSTR = GETTOK(&INVAL, &MYLEN,&CTR,',X',&MYLEN,&OUTVAR.EVAL);
-SET &VAROUT = &VARSTR.LENGTH;
-SET &VARLN = '''' | 'A' | &VAROUT | '''';
-SET &VARSTR = '''' | LJUST(&VAROUT.EVAL,&VARSTR,&VARLN.EVAL) || '''';
-IF &VARSTR.EVAL EQ ' ' GOTO STOPIT;
-IF &CTR GT 1 GOTO ONEMORE;
-SET &MYWHERE = &MYWHERE | '''' | &VARSTR.EVAL || '''' | ' ';
-GOTO SKIPMORE
-ONEMORE
-SET &MYWHERE = &MYWHERE | 'OR ' | '''' | &VARSTR.EVAL || '''' | ' ';
-SKIPMORE
-TYPE &MYWHERE.EVAL
-SET &CTR = &CTR + 1;
-ENDLP
-STOPIT
-TYPE &MYWHERE
TABLE FILE CAR
PRINT CAR MODEL
BY COUNTRY
WHERE COUNTRY EQ &MYWHERE
END

I hope this helps you, Nivas.
-Michael

This message has been edited. Last edited by: <Mabel>,
October 29, 2003, 12:09 AM
susannah
have you got a published html entry page for your users to enter their parms?
if so, you could populate a drop down box, make it a multi select drop down box, and let the published page summon the drop down optionlist from a file, which you dynamically create every day (or however often your site changes).
That's what i do. My "Published" html page (using the PUBLISH thing in MRE), i copy into another empty fex. Put a filedef at the top line of the fex (a filedef to the optionlist txt file i create), and then exec the rest of the html code with
-HTMLFORM BEGIN
[HTML]
blah blah blah
select box goes here, etc
form calls focus servelt or whatever
-HTMLFORM END.

Then erase my published page, because i dont run it as an html page anymore, i run it as a fex.
I do this all over my mre sites. Let me now if this idea works for you