Focal Point
convert alfanumeric filed in numeric

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

July 20, 2007, 10:23 AM
roby
convert alfanumeric filed in numeric
Hi
i have field in focus like type is A17. (this filed contains 12345678,99)
I want display to P15.2 format.
Please how to solve this problem.
July 20, 2007, 12:00 PM
Darin Lee
Try your documentation - ATODBL


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
July 20, 2007, 02:38 PM
Leah
As Darin says atodbl works; we did have an issue with a very large number losing the last digits value. Not sure if it will like the imbedded comma or not.


Leah
July 26, 2007, 10:23 AM
Kerry
Hi roby,

Has this issue been resolved? Many thanks to Darin and Leah's input.

Please try the following code:

DEFINE FILE EMPDATA     
-*if input has no commas                                         
MYA15A/A15='12345678.00';                                        
MYP152/P15.2=ATODBL(MYA15,'15','D15.2');  
-*if input has commas                       
MYA15C/A15='12,345,678.00';                                      
MYA15NC/A15=EDIT((RJUST(15,MYA15C,'A15')),'9$99$999$999999');    
MYP15WC/P15.2=ATODBL(MYA15NC,'15','D15.2');                      
END                                                              
TABLE FILE EMPDATA                                               
PRINT LN NOPRINT                                                 
MYA15A AS 'ALPHA 15'                                             
MYP152 AS 'P15.2'                                                
MYA15C AS 'ALPHA 15, WITH COMMAS'                                
MYA15NC AS 'ALPHA 15,COMMAS REMOVED'                             
MYP15WC AS 'P15.2 OF,WITHOUT COMMAS'


Hope this helps. Big Grin

Cheers,

Kerry


Kerry Zhan
Focal Point Moderator
Information Builders, Inc.
July 26, 2007, 10:36 AM
John_Edwards
Kerry is to be commended for sending an actual solution.



July 26, 2007, 11:03 AM
FrankDutch
If the comma is always on the same position you can do this

FIRST/P14.2=EDIT(ORIGINAL,'99999999999999$$$');
-* this holds the first 14 characters as a number
SECOND/P5.2=EDIT(ORIGINAL,'$$$$$$$$$$$$$$$99')/100;
RESULT/P15.2=FIRST+SECOND;

If the comma is not always on the same position you fist have to find that position with the function POSIT

COMMA/I2 = POSIT(ORIGINAL, 17, ',', 1, 'I2');

Based on the result you do more or less the same.
remove the comma from the string with STRREP function and then convert the string to a number.

Now that number is to big, it has to be divided by 10, 100, 1000 or 10.000 based on the position the comma was.

suppose the result of the formula COMMA was 13, than the divider is:

17-13=4 that makes 10^4 is 10.000

I hope this helps.

If you want to display the result as a value with a comma than use the SET command
SET CDN=ON




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

July 26, 2007, 11:31 AM
Darin Lee
Sometimes you learn things a little better if you have to do some of the work yourself. IMO, if it's pretty clear in the docs (which is not always the case) you should try that first instead of asking others to fix your problem.

But yes, Kerry is very helpful and consistently follows up on issues. Thanks.


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
July 26, 2007, 12:54 PM
Tony A
I'm with you there Darin.

Posting a solution is OK in most situations but where there is a distinct lack of training it does nothing to help the individual, and their management must be rubbing their hands when they think of all the free work they're getting done for them!

I'm all for helping those who show an attempt at solving their problem by stating what they have so far ....

Off the soapbox I go .. Wink

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