Focal Point
Wrong result with ATODBL function

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

March 03, 2008, 10:38 AM
Jérény Deidda
Wrong result with ATODBL function
Hi,

I'm trying to convert an alphanumeric variable to a double precision format variable with the ATODBL function but there is a problem: I always become 0.00000 as result.

TABLE FILE OPP020
PRINT 
     O20TXUNITE
     O20ACOURS1
COMPUTE CHANGE/D14.7 = ATODBL('&MYVAR.EVAL','14',CHANGE);
END  


THE &MYVAR variable is the result of this:

-READ TABDEVPF &MYVAR.14  


In the master file, MYVAR is P14.7

Thanks for your help,

Jérémy.


WebFOCUS 7.6.4 running on Windows
Output formats : PDF, Excel and HTML
My blog
March 03, 2008, 10:53 AM
Leah
quote:
In the master file, MYVAR is P14.7


Which isn't alpha which is what ATODBL is supposed to have as input. It returns zero if it doesn't like the input.


Leah
March 03, 2008, 10:54 AM
Francis Mariani
-SET &ECHO=ALL;
-SET &MYVAR = 2912.12234;

TABLE FILE CAR
PRINT 
COMPUTE CHANGE/D14.7 = ATODBL('&MYVAR','&MYVAR.LENGTH',CHANGE);
COUNTRY
END


The length (second parameter for ATODBL) must be exactly the length of the data in the variable - the best way to to do this is to use &var_name.LENGTH.


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
March 03, 2008, 10:59 AM
Darin Lee
&vars are not classified as alpha or numeric. If the value contains 100 you could use it in either expression below without having to change any formats.

WHERE CODE EQ '&var';

OR

WHERE COUNTER GE &var;

The exception would be for dates. If it contains a value which will be compared as or used in further DATE computations, it needs to be converted to a smart date.

The use of quote marks tells the expression whether it is to be used as alpha or numeric.

You should just be able to say
COMPUTE CHANGE/D14.7=&MYVAR ;


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
March 03, 2008, 11:00 AM
Francis Mariani
Why didn't I think of that?


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
March 03, 2008, 11:06 AM
Jérény Deidda
Thanks Leah and Francis,

I replaced '14' by '&CHGDEVREF.LENGHTH' but it's always the same result : 0,0000000.

I think the problem is that the input format is alpha (' 0,6318400') and not 0,6318400 like your sample.

Another idea?


WebFOCUS 7.6.4 running on Windows
Output formats : PDF, Excel and HTML
My blog
March 03, 2008, 11:11 AM
Jérény Deidda
quote:
Originally posted by Darin Lee:
&vars are not classified as alpha or numeric. If the value contains 100 you could use it in either expression below without having to change any formats.

WHERE CODE EQ '&var';

OR

WHERE COUNTER GE &var;

The exception would be for dates. If it contains a value which will be compared as or used in further DATE computations, it needs to be converted to a smart date.

The use of quote marks tells the expression whether it is to be used as alpha or numeric.

You should just be able to say
COMPUTE CHANGE/D14.7=&MYVAR ;


And so what can I do? If I try this:

  
TABLE FILE OPP020
PRINT 
     O20TXUNITE
     O20ACOURS1
COMPUTE CHANGE/D14.7 = ATODBL(&MYVAR,'14',CHANGE);
END  


There is this error:

(FOC275) FOCUS FUNCTION HAS INCORRECT NUMBER OF ARGUMENTS;
(FOC009) INCOMPLETE REQUEST STATEMENT BYPASSING TO END OF COMMAND


WebFOCUS 7.6.4 running on Windows
Output formats : PDF, Excel and HTML
My blog
March 03, 2008, 11:20 AM
Darin Lee
What I was saying is that there is no need to use the ATODBL function.

COMPUTE CHANGE/D14.7=&MYVAR ;
And it appears that you need to make sure the CDN setting is correct (ON)


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
March 03, 2008, 11:23 AM
Francis Mariani
I think you will have to change the "," to a "." - I don't think functions or DEFINE/COMPUTE can handle "," as the decimal separator.

SET CDN = ON/OFF/SPACE/QUOTE only works for displaying data in a report.


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
March 03, 2008, 11:50 AM
Darin Lee
Not quite sure how this worked for the other side of the pond.


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
March 04, 2008, 02:39 AM
Jérény Deidda
Thanks Darin,

the problem is solved.


WebFOCUS 7.6.4 running on Windows
Output formats : PDF, Excel and HTML
My blog
March 04, 2008, 10:48 AM
Francis Mariani
How?


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