Blog Archive

iSeries RPGLE Edit Codes - For use in %editc() and EDTCDE on AS400

How to use the Edit Code

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

This function returns a character result representing the numeric value edited according to the edit code. In general, the rules for the numeric value and edit code are identical to those for editing numeric values in output specifications. The third parameter is optional, and if specified, must be one of:

Indicates that asterisk protection is to be used. This means that leading zeros are replaced with asterisks in the returned value. For example, %EDITC(-0012.5 : 'K' : *ASTFILL) returns '***12.5-'.

Indicates that a floating currency symbol is to be used. The actual symbol will be the one specified on the control specification in the CURSYM keyword, or the default, '$'. When *CURSYM is specified, the currency symbol is placed in the the result just before the first significant digit. For example, %EDITC(0012.5 : 'K' : *CURSYM) returns ' $12.5 '.

Indicates that floating currency is to be used with the provided currency symbol. It must be a 1-byte character constant (literal, named constant or expression that can be evaluated at compile time). For example, %EDITC(0012.5 : 'K' : 'X') returns ' X12.5 '.

Edit Code Description No Sign CR Sign Sign '-' Right Sign '-' Left
Commas and Zero Balances 1 A J N
Commas 2 B K O
Zero Balances 3 C L P
No Commas or Zero Balances 4 D M Q
Date Edit (4 Digits) W      
No Edit - Sign Suppression X      
Date Edit Y      
Leading Zeros Suppressed Z