  | 
		
HP COBOL Reference Manual
 
 
Zero Suppression and Replacement Editing
 
 
  -  One or more occurrences of the space symbol (Z) or the asterisk
  (*) define a floating suppression string, which can suppress leading
  zeros in numeric character positions. The space symbol (Z) causes
  spaces to replace the zeros; an asterisk (*) causes asterisks to
  replace the zeros. 
 The suppression symbols are mutually exclusive.
  That is, character-string can contain either the space symbol
  (Z) or the asterisk (*), but not both.  Each suppression symbol
  counts toward the size of the item.  You can include simple
  insertion symbols either within the floating string or immediately to
  its right. These simple insertion symbols are treated as part of the
  floating string. That is, they appear in results only when the value of
  the item is large enough to include a position occupied by a simple
  insertion symbol.  You can use zero suppression symbols to represent
  either:
  
    - Any or all leading numeric character positions to the left of the
    decimal point
    
 - All numeric character positions on both sides of the decimal point
    
 For example, both ZZZ9.99 and ZZ.ZZ are valid
    character-strings, but ZZZ.Z9 is not.
    
     The following actions occur if the suppression symbols represent
    any or all leading numeric character positions to the left of the
    decimal point:
  
    - The replacement character replaces any leading zero in the data
    that corresponds to a suppression symbol in the string.
    
 - Suppression ends at either the first nonzero digit in the data
    represented by the suppression string or at the decimal point,
    whichever appears first in the data.
  
  
     The following events occur if the suppression symbols represent all
    numeric positions in character-string:
  
    - If the value of the data is not zero, the result is the same as if
    all suppression symbols were to the left of the decimal point. That is,
    zeros to the right of the decimal point are not suppressed.
    
 - If the value is zero and the suppression symbol is a Z, all
    character positions in the edited item (including any editing
    characters) contain spaces.
    
 - If the value is zero and the suppression symbol is an asterisk (*),
    all character positions in the edited item (including any insertion
    editing characters other than the decimal point) contain asterisks. The
    decimal point appears in the item.
  
  
   - The plus sign (+), minus sign (-), asterisk (*), space (Z), and
  currency symbol (cs) are mutually exclusive when they are used as
  floating replacement characters. That is, if any one of these symbols
  appears as a floating replacement character, none of the other symbols
  can appear as a floating replacement character in the same PICTURE
  clause.
  
PICTURE Symbol Precedence Rules
 
 
  - character-string must contain either:
  
    - At least one of the symbols A, X, Z, 9, or asterisk (*)
    
 - At least two of the symbols plus sign (+), minus sign (-), or
    currency symbol (cs)
  
  
   - Figure 5-10 summarizes the rules for combining symbols to form
  character-strings more complex than the basic possibilities
  listed in rule 1. The table shows that the use of one symbol in a
  character-string excludes the use of certain others before or
  after it. 
 The table uses the following conventions:
  
    - A Y at an intersection means the symbols at the top of the
    column (First Symbol) can precede the symbols at the left of
    the row (Second Symbol).
    
 - Braces ({ }) enclose symbols that are mutually exclusive.
    
 - The currency symbol appears as cs.
    
 - Symbols appear twice in a column or row when their rules of use
    depend upon their location in a character-string. These double
    entry symbols are as follows:
    
      - Fixed insertion symbols (+ and --)
      
 - Floating symbols Z, asterisk (*), plus sign (+), minus sign (-),
      and currency symbol (cs)
      
 - P
    
  
       The uppermost entry in a column (or the leftmost entry in a row)
      represents symbol use left of the actual or implied decimal point
      position. The second entry represents symbol use to the right of the
      decimal point.
    
  
Figure 5-10 PICTURE Symbol Precedence Rules
  
 
Additional References
 
 
Examples
 
 
The Procedure Division entry for the MOVE statement contains examples
that illustrate this clause.
5.3.38 RECORD
 
