EDTWRD (Edit Word) keyword for display files

You use this field-level keyword to specify an edit word if you cannot obtain the editing that you want through the EDTCDE keyword.

The format of the keyword is:
EDTWRD('edit-word')

An edit word specifies the form in which the field values are to be displayed and clarifies the data by inserting characters directly, such as decimal points, commas, floating- and fixed-currency symbol, and credit balance indicators. The edit word can also be used to suppress leading zeros and to provide asterisk fill protection.

If a field previously defined in a database file has EDTWRD specified, you need not specify EDTWRD for that field in the display file. You can specify R in position 29 to refer to the previously defined field. The editing specified for the referenced field is included in the display file. However, if you also specify length, data type, or decimal positions for a display file field, editing specified for the referenced field is not included in the display file, and you must specify editing again in the display file.

Parts of an edit word

An edit word consists of three parts: the body, the status, and the expansion. Figure 1 shows the three parts of an edit word.

Figure 1. Three parts of an edit word
Three parts of an edit word: the body, the status, and the expansion.

The body is the space for the digits transferred from the data field to the output record. The body begins at the farthest left position of the edit word. The number of blanks (plus one for a zero or an asterisk) it contains is equal to the number of digits of the data field to be edited. If the zero or asterisk is the first character in the edit word, the number of blanks it contains might equal the number of digits in the data field. The body ends with the farthest right character that can be replaced by a digit.

The status positions display the sign (+ or -) of the data field. The status continues to the right of the body to either a CR (credit) or - (minus) symbol. These two symbols print only when the field is negative. Edit words without the CR or - symbol have no status positions.

The expansion positions are not changed by the edit operation. The expansion starts at the first position to the right of the status (or body, if status is not specified) and ends with the farthest right character of the edit word.

Forming the body of an edit word

The following characters have special meanings when used in the body of an edit word.

Blank
A blank is replaced with the character from the corresponding position of the data field. A blank position is referred to as a digit position.
Ampersand
An ampersand causes a blank in the edited field. The ampersand is not displayed. Note that ampersands specified in the edit word between blanks can result in incorrect data when specified for an input/output field. This is because embedded blanks in a numeric-only field are converted to zeros.
Zero
A zero stops zero suppression. Place it in the farthest right position where zero suppression is to stop. The zero is replaced with the character from the corresponding position of the data field, unless that character is a zero. Any zeros in the data that appear to the right of the stop-zero-suppression character are displayed. The stop-zero-suppression character is considered a digit position; however, when it is the first character, it might not represent the digit position. At least one leading zero is suppressed, unless it is the first character of the EDTWRD. Then it does not count as a digit because the number of blanks equals the number of digits in the field. Each zero that is suppressed is replaced by a blank. An asterisk replaces zeros with asterisks (asterisk protection). Place the asterisk in the farthest right position where zero suppression is to stop. Each zero that is suppressed is replaced by an asterisk.
Note: If your display file was created before Version 2 Release 1, it is possible that the Edit Word (EDTWRD) keyword will produce different output after a recompile.
Asterisk
An asterisk preceding a zero is interpreted as representing asterisk protection, and in this case, the zero prints as a constant. Any asterisks or zeros to the right of the stop-zero-suppression character are constants.
Currency symbol

If you code a currency symbol immediately to the left of the zero suppression code, a currency symbol is inserted in the position to the left of the first significant digit. It is called the floating-currency symbol when used in this manner.

If you code a currency symbol in the farthest left position of the edit word, it is fixed and prints in the same location each time. When used in this manner, it is called the fixed-currency symbol.

The currency symbol is not considered a digit replace position. This symbol must correspond to the system value QCURSYM.

Decimals and commas

Decimals and commas are printed in the same relative positions in which they are coded in the edit word unless they are to the left of the first significant digit. In that case, they are blanked out or replaced by an asterisk.

All other characters are printed if they are to the right of significant digits in the edit word. If they are to the left of the high-order significant digits in the edit word, they are blanked out or replaced by asterisks if asterisk protection is being used.

If a constant is to be printed in the left most position, the constant must be preceded by a zero and the field length increased by one.

Forming the status of an edit word

The following characters have special meanings when used in the status of an edit word.

Ampersand
Causes a blank in the edited output field. An ampersand cannot be placed in the edited output field.
CR or minus symbol
If the sign in the edited output field is plus (+), these positions are blanked out. If the sign in the edited output field is minus (-), these positions remain undisturbed.

Forming the expansion of an edit word

The characters in the expansion portion of an edit word are always written. The expansion cannot contain blanks. If a blank is required in the edited output field, specify an ampersand in the body of the edit word.

Specifying a valid edit word

Use the following rules to specify a valid edit word:

  • The EDTWRD keyword is valid for numeric only fields (Y specified in position 35).
  • You cannot specify both EDTWRD and EDTCDE for the same field.
  • The DFT and DFTVAL keywords cannot be specified with the EDTWRD keyword.
  • Enclose the edit word in single quotation marks.
  • The sum of the blanks and stop-zero-suppression characters (digit positions) in the edit word must equal the length of the field.
  • If the stop-zero-suppression character is the first character in the edit word, the sum of the blanks might equal the length of the field or the length of the field minus one.
  • When you use the floating-currency symbol, the currency symbol is not counted as a digit position. For example, if you specify the floating-currency symbol for a field with a length of 7 and 2 decimal positions, the edit word is:
    EDTWRD('____$0.__)

    where _ represents a blank.

  • If you want to show a negative sign with a negative number, include a sign in the edit word. Use either the minus sign (-) or the letters CR (credit) to the right of the last digit replacement character. These print only if the number is negative.

Option indicators are not valid for this keyword.

Figure 2 shows sample edit words with the program value of the field and the display value of the field (as edited).

Figure 2. Sample edit words
A figure of example edit words.

Example

The following example shows how to specify the EDTWRD keyword.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00020A            FIELDA         7  2   5  2EDTWRD('    $0. ')
     A