Focal Point
[SOLVED] Removing OR and single quote from a drop down selected values.

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

December 06, 2008, 03:15 AM
Santhu
[SOLVED] Removing OR and single quote from a drop down selected values.
In the HTML file we got a drop down which can select multiple values. when we select multiple values the selected value is stored in &PRODUCTCODE the value is '14' OR '35' OR '21'. Can we remove single quote and OR from this and can i have in this pattern 14,35,21.

Is this possible??

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


WebFOCUS 8.0.0.7 App Studio
December 06, 2008, 04:43 AM
Santhu
Can anybody respond to it??


WebFOCUS 8.0.0.7 App Studio
December 06, 2008, 04:45 AM
<JG>
Yes but I'm not going to until you've read the manual and looked at character functions
December 06, 2008, 05:59 AM
Santhu
Dear JG,

I read the manuals and found that i can use STRREP
-SET &PRODUCTCODE1 = '14 OR 35 OR 21';
-SET &PRODUCTCODE = STRREP (&PRODUCTCODE1.LENGTH, '&PRODUCTCODE1.EVAL', 4, ' OR ', 1, ',', 40, 'A40');

-TYPE &PRODUCTCODE1
-TYPE &PRODUCTCODE

In this case my output is 14,35,21 perfect.

But My String is
-SET &PRODUCTCODE1 = ''14' OR '35' OR '21'';

here if i can remove single quote first then half the work is done.

Can u help me out now??

Thanks and Regards
Ur Santhu


WebFOCUS 8.0.0.7 App Studio
December 06, 2008, 06:15 AM
<JG>
Good attempt,

Two stage process

1st use the STRIP function to remove the single quotes.

