Focal Point
[SOLVED] Converting Alpha to Decimal

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/104107153

January 25, 2010, 04:51 PM
TryFocus
[SOLVED] Converting Alpha to Decimal
How to convert Alpha TO Decimal value.
  
-SET &VARIABLE1 = '258,123.25'

How to convert the above Value into Integer..?



WF 7.6
IIS
HTMl Excel, PDF

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


Prod: WF 7.6.10 windows. -- MRE/Dashboard/Self Service/ReportCaster - Windows XP
January 25, 2010, 05:30 PM
Prarie
Do a search on ATODBL..that should help you out.
January 25, 2010, 05:33 PM
Francis Mariani
-SET &ECHO=ALL;

SET DMPRECISION = 2
-RUN

-SET &VAR1 = 258123.25;
-SET &VAR2 =  &VAR1 * 1;

-TYPE &VAR1 &VAR2


Look at WebFOCUS/iWay New Features > Reporting Language > Specifying Precision for Dialogue Manager Calculations


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 25, 2010, 05:57 PM
TryFocus
Thank you for response..
I guess my question was interpretted wrong.

Variable has Alpha value ie:25,258.12

&VAR/A15 = '25,258.12' ;
I want to convert this comma seperated Alpha value to Decimal, so that I perform some computations.

Conversion from alpha to Decimal
'25,258.12' --> 25258.12

Thanks


Prod: WF 7.6.10 windows. -- MRE/Dashboard/Self Service/ReportCaster - Windows XP
January 26, 2010, 03:28 AM
Tony A
Prarie gave you the answer, however you will have to preprocess the alpha value to remove commas.

However, by the time you've stripped (hint) out the comma(s) you could then just use Francis' suggestion as it is a variable (which doesn't really have a format).

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 
January 26, 2010, 04:56 AM
Alan B
Always an interesting one this. For calculations in DM, always done in double precision, but displayed truncated unless DMPRECISION is used.

ATODBL, which seems to be needed and cannot take commas in the input string, is not needed. &variables are what they contain(ish).

So get rid of the commas, using STRREP, then the variable can be used in calculations.

The redisplay is then an issue, as 123456.70 displays as 123456.7, so use FTOA to get a full 2 decimal point display.

THEN decide how you want the result of a calculation displayed. Using F10.2 truncates the decimals and D10.2 rounds the decimals, but then D10.2 will also add the comma in and F10.2 doesn't. Go figure which you want.

SET DMPRECISION = 2
-RUN

-SET &VAR1 = '258,123.25';
-SET &LEN1 = &VAR1.LENGTH;
-SET &VAR2 = STRREP(&LEN1,&VAR1,1,',',0,'X',&LEN1,'A&LEN1.EVAL');
-SET &VAR3 = &VAR2*1.23;
-SET &VAR4 = FTOA(&VAR3,'(F10.2)','A16');
-SET &VAR5 = FTOA(&VAR3,'(D10.2)','A16');

-TYPE &VAR2 &VAR3 &VAR4 &VAR5 

gives
258123.25 317491.6 317491.59 317,491.60

The actual full precision result is 317491.5975


Alan.
WF 7.705/8.007
January 26, 2010, 05:56 AM
Tony A
Exactly Alan, but I would have used STRIP instead of STRREP -

-SET &VAR2 = STRIP(&VAR1.LENGTH, '&VAR1.EVAL', ',', 'A&VAR1.LENGTH');

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 
January 26, 2010, 08:56 AM
TryFocus
Thanks Alan B
Your solution is crystal clear.

Thanks


Prod: WF 7.6.10 windows. -- MRE/Dashboard/Self Service/ReportCaster - Windows XP