Focal Point
[SOLVED] .EXISTS Always returns 1

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

December 18, 2008, 11:10 PM
focuscon
[SOLVED] .EXISTS Always returns 1
I'm on release 7.6.5 on WIN XP. I have a drill down fex that is being passed the BY fields and their respective values. It is also being passed the results of a MULTI SELECT WHERE statement. It is quite possible that
&COUNTRY1 = 'ENGLAND' OR 'FRANCE' OR 'ITALY' as a result of the MULTI SELECT and a second value for &COUNTRY2 = 'ITALY' as the value of a BY field on the summary report. I need the drill down isolate the &COUNTRY2 value. To do that I need to determine if &COUNTRY0.EXISTS. The problem is the .EXISTS always returns 1.
Here is the HTML Output
 -SET &IDX=0;
 -SET &TK2=2;
 -SET &TB=1;
 -SET &NAMEFLD = 0;
 -SET &ERSAND = '&';
 -SET &P2 = 29;
 CURRENTLY DEFINED & VARIABLES:
 &&APPLOCK     = APP_NOT_LOCKED
 &&APP_PERMIT  = ALL
 &&EDAAPP      = APP-ENABLED
 &&EDACONF     = C:\ibi\srv76\wfs5
 &&OSTYPE      = WINNT
 &&SRVTYPE     = PTH
 &ACCEPTS      =        0
 &ERSAND    = &
 &APPROOT      = C:\ibi\apps
 &AUTOINDEX    = NO
 &B            = 3
 &BASEIO       =        0
 &BYE          = 'COUNTRY' OR 'CAR' OR 'MODEL'
 &CAR          = ALFA ROMEO
 &CHNGD        =        0
 &CLICKED_ON   =
 &COUNTRY      = 'ENGLAND' OR 'FRANCE' OR 'ITALY'
 &COUNTRY0     = 2
 &COUNTRY1     = 'ENGLAND' OR 'FRANCE' OR 'ITALY'
 &COUNTRY2     = ITALY
 &DATE         = 12/18/08
 &DBMSERR      =        0
 &DELTD        =        0
 &DMY          = 181208
 &DMYY         = 18122008
 &DUPLS        =        0
 &ECHO         = ALL
 &EXITRC       =        0
 &FOCEXURL     = /ibi_apps/WFServlet?IBIF_webapp=/ibi_apps&IBIC_server=EDASERV
 &FOCFEXNAME   = CARTST1D1
 &FOCFOCEXEC   = _CARTST1D1
 &FOCGRAPHCNT  =        0
 &FOCHTMLURL   = /ibi_html
 &FOCINCLUDE   = CARTST1D1
 &FOCNEXTPAGE  =        0
 &FORMAT       =        0
 &IDX          = 0
 &INDEXIO      =        0
 &INPUT        =        0
 &INVALID      =        0
 &LINES        =        0
 &MDY          = 121808
 &MDYY         = 12182008
 &MODEL        = 2000 SPIDER VELOCE
 &NAMEFLD      = 0
 &NOMATCH      =        0
 &P2           = 29
 &READS        =        0
 &RECORDS      =        0
 &REJECTS      =        0
 &RETCODE      =        0
 &SETFILE      =
 &SORTIO       =        0
 &TB           = 1
 &TK2          = 2
 &TOD          = 19.38.31
 &TRANS        =        0
 &WFDESCRIBE   = OFF
 &YMD          = 081218
 &YYMD         = 20081218
 -? &
 -RUN
 TABLE FILE CAR
 PRINT *
 -REPEAT LOOPB FOR  TB FROM 1 TO 50 STEP 2
 -SET &NXTBY = GETTOK('COUNTRY' OR 'CAR' OR 'MODEL',29,1,' OR ', 15, 'A15');
 -SET &NXTB2 = STRIP(15,'COUNTRY'      ,'''','A15');
 -SET &NB = 1 /2 + 1;
 -IF COUNTRY         EQ ' ' THEN GOTO CONT2;
 -SET &NXTB3 = 'BY ' | COUNTRY        ;
 BY COUNTRY         SUBTOTAL MULTILINES
 -REPEAT LOOPB FOR  TB FROM 1 TO 50 STEP 2
 -SET &NXTBY = GETTOK('COUNTRY' OR 'CAR' OR 'MODEL',29,3,' OR ', 15, 'A15');
 -SET &NXTB2 = STRIP(15,'CAR'          ,'''','A15');
 -SET &NB = 3 /2 + 1;
 -IF CAR             EQ ' ' THEN GOTO CONT2;
 -SET &NXTB3 = 'BY ' | CAR            ;
 BY CAR             SUBTOTAL MULTILINES
 -REPEAT LOOPB FOR  TB FROM 1 TO 50 STEP 2
 -SET &NXTBY = GETTOK('COUNTRY' OR 'CAR' OR 'MODEL',29,5,' OR ', 15, 'A15');
 -SET &NXTB2 = STRIP(15,'MODEL'        ,'''','A15');
 -SET &NB = 5 /2 + 1;
 -IF MODEL           EQ ' ' THEN GOTO CONT2;
 -SET &NXTB3 = 'BY ' | MODEL          ;
 BY MODEL           SUBTOTAL MULTILINES
 -REPEAT LOOPB FOR  TB FROM 1 TO 50 STEP 2
 -SET &NXTBY = GETTOK('COUNTRY' OR 'CAR' OR 'MODEL',29,7,' OR ', 15, 'A15');
 -SET &NXTB2 = STRIP(15,               ,'''','A15');
 -SET &NB = 7 /2 + 1;
 -IF                 EQ ' ' THEN GOTO CONT2;
 -CONT2
 -REPEAT LOOPC FOR  TB FROM 1 TO 50 STEP 2
 -SET &NXTBY = GETTOK('COUNTRY' OR 'CAR' OR 'MODEL',29,1,' OR ', 15, 'A15');
 -SET &NXTB2 = STRIP(15,'COUNTRY'      ,'''','A15');
 -SET &NB = 1 /2 + 1;
 -IF COUNTRY         EQ ' ' THEN GOTO CONT3;
 -SET &NAMEFLD1 = COUNTRY         || '0';
 -SET &NAMEFLD  = 1 ;
 -SET &TAR = IF 1 THEN '&' || COUNTRY         || '2' ELSE '&' || COUNTRY        ;
 -SET &TARGET = TRIM('T',ITALY,15,' ',1,'A15');
 -SET &NXTW  = 'WHERE ' | COUNTRY         | ' EQ ';
 WHERE COUNTRY EQ
 'ITALY'
 -REPEAT LOOPC FOR  TB FROM 1 TO 50 STEP 2
 -SET &NXTBY = GETTOK('COUNTRY' OR 'CAR' OR 'MODEL',29,3,' OR ', 15, 'A15');
 -SET &NXTB2 = STRIP(15,'CAR'          ,'''','A15');
 -SET &NB = 3 /2 + 1;
 -IF CAR             EQ ' ' THEN GOTO CONT3;
 -SET &NAMEFLD1 = CAR             || '0';
 -SET &NAMEFLD  = 1 ;
 -SET &TAR = IF 1 THEN '&' || CAR             || '2' ELSE '&' || CAR            ;
 0 ERROR AT OR NEAR LINE     29  IN PROCEDURE CARTST1D1
 (FOC295) A VALUE IS MISSING FOR: &CAR2

 


Here is the fex:
 -* File CARTST1D.fex                                      ';
-SET &ECHO=ALL;
-SET &IDX=0;
-SET &TK2=2;
-SET &TB=1;
-SET &NAMEFLD = 0;
-SET &ERSAND = '&';
-SET &P2 = &BYE.LENGTH;
-? &
-RUN
 TABLE FILE CAR
PRINT *
-REPEAT LOOPB FOR &TB FROM 1 TO 50 STEP 2
-SET &NXTBY = GETTOK(&BYE,&P2,&TB,' OR ', 15, 'A15');
-SET &NXTB2 = STRIP(15,&NXTBY,'''','A15');
-SET &NB = &TB /2 + 1;
-IF &NXTB2 EQ ' ' THEN GOTO CONT2;
-SET &NXTB3 = 'BY ' | &NXTB2;
&NXTB3 SUBTOTAL MULTILINES
-LOOPB
-CONT2
-REPEAT LOOPC FOR &TB FROM 1 TO 50 STEP 2
-SET &NXTBY = GETTOK(&BYE,&P2,&TB,' OR ', 15, 'A15');
-SET &NXTB2 = STRIP(15,&NXTBY,'''','A15');
-SET &NB = &TB /2 + 1;
-IF &NXTB2 EQ ' ' THEN GOTO CONT3;
-SET &NAMEFLD1 = &NXTB2.EVAL || '0';
-SET &NAMEFLD  = &NAMEFLD1.EXISTS ;
-SET &TAR = IF &NAMEFLD THEN '&ERSAND.EVAL' || &NXTB2.EVAL || '2' ELSE '&ERSAND.EVAL' || &NXTB2.EVAL;
-SET &TARGET = TRIM('T',&TAR.EVAL,15,' ',1,'A15');
-SET &NXTW  = 'WHERE ' | &NXTB2.EVAL | ' EQ ';
&NXTW.EVAL
'&TARGET.EVAL'
-LOOPC
-CONT3
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
     UNITS=IN,
     PAGESIZE='Letter',
     SQUEEZE=ON,
     ORIENTATION=PORTRAIT,
$
TYPE=REPORT,
     GRID=OFF,
     FONT='ARIAL',
     SIZE=9,
     RIGHTGAP=0.125000,
$
TYPE=TITLE,
     STYLE=BOLD,
$
TYPE=TABHEADING,
     SIZE=12,
     STYLE=BOLD,
$
TYPE=TABFOOTING,
     SIZE=12,
     STYLE=BOLD,
$
TYPE=HEADING,
     SIZE=12,
     STYLE=BOLD,
$
TYPE=FOOTING,
     SIZE=12,
     STYLE=BOLD,
$
TYPE=SUBHEAD,
     SIZE=10,
     STYLE=BOLD,
$
TYPE=SUBFOOT,
     SIZE=10,
     STYLE=BOLD,
$
TYPE=SUBTOTAL,
     BACKCOLOR=RGB(210 210 210),
$
TYPE=ACROSSVALUE,
     SIZE=9,
$
TYPE=ACROSSTITLE,
     STYLE=BOLD,
$
TYPE=GRANDTOTAL,
     BACKCOLOR=RGB(210 210 210),
     STYLE=BOLD,
$
TYPE=REPORT,
     COLUMN=N4,
     SQUEEZE=0.375000,
$
ENDSTYLE
END

 

This message has been edited. Last edited by: Kerry,
December 19, 2008, 02:05 AM
Tony A
FocusCon,

Within your code, the only .EXISTS is a check for &NAMEFLD1 which is set on the previous line so yes, it will always exist in this code.
quote:
-SET &NAMEFLD1 = &NXTB2.EVAL || '0';
-SET &NAMEFLD = &NAMEFLD1.EXISTS ;

If you want NAMEFLD1 to be interpretted to COUNTRY0 (as per the previous line) so that you get COUNTRY0.EXISTS, then try adding .EVAL so you get &NAMEFLD1.EVAL.EXISTS. I'm not totally convinced that will work but it's worth a try.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
December 19, 2008, 07:10 AM
<JG>
Your logic in LOOPC looks as it will never work.

Try this

-REPEAT LOOPC FOR &TB FROM 1 TO 50 STEP 2
-SET &NXTBY = GETTOK(&BYE,&P2,&TB,' OR ', 15, 'A15');
-SET &NXTB2 = STRIP(15,&NXTBY,'''','A15');
-SET &NB = &TB /2 + 1;
-IF &NXTB2 EQ ' ' THEN GOTO CONT3;
-SET &NAMEFLD1 = &NXTB2.EVAL || '0';
-SET &NAMEFLD = &NAMEFLD1.EXISTS ;
-SET &TARGET = IF &NAMEFLD THEN &|&NXTB2.EVAL ELSE &|&NXTB2.EVAL;
-SET &NXTW = 'WHERE ' | &NXTB2.EVAL | ' EQ ';
-SET &SLX = STRIP(&TARGET.LENGTH,&TARGET,'''','A&TARGET.LENGTH');
-SET &SL=TRUNCATE(&SLX);
-SET &Q=IF &TARGET.LENGTH - &SL.LENGTH EQ 0 THEN '.QUOTEDSTRING' ELSE '';
&NXTW.EVAL
&TARGET&Q.EVAL
-LOOPC
December 19, 2008, 10:33 AM
j.gross
 &COUNTRY      = 'ENGLAND' OR 'FRANCE' OR 'ITALY'
 &COUNTRY0     = 2
 &COUNTRY1     = 'ENGLAND' OR 'FRANCE' OR 'ITALY'
 &COUNTRY2     = ITALY


To answer why you have &COUNTRY0 (or &[whatever]0 in your real world)

Obviously
&COUNTRY1 = 'ENGLAND' OR 'FRANCE' OR 'ITALY'
and
&COUNTRY2 = ITALY
do not come from a single Multi-SELECT.

It appears that WF Client (servlet) is being presented with two parameters -- both named COUNTRY (perhaps one from a Multi-select autoprompt, and another inherited from your launch page and passed through by the autoprompt page). Standard procedure is for Client to assume the conflicting parameters come from a multi-select, and convert those into an indexed list of & variables (leaving a copy of the first under its original name). If you rename one or the other, &COUNTRY0 will go away.

This message has been edited. Last edited by: j.gross,


- Jack Gross
WF through 8.1.05
December 19, 2008, 11:33 AM
Darin Lee
First thing that caught my eye (and confused me from the start) was similar to what Jack mentioned. If &COUNTRY0=2 then how are you getting three values. Then I thought, well if you have an &COUNTRY1 value it would only contain a single value, not an OR phrase. So you must have something crossed up as far as the parameters that are being sent.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
December 19, 2008, 02:30 PM
focuscon
quote:
Thanks Jack, Darin, amd John for your inputs. This is an Adhoc reporting application where a sort order is expressed by a predetermined list of fields, which I parse into BY statements and various targeting lists which convert to WHERE statementst. There is also a list of measures which form the object fields of a SUM statement. The summary report hyperlinks each of the BY fields for drill down.The issue is with the drill down fex that is being passed the BY fields and their respective values. It is also being passed the results of a MULTI SELECT target lists that are converted to WHERE statements. It is quite possible that
&COUNTRY1 = 'ENGLAND' OR 'FRANCE' OR 'ITALY' as a result of the MULTI SELECT and a second value for &COUNTRY2 = 'ITALY' as the value of a BY field on the summary report. I need the drill down isolate the &COUNTRY2 value. To do that I need to determine if &COUNTRY0.EXISTS. The problem is the .EXISTS always returns 1.

December 19, 2008, 03:12 PM
focuscon
quote:

Thanks JG, your solution worked although not in the manner you might have expected. The statement
  -SET &Q=IF &TARGET.LENGTH - &SL.LENGTH EQ 0 THEN '.QUOTEDSTRING' ELSE '';
Always returned the QUOTEDSTRING, regardless if the two string lengths differed.
Thanks again. I had been struggling with this awhile. Are you still working in Munich?

December 19, 2008, 03:21 PM
j.gross
Please post the DRILLDOWN declaration in the parent report's STYLESHEET


- Jack Gross
WF through 8.1.05
December 19, 2008, 03:44 PM
susannah
quote:
&COUNTRY = 'ENGLAND' OR 'FRANCE' OR 'ITALY'
&COUNTRY0 = 2
&COUNTRY1 = 'ENGLAND' OR 'FRANCE' OR 'ITALY'
&COUNTRY2 = ITALY


i'm with Jack... you seem to have both the 2 different flavors of mutli-select working on the same variable.
The old way (older versions of devstu ) give you 0,1,2...
The new way (newer versions of devstu) gives you &COUNTRY as a single compound filter.
So it seems your first process uses the new way and gives you a compound value for the &COUNTRY filter
and your second process is the old way,
taking that compound as &COUNTRY1 and adding ITALY to it as &COUNTRY2...which gives you a &COUNTRY0 count of 2.
it seems more complicated than it needs to be.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
December 20, 2008, 03:13 AM
<JG>
focuscon

quote:
Always returned the QUOTEDSTRING, regardless if the two string lengths differed.

Very strange, on my system it returns correctly

 
-SET &Q=IF &TARGET.LENGTH - &SL.LENGTH  EQ 0 THEN '.QUOTEDSTRING' ELSE '';
-TYPE Q IS &Q.EVAL

returns
for country
-SET &Q=IF 32 - 26  EQ 0 THEN '.QUOTEDSTRING' ELSE '';
-TYPE Q IS
Q IS

for car
-SET &Q=IF 10 - 10  EQ 0 THEN '.QUOTEDSTRING' ELSE '';
-TYPE Q IS .QUOTEDSTRING
Q IS .QUOTEDSTRING

for model
-SET &Q=IF 18 - 18  EQ 0 THEN '.QUOTEDSTRING' ELSE '';
-TYPE Q IS .QUOTEDSTRING
Q IS .QUOTEDSTRING

December 22, 2008, 01:17 PM
j.gross
"focuscon" --

quote:
I need the drill down [to] isolate the &COUNTRY2 value. To do that I need to determine if &COUNTRY0.EXISTS. The problem is the .EXISTS always returns 1.


Not really, just test &COUNTRY2.EXISTS


I am guessing that you mean
- there could be several BY variables (such as represented by &COUNTRY2=Italy in your sample),
- and you expect them to be passed in as a series of indexed & variables,
- and you are trying to use the method in Using a Dynamic Multi-Select Drop-Down List to handle the list
- but the #1 entry ("&COUNTRY1" with "'value' OR 'value' OR 'value'") is muddying the waters.
As I suggested earlier, make the names of your two sources of values distinct, and everything will fall in place.


If you still need help with this, post the essentials of the 'parent' table's drilldown (the drilldown declaration in the stylesheet, and the verb and verb-objects and BY phrases for decyphering column-references in the drilldown), plus aa actual drilldown URL from the generated parent report.

-j.g.