Focal Point
test for specific user input parameter [SOLVED]
January 20, 2011, 02:24 PM
Tomsweb test for specific user input parameter [SOLVED]
I have a user supplied parameter which could be any one of 6 values (ie. agegrp, county, race, etc.)
I have a define to assign flag ('1') for user selection of AGEGRP and ('0') for any of the other 5 values.
Here is my code:
quote:
-SET &RPTTYPE = 'RACE'; -SET &XFNT = &RPTTYPE | '_' | 10 | '_' | A; -TYPE XFNT = &XFNT DEFINE FILE RACE_10_A QFLAG/A1 = IF RACE EQ 'AGEGRP' THEN '1' ELSE '0'; END TABLE FILE RACE_10_A SUM QFLAG END -RUN
The problem I am having is that I cannot get a
onsistent answer (1 or 0) when I run it.
Is there someting I am missing here?
Thanks!
This message has been edited. Last edited by: Tomsweb , January 21, 2011 11:30 AM Tomsweb WebFOCUS 8.1.05M, 8.2.x APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports Apache Tomcat/8.0.36
January 20, 2011, 02:34 PM
Francis Mariani What are you expecting to have returned in the report? You will get one value for QFLAG, the last one read.
TABLE FILE RACE_10_A
SUM
QFLAG
END
-RUN 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
January 20, 2011, 02:42 PM
<JG> quote:
TABLE FILE RACE_10_A SUM QFLAG
Francis hits it on the head.
SUM means SUM,.
In WebFOCUS for ALPHA values that means the last value ,
for numerics it means the sum of the values.
Ask the right question and you get the right answer.
January 20, 2011, 02:43 PM
Tomsweb Hi Francis
No, I am actually trying to create other define logic based on whether user selected
to work with race table or the agegrp table. The table request is there to see if the
define field matched the user input parameter.
Thanks,
Tomsweb WebFOCUS 8.1.05M, 8.2.x APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports Apache Tomcat/8.0.36
January 20, 2011, 03:01 PM
Tomsweb JG?
Again, the user selects from among 6 values for the table to report against.
I am trying to build some logic to have the data in the agegrp table handled a little differently than data in the other tables.
So, the question is:
-SET &RPTTYPE = 'AGEGRP';
-SET &XFNT = &RPTTYPE | '_' | 10 | '_' | A;
DEFINE FILE &XFNT
QFLAG/A1 = IF &RPTTYPE EQ 'AGEGRP' THEN '1' ELSE '0';
END
When I look at the QFLAG field above, I'm expecting to get a value of '1' because in
this case, the value of &RPTTYPE does EQ 'AGEGRP'.
But I am getting '0' for my answer. What is wrong that I am getting a '0', when I think
I should be getting a '1'?
Thanks!
Tomsweb WebFOCUS 8.1.05M, 8.2.x APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports Apache Tomcat/8.0.36
January 20, 2011, 04:04 PM
Waz Makesure you put quotes around the amper variable, otherwise it will think it is a field.
DEFINE FILE &XFNT
QFLAG/A1 = IF '&RPTTYPE' EQ 'AGEGRP' THEN '1' ELSE '0';
END Waz... Prod: WebFOCUS 7.6.10/8.1.04 Upgrade: WebFOCUS 8.2.07 OS: Linux Outputs: HTML, PDF, Excel, PPT In Focus since 1984 Pity the lost knowledge of an old programmer!
January 20, 2011, 04:24 PM
Tomsweb Thanks Waz,
Here is the error I get if the user selection does not match AGEGRP:
quote:
-SET &RFMT = 'HTML'; -SET &RPTTYPE = 'RACE'; -SET &XFNT = RACE | '_' | 10 | '_' | A; DEFINE FILE RACE_10_A QFLAG/A1 WITH AGEGRP = IF 'RACE' EQ 'AGEGRP' THEN '1' ELSE '0'; END TABLE FILE RACE_10_A PRINT QFLAG END -RUN
0 ERROR AT OR NEAR LINE 12 IN PROCEDURE agegrp_break
(FOC003) THE FIELDNAME IS NOT RECOGNIZED: AGEGRP
0 ERROR AT OR NEAR LINE 43 IN PROCEDURE agegrp_break
(FOC003) THE FIELDNAME IS NOT RECOGNIZED: QFLAG
BYPASSING TO END OF COMMAND
(FOC009) INCOMPLETE REQUEST STATEMENT
-EXIT
[/QUOTE]
Here is what I get if the user selection matches AGEGRP:
quote:
PAGE 1 QFLAG 1 1 1 1 1 1 1 1 1 1 1
I have written code to handle this sort of thing before, but today I am in qicksand !
Thanks,
Tomsweb WebFOCUS 8.1.05M, 8.2.x APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports Apache Tomcat/8.0.36
January 20, 2011, 04:35 PM
Waz The issue with with WITH.
QFLAG/A1 WITH AGEGRP = IF 'RACE' Change your code to use &RPTTYPE, or another field that exists in each table.
QFLAG/A1 WITH &RPTTYPE = IF '&RPTTYPE' EQ 'AGEGRP' THEN '1' ELSE '0';
Waz... Prod: WebFOCUS 7.6.10/8.1.04 Upgrade: WebFOCUS 8.2.07 OS: Linux Outputs: HTML, PDF, Excel, PPT In Focus since 1984 Pity the lost knowledge of an old programmer!
January 20, 2011, 04:39 PM
Tomsweb Thanks Waz. It works.
Tomsweb WebFOCUS 8.1.05M, 8.2.x APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports Apache Tomcat/8.0.36
January 20, 2011, 11:33 PM
Doug Try This:
-SET &RPTTYPE = 'RACE';
-SET &TABLE_NAME = &RPTTYPE || '_10_A' ;
-TYPE TABLE_NAME = &TABLE_NAME
DEFINE FILE &TABLE_NAME.EVAL
TOTAL_FLAG/I1 = IF '&RPTTYPE.EVAL' EQ 'TOTAL' THEN 1 ELSE 0;
END
TABLE FILE &TABLE_NAME.EVAL
PRINT JUL09 JUN10
BY TOTAL_FLAG NOPRINT
BY &RPTTYPE
END
-* STYLE SHEET
-* TYPE=DATA, BACKCOLOR=RED WHEN &RPTTYPE EQ 'TOTAL',%
-* MORE STYLES AS IN YESTERDAYS CODE
-* ENDSTYLE
-RUN