Function
 
 
The RECORD clause specifies the number of character positions in either
a fixed- or variable-length record. If the number of character
positions does not vary, the RECORD clause specifies the minimum and
maximum number of character positions in a variable-length record.
  
 
shortest-rec
is an integer that specifies the minimum number of character positions
in a variable-length record. Its value must be greater than or equal to
zero.
longest-rec
is an integer greater than shortest-rec. It specifies the
maximum number of character positions in a variable-length record or
the size of a fixed-length record.
depending-item
is the data-name of an elementary unsigned integer data item in the
Working-Storage or Linkage Section. It specifies the number of
character positions for an output operation, and it contains the number
of character positions after a successful input operation.
 
Syntax Rules
 
 
  - No record description entry for a file can specify the following:
  
    - Fewer character positions than shortest-rec
    
 - More character positions than longest-rec
  
  
   - In a sort-merge file description entry, the first
  shortest-rec character positions of the record must be large
  enough to include all keys specified in any SORT or MERGE statement for
  the sort or merge file.
  
 - For an indexed file, the first shortest-rec character
  positions of the record must be large enough to include all record keys.
  
 - If the DEPENDING ON phrase is present and if the associated file
  connector is an external file connector, depending-item must
  have the external attribute and must specify the same data-name in all
  file description entries associated with the external file connector.
  
General Rules
 
 
Both Formats
 
 
  - The absence of a RECORD clause is the same as a Format 1 RECORD
  clause with no shortest-rec phrase and with
  longest-rec equal to the greatest number of character
  positions described for any of the file's records.
  
 - The number of characters described by a record description entry is
  the sum of both of the following:
  
    - The number of character positions in all elementary items excluding
    redefinitions and renamings
    
 - The number of fill bytes added because of alignment requirements
  
  
     If the record description entry contains a table definition, the
    sum includes the number of character positions in the maximum number of
    table elements.
   - If the associated file connector is an external file connector, all
  file description entries in the run unit associated with that file
  connector must define the same values for shortest-rec and
  longest-rec. If the RECORD clause is not specified, all record
  description entries associated with this file connector must be the
  same length.
  
Format 1
 
 
  - If there is no shortest-rec phrase, Format 1 specifies
  fixed-length records. longest-rec then specifies the number of
  character positions in each record of the file.
  
 - If there is a shortest-rec phrase, Format 1 specifies
  variable-length records, the same as Format 2 without the DEPENDING
  phrase.
  
 - For variable-length records:
  
    - The maximum record size for a READ or RETURN operation is the
    number of character positions described in the largest record
    description entry for the file.
    
 - During execution of a RELEASE, REWRITE, or WRITE statement, the
    number of character positions in a record equals the number of
    character positions in the record description entry referred to by the
    statement.
    
 - If all record description entries for the file describe records of
    the same size, RELEASE, REWRITE, and WRITE statements for the file
    transfer fixed-length records in variable-length format.
  
  
  
Format 2
 
 
  - Format 2 specifies variable-length records.
  
 - If the clause does not contain shortest-rec, the minimum
  number of character positions in any of the file's records is the least
  number of character positions described by a record description entry
  for the file.
  
 - If the clause does not contain longest-rec, the maximum
  number of character positions in any of the file's records is the
  greatest number of character positions described by a record
  description entry for the file.
  
 - If there is a DEPENDING phrase, the program must set
  depending-item to the number of character positions in the
  record before executing a RELEASE, REWRITE, or WRITE statement for the
  file.
  
 - After successful execution of a READ or RETURN statement for the
  file, the value of depending-item indicates the number of
  character positions in the accessed record.
  
 - The depending-item value is not changed by executions of:
  
    - DELETE and START statements
    
 - Unsuccessful READ and RETURN statements
  
  
   - For RELEASE, REWRITE, and WRITE statement execution, determining
  the number of character positions in the record depends partly upon
  whether or not the record contains a variable occurrence item (an item
  described by the OCCURS clause or one that is subordinate to another
  item so described). During execution of these statements, three rules
  determine the number of character positions in the record:
  
    - If there is a depending-item, its value specifies the
    number of character positions.
    
 - If there is no depending-item and the record does not
    contain a variable occurrence item, the number of character positions
    described by the record description entry specifies the number of
    character positions.
    
 - If there is no depending-item and the record contains a
    variable occurrence item, the number of character positions is the sum
    of the character positions in the fixed part of the record and the
    table elements specified by the OCCURS clause depending-item
    when the output statement executes.
  
  
  
  
  
		 |