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 - SET Variable Format Question

Read-Only Read-Only Topic
Go
Search
Notify
Tools
SOLVED - SET Variable Format Question
 Login/Join
 
Platinum Member
posted
I have a series of -SET variables that I'm trying to assign the format to:

-SET &TOTAL01= &RECORDS;
-SET &TOTAL01PCT= &RECORDS * .90;
-SET &TOTAL02PCT= &RECORDS * .10;


I noticed that when the value for &TOTAL01 is equal to 181, that the value of &TOTAL01PCT is 162, and the value of &TOTAL02PCT is 18. This does not total the original 181.

I think the problem is that 181 * .90 is actually 162.9, but the SET variable is actually returning 162.

Is there a way to apply formatting to the SET variable so that this will round correctly?

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


Production - 7.6.4
Sandbox - 7.6.4
 
Posts: 241 | Location: Bethesda, MD | Registered: August 14, 2007Report This Post
Platinum Member
posted Hide Post
Hi,

You can use the DMPRECISION setting before the calculation and to whatever the precision is.

  
SET DMPRECISION = 2
-RUN


Best Regards,

Jimmy Pang


DEV: WF 7.6.10
TEST: WF 7.6.10
PROD: WF 7.6.10
MRE: WF 7.6.4
OS/Platform: Windows
Dev Studio: WF 7.7
Output: HTML, EXCEL, PDF, GRAPH, LOTUS, CSV
 
Posts: 117 | Location: Toronto, Ontario, Canada | Registered: February 29, 2008Report This Post
Expert
posted Hide Post
quote:
SET DMPRECISION = 2
-RUN


Doesn't work for DM commands, this does:

  
-SET &TOTAL01   = 181;
-SET &TOTAL01PCT= (&TOTAL01 * .90) * 100;
-SET &TOTAL02PCT= (&TOTAL01 * .10) * 100;
-SET &TOTAL01_PCT = IF &TOTAL01PCT.LENGTH EQ 5 THEN EDIT(&TOTAL01PCT,'999.9') ELSE
-                   IF &TOTAL01PCT.LENGTH EQ 4 THEN EDIT(&TOTAL01PCT,'99.9')  ELSE
-                   IF &TOTAL01PCT.LENGTH EQ 3 THEN EDIT(&TOTAL01PCT,'9.9')   ELSE EDIT(&TOTAL01PCT,'.9');
-SET &TOTAL02_PCT = IF &TOTAL02PCT.LENGTH EQ 5 THEN EDIT(&TOTAL02PCT,'999.9') ELSE
-                   IF &TOTAL02PCT.LENGTH EQ 4 THEN EDIT(&TOTAL02PCT,'99.9')  ELSE
-                   IF &TOTAL02PCT.LENGTH EQ 3 THEN EDIT(&TOTAL02PCT,'9.9')   ELSE EDIT(&TOTAL01PCT,'.9');

-TYPE &TOTAL01_PCT
-TYPE &TOTAL02_PCT
-EXIT


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
Expert
posted Hide Post
quote:
Doesn't work for DM commands

??????

Then why does this -
SET DMPRECISION = 2
-RUN
-SET &TOTAL01   = 181;
-SET &TOTAL01PCT= &TOTAL01 * 0.90;
-SET &TOTAL02PCT= &TOTAL01 * 0.10;
-? &TOTAL

give this
 CURRENTLY DEFINED & VARIABLES STARTING WITH 'TOTAL':
 &TOTAL01      = 181
 &TOTAL01PCT   = 162.9
 &TOTAL02PCT   = 18.1

If the requirement is to have "correctly" rounded integers then I would be inclined to force the rounding and go with this -
-SET &TOTAL01   = 181;
-SET &TOTAL01PCT= (&TOTAL01 * 0.90) + 0.5;
-SET &TOTAL02PCT= (&TOTAL01 * 0.10) + 0.5;
-? &TOTAL

Don't forget that if you used a multiplier of .5 in this example then you would get 91 and 91 so you need to know the data you are handling and code accordingly.

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 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Platinum Member
posted Hide Post
Hi,

Seems to work for me

  

-SET &TOTAL01   = 181; 
-SET &TOTAL01PCT= &TOTAL01 * .90;
-TYPE &TOTAL01PCT

SET DMPRECISION = 2
-RUN

-SET &TOTAL01PCT= &TOTAL01 * .90;
-TYPE &TOTAL01PCT



My output is
162
162.9

The first output is before the DMPRECISION is set (default is OFF)

Bst Regards,

Jimmy Pang


DEV: WF 7.6.10
TEST: WF 7.6.10
PROD: WF 7.6.10
MRE: WF 7.6.4
OS/Platform: Windows
Dev Studio: WF 7.7
Output: HTML, EXCEL, PDF, GRAPH, LOTUS, CSV
 
Posts: 117 | Location: Toronto, Ontario, Canada | Registered: February 29, 2008Report This Post
Expert
posted Hide Post
Jimmy,

You are absolutely correct. I used it above the 1st -SET, not the 2nd. Much cleaner/easier!!

Thanks!


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
Platinum Member
posted Hide Post
What if I want the 162.9 to round up to 163?


Production - 7.6.4
Sandbox - 7.6.4
 
Posts: 241 | Location: Bethesda, MD | Registered: August 14, 2007Report This Post
Platinum Member
posted Hide Post
Hi,

You can try DMPRECISION = 0

Best Regards,

Jimmy Pang


DEV: WF 7.6.10
TEST: WF 7.6.10
PROD: WF 7.6.10
MRE: WF 7.6.4
OS/Platform: Windows
Dev Studio: WF 7.7
Output: HTML, EXCEL, PDF, GRAPH, LOTUS, CSV
 
Posts: 117 | Location: Toronto, Ontario, Canada | Registered: February 29, 2008Report This Post
Platinum Member
posted Hide Post
Thank you. This appears to be working.

You all are the best!


Production - 7.6.4
Sandbox - 7.6.4
 
Posts: 241 | Location: Bethesda, MD | Registered: August 14, 2007Report 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 - SET Variable Format Question

Copyright © 1996-2020 Information Builders