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.



Read-Only Read-Only Topic
Go
Search
Notify
Tools
TRUNCATING DECIMALS
 Login/Join
 
Gold member
posted
I'm stuck on how to truncate decimals in Webfocus.

I want to truncate for example:

3456.7891 to 3456.7 * I don't want to round off to 3456.8

I don't think there is a trunc command in webfocus


WF 8105M
- Portal, Dashboard
- Rcaster, Data Migrator
- Windows 2012 Client Server
- Dev/App Studio 8105
- Data: SQL, Oracle, Neteeza,MVS
 
Posts: 78 | Registered: October 24, 2006Report This Post
Guru
posted Hide Post
Here's a post with several ways to truncate.

Truncating


Glenda

In FOCUS Since 1990
Production 8.2 Windows
 
Posts: 301 | Location: Galveston, Texas | Registered: July 07, 2004Report This Post
Virtuoso
posted Hide Post
oh too funny

( we need a smiley for head spinning out of control)


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
 
Posts: 1903 | Location: San Antonio | Registered: February 28, 2005Report This Post
Guru
posted Hide Post
Sorry guys. I never professed to be a teacher. I was just giving another example of how it could be accomplished. I guess I should have broken it out for those that like to see the fields built one at a time.

Maybe this helps:

DEFINE FILE CAR
TAX/D12.4 = .08125;
SALESTAX/D12.4 = RETAIL_COST * TAX;
-*MULTIPLY SALESTAX BY 100 AND CONVERT TO ALPHA
FTOA_SALESTAX/A14 = FTOA(SALESTAX*100, '(D12.2)', 'A14');
-*FIND THE POSITION OF THE DECIMAL
POSIT_DECIMAL/I2 = POSIT(FTOA_SALESTAX, 14, '.', 1, 'I2');
-*USE SUBSTR TO KEEP EVERYTHING TO THE LEFT OF THE DECIMAL
SUBSTR_SALESTAX/A14 = SUBSTR(14, FTOA_SALESTAX, 1, POSIT_DECIMAL-1, 14, 'A14');
-*REMOVE THE COMMAS
STRIP_SALESTAX/A14 = STRIP(14,SUBSTR_SALESTAX, ',', 'A14');
-*CONVERT BACK TO NUMERIC AND DEVIDE BY 100
TRUNC_SALESTAX/D12.2 = EDIT(STRIP_SALESTAX)/100;
END

TABLE FILE CAR
PRINT
RETAIL_COST
TAX
SALESTAX
TRUNC_SALESTAX
COMPUTE DRIVEOUT/D12.2 = RETAIL_COST + TRUNC_SALESTAX;
ON TABLE PCHOLD FORMAT EXL2K
END
-EXIT


Glenda

In FOCUS Since 1990
Production 8.2 Windows
 
Posts: 301 | Location: Galveston, Texas | Registered: July 07, 2004Report This Post
Gold member
posted Hide Post
Thanks Glenda that was helpful!!!

That a lot of steps to truncate something thou...


WF 8105M
- Portal, Dashboard
- Rcaster, Data Migrator
- Windows 2012 Client Server
- Dev/App Studio 8105
- Data: SQL, Oracle, Neteeza,MVS
 
Posts: 78 | Registered: October 24, 2006Report This Post
Gold member
posted Hide Post
Try:

DEFINE FILE CAR
INVAL/D12.4 WITH CAR = 3456.7891 ;
MYT/D12.4 = INT(INVAL*10)/10 ;
END
TABLE FILE CAR
PRINT INVAL MYT
IF RECORDLIMIT EQ 1
END


IBI Development
 
Posts: 61 | Registered: November 15, 2005Report This Post
Expert
posted Hide Post
Nice and clean. Works with
MYT/D12.1 = INT(INVAL*10)/10 ; 
as well.


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Virtuoso
posted Hide Post
No Glenda...that's a lot of nice stuff. Smiler


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
 
Posts: 1903 | Location: San Antonio | Registered: February 28, 2005Report This Post
Gold member
posted Hide Post
Francis even better!!!


WF 8105M
- Portal, Dashboard
- Rcaster, Data Migrator
- Windows 2012 Client Server
- Dev/App Studio 8105
- Data: SQL, Oracle, Neteeza,MVS
 
Posts: 78 | Registered: October 24, 2006Report This Post
Expert
posted Hide Post
This is Edward's glory, not mine Smiler


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Gold member
posted Hide Post
Ok guys.

Gotta another question.

How would you truncate the other way around.

3456.7891 to .7891 ???


WF 8105M
- Portal, Dashboard
- Rcaster, Data Migrator
- Windows 2012 Client Server
- Dev/App Studio 8105
- Data: SQL, Oracle, Neteeza,MVS
 
Posts: 78 | Registered: October 24, 2006Report This Post
Expert
posted Hide Post
How about
DEFINE FILE CAR
VAL1/D12.4 WITH CAR = 3456.7891 ;
VAL2/D12 = INT(VAL1);
VAL3/D12.4 = VAL1 - VAL2;
END
TABLE FILE CAR
PRINT VAL1 VAL2 VAL3
IF RECORDLIMIT EQ 1
END


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Gold member
posted Hide Post
OK figured it out.

Is there another shortcut beside this method

PARTIAL/A19 = FTOA(SHARES, '(D15.4)', 'A19');
PARTIAL1/A19 = EDIT(PARTIAL,'$$$$$$$$$$$$$99999');
PARTIAL2/D15.4 = EDIT(PARTIAL1);


WF 8105M
- Portal, Dashboard
- Rcaster, Data Migrator
- Windows 2012 Client Server
- Dev/App Studio 8105
- Data: SQL, Oracle, Neteeza,MVS
 
Posts: 78 | Registered: October 24, 2006Report This Post
Virtuoso
posted Hide Post
How about DMOD

VAL1/D12.4 WITH CAR=3456.7891;
VAL2/D2.4  = DMOD(VAL1, 1, VAL2);
END




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Virtuoso
posted Hide Post
Althought the solution Glenda posted works I think it is far to complex.
The available formats give you the posibility to do this in a more mathematical way.

And just to show you the difference I would suggest to rus this small program and see ...


DEFINE FILE CAR
VAL1/D12.5=1234.5678;
VALUPDEC/D12.2=VAL1;
VALUPPACK/P12.2=VAL1;
VALDOWNDEC/D12.2=VAL1-.005;
VALDOWNPACK/P12.2=VAL1-.005;
END
TABLE FILE CAR
PRINT
 COUNTRY 
 VAL1
 VAL1/D12.2
 VALUPDEC
 VALUPDEC/D12.5
 VALUPPACK
 VALUPPACK/D12.5
 VALDOWNDEC
 VALDOWNDEC/D12.5
 VALDOWNPACK
 VALDOWNPACK/D12.5
ON TABLE SET PAGE-NUM OFF
ON TABLE COLUMN-TOTAL
END


And suppose you have a negativ number that should be rounded up or down...would you use Glenda's solution?

BTW please update your signature....!




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Virtuoso
posted Hide Post
I agree with Frank - there are a lot of ways to do this, but using the 'P' format has been my preferred method because of it's simplicity - no functions and very simple format redefinition (which can be done without a DEFINE in many cases.


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
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic


Copyright © 1996-2020 Information Builders