Sunday, October 2, 2011

EDTCODE in AS400


EDTCDE - EDITC - EDITW


Edit Code
Description
No
Sign
CR
Sign
Sign-
(R)
-Sign
(L)
Commas and zero balances1AJN
Commas2BKO
Zero balances3CLP
No commas or zero balances4DMQ
Date edit (4 digits)W   
No edit (suppress sign)X   
Date editY   
Suppress leading zerosZ   
     
User defined edit codes 5 - 9

User defined edit codes are created with the CRTEDTD or WRKEDTD commands. Any user-defined edit code will exist in library QSYS, with the name QEDIT5, QEDIT6. QEDIT7, QEDIT8 and QEDIT9.


Edit CodePositiveNegativeZeroes
112,345.6712,345.67.00
212,345.6712,345.67 
312345.6712345.67.00
412345.6712345.67 
A12,345.6712,345.67CR.00
B12,345.6712,345.67CR 
C12345.6712345.67CR.00
D12345.6712345.67CR 
J12,345.6712,345.67-.00
K12,345.6712,345.67- 
L12345.6712345.67-.00
M12345.6712345.67- 
N12,345.67-12,345.67.00
O12,345.67-12,345.67 
P12345.67-12345.67.00
Q12345.67-12345.67 


Edit codes are generally used in RPG Output specifcations,
EDTCDE & EDTWRD in DDS specifications,
%EDITC & %EDITW in Definition and Calculation specifications.

RPG Output Specifications.

The edit code is in position 44 on the same line as the field name to be edited.
An edit word can be entered in quotation marks for more specific editing.

DDS Specifications.

EDTCDE() or EDTWRD() on screen and printer dds's is entered in the section against the field name to specify how the field is displayed.  If the EDTCDE() orEDTWRD() is used on a PF dds, the keyword is used to format the field in QUERY reports.

Calculation specifications.

%EDITC in the calculations section formats a numeric field and stores it in a character field.   %TRIM can be used with this to left justify an edited field.



%EDITC has the following formats ...



%EDITC(number: editcode);12,345.67
%EDITC(number: editcode: currency);€12,345.67
%EDITC(number: editcode: *astfill);***12,345.67
%EDITC(number: editcode: *cursym);€12,345.67

where number = 0012345.67,
editcode = K,
currency = €,
*cursym = €.
*CURSYM has a default value of $.
This is defined in the system values at QCURSYM. To change the value of *CURSYM for the program, use CURSYM on the H (control) specification.
e.g. H cursym('€')



This is an example of using %EDITW ...



      %EDITW(znumber: zword);12,345Euros 67Cents

where znumber is defined as 7,2 and containes 0012345.67,
zword contains "    ,   Euros&  Cents".
(There are 4 spaces to the left of the comma, 3 spaces to the right of the comma and 2 spaces after Euros.
The & will force a space to be output, the spaces will be filled with digits from the number field.)



1 comment: