Zero suppression item – Z


A result-string is zero-suppressed by removing leading 0 characters from the value and replacing them with spaces.  Recall from the discussion above that the result string is built up, a piece at a time, in a left-to-right manner.  When a zero-suppression item is encountered in the mapping string, it is applied to the result string as it exists at that point in time.  Thus, to zero-suppress the ‘final’ result a certain way, you would place the zero-suppression item last (right-most) in the mapping string.


Because the action of a zero-suppression is applied to the result string and not to the source string, the mapping string can contain additional column-reference operands to the right of a zero-suppression, since the data characters in the source string remain undisturbed in their original locations.


There is no provision for zero suppression to act other than to replace suppressed characters in the result string by spaces.  Because of this, the result string will always have the same length after zero suppression is done as it had beforehand.  If you need some other result, such as replacing leading zeros with a special character like * or to remove leading zeros altogether without replacing them with spaces, some other mapping codes might be used to achieve these effects.


If you need something more elaborate, such as floating +/- signs, floating dollar signs, enclosing negative numbers in parentheses or suffixing them with DB/CR codes (the sorts of things you can do in a COBOL program with a PICTURE clause), an execute-macro string, also known as an “E string”, may be useful.  It may also be possible with a careful combination of trimming, padding, text insertion, and Move and Delete commands, to achieve some of these results.


Zero suppression can be applied to any character string, but it will make the most sense to use this on strings that are already formatted as numeric values.  For example, suppose you had the string "0,012.34".   If this were zero-suppressed, you would probably want any “insignificant” commas removed, but you would not want the decimal point and digits after it removed, even if they were zero.  That is, you would most likely want the string changed to "°°°12.34" (where “°” represents blank positions).


A zero-suppression item consists of the letter Z followed by a optional zero-suppression specification.


Syntax of a zero-suppression item:


Z  [ ignore-characters ]  [ minimum-length ]


Z:

       Introduces the zero-suppression item


Ignore-characters :


Defines a list of one or more leading non-significant characters to be ignored while performing zero suppression.  Once a “significant” character (any character in the range of 1-9, or any character not in the ignore-list) is encountered while scanning the data left-to-right, that digit and all data to the right of it is considered as “significant”.  By default, leading 0 and blank characters are ignored; this assumption cannot be changed.


What the ignore-characters list does is to specify additional characters to be ignored.  The most likely character you want to ignore is a digit separator.  U.S. style numbers separate digits with a comma, while European style numbers use dots for this.  If your data already has separators, you can use this ignore-characters operand to define what that separator is.  Note.  While leading 0 and blank characters are always ignored, the digits 1-9 are never ignored, even if you ask for this to be done.  That is, digits 1-9 are always considered as significant.


Application note:  If you have some unusual requirements that don’t fit into what the Z command normally does, you have two options.  First, you could try using the RC command to replace certain ‘problem’ characters in the result string prior to the Z command, and then perhaps use a second RC command after the Z, to ‘undo’ what the first RC did, if that is necessary for you.  If that is not sufficient, an execute-macro string, also known as an “E string”, may be useful.


Minimum-length:


A decimal number that defines the right-most number of characters that will not be suppressed, regardless of their content.  If minimum-length is omitted, there is no minimum length.  That means if the original data consists entirely of blanks, zeros or other ignored characters, the end result will be a blank field of equal size.  Thus, omitting the minimum length, and specifying the minimum length as 0 will have the same result.  If the minimum length is equal to or greater than the current length of the result string, the result string will be left unchanged.


Example:  To zero-suppress a dollar-amount field, skipping insignificant commas, and retaining a “cents portion” that already had a dot and 2 digits , use Z','3.


A complete mapping string that used this item would look like:

M"1+ Z','3"


or with the 1+ implied by auto-copy we can shorten this to:

M"Z','3"




Created with the Personal Edition of HelpNDoc: Easily create Help documents