HP 3000 Manuals

File Description Clauses [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation


HP COBOL II/XL Reference Manual

File Description Clauses 

Each clause described on the following pages, if used, must be part of a
file description entry.  However, several of the clauses do not apply to
sort-merge files (that is, to SD level indicator entries).  Those that do
not apply to SD level entries are noted as they are described.

The FILE SECTION must begin in Area A with the words FILE SECTION
followed by a period.  The header is followed by a level indicator
(either FD or SD) and the name of the file being described.  One or more
record description entries must follow each file description entry.  A
file description entry is terminated by a period.

The general formats for the file description clauses are:

[]
FD Level Indicator - For Data File Descriptions The FD level indicator names the data file being described. It must be the first clause in a data file description entry. Syntax. The data file description clause has the following format: FD file-name-1 Parameters. FD indicates that the clauses that follow are data file description clauses. file-name-1 the name of the data file being described. Description. The characters FD must begin in Area A. These characters are followed by a space and the name of the data file being described. Following the name, several clauses, mostly optional, are used to describe the file. At least one record description entry must follow the file description entry. SD Level Indicator - For Sort File Descriptions An SD level indicator names the file to be sorted or merged. It must be the first entry in a sort-merge file description entry. Syntax. The format of the SD level indicator is: SD file-name-1 Parameters. SD indicates that the clauses that follow are used to describe a file to be sorted and/or merged. file-name-1 the name of the file being described. Description. The characters SD must begin in Area A. These characters are followed by a space and the name of the data file being described. The name may then be followed by a RECORD CONTAINS clause or DATA RECORDS clause, and must be followed by at least one record description entry. BLOCK CONTAINS Clause The BLOCK CONTAINS clause allows you to specify the blocking factor of the file being described. This clause should be used if the actual blocking factor of the file being described cannot be determined by the operating system. For example, this clause is optional when the physical record contains exactly one complete logical record or, for sequential files only, when the physical device associated with the file is a unit-record device (such as a card reader). When the BLOCK CONTAINS clause is omitted, the default blocking factor from the operating system is automatically assigned. This clause does not apply to sort-merge files (SD level descriptions). Syntax.
[]
Parameters. integer-1 optional and must be positive. It refers to the minimum blocking factor size or to the minimum size of the physical record, depending upon whether the keyword RECORDS or CHARACTERS is used. Due to the way in which the operating system determines file attributes, this phrase is treated as a comment. integer-2 required and must be positive. If used in conjunction with integer-1, it specifies the maximum size of the physical record; used alone, however, it specifies the exact size of the physical record, or the exact blocking factor. RECORDS specifies that the physical record size of the file is determined by its blocking factor. CHARACTERS when specified, is used to determine the blocking factor by dividing the value of integer-2 by the logical record size. Refer to the RECORD CONTAINS clause description in this chapter. Description. When the word CHARACTERS is used, the physical record size should be specified as a multiple of the maximum logical record size. Note that this logical record size must include any slack bytes generated by the compiler. Refer to the SYNCHRONIZED clause description in this chapter. If logical records of differing size are grouped into one physical record, they are treated differently, according to the file's organization: * Sequential or indexed file - The size of a logical record is variable, and is equal to the size of the record currently being accessed. * Random and relative files require fixed length records. To illustrate the use of the BLOCK CONTAINS clause: * A magnetic tape file contains variable length logical records with a maximum of 120 characters, blocked with a minimum of four logical records per physical record. There is a maximum of 480 characters (bytes) per physical record, and a minimum of 60 bytes per physical record.
[]
In this case, you can use either: BLOCK CONTAINS 4 RECORDS. or: BLOCK CONTAINS 60 TO 480 CHARACTERS.
NOTE The figures specified above are only used as estimates by the operating system. The actual blocking factor varies depending on the logical records, and the physical record size for variable records contains control information. Therefore, it is larger than specified in the BLOCK CONTAINS clause. This applies to relative files as well. Refer to the MPE File System Manual for more information on blocking factors.
* A random access disk file contains fixed length logical records of 206 bytes (103 words) each. Therefore, there are 50 unused bytes per sector. To minimize this waste, a blocking factor of six records can be used: BLOCK CONTAINS 6 RECORDS. * A serial access disk file contains variable length logical records, ranging from 256 to 2560 bytes per record. The blocking factor is 10. You can use either: BLOCK CONTAINS 256 TO 2560 CHARACTERS. or: BLOCK CONTAINS 10 RECORDS. CODE-SET Clause The CODE-SET clause specifies the character code convention that represents data stored in sequential files. This clause may be specified for all files with sequential organization. This clause is optional, with ASCII being the default if it is not specified. Syntax.
[]
Parameters. alphabet-name-1 a previously defined name related to either EBCDIC, EBCDIK, STANDARD-1, STANDARD-2 or NATIVE. It must be specified in the ALPHABET clause of the SPECIAL-NAMES paragraph in the ENVIRONMENT DIVISION. Description. If the CODE-SET clause is specified, alphabet-name-1 indicates the character code convention used to represent the data on the related file. It further indicates the conversion routine to be used in translating the data into ASCII (when reading it) and translating data back into its original character code (when writing it from your program). When the CODE-SET clause is used for a file, all data in that file must be described as USAGE IS DISPLAY, and any signed numeric data must be described with the SIGN IS SEPARATE clause.
NOTE The HP utility FCOPY can be used to translate EBCDIC files containing records with elements that are other than USAGE DISPLAY. Refer to the FCOPY Reference Manual for more information.
DATA RECORDS Clause The DATA RECORDS clause is an obsolete feature of the 1985 ANSI COBOL standard. For any type of file (random, sequential, sort-merge, and so forth) the DATA RECORDS clause serves only to document the names of data records associated with a file. This clause is, therefore, optional for both FD and SD level file descriptions. Syntax.
[]
Parameters. data-name-2 and its subsequent occurrences are the names of data records. Description. Use of more than one data name in this clause indicates that the file contains more than one type of data record. For instance, they might be of different size or format. EXTERNAL Clause The EXTERNAL clause is a feature of the 1985 ANSI COBOL standard. The EXTERNAL clause specifies the external attributes of a file connector, the associated data records, and the associated data items. Syntax. IS EXTERNAL Description. If the file description entry for a sequential file contains the LINAGE clause and the EXTERNAL clause, the LINAGE-COUNTER data item is an external data item. FILLER cannot be specified for any record descriptions associated with a file description entry that contains the EXTERNAL clause. See Chapter 11 , "Interprogram Communication", for more detailed information. GLOBAL Clause The GLOBAL clause is a feature of the 1985 ANSI COBOL standard. The GLOBAL clause specifies that the file connector, the data records and associated data items are available to the contained programs within a nested program in which the file is declared global. Syntax. IS GLOBAL Description. The GLOBAL clause can only be specified in the FD clause of the FILE SECTION. Refer to Chapter 11 , "Interprogram Communication," for more detailed information. LABEL RECORDS Clause [REV BEG] The LABEL RECORDS clause is an obsolete feature of the 1985 ANSI COBOL standard.[REV END] The LABEL RECORDS clause specifies whether one or more labels exist on the file and, optionally, the names of the records containing the label. This clause does not apply to sort-merge files.[REV BEG] This clause is optional.[REV END] Syntax.
[]
Parameters. OMITTED specifies that no explicit labels exist for the file or the device to which the file is assigned. STANDARD specifies that labels exist for the file or the device to which it has been assigned, and that the labels conform to the operating system's label specification. data-name-1 the name of the label record which must be described in a record description entry associated with the file. This record must not appear in the DATA RECORDS clause associated with the file. Use of this option indicates that user labels, as well as standard labels, are to be processed. All PROCEDURE DIVISION references to these names, or to any subordinate items, must appear within USE procedures. Label records for all files share the same area of memory. Data-name-1 cannot be an external record. The data-name-1 parameter is an HP extension to the ANSI COBOL standard. Description. With HP COBOL II, it does not matter whether you specify that labels are STANDARD or OMITTED because the operating system processes standard labels before making the associated file available to your COBOL program. If the file being described is an external file, all programs describing this file must have consistent LABEL RECORDS clauses. LINAGE Clause The purpose of the LINAGE clause is to describe the format of a logical page. It is used in conjunction with sequential files opened for output. Although there is not necessarily any relation between a logical and a physical page, it is advisable (particularly when writing a logical page to the line printer) to consider the size of a physical page when you are defining a logical one. The LINAGE clause applies only to sequential files. It has no meaning for relative, random, indexed, or sort-merge files. Its use is optional with sequential files, but it must be used if you intend to write records to the file using the END-OF-PAGE (or EOP) phrase of the WRITE statement. A logical page consists of a top margin, page body, footing area, and bottom margin. Within a file, logical pages are contiguous. Figure 7-1 shows the concept of a logical page. Syntax.
[]
Parameters. data-name-4 each reference an elementary unsigned integer data item. through data-name-7 integer-6 greater than zero. integer-7 greater than or equal to zero and not greater than integer-6. integer-8 and each greater than or equal to zero. integer-9 Description. The LINAGE clause uses data-name-4 or integer-6 to define the number of lines in the page body. The page body is the area of the logical page in which lines can be written or spaced. Because a page size is being defined, integer-6 (or the value associated with data-name-4) must be greater than 0. If the file being described is an external file, and any file description entries for this file have a LINAGE clause, all file description entries in the run unit that describe this file must have a LINAGE clause. Also, the parameters must be either constants or external data items. Corresponding parameters must be the same in all LINAGE clauses for this file.
[]
Figure 7-1. Example of the LINAGE Clause and its Logical Representation FOOTING Phrase. The FOOTING phrase is optional. If specified, however, it uses integer-7 or data-name-5 to define the FOOTING AREA of the page body. The entire page body can be the footing area. That is, integer-7 (or, the value of data-name-5) may be 1, in which case the footing area is all of the page body. The footing area is used in conjunction with the END-OF-PAGE phrase of the WRITE statement. It signifies that the end of the logical page has been reached. If you do not use the FOOTING phrase, then the only way that an end of page condition can occur is for a WRITE statement to attempt to write a record beyond the end of the logical page body (that is, when a page overflow condition exists). LINES AT TOP and LINES AT BOTTOM Phrases. The LINES AT TOP and LINES AT BOTTOM phrases are optional. They are used to specify a top margin and a bottom margin, respectively, for the logical page. If neither phrase is used, the margins are assumed to be zero. If THE LINES AT TOP phrase is specified, it uses integer-8 or data-name-6 to specify the number of lines in the top margin. If THE LINES AT BOTTOM phrase is specified, it uses data-name-7 or integer-9 to specify the number of lines in the bottom margin. The top and bottom margins are distinct from the page body; therefore, no data may be written into them. Use of Data Names Versus Use of Integers. The use of integers in a LINAGE clause allows for less flexibility than does the use of data names. When an integer (either integer-6, integer-7, or integer-8) is specified, it is used when the file associated with the LINAGE clause is opened for output. This value is used for every logical page written for the file and cannot change during a particular execution of the program in which it appears. The values of data names, on the other hand, can vary during the execution of a program. Therefore, the values are checked and used not only when the associated file is open for output, but also whenever a WRITE statement containing an ADVANCING PAGE phrase is executed, or a WRITE statement is executed and a page overflow condition occurs. Taking each of these cases in turn: * When the file is opened for output, the current values of data-name-4, data name-5, data-name-6, and data-name-7 are used to define their associated sections of the FIRST logical page only. * When a WRITE statement is executed, and the ADVANCING PAGE phrase is activated, the current values of data-name-4, data name-6 and data-name-7 are used to define the page body, top and bottom margins of the next logical page. * If a footing area has been defined, the ADVANCING PAGE phrase is activated when the WRITE statement in which it appears attempts to write data into the footing area. In this case, the data is written into the footing area of the current logical record and the current value of data-name-5 is then used to define the footing area for the next logical page. * When a WRITE statement is executed and a page overflow condition occurs, thus forcing an end-of-page condition, the current values of data-name-4, data name-6, and data-name-7 are used to define their associated parts of the next logical page. This type of end-of-page condition implies that either the value of data-name-5 is the same as that of data-name-4 or that a footing area was not defined (the two are equivalent). In either case, the data to be written is placed in the first available line of the next logical record (depending upon whether the BEFORE or AFTER ADVANCING phrase was used in the WRITE statement). If a footing area has been defined, the current value of data-name-5 is then used to define the footing area of this logical record. LINAGE-COUNTER. Any time a LINAGE clause is specified for a file, a LINAGE-COUNTER is supplied for the file. Because you can have more than one file whose description contains a LINAGE clause, you must qualify the LINAGE-COUNTER of each file by using the file name. The value of a LINAGE-COUNTER at any given time is the current line number of the associated page body. This value ranges from one, for the first line of a page body, to integer-6 (or the value of data-name-4). You can reference a LINAGE-COUNTER in the PROCEDURE DIVISION, but cannot change it. Each time a record is written to a logical page, the associated LINAGE-COUNTER is incremented according to the following rules: * When the file associated with LINAGE-COUNTER is first opened, LINAGE-COUNTER is set to one. * If the ADVANCING phrase of the WRITE statement is not specified, LINAGE-COUNTER is incremented by one when the WRITE statement is executed. * If the ADVANCING phrase is used with a WRITE statement, and * is of the form, ADVANCING integer-1 or ADVANCING identifier-2, LINAGE-COUNTER is incremented by integer-1 (or the value of identifier-2) when the WRITE statement is executed. * is of the form ADVANCING PAGE, LINAGE-COUNTER is reset to one. * If a new logical page is to be written upon, LINAGE-COUNTER is reset to one. RECORD CONTAINS Clause The RECORD CONTAINS clause specifies the size, in characters, of data records in a file. Because each data record of a file is completely defined in a record description entry, this clause is optional for any file description entry. Syntax. The RECORD CONTAINS clause has the following three formats:
[]
Parameters. integer-1 specifies the number of characters contained in each record of the file. integer-2 specifies the minimum number of character positions to be contained in any record of the file. integer-3 specifies the maximum number of character positions to be contained in any record of the file. integer-4 specifies the minimum number of characters in the smallest size data record. integer-5 specifies the maximum number of characters in the largest size data record. data-name-1 must be an elementary unsigned integer in the WORKING-STORAGE or LINKAGE section. Description. The size of a record is determined by taking the sum of the numbers of all characters in all fixed length elementary items, and adding to that sum the maximum number of characters in any variable length item subordinate to the record. This sum may differ from the actual size of the record because of slack bytes. Refer to the SYNCHRONIZED and USAGE clause descriptions appearing later in this chapter. If the RECORD clause is not specified in all formats, the size of each data record is completely defined in the record description entry. Fixed Length Records. Format 1 is used to specify fixed length records. integer-1 specifies the number of character positions contained in each record in the file. Variable Length Records. Format 2 is used to specify variable length records. The number of character positions associated with a record description is determined by the sum of the number of character positions in all elementary data items excluding redefinitions and renamings, plus any implicit FILLER due to synchronization. If a table is specified, the minimum or maximum number of table elements described in the record is used in the summation above to determine the minimum or maximum number of character positions associated with the record description. If integer-2 is not specified, the minimum number of character positions to be contained in any record of the file is equal to the least number of character positions described for a record in that file. If integer-3 is not specified, the maximum number of character positions to be contained in any record of the file is equal to the greatest number of character positions described for a record in that file. If data-name-1 is specified, the number of character positions in the record must be placed into the data item referenced by data-name-1 before any RELEASE, REWRITE, or WRITE statement is executed for the file. If data-name-1 is specified, the execution of a DELETE, RELEASE, REWRITE, START, or WRITE statement or the unsuccessful execution of a READ or RETURN statement does not alter the content of the data item referenced by data-name-1. During execution of a RELEASE, REWRITE, or WRITE statement, the number of character positions in the record is determined by the following three conditions: * If data-name-1 is specified, by the content of the data item referenced by data-name-1. * If data-name-1 is not specified and the record does not contain a variable occurrence data item, by the number of character positions in the record. * If data-name-1 is not specified and the record does contain a variable occurrence data item, by the sum of the fixed portion and that portion of the table described by the number of occurrences at the time of execution of the output statement. If data-name-1 is specified, after the READ or RETURN statement for the file successfully executes, the contents of the data item referenced by data-name-1 indicate the number of character positions in the record just read. If the INTO phrase is specified in the READ or RETURN statement, the number of character positions in the current record that participate as the sending data items in the implicit MOVE statement are determined by the following two conditions: * If data-name-1 is specified, by the content of the data item referenced by data-name-1. * If data-name-1 is not specified, by the value that would have been moved into the data item referenced by data-name-1. Format 2 is the preferable way to specify variable length records. If format 3 is used, the RECORDING MODE clause must also be specified. In format 3 of the RECORD clause, the size of each data record is completely defined in the record description entry. The size of each data record is specified in terms of the number of character positions required to store the logical record, regardless of the types of characters used to represent the items within the logical record. The size of a record is determined by the sum of the number of characters in all fixed length elementary items plus the sum of the maximum number of characters in any variable length item subordinate to the record. This sum can be different from the actual size of the record. Example. The following example illustrates use of the RECORD VARYING clause. IDENTIFICATION DIVISION. PROGRAM-ID. COBVAR. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT IFILE ASSIGN TO "IFILE". SELECT IFILE2 ASSIGN TO "IFILE". DATA DIVISION. FILE SECTION. FD IFILE RECORD IS VARYING FROM 10 TO 50 DEPENDING ON LEN. 01 IREC. 05 FILLER PIC X OCCURS 10 TO 50 TIMES DEPENDING ON LEN. FD IFILE2 RECORD IS VARYING FROM 10 TO 50. 01 IREC2 PIC X(50). WORKING-STORAGE SECTION. 01 LEN PIC S9(4) BINARY. 01 LEN-ED PIC ++++9. 01 WREC PIC X(50). PROCEDURE DIVISION. P1. DISPLAY "EXAMPLE 1 ODO REC" OPEN INPUT IFILE PERFORM UNTIL LEN = -1 READ IFILE AT END MOVE -1 TO LEN NOT AT END DISPLAY IREC MOVE LEN TO LEN-ED DISPLAY "Length is ", LEN-ED END-READ END-PERFORM CLOSE IFILE DISPLAY SPACE DISPLAY "EXAMPLE 2 FIXED REC" OPEN INPUT IFILE2 MOVE ALL "X" TO IREC2 READ IFILE2 AT END MOVE -1 TO LEN END-READ DISPLAY IREC2 DISPLAY SPACE DISPLAY "EXAMPLE 3 READ INTO WREC" MOVE ALL "X" TO IREC2 WREC READ IFILE2 INTO WREC AT END MOVE -1 TO LEN END-READ DISPLAY IREC2 DISPLAY WREC CLOSE IFILE2. If IFILE contains the following data: 1234567890 123456789*123456789* 123456789*123456789*123456789* The program will produce the following output: EXAMPLE 1 ODO REC 1234567890 Length is +10 123456789*123456789* Length is +20 123456789*123456789*123456789* Length is +30 EXAMPLE 2 FIXED REC 1234567890XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX EXAMPLE 3 READ INTO WREC 123456789*123456789*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 123456789*123456789* RECORDING MODE Clause The RECORDING MODE clause is an HP extension to the ANSI COBOL standard. The RECORDING MODE clause specifies how logical records are contained in the file, and whether or not the logical record being read or written spans more than one physical record (generally because of hardware constraints or for I-O efficiency). This clause does not apply to sort-merge files. This clause is optional. Syntax.
[]
Parameters. F specifies fixed length logical records. This implies that no OCCURS DEPENDING on clause can be associated with any record description entry for the file. Also, if more than one record description entry is supplied for the file, all record lengths calculated from the record descriptions must be the same. This option is the only one that is valid for random access and relative files. V specifies variable length logical records. U specifies undefined length logical records. This kind of file cannot be blocked. Therefore, the BLOCK CONTAINS clause need not be used for this kind of file. S enables the MULTI-RECORD (or more accurately, "multi-block") option. This option allows the reading or writing of a single logical record across more than one physical record. Description. If none of the above codes is specified, an F is the default value. Logical records are contained in files as either fixed, variable, or undefined in length. A fixed length record file contains logical records whose lengths are all the same. A variable length record file contains logical records whose lengths may vary. In such a file, each record is preceded by a[REV BEG] two-byte count, which specifies the length of that[REV END] particular record. An undefined length record file contains logical records of undetermined length. In such a file, each logical record is equivalent to one physical record, and a physical record is as long as the longest possible logical record in the file. To clarify the case of logical records spanning more than one physical record, assume you want to read logical records of 128 characters each from a card reader. Each card represents a physical record of 80 characters. Therefore, to read one logical record, you must read two physical records. In such a case, you could specify the recording mode as equal to S, the operating system's multi-record option. VALUE OF Clause The VALUE OF clause is an obsolete feature of the 1985 ANSI COBOL standard. The VALUE OF clause allows you to access existing files on labeled tapes or to create a new labeled tape. A label contains identification, whether the label is in IBM or ANSI standard format, the expiration date of the file protection, and the position of the file on the tape. This clause does not apply to sort-merge files. Syntax.
[]
Parameters. label-info-1 specifies one of the following fields: VOL, LABELS, SEQ, or EXDATE. Each of these fields is described in Table 7-1 on the following page. data-name-2 must be described in the WORKING-STORAGE SECTION. This name can be qualified, but cannot be subscripted, indexed, or described with the USAGE IS INDEX clause in a data description. It is used to specify the value of the associated label-info entry. The possible values are shown in Table 7-1 on the following page. literal-1 a COBOL literal or a figurative constant. Description. The data name associated with VOL can specify a data item of any category, but must consist of a maximum of six characters or digits. The data name associated with SEQ can also specify a data item of any category, but must consist of a maximum of four digits or characters. The data names associated with LABELS and EXDATE must name alphanumeric data items; the respective picture strings for LABELS must describe data that is three characters long, EXDATE that is eight characters long and of the form, mm/dd/yy. All VALUE OF clauses for each external file in the run unit must be consistent. Table 7-1. Values of the LABEL INFO and DATA NAME Parameters in the VALUE OF Clause ----------------------------------------------------------------------------------------------- - label-info-n - Meaning - data-name-n or literal-n - ----------------------------------------------------------------------------------------------- | VOL | Volume identification. | Any combination of one to six characters | | | | from the set A through Z, and 0 through 9. | ----------------------------------------------------------------------------------------------- - LABELS - ANSI standard or IBM format. - ANS or IBM. - ----------------------------------------------------------------------------------------------- | SEQ | Relative position of file on a | 0 to 9999, NEXT, or ADDF. | | | magnetic tape. | | ----------------------------------------------------------------------------------------------- | EXDATE | Date when file may be written | Date, in the form month/day/year. The | | | over. Until that time, the | default is 00/00/00. | | | file is protected. | | ----------------------------------------------------------------------------------------------- Example. DATA DIVISION. FILE SECTION. FD TAPEFL VALUE OF VOL IS "JTAPE1", LABELS IS "ANS", SEQ IS 10, EXDATE IS "02/25/85". : FD NEW-TAPE VALUE OF VOL IS "JTAPE2", LABELS IS "ANS", SEQ IS "ADDF", EXDATE IS "02/25/85". : PROCEDURE DIVISION. DISPLAY "PLEASE MOUNT NEW TAPE FOR JTAPE2" UPON CONSOLE. OPEN OUTPUT NEW-TAPE, INPUT TAPEFL. . . . Assuming that NEW-TAPE names a new file, when the OPEN statement above is executed, the information given in the VALUE OF clause is used to write a label for the tape volume. When TAPEFL is opened, the specification of 10 for the SEQ value causes the tape to automatically be placed at the beginning of the tenth file on the volume named JTAPE1. Note that a message requesting that the volumes JTAPE2 and JTAPE1 be mounted is displayed on the operator's console. Because JTAPE2 is a new volume, the DISPLAY statement above was used to tell the operator that JTAPE2 does not already exist.


MPE/iX 5.0 Documentation