Introduction
Numeric fields are stored in the database without any formatting whatsoever. Apply format (sometimes called edit codes as well) codes to numeric fields allows you to add formatting to make your numerical values more readable for your end-user. For instance instead of showing your user a value of 9876532, a format code would allow you to instead show the value as $9,876,532. The value, of course is the same but the additional formatting makes it much easier to quickly read and better understand the value.
m-Power ships with many format codes by default (see table below), but you can also create your own custom format codes as well.
Overview
Defined edit codes are stored in a text file /mrcjava/mrcclasses/editcode.txt which includes default and mrc pre-defined codes. The mrc pre-defined codes are called user defined code, so you can either change or define your new edit code within this section.
Summary of Default Edit Codes
Edit Code Name | Commas | Decimal point | Sign for Negative | Decimal or Blank | Positive Example | Negative Example |
None | No | No | No Sign | 1234567 | 1234567 | |
1 | Yes | Yes | No Sign | .00 or 0 | 12,345.67 | 12,345.67 |
2 | Yes | Yes | No Sign | Blanks | 12,345.67 | 12,345.67 |
3 | No | Yes | No Sign | .00 or 0 | 12345.67 | 12345.67 |
4 | No | Yes | No Sign | Blanks | 12345.67 | 12345.67 |
A | Yes | Yes | CR | .00 or 0 | 12,345.67 | 12,345.67CR |
B | Yes | Yes | CR | Blanks | 12,345.67 | 12,345.67 |
C | No | Yes | CR | .00 or 0 | 12345.67 | 12345.67CR |
D | No | Yes | CR | Blanks | 12345.67 | 12345.67CR |
J | Yes | Yes | – (minus) | .00 or 0 | 12,345.67 | 12,345.67- |
K | Yes | Yes | – (minus) | Blanks | 12,345.67 | 12,345.67- |
L | No | Yes | – (minus) | .00 or 0 | 12345.67 | 12345.67- |
M | No | Yes | – (minus) | Blanks | 12345.67 | 12345.67- |
Y | No | No | No Sign | 1234567 | 1234567 | |
Z | No | No | No Sign | 1234567 | 1234567 | |
N | Yes | Yes | – (floating) | .00 or 0 | 12,345.67 | -12,34567 |
O | Yes | Yes | – (floating) | Blanks | 12,345.67 | -12,34567 |
P | No | Yes | – (floating) | .00 or 0 | 12345.67 | -12345.67 |
Q | No | Yes | – (floating) | Blanks | 12345.67 | -12345.67 |
Specifying Your own Edit Word
The following is a brief explanation of the rules for defining an edit word.
— Any character other than a space, ampersand (&), zero, asterisk (*), decimal point (.), comma (,), minus sign (-), or CR will be treated as a literal and will be printed wherever it occurs. — No literal will be printed which occurs to the left of the first significant digit in a number. — A blank in the edit word will be replaced with the digit from the corresponding position of the data field. — An ampersand will be replaced by a space. — To stop suppression of leading zeros, place a zero or an asterisk in the farthest right position where zero suppress is to stop. A zero will cause leading zeros to be replaced with spaces. An asterisk will cause leading zeros to be replaced with asterisks. — Either a minus sign or CR may be used to indicate a negative number. Whichever one is used, it must appear to the right of the last digit in the number. If a number is positive, the minus sign or CR will be replaced by spaces. — Commas or decimal points which occur to the left of the first significant digit of a number will not be printed. |
As an example of how these rules are applied, the following is the edit word customer account number where the first six digits are the base customer number and the last three digits are a location code:
0____-___ where the underscores indicate spaces.
The zero indicates that leading zero suppression stops in the first digit of the customer number. The minus sign is treated as a literal since it is not to the right of the last digit in the number. If a customer’s account number was 000234001, this edit word would cause the number to be displayed as 00234-001.