Does anyone have any ideas for a routine to trim leading and trailing zeros from a numeric field that is zoned(7:4) and plop them into a character field.
Thanks
Thanks
dcl-s str varchar(10); str = %char(num); // get 00123.5600 as the string '123.4500' str = %trimr(str : '0'); // Trim trailing zeros from the decimal places str = %trimr(str : '.'); // Trim the decimal point if the decimal places were all zero if %subst(str : 1 : 1) = '.'; // If the first character is the decimal point str = '0' + str; // Change '.123' to '0.123' endif;
ctl-opt decedit('0.'); . . dcl-s str varchar(20); str = %trimr(%trimr(%char(num):'0'):'.');
Comment