September 19, 2007, 12:20 PM
GlendaSorry 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
September 19, 2007, 01:39 PM
WFLurkerThanks Glenda that was helpful!!!
That a lot of steps to truncate something thou...
September 19, 2007, 02:11 PM
Edward WolfgramTry:
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
September 19, 2007, 02:18 PM
Francis MarianiNice 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
September 19, 2007, 02:18 PM
PrarieNo Glenda...that's a lot of nice stuff.
| In Focus since 1993. WebFOCUS 7.7.03 Win 2003 |
September 19, 2007, 04:27 PM
WFLurkerFrancis even better!!!
WF 8105M
- Portal, Dashboard
- Rcaster, Data Migrator
- Windows 2012 Client Server
- Dev/App Studio 8105
- Data: SQL, Oracle, Neteeza,MVS
September 19, 2007, 04:48 PM
Francis MarianiThis is Edward's glory, not mine
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
November 08, 2007, 03:51 PM
WFLurkerOk 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
November 08, 2007, 04:04 PM
Francis MarianiHow 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
November 08, 2007, 04:20 PM
WFLurkerOK 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
November 08, 2007, 04:29 PM
FrankDutchHow 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 |
November 09, 2007, 03:55 AM
FrankDutchAlthought 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 |
November 09, 2007, 11:36 AM
Darin LeeI 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