Focal Point
[CLOSED] How to pass multiple values into the CONTAIN and LIKE operator

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

February 19, 2015, 02:33 AM
info4pal
[CLOSED] How to pass multiple values into the CONTAIN and LIKE operator
Hi,

Can we pass multiple values[say text values - ABC,XYZ] into the CONTAIN and the LIKE operator.

Any hints/examples on the same would be helpful.

Thanks a lot in advance!

Regards,
IP

This message has been edited. Last edited by: Tamra,


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
February 19, 2015, 02:55 AM
Ram Prasad E
You can use OR conditional operator for filtering on multiple values. Try below code.

APP PATH IBISAMP
TABLE FILE CAR
BY COUNTRY
WHERE COUNTRY LIKE '%J%' OR '%Y%' OR '%W%';
END


Thanks,
Ram

This message has been edited. Last edited by: Ram Prasad E,


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
February 19, 2015, 03:51 AM
info4pal
Hi,

Thanks Ram for the quick response and for the solution but I want to know how to pass the &variable from the html page to the fex using Contain or like operator.

Thanks!


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
February 19, 2015, 03:56 AM
Ram Prasad E
In case of multi value parameters for LIKE operator, you need to convert J,Y,W to '%J% OR '%Y%' OR '%W%' to use in filter. I doubt if its possible to pass it directly.

Even in RDBMS in case of multi values for LIKE, you have to break it into 2 conditions using OR clause as below.

column_1 like '%abc%' or column_1 like '%xyz% or etc.

Hope this helps.

Thanks,
Ram


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
February 19, 2015, 03:57 AM
info4pal
Hi,

Please let me know how to pass multiple values from the html page to the fex.
Also let me know the use of APP PATH IBISAMP
in the above step you had mentioned.

Thanks!


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
February 19, 2015, 04:03 AM
info4pal
Hi,

Would you mind sharing some sample example using CAR file.Thanks!


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
February 19, 2015, 04:03 AM
Ram Prasad E
If you use list box in html page, then check its property to enable multiple. By default multiple selection from the list box will be passed as comma separated like abc, xyz,etc.


By using APP PATH IBISAMP, I force WF engine to search for CAR master file within IBISAMP folder.

Thanks,
Ram


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
February 19, 2015, 04:05 AM
Ram Prasad E
Refer to my first post for sample using car file.


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
February 20, 2015, 05:48 AM
davidcl6
If you have an unknown number of values being passed in you could set up a -REPEAT statement from 1 to no_vals variable with first command

-REPEAT LOOP &CNT from 1 TO &SELECT0
-SET &CODE = IF &CNT EQ Q THEN 'WHERE COUNTRY CONTAINS ''&SELECT&CNT.EVAL'''
- ELSE ' OR ''&SELECT&CNT.EVAL'''
&CODE.EVAL
-LOOP

Not in Webfocus at present (so the syntax might not be 100%) but this technique should work and does work on multi select dropdowns.

Regards, David


Webfocus Release 7.6.11
Unix
EXL2K
February 23, 2015, 04:33 PM
rogerwilkouk
We do this on a couple of Reports.
It ,might not be the prettiest way of doing things but it will work

 
TABLE FILE CAR
PRINT 
     CAR.ORIGIN.COUNTRY
     CAR.COMP.CAR
WHERE CAR.ORIGIN.COUNTRY CONTAINS &COUNTRY.VALIDATE.;
ON TABLE SET PAGE-NUM NOLEAD 
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT XLSX
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
     INCLUDE = endeflt,
$
ENDSTYLE
END
 


Note: The Parameter doesn't contain the quotes around it even though it is an Alpha field.

Then in the Parameter, the User can type (exactly as shown below)
'GLA' OR 'RAN'

This bring up England and France.


WF 81.5, Windows7
AS/400 Database.
All Outputs

February 24, 2015, 08:39 AM
info4pal
Hi,

Ram,Davidcl6 and Rogerwilkouk - I will try it and will let you know how it works.

Thanks a lot!

Regards,
IP


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
February 25, 2015, 04:59 AM
Danny-SRL
IP,

Here is a suggestion:

  
-SET &ECHO=ALL;
-* File info4pals02.fex
-DEFAULT &PARM='TIRE,BRAKE,WHEEL'
-* Length of params
-SET &PLEN=&PARM.LENGTH;
-* Strip the commas
-SET &PARMC=STRIP(&PLEN,&PARM,',','A&PLEN');
-* Length without the commas
-SET &ALEN=ARGLEN(&PLEN, &PARMC, 'I3');
-* Number of commas
-SET &CLEN=&PLEN - &ALEN;
-TYPE &PLEN &ALEN &CLEN
-* Length after replacing commas with ' OR '
-SET &OLEN=&PLEN + 5*&CLEN;
-* Replace commas
-SET &P=STRREP (&PLEN, &PARM, 1, ',', 6, ''' OR ''', &OLEN, 'A&OLEN.EVAL');
-SET &P='''' | &P ||'''';
-* Run the procedure
TABLE FILE CAR
SUM SALES
BY COUNTRY 
BY STANDARD
IF STANDARD CONTAINS &P
END




Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF