HP 3000 Manuals

Data Division (cont.) [ COBOL/HP-UX Language Reference for the Series 700 and 800 ] MPE/iX 5.0 Documentation


COBOL/HP-UX Language Reference for the Series 700 and 800

Data Division (cont.) 

The REDEFINES Clause 

Function 

The REDEFINES clause allows the same computer storage area to be
described by different data description entries.

General Format 

[]
Note that level-number and data-name-1 or FILLER (ANS85) are shown in the above format to improve clarity. Level-number, and data-name-1 and FILLER (ANS85) are not part of the REDEFINES clause. Syntax Rules 1. The REDEFINES clause, when specified, must immediately follow data-name-1 or FILLER, (ANS85) or it can follow the PICTURE or USAGE clause. (OSVS) (MF) 2. The level-numbers of data-name-1 and data-name-2 must be identical but must not be 66 , 78 (MF) or 88. 3. This clause must not be used in level 01 entries in the File Section, since multiple level 01 entries subordinate to an FD or SD indicator represent implicit redefinitions of the same areas. (See General Rule 2 of the section "The DATA RECORDS Clause" in Chapter 5 , File Input and Output.) ________________________________________________________________________ |(MF) | |This clause can be used on level 01 entries in the File Section. | ________________________________________________________________________ 4. This clause must not be used in level 01 entries in the Communication Section since multiple level 01 entries subordinate to a CD indicator represent implicit redefinition of the same area. 5. The data description for data-name-2 can contain a REDEFINES clause and (OSVS) (VSC2) data-name-2 can be subordinate to an entry which contains a REDEFINES clause. Its data description cannot contain an OCCURS clause. However, data-name-2 can be subordinate to an item whose data description entry contains an OCCURS clause. In this case, the reference to data-name-2 in the REDEFINES clause can not be subscripted or indexed. Neither the original definition nor the redefinition can include an item whose size is variable as defined in the OCCURS clause. (See the section "The OCCURS Clause" in this chapter.) ________________________________________________________________________ |(MF) | |The data description for data-name-2 can contain an OCCURS clause. | ________________________________________________________________________ 6. No entry having a level-number numerically lower than the level-number of data-name-2 and data-name-1 can occur between the data description entries of data-name-2 and data-name-1. ________________________________________________________________________ |(OSVS) (VSC2) (MF) | | | | | | | |7. An external or internal floating-point data item can be the | | subject or object of a REDEFINES clause. | | | ________________________________________________________________________ General Rules 1. Redefinition starts at data-name-2 and ends when a level-number less than or equal to that of data-name-2 is encountered. 2. When the level-number of data-name-1 is other than 01, it must specify the same number of character positions that the data item referenced by data-name-2 contains ________________________________________________________________________ |(OSVS) (ANS85) | |except that the data-name-1 area can be either smaller than the | |data-name-2 area | ________________________________________________________________________ ________________________________________________________________________ |(MF) | |or be larger than the data- name-2 area. In this case, extra storage | |is reserved to provide sufficient storage for the number of | |character positions in the largest of the redefining or redefined | |items. | ________________________________________________________________________ It is important to observe that the REDEFINES clause specifies the redefinition of a storage area, not of the data items occupying the area. 3. Multiple redefinitions of the same character positions are permitted. The entries giving the new descriptions of the character positions must follow the entries defining the area being redefined, without intervening entries that define new character positions. Multiple redefinitions of the same character positions must all use the data-name of the entry that originally defined the area ________________________________________________________________________ |(VSC2) (OSVS) | |or the data-name of any other preceding redefinition of that | |entry. | ________________________________________________________________________ 4. The entries giving the new description of the character positions must not contain any VALUE clauses except in condition-name entries. 5. Multiple level 01 entries subordinate to any given level indicator (FD, CD or SD) represent implicit redefinitions of the same area. ________________________________________________________________________ |(ANS85) | | | | | | | |6. Data-name-2 must not be qualified even if it is not unique since | | no ambiguity of reference exists in this case because of the | | required placement of the REDEFINES clause within the source | | program. | | | ________________________________________________________________________ The RENAMES Clause Function The RENAMES clause permits alternative, possibly overlapping, groupings of elementary items. General Format
[]
Note that level-number 66 and data-name-1 are shown in the above format to improve clarity. Level-number and data-name-1 are not part of the RENAMES clause. Syntax Rules 1. Any number of RENAMES entries can be written for a logical record. 2. All RENAMES entries referring to data items within a given logical record must immediately follow the last data description entry of the associated record description entry. 3. Data-name-2 and data-name-3 must be names of elementary items or groups of elementary items in the same logical record, and cannot be the same data-name. A 66 level entry cannot rename another 66 level entry nor can it rename a 77, 78, (MF) 88, or 01 entry. 4. Data-name-1 cannot be used as a qualifier, and can only be qualified by the names of the associated level 01, FD, CD or SD entries. Neither data-name-2 nor data-name-3 can have an OCCURS clause in its data description entry nor be subordinate to an item that has an OCCURS clause in its data description entry. (See the section "The OCCURS Clause" .) 5. The beginning of the area described by data-name-3 must not be to the left of the beginning of the area described by data-name-2. The end of the area described by data-name-3 must be the right of the end of the area described by data-name-2. Data-name-3, therefore, cannot be subordinate to data-name-2. 6. Data-name-2 and data-name-3 can be qualified. 7. The words THRU and THROUGH are equivalent. 8. None of the items within the range, including data-name-2 and data-name-3, if specified, can be an item whose size is variable as defined in the section "The OCCURS Clause" in this chapter. General Rules 1. When data-name-3 is specified, data-name-1 is a group item which includes all elementary items starting with data-name-2 (if data-name-2 is an elementary item) or the first elementary item in data-name-2 (if data-name-2 is a group item), and concluding with data-name-3 (if data-name-3 is an elementary item) or the last elementary item in data-name-3 (if data-name-3 is a group item). 2. When data-name-3 is not specified, all of the attributes of data-name-2 become the data attributes for data-name-1. ________________________________________________________________________ |(OSVS) (VSC2) | | | | | | | |3. When data-name-2 and data-name-3 are not explicitly qualified and| | when no ambiguity of reference exists, implied qualification of | | the 01 level item is used. | | | ________________________________________________________________________ The SIGN Clause Function The SIGN clause specifies the position and the mode of representation of the operational sign when it is necessary to describe these properties explicitly. General Format
[]
Syntax Rules 1. The SIGN clause can be specified only for a numeric data description entry whose PICTURE contains the character "S" , or a group item containing at least one such numeric data description entry. 2. The numeric data description entries to which the SIGN clause applies must be described, implicitly or explicitly, as USAGE IS DISPLAY. 3. At most one SIGN clause can apply to any given numeric data description entry. ________________________________________________________________________ |This rule is removed. (ANS85) | ________________________________________________________________________ 4. If the CODE-SET clause is specified, any signed numeric data description entries associated with that file description entry must be described with the SIGN IS SEPARATE clause. ________________________________________________________________________ |(MF) | |This restriction is not enforced. See the section "The CODE-SET | |Clause" in the chapter File Input and Output. | ________________________________________________________________________ General Rules 1. The optional SIGN clause, if present, specifies the position and the mode of representation of the operational sign for the numeric data description entry to which it applies, or for each numeric data description entry subordinate to the group to which it applies. The SIGN clause applies only to numeric data description entries whose PICTURE contains the character "S"; the "S" indicates the presence of, but neither the representation nor, necessarily, the position of the operational sign. 2. A numeric data description entry whose PICTURE contains the character "S", but to which no optional SIGN clause applies, has an operational sign, but neither the representation nor, necessarily, the position of the operational sign is specified by the character "S". In this (default) case, General Rules 3 through 5 do not apply to such signed numeric data items. The representation of the default operational sign is defined in the section "Selection of Character Representation and Radix" in the chapter COBOL Concepts. 3. If the optional SEPARATE CHARACTER phrase is not present, then: a. The operational sign will be presumed to be associated with the leading (or, respectively, trailing) digit position of the elementary numeric data item in a manner defined in the section "Selection of Character Representation and Radix" in the chapter COBOL Concepts. b. The letter "S" in a PICTURE character-string is not counted in determining the size of the item (in terms of standard data format characters). 4. If the optional SEPARATE CHARACTER phrase is present, then: a. The operational sign will be presumed to be the leading (or, respectively, trailing) character position of the elementary numeric data item; this character position is not a digit position. b. The letter "S" in a PICTURE character-string is counted in determining the size of the item (in terms of standard data format characters). c. The operational signs for positive and negative are the standard data format characters "+" and "-", respectively. 5. Every numeric data description entry whose PICTURE contains the character "S" is a signed numeric data description entry. If a SIGN clause applies to such an entry and conversion is necessary for purposes of computation or comparisons, conversion takes place automatically. ________________________________________________________________________ |(ANS85) | | | | | | | |6. If a SIGN clause is specified for an item (either an elementary | | numeric data description entry or a group item) which is | | subordinate to a group item for which a SIGN clause is also | | specified, then the SIGN clause specified in the subordinate item| | takes precedence. | | | ________________________________________________________________________ ________________________________________________________________________ |(OSVS) (VSC2) (MF) | | | | | | | |7. The SIGN clause is treated as documentary for external | | floating-point items. For internal floating-point items, the | | SIGN clause is invalid and will result in a diagnostic | | message. | | | ________________________________________________________________________ The SYNCHRONIZED Clause Function The SYNCHRONIZED clause specifies the alignment of an elementary item on the natural boundaries of the computer memory. ________________________________________________________________________ |(XOPEN) | |Although it is a part of the standard COBOL definition, this | |feature is explicitly excluded from the X/Open COBOL language | |definitions and should not be used in a conforming X/Open COBOL source| |program. | ________________________________________________________________________ General Format
[]
Syntax Rules 1. This clause should only appear with an elementary item. 2. SYNC is an abbreviation for SYNCHRONIZED. ________________________________________________________________________ |(OSVS) (VSC2) | | | | | | | |3. The SYNCHRONIZED clause can appear with a non-elementary | | item. | | | ________________________________________________________________________ General Rules 1. SYNCHRONIZED RIGHT specifies that the elementary item is to be positioned such that it will terminate on the right character position of the natural boundary in which the elementary item is placed. ________________________________________________________________________ |(MF) | |It takes effect only if the IBMCOMP directive is set. | ________________________________________________________________________ 2. Specification of the LEFT phrase in the SYNCHRONIZED clause will have no effect. 3. The effect of the SYNCHRONIZED clause is, by definition, implementation- dependent. See your COBOL System Reference for details. 4. This clause specifies that the subject data item is to be aligned in the computer such that no other data item occupies any of the character positions between the leftmost and rightmost natural boundaries of the computer memory which delimits this data item. If the number of character positions required to store this data item is less than the number of character positions between those natural boundaries, the unused character positions (or portions thereof) must not be used for any other data item. Such unused character positions, however, are included in: a. The size of any group item(s) to which the elementary item belongs, and: b. The character positions redefined when this data item is the object of a REDEFINES clause. Thus the size of an elementary item is unchanged by the SYNCHRONIZED clause, but extra character positions are assigned by the use of the clause. 5. SYNCHRONIZED not followed by either RIGHT or LEFT specifies that the elementary item is to be positioned between natural boundaries in such a way as to use the elementary data item efficiently. 6. Whenever a SYNCHRONIZED item is referenced in the source program, the original size of the item, as shown in the PICTURE clause, is used in determining any action that depends on size, such as justification, truncation or overflow. 7. If the data description of an item contains the SYNCHRONIZED clause and an operational sign, the sign of the item appears in the normal operational sign position, regardless of whether the item is SYNCHRONIZED LEFT or SYNCHRONIZED RIGHT. 8. When the SYNCHRONIZED clause is specified in a data description entry of a data item that also contains an OCCURS clause, or in a data description entry of a data item subordinate to a data description entry that contains an OCCURS clause, then: a. Each occurrence of the data item is SYNCHRONIZED. b. Any implicit FILLER generated for other data items within that same table are generated for each occurrence of those data items. ________________________________________________________________________ |(OSVS) (VSC2) | | | | | | | |9. If the SYNCHRONIZED clause is specified with a non-elementary | | item, then the clause applies to all the items subordinate to | | that non-elementary item. | | | ________________________________________________________________________ 10. The effect of the use of the SYNCHRONIZED clause is discussed in the section "Selection of Character Representation and Radix" in the chapter COBOL Concepts. The USAGE Clause Function The USAGE clause specifies the format of a data item in the computer storage. General Format
[]
Syntax Rules 1. The PICTURE character-string of a COMPUTATIONAL, COMPUTATIONAL-3, (OSVS) (VSC2) (MF) (XOPEN) or COMPUTATIONAL-5 (MF) (XOPEN) BINARY, PACKED-DECIMAL (ANS85) item can contain only "9"s, the operational sign character "S", the implied decimal point character "V" , one or more "P"s. (See the section "The PICTURE Clause" earlier in this chapter.) 2. COMP is an abbreviation for COMPUTATIONAL. ________________________________________________________________________ |(ANS85) | | | | | | | |3. BINARY is equivalent to COMPUTATIONAL. | | | ________________________________________________________________________ ________________________________________________________________________ |(OSVS) (VSC2) (MF) | | | | | | | |4. COMP-4 is an abbreviation for COMPUTATIONAL-4 and is equivalent | | to COMPUTATIONAL. | | | ________________________________________________________________________ ________________________________________________________________________ |(MF) (OSVS) (VSC2) (XOPEN) | | | | | | | |5. COMP-3 is an abbreviation for COMPUTATIONAL-3. | | | ________________________________________________________________________ ________________________________________________________________________ |(ANS85) | | | | | | | |6. PACKED-DECIMAL is equivalent to COMPUTATIONAL-3. | | | ________________________________________________________________________ ________________________________________________________________________ |(MF) (XOPEN) | | | | | | | |7. COMP-5 is an abbreviation for COMPUTATIONAL-5. | | | ________________________________________________________________________ ________________________________________________________________________ |(OSVS) (VSC2) (MF) | | | | | | | |8. COMP-1 is an abbreviation for COMPUTATIONAL-1. | | | |9. COMP-2 is an abbreviation for COMPUTATIONAL-2. | | | ________________________________________________________________________ 10. The USAGE clause cannot be specified for level 66 or 88 data description entries. ________________________________________________________________________ |(MF) | | | | | | | |11. The PICTURE character-string of a COMPUTATIONAL-X item must | | consist either of all "9" s or of all "X"s. Either gives an item| | whose category is numeric. | | | |12. The PICTURE clause of an elementary item can contradict the USAGE| | clause of a group to which the item belongs. In this case the | | USAGE specified at the group level will be ignored for that | | elementary item. | | | ________________________________________________________________________ ________________________________________________________________________ |(VSC2) (MF) | | | | | | | |13. The SYNCHRONIZED, JUSTIFIED, PICTURE, VALUE, SIGN and BLANK WHEN | | ZERO clauses cannot be used to describe group or elementary items| | described with the USAGE IS POINTER clause. | | | ________________________________________________________________________ 14. An index data item can be referenced explicitly only in a SEARCH or SET statement, a relation condition, the USING phrase of a Procedure Division header, the USING phrase of an ENTRY statement (OSVS) (VSC2) (MF) or the USING phrase of a CALL statement. 15. The SYNCHRONIZED, JUSTIFIED, PICTURE, VALUE, SIGN and BLANK WHEN ZERO clauses cannot be used to describe group or elementary items described with the USAGE IS INDEX clause. ________________________________________________________________________ |(OSVS) (VSC2) | |The SYNCHRONIZED clause can be used to describe group or elementary | |items described with the USAGE IS INDEX clause. | ________________________________________________________________________ 16. An elementary data item described with a USAGE IS INDEX clause can not be a conditional variable. ________________________________________________________________________ |(OSVS) (VSC2) (MF) | | | | | | | |17. COMPUTATIONAL-1 and COMPUTATIONAL-2 items (internal | | floating-point) cannot have PICTURE strings. | | | ________________________________________________________________________ ________________________________________________________________________ |(MF) | | | | | | | |18. A declaration with USAGE IS PROCEDURE-POINTER must contain no | | other data description clauses. | | | ________________________________________________________________________ General Rules 1. The USAGE clause can be written at any level. If the USAGE clause is written at group level, it applies to each elementary item in the group but does not have any effect on the allowed use of the group item. The USAGE clause of an elementary item cannot contradict the USAGE clause of a group to which the item belongs. 2. The USAGE clause specifies the manner in which an elementary data item is represented in the storage of a computer. It does not affect the use of the data item, although the specifications for some statements in the Procedure Division can restrict the operands to elementary items with particular USAGE clauses. The USAGE clause can affect the radix or type of character representation of the item. 3. A COMPUTATIONAL, COMPUTATIONAL-3, (OSVS) (VSC2) (MF) (XOPEN) COMPUTATIONAL-5, (MF) (XOPEN) COMPUTATIONAL-X,(MF) PACKED-DECIMAL,or BINARY (ANS85) item is capable of representing a value to be used in computations and must be numeric. If a group item is described with one of these clauses, the clause applies to the elementary items in the group, not to the group item itself; the group item cannot be used in computations. The effect of these clauses is discussed in the section "Selection of Character Representation and Radix" in the chapter COBOL Concepts. 4. The USAGE IS DISPLAY clause indicates that the format of the data is a standard data format. 5. If the USAGE clause is not specified for an elementary item, or for any group to which the item belongs, the usage is implicitly DISPLAY. ________________________________________________________________________ |(OSVS) (VSC2) (MF) | | | | | | | |6. The USAGE IS DISPLAY clause is valid for the following types of | | items: | | | | | | * Alphabetic | | | | * Alphanumeric | | | | * Alphanumeric-edited | | | | * Numeric-edited | | | | * External floating-point | | | | * External decimal (numeric) | | | ________________________________________________________________________ 7. Space requirements and storage definitions for the various USAGE storage options are given under the section "Selection of Character Representation and Radix" in the chapter COBOL concepts. ________________________________________________________________________ |(MF) (VSC2) | | | | | | | |8. The USAGE IS POINTER clause identifies a data item in which you | | can store the address of a data item (see the section "The SET | | Statement" in this chapter). | | | ________________________________________________________________________ ________________________________________________________________________ |(MF) | | | | | | | |9. The USAGE IS PROCEDURE-POINTER clause specifies that a data item | | is a procedure pointer data item in which you can store the | | address of a procedure. (See "The SET Statement" in this | | chapter.) The procedure can be written in any language: if | | COBOL, it represents the Procedure Division of a program that is | | not nested and identified by either: | | | | the program-name of the PROGRAM-ID paragraph; or | | | | the entry-name of an ENTRY statement. | | | ________________________________________________________________________ 10. An elementary item described with the USAGE IS INDEX clause is called an index data item and contains a value which must correspond to an occurrence number of a table element. The elementary item cannot be a conditional variable. Your COBOL system will allocate a 4-byte binary field with an implied PICTURE of 9(9) COMP. If a group item is described with the USAGE IS INDEX clause the elementary items in the group are all index data items. The group itself is not an index data item and cannot be used in a SEARCH or SET statement or in a relation condition. 11. An index data item , pointer data item or procedure pointer data (MF) item can be part of a group which is referred to in a MOVE or input-output statement, in which case no conversion will take place. Your COBOL system will allocate a 4-byte binary field for the data item.


MPE/iX 5.0 Documentation