Page 1 of 1

(RPG) How to convert numbers to text and vice versa

Posted: Tue Aug 14, 2012 10:19 am
by MarkDuignan
To prepare numeric data for display as text use the RPG built in functions:

%EDITC(numeric : editcode {: *ASTFILL | *CURSYM | currency-symbol})
Or
%EDITW(numeric : editword)

To convert text input to numeric values use the RPG built in function:

%DEC(numeric expression {:digits:decpos}) – typically in a monitor block like this:

ValidNumber = True;
monitor;
num = %dec(Alpha:15:2) ;
on-error;
ValidNumber = False;
Endmon;

Refer to your RPG documentation for more details.