A handy little technique I noted down ages ago allows a conversion from a character field to a numeric field using an RPG IV BIF. Some sites have standard program or routines to do this but if you don't have one this might be handy.
The following code takes an alpha field value and converts it to a number before adding 10 to it just to prove it works. The one draw back to be wary of, is the occurance of alpha fields with all blanks in it. You must perform a condition before the %DEC BIF to make sure blanks are replaced with zeros or the %DEC will runtime fail.
*
*
DMyAlpha S 4A
DMyNumber S 4 0
*
*
*
/FREE
MyAlpha = '1234';
//
// Check Source For 0's Zeroes
// which in this case is not
// necessary as MyAlpha is
// hard coded to '1234'
//
If ( MyAlpha = *BLANKS );
MyAlpha = '0000';
Endif;
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.