|
Hi Griz,
The character field I need to convert always has a decimal followed by 4 numbers. I don't know of any other way to convert an alphanumeric field and have the 4 decimal point precision.
For example:
** This code requires V5R2 or later. D CharData s 11A inz('12.2963 ') D decprice s 11P 4
/free
decprice = %dec( CharData : 11: 4);
/end-free
You can get it from the Midrange.com FAQ: http://faq.midrange.com/data/cache/52.html
Once you have it installed, you call it as follows:
decprice = getNum( CharData );
H DFTACTGRP(*NO) BNDDIR('QC2LE')
D atof PR 8F extproc('atof') D alpha * value options(*string)
D CharData s 11A inz('12.2963 ') D decprice s 11P 4
/free
decprice = %dech( atof(CharData) : 11: 4); dsply (%char(decprice)); *inlr = *on;
/end-free
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.