Focal Point
[SOLVED] Convert alpha to numeric after readfile

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

May 13, 2015, 08:34 AM
Jay Potter
[SOLVED] Convert alpha to numeric after readfile
I have 2 variables created from a readfile command that are intergers. I also have 2 variables created from a readfile command that are D9.2. I am trying to use these variables to create percentage variables. I originally tried to just divide the 2 variables, but I got an error indicating I was trying to calculate alpha variables. I also have tried the following commands. I keep getting the value of 0.

-SET &NUMBEROFRX_PER = (ATODBL(&NUMBEROFRX_25, '13', I6)/ATODBL(&NUMBEROFRX_ALL, '13', I6)) * 100;

-SET &HOSPICECHARGE_PER = (ATODBL(&HOSPICECHARGE_25, '13', D9.2)/ATODBL(&HOSPICECHARGE_ALL, '13', D9.2)) * 100;

This message has been edited. Last edited by: Jay Potter,


WebFocus 8.1.5
iSeries/Windows
DB2/SQL/Access
Dev Studio
App Studio
Maintain
ReportCaster
May 13, 2015, 09:41 AM
MartinY
It does work well Jay, maybe you have another issue. Maybe precision ?
SET DMPRECISION = 2
DEFINE FILE CAR
RC /P9.2 = RETAIL_COST + .25;
DC /P9.2 = DEALER_COST + .33;
END
TABLE FILE CAR
PRINT RC DC
BY COUNTRY NOPRINT
WHERE COUNTRY EQ 'FRANCE';
ON TABLE SAVE AS HLD FORMAT ALPHA
END
-RUN

-READ HLD &RCOST.I9. &DCOST.I9.
-RUN

-TYPE &RCOST, &DCOST

-SET &RATE = &RCOST / &DCOST;
-TYPE &RATE
-SET &RATE2 = ((ATODBL(&RCOST, '9', P9.2) + 1.25) * 15) / (ATODBL(&DCOST, '9', P9.2) + 4.33);
-TYPE &RATE2



WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
May 13, 2015, 11:36 AM
Jay Potter
Thanks for at least confirming that the command I was using was correct. I backed up a few steps and started again and I got it to work. Who knows what I did wrong the first time.


WebFocus 8.1.5
iSeries/Windows
DB2/SQL/Access
Dev Studio
App Studio
Maintain
ReportCaster