Processing Files and Records
6.1 Defining Files and Records
Example 6–4 Creating Variable-Length Records with the DEPENDING ON
Phrase
FILE SECTION.
FD
INFILE.
01
IN-REC.
03
IN-TYPE
PIC X.
03
REST-OF-REC
PIC X(499).
FD
OUTFILE
RECORD VARYING FROM 200 TO 500 CHARACTERS
DEPENDING ON OUT-LENGTH.
01
OUT-REC
PIC X(500).
WORKING-STORAGE SECTION.
01
OUT-LENGTH
PIC 999 COMP VALUE ZEROES.
Example 6–5 Creating Variable-Length Records with the RECORD VARYING
Phrase
FILE SECTION.
FD
OUTFILE
RECORD VARYING FROM 200 TO 500 CHARACTERS.
01
OUT-REC-1
PIC X(200).
01
OUT-REC-2
PIC X(500).
Example 6–6 Creating Variable-Length Records and Using the OCCURS Clause
with the DEPENDING ON Phrase
.
.
.
FILE SECTION.
FD
PARTS-MASTER
RECORD VARYING 118 TO 163 CHARACTERS.
01
PARTS-REC.
03
P-PART-NUM
PIC X(10).
03
P-PART-INFO
PIC X(100).
03
P-BIN-INDEX
PIC 999.
03
P-BIN-NUMBER
PIC X(5)
OCCURS 1 TO 10 TIMES DEPENDING ON P-BIN-INDEX.
.
.
.
Example 6–6 creates variable-length records by using the OCCURS clause
with the DEPENDING ON phrase in the record description. Compaq COBOL
determines record length by adding the sum of the variable record’s fixed portion
to the size of the table described by the number of table occurrences at execution
time.
In this example, the variable record’s fixed portion size is 113 characters. (This
is the sum of P-PART-NUM, P-PART-INFO, and P-BIN-INDEX.) If P-BIN-
INDEX contains a 7 at execution time, P-BIN-NUMBER will be 35 characters
long. Therefore, PARTS-REC’s length will be 148 characters; the fixed portion’s
length is 113 characters, and the table entry’s length at execution time is 35
characters.
Processing Files and Records 6–11
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......