-SET &PRODUCTCODE = '''14'' OR ''35'' OR ''21''';
-SET &PRODUCTCODE=STRIP(&PRODUCTCODE.LENGTH, &PRODUCTCODE , '''', 'A&PRODUCTCODE.LENGTH');
-SET &PRODUCTCODE = '14 OR 35 OR 21';
-SET &PRODUCTCODE = STRREP (&PRODUCTCODE.LENGTH, '&PRODUCTCODE.EVAL', 4, ' OR ', 1, ',', 40, 'A40');
-TYPE &PRODUCTCODE
December 06, 2008, 06:37 AM
Santhu
Thank you JG,

small problem is you placed two single quotes for each value.
In My string only one single quote is being used.
-SET &PRODUCTCODE = ''14' OR '35' OR '21'';

Please tell some solution for this...


WebFOCUS 8.0.0.7 App Studio
December 06, 2008, 07:27 AM
Santhu
Dear JG can you solve this problem...


WebFOCUS 8.0.0.7 App Studio
December 06, 2008, 08:36 AM
Santhu
can anybody respond to this query???


WebFOCUS 8.0.0.7 App Studio
December 06, 2008, 08:49 AM
<JG>
Santhu, you really must get some basic training.

The reason for the multiple single quotes is to construct a string like yours.

Just run the code with -SET &ECHO=ALL; as the first line and you will see that it
is exactly what you want.
December 06, 2008, 08:56 AM
Santhu
quote:
-SET &PRODUCTCODE = ''14' OR '35' OR '21'';


No JG,
you used this string '''14'' OR ''35'' OR ''21'''
But i am using this string ''14' OR '35' OR '21''
there is a difference of string. what i use and you use .
So, Please try to use this string ''14' OR '35' OR '21'' and get this output '14 OR 35 OR 21'

Regards,
Ur Santhu


WebFOCUS 8.0.0.7 App Studio
December 06, 2008, 09:22 AM
<JG>
If you do not want to test the code with the ECHO ON
so that you can actually see what it is doing then there is
absolutely no point in trying to help you.
December 07, 2008, 12:16 PM
susannah
Santhu,
download the USING FUNCTIONS manual
read the CTRAN function
you can translate any character string to anything else you want
eg the values for blank, apos, and quote
are 32,39, and 34 respectively.
turn on the echo as jg suggests, and look at your results




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
December 08, 2008, 09:04 AM
GinnyJakes
This may not be the neatest way to do this and only gets rid of the OR's but maybe you can change it to suit your needs. This is code I wrote almost two years ago to help a developer and hasn't been touched since. It should run by itself.
-* File ar_where_loop.fex
-SET &DIVISION = &DIV.(OR(<AM,AM>,<CHE,CHE>,<CHW,CHW>,<CP,CP>,<CT,CT>,<CV,CV>,<FOR,FOR>,<GB,GB>,<GC,GC>,<GU,GU>,<IR,IR>,<KI,KI>,<KSE,KSE>,<KSW,KSW>,<KY,KY>,<LS,LS>,<MR,MR>,<MTN,MTN>,<MTS,MTS>,<NC,NC>,<NE,NE>,<NEE,NEE>,<NEW,NEW>,<NK,NK>,<NWE,NWE>,<NWN,NWN>,<NWS,NWS>,<NWW,NWW>,<OT,OT>,<PRN,PRN>,<PRS,PRS>,<PRW,PRW>,<RR,RR>,<SC,SC>,<SFE,SFE>,<SFW,SFW>,<SO,SO>,<SWE,SWE>,<SWW,SWW>,<TCE,TCE>,<TCS,TCS>,<TCW,TCW>,<TX,TX>,<UP,UP>)).Select one or more DIVISIONS. ;
-***** EXAMPLE of selection ****
-* DIV = 'AM' OR 'CHW' OR 'CP' OR 'FOR'

-*  Loop thru this list & add single quotes and commas where necessary around options - to go in the SQL IN statement
-*  NEED TO TAKE THE "OR" OUT OF THE STRING PASSED FROM THE WEB SERVER

-SET &IVTGTYP=&DIV;
-SET &LENGTH_LEFT  = &IVTGTYP.LENGTH;
-SET &WHR = '  ';

-DIVLOOP
-SET &SP_POS=POSIT(&IVTGTYP,&LENGTH_LEFT,' ',1,'I2');
-* IF THERE ARE NO MORE ORS, YOU HAVE THE LAST ONE AND CAN EXIT THE LOOP.
-IF &SP_POS NE 0 GOTO DIVGET;
-SET &DIVTOK=&IVTGTYP;
-GOTO DIVEND
-DIVGET
-SET &TOKEND=&SP_POS-1;
-SET &TOKLEN=&SP_POS-1;
-SET &TOKFMT='A'|&TOKLEN;
-*-TYPE SP_POS=&SP_POS TOKEND=&TOKEND TOKLEN=&TOKLEN
-* GET THE FIRST DIVISION IN THE STRING
-SET &DIVTOK  = SUBSTR(&LENGTH_LEFT, &IVTGTYP, 1, &TOKLEN, &TOKLEN, '&TOKFMT');
-*-TYPE DIVTOK=&DIVTOK
-* MOVE THE STARTING POSITION PAST THE EXTRACTED DIVISION AND THE ' OR ' AND GET THE REST OF THE STRING.
-SET &STR_START=&TOKLEN+5;
-SET &STR_LENGTH=&LENGTH_LEFT;
-SET &LENGTH_LEFT=&LENGTH_LEFT-&TOKLEN-4;
-*-TYPE LENGTH LEFT=&LENGTH_LEFT STR_START=&STR_START STR_LENGTH=&STR_LENGTH
-SET &STRFMT='A'|&LENGTH_LEFT;
-*-TYPE STRFMT=&STRFMT
-SET &IVTGNEW=SUBSTR(&STR_LENGTH,&IVTGTYP,&STR_START,&STR_LENGTH,&LENGTH_LEFT,'&STRFMT');
-*-TYPE &IVTGNEW
-SET &IVTGTYP=&IVTGNEW;
-SET &WHR  =  &WHR || &DIVTOK || ',';
-GOTO DIVLOOP
-DIVEND
-SET &WHR  =  &WHR || &DIVTOK;
-* Parameter is set to pass to SQL select statement
-*-SET &FWHR  =  &WHR ;
-TYPE &WHR



Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
December 08, 2008, 11:21 AM
Francis Mariani
This Dialogue Manager command:

-SET &PRODUCTCODE1 = ''14' OR '35' OR '21'';
produces this error when executed in v7.6.5:

 0 ERROR AT OR NEAR LINE      3  IN PROCEDURE ADHOCRQ FOCEXEC *
 (FOC261) EXPRESSION IS INCOMPLETE BECAUSE AN OPERATION IS MISSING
There's not enough apostrophes in the code.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
December 08, 2008, 01:43 PM
<JG>
quote:
-SET &PRODUCTCODE1 = ''14' OR '35' OR '21'';


Francis you are absolutely correct.

That's why in the example that I posted for Santhu my code was

-SET &PRODUCTCODE = '''14'' OR ''35'' OR ''21'''; (WF767 is what I used)

To code it longhand (the old fashioned way)

-SET &PRODUCTCODE = '''' || '14' || '''' || ' OR ' | '''' | '35' ||'''' || ' OR ' | '''' || '21' || '''';

Both generate the required input string you would get from a multi select drop down.

The problem is Santhu does not understand even the basics of WebFOCUS and he wants someone to do his job for him
but he is not prepared to accept the advice given.

What he wants is a simple 2 stage process

STRIP
STRREP

Ginny, 2 lines not a book.
December 09, 2008, 12:44 AM
dhagen
Santhu,

You seem to be having a hard time understanding the recommendations of your fellow Focal Pointers. If you do not understand it, then do it another way. I would suggest that you use JavaScript. If you change your PRODUCTCODE from a list box to a hidden input, then add another list to contain the original list, you can add some JS code prior to the OnExecute() function to set the value of PRODUCTCODE to the desired value.

Hint: If you use the Prototype JavaScript Framework 1.6 or higher, this can be done in one line of JavaScript.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott