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

Please do not use to report errors- use your regional help desk.
Please mark posts as being for RPG or RDMLX (LANSA) developer.
To subscribe by email, display this forum, scroll to the end and select ‘Subscribe Forum’.
Post Reply
MarkDuignan
Posts: 346
Joined: Wed Apr 18, 2012 10:33 am

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

Post 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.
Post Reply