Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Running different code depending on checkbox selection

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Running different code depending on checkbox selection
 Login/Join
 
Gold member
posted
I have a guided ad-hoc application that I need to enhance. I need to add a checkbox that will calculate the measure differently if it's checked. So, I'm assuming I need to check the value of the checkbox and then depending on what it is, I will run a different section of code. I've tried different ways but I can't seem to get it to go. Here is the scaled down version of my code:

-SET &CMT_FET = IF &EXCLUDE_FET IS 'OFF' THEN ' ' ELSE '-*';
-SET &CMT_NOFET = IF &EXCLUDE_FET IS 'ON' THEN ' ' ELSE '-*';
.
.
.
.
&CMT_FET TABLE FILE SALES_COMPLETE_US
&CMT_FET SUM
&CMT_FET  COMPUTE GP%/D12.2 = ( SALES_COMPLETE_US.EXTENDED_FET_GP_DLRS / SALES_COMPLETE_US.EXTENDED_FET_PRICE ) * 100; NOPRINT AS 'GP%'
&CMT_FET  &Measures.(AND(<Qty,SALES_COMPLETE_US.SALES_COMPLETE_US.QTY>,<Sales $,SALES_COMPLETE_US.SALES_COMPLETE_US.EXTENDED_FET_PRICE>,<Cogs $,SALES_COMPLETE_US.SALES_COMPLETE_US.EXTENDED_FET_COST>,<GP$,SALES_COMPLETE_US.SALES_COMPLETE_US.EXTENDED_FET_GP_DLRS>,<GP%,GP%>).Select Measures.
&CMT_FET GOTO SORTS

&CMT_NOFET TABLE FILE SALES_COMPLETE_US
&CMT_NOFET SUM
&CMT_NOFET  COMPUTE GP%/D12.2 = ( SALES_COMPLETE_US.EXTENDED_GP_DLRS / SALES_COMPLETE_US.EXTENDED_PRICE ) * 100; NOPRINT AS 'GP%'
&CMT_NOFET  &Measures.(AND(<Qty,SALES_COMPLETE_US.SALES_COMPLETE_US.QTY>,<Sales $,SALES_COMPLETE_US.SALES_COMPLETE_US.EXTENDED_PRICE>,<Cogs $,SALES_COMPLETE_US.SALES_COMPLETE_US.EXTENDED_COST>,<GP$,SALES_COMPLETE_US.SALES_COMPLETE_US.EXTENDED_GP_DLRS>,<GP%,GP%>).Select Measures.
&CMT_NOFET GOTO SORTS

-SORTS
BY &PrimarySort
BY &SecondarySort
BY &TertiarySort
BY &Sort4
BY &Sort5

BY &ATTRIB_PROD
BY &ATTRIB_CUST
BY &ATTRIB_ORDER
  



Does anyone have an idea on a good way to do this?

Thanks!

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


WebFOCUS 7.7.03
Linux / Universe Db
HTML/PDF/EXCEL/HTML Active
 
Posts: 90 | Registered: November 03, 2009Report This Post
Expert
posted Hide Post
Branching might be better. Such as -GOTO RPTLBL_&EXCLUDE_FET.EVAL; which goes to either RPTLBL_ON or RPTLBL_OFF. Just one of many alternatives... Not that smart code is bad... just simplier... imho.
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Gold member
posted Hide Post
Are there limitations on where I can put this code? I see what you mean and I will try it. Thanks!


WebFOCUS 7.7.03
Linux / Universe Db
HTML/PDF/EXCEL/HTML Active
 
Posts: 90 | Registered: November 03, 2009Report This Post
Gold member
posted Hide Post
Here is the way my code looks now:

-GOTO EXCLFET_&EXCLUDE_FET.EVAL

-EXCLFET_OFF

 TABLE FILE SALES_COMPLETE_US
 SUM
  COMPUTE GP%/D12.2 = ( SALES_COMPLETE_US.EXTENDED_FET_GP_DLRS / SALES_COMPLETE_US.EXTENDED_FET_PRICE ) * 100; NOPRINT AS 'GP%'
  &Measures.(AND(<Qty,SALES_COMPLETE_US.SALES_COMPLETE_US.QTY>,<Sales $,SALES_COMPLETE_US.SALES_COMPLETE_US.EXTENDED_FET_PRICE>,<Cogs $,SALES_COMPLETE_US.SALES_COMPLETE_US.EXTENDED_FET_COST>,<GP$,SALES_COMPLETE_US.SALES_COMPLETE_US.EXTENDED_FET_GP_DLRS>,<GP%,GP%>).Select Measures.

-EXCLFET_ON

 TABLE FILE SALES_COMPLETE_US
 SUM
  COMPUTE GP%/D12.2 = ( SALES_COMPLETE_US.EXTENDED_GP_DLRS / SALES_COMPLETE_US.EXTENDED_PRICE ) * 100; NOPRINT AS 'GP%'
  &Measures.(AND(<Qty,SALES_COMPLETE_US.SALES_COMPLETE_US.QTY>,<Sales $,SALES_COMPLETE_US.SALES_COMPLETE_US.EXTENDED_PRICE>,<Cogs $,SALES_COMPLETE_US.SALES_COMPLETE_US.EXTENDED_COST>,<GP$,SALES_COMPLETE_US.SALES_COMPLETE_US.EXTENDED_GP_DLRS>,<GP%,GP%>).Select Measures.


BY &PrimarySort
BY &SecondarySort
BY &TertiarySort
BY &Sort4
BY &Sort5

BY &ATTRIB_PROD
BY &ATTRIB_CUST
BY &ATTRIB_ORDER  



It's blowing up on the 2nd TABLE command because it is dropping through to that code after it runs the first section. How do I tell it to skip over that part and move on to the sorts?


WebFOCUS 7.7.03
Linux / Universe Db
HTML/PDF/EXCEL/HTML Active
 
Posts: 90 | Registered: November 03, 2009Report This Post
Guru
posted Hide Post
Try adding the -GOTO and the associated - Tag
-GOTO EXCLFET_&EXCLUDE_FET.EVAL

-EXCLFET_OFF

TABLE FILE SALES_COMPLETE_US
SUM
COMPUTE GP%/D12.2 = ( SALES_COMPLETE_US.EXTENDED_FET_GP_DLRS / SALES_COMPLETE_US.EXTENDED_FET_PRICE ) * 100; NOPRINT AS 'GP%'
&Measures.(AND(,,,,).Select Measures.
-* New line
-GOTO FINISHIT
-* New line
-EXCLFET_ON

TABLE FILE SALES_COMPLETE_US
SUM
COMPUTE GP%/D12.2 = ( SALES_COMPLETE_US.EXTENDED_GP_DLRS / SALES_COMPLETE_US.EXTENDED_PRICE ) * 100; NOPRINT AS 'GP%'
&Measures.(AND(,,,,).Select Measures.
-* other new line
-FINISHIT
-* other new line

BY &PrimarySort
BY &SecondarySort
BY &TertiarySort
BY &Sort4
BY &Sort5

BY &ATTRIB_PROD
BY &ATTRIB_CUST
BY &ATTRIB_ORDER


WF 7.6.11
Oracle
WebSphere
Windows NT-5.2 x86 32bit
 
Posts: 398 | Registered: February 04, 2008Report This Post
Gold member
posted Hide Post
Great!! That got me through to where it is running the right piece of code and moving on. However, it also exposed another problem. In my Measures list, the values being passed in are coming from the HTML page. The user can choose any number of these measure to be calculated and the checkboxes associated with them have specific fields assigned to them in the Parameters tab of HTML composer. How do I get the code to recognize that it has to use a different set of measures if that EXCLUDE_FET checkbox is checked?


WebFOCUS 7.7.03
Linux / Universe Db
HTML/PDF/EXCEL/HTML Active
 
Posts: 90 | Registered: November 03, 2009Report This Post
Guru
posted Hide Post
Without knowing the particulars, you can do a
-SET &something=IF &VAR EQ 'A' THEN 'WHATE' ELSE 'WHATF;

Then in your code do

PRINT &something ....


WF 7.6.11
Oracle
WebSphere
Windows NT-5.2 x86 32bit
 
Posts: 398 | Registered: February 04, 2008Report This Post
Gold member
posted Hide Post
Quite honestly - I'm not clear on what you are trying to tell me.


WebFOCUS 7.7.03
Linux / Universe Db
HTML/PDF/EXCEL/HTML Active
 
Posts: 90 | Registered: November 03, 2009Report This Post
Virtuoso
posted Hide Post
quote:
How do I get the code to recognize that it has to use a different set of measures if that EXCLUDE_FET checkbox is checked?


Use virtual (defined) fieldnames, instead of database fields, as "values" in the selection control. Code the DEFINE both ways,

DEFINE FILE SALES_COMPLETE_US
sales/D12.2=SALES_COMPLETE_US.SALES_COMPLETE_US.EXTENDED_FET_PRICE;
etc
END

DEFINE FILE SALES_COMPLETE_US
sales/D12.2=SALES_COMPLETE_US.SALES_COMPLETE_US.EXTENDED_PRICE;
etc
END

and provide a conditional execution structure (gotos and labels) to execute the appropriate DEFINE sequence depending on the value of &EXCLUDE_FET.

If the format of the defined fields exactly matches the usage in the MFD, the TABLE-to-SQL translator should be smart enough to pass the summation on to the database server.

Note that, if you are using the autoprompt feature to generate the HTML parameter selection page dynamically, the prompt for &Measures is triggered by the first occurence of &Measures in the code (regardless of whether that line will be reached in execution); the method I suggest overcomes that issue.


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Guru
posted Hide Post
-SET &COMPIR=IF &EXCLUDE_FET IS 'OFF' THEN 'SALES_COMPLETE_US.EXTENDED_FET_GP_DLRS / SALES_COMPLETE_US.EXTENDED_FET_PRICE' ELSE
- '&SALES_COMPLETE_US.EXTENDED_GP_DLRS / SALES_COMPLETE_US.EXTENDED_PRICE';


Then in the body of the fex
COMPUTE GP%/D12.2 = &COMPIR / 100.

play with this logic and see how you like it. You msy have to use '' etc.


WF 7.6.11
Oracle
WebSphere
Windows NT-5.2 x86 32bit
 
Posts: 398 | Registered: February 04, 2008Report This Post
Gold member
posted Hide Post
Thank you all very much!!! I was able to use Jack's suggestion and got it to work like a charm. I appreciate your suggestion too RSquared and I will keep that in mind for the future. I'm sure I will be running in to these situations rather frequently. Thanks again!


WebFOCUS 7.7.03
Linux / Universe Db
HTML/PDF/EXCEL/HTML Active
 
Posts: 90 | Registered: November 03, 2009Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Running different code depending on checkbox selection

Copyright © 1996-2020 Information Builders