READ
|
WORK
[FILE ]
work-file-number
[ONCE ]
|
||||||||
RECORD
operand1
|
|||||||||
[AND ]
[SELECT ]
|
OFFSET
n
|
operand2 | |||||||
FILLER
nX
|
|||||||||
[GIVING
LENGTH operand3]
|
|||||||||
AT [END ] [OF ] [FILE ]
|
|||||||||
statement | |||||||||
END-ENDFILE
|
|||||||||
statement | |||||||||
END-WORK
|
READ
|
WORK [FILE ]
work-file-number
[ONCE ]
|
||||||||
RECORD {operand1
[FILLER
nX ]}
|
|||||||||
[AND ]
[SELECT ]
|
OFFSET
n
|
operand2 | |||||||
FILLER
nX
|
|||||||||
[GIVING LENGTH
operand3]
|
|||||||||
AT [END ] [OF ] [FILE ]
|
statement | ||||||||
DO
statement
DOEND
|
|||||||||
statement | |||||||||
[LOOP ]
|
This document covers the following topics:
For an explanation of the symbols used in the syntax diagram, see Syntax Symbols.
Related Statements: CLOSE WORK FILE | DEFINE WORK FILE | WRITE WORK FILE
Belongs to Function Group: Control of Work Files / PC Files
The READ WORK FILE
statement is used to read data from a
non-Adabas physical sequential work file. The data is read sequentially from
the work file. How it is read is independent of how it was written to the work
file.
This statement can only be used within a program to be executed
under Com-plete, CICS, CMS, TSO or TIAM, or in batch mode. Appropriate JCL or
system commands must be executed to allocate the work file. For further
information, see the Operations documentation. For
information on work file assignments, see profile parameter
WORK
in the
Parameter Reference.
READ WORK FILE
initiates and executes a processing loop for
reading of all records on the work file. Automatic break processing may be
performed within a READ WORK FILE
loop.
Notes:
READ WORK FILE
statement, Natural automatically closes the work
file.
READ WORK FILE
processing loop.
Operand | Possible Structure | Possible Formats | Referencing Permitted | Dynamic Definition | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
operand1 | S | A | G | A | U | N | P | I | F | B | D | T | L | C | G | yes | yes | |||
operand2 | S | A | G | A | U | N | P | I | F | B | D | T | L | C | yes | yes | ||||
operand3 | S | I | yes | yes |
Format C is not valid for Natural Connection.
See also Field Lengths.
Syntax Element Description:
work-file-number |
Work File Number:
The number of the work file (as defined to Natural) to be read. Variable Index
Range:
When reading an array from a work file, you can specify a variable index range for the array. For example: READ WORK FILE work-file-number #ARRAY (I:J) |
|
---|---|---|
ONCE |
ONCE Option:
If a |
|
RECORD operand1 FILLER nX |
RECORD Option:
If A In structured mode, or if the record to be used is defined using a
No checking and no conversion is performed by Natural on the data contained in the record. It is the user's responsibility to describe the record layout correctly in order to avoid program abends caused by non-numeric data in numeric fields. Because no checking is performed by Natural, this option is the fastest way to process records from a sequential file. The record area defined by operand1 is filled with blanks before the record is read. Thus, an end-of-file condition will return a cleared area. Short records will have blanks appended. The RECORD option cannot be used:
If work file type CSV is used, the RECORD option is ignored and the processing switches to SELECT mode. |
|
SELECT |
SELECT Option (Default):
If |
|
OFFSET n | OFFSET 0 indicates the first byte of the record.
OFFSET cannot be specified for work files defined
as TYPE UNFORMATTED .
|
|
FILLER nX | Indicates that n bytes are to be skipped in the input record. | |
Natural will assign the selected values to the individual fields and check that numeric fields as selected from the record actually contain valid numeric data according to their definition. Because checking of selected fields is performed by Natural, this option results in more overhead for the processing of a sequential file. If a record does not fill all fields specified in the
If the file type CSV is read, the |
||
GIVING LENGTH operand3 |
The operand3 must be defined with format/length I4. If the work file is defined as If the |
|
AT END OF FILE |
The If the |
|
END-WORK | The Natural reserved word
END-WORK must be used to end the READ WORK FILE
statement.
|
The field lengths in the Operand Definition Table are determined as follows:
Format | Length |
---|---|
A, B, I, F | The number of bytes in the input record is the same as the internal length definition. |
N | The number of bytes in the input record is the sum of internal positions before and after the decimal point. The decimal point and sign do not occupy a byte position in the input record. |
P, D, T | The number of bytes in the input record is the sum of positions before and after the decimal point plus 1 for the sign, divided by 2 rounded upwards. |
L | 1 byte is used. For C format fields, 2 bytes are used. |
Field Definition | Input Record |
---|---|
#FIELD1 (A10) | 10 bytes |
#FIELD2 (B15) | 15 bytes |
#FIELD3 (N1.3) | 4 bytes |
#FIELD4 (N0.7) | 7 bytes |
#FIELD5 (P1.2) | 2 bytes |
#FIELD6 (P6.0) | 4 bytes |
See also Format and Length of User-Defined Variables in the Programming Guide.
Work File Type | Handling |
---|---|
UNFORMATTED | Reading a dynamic variable from an UNFORMATTED work file puts
the complete rest of the file into the variable (from the current position). If
the file exceeds 1073741824 bytes, then a maximum of 1073741824 bytes is placed
into the variable.
Format: |
FORMATTED | Reading a dynamic variable from a FORMATTED work file fills the variable in its currently defined length (including length 0). If the end-of-file is reached, the remainder of the current field is filled with blanks. The subsequent fields are unchanged. |
** Example 'RWFEX1': READ WORK FILE ************************************************************************ DEFINE DATA LOCAL 1 EMPLOY-VIEW VIEW OF EMPLOYEES 2 PERSONNEL-ID 2 NAME * 1 #RECORD 2 #PERS-ID (A8) 2 #NAME (A20) END-DEFINE * FIND EMPLOY-VIEW WITH CITY = 'STUTTGART' WRITE WORK FILE 1 PERSONNEL-ID NAME END-FIND * * ... * READ WORK FILE 1 RECORD #RECORD DISPLAY NOTITLE #PERS-ID #NAME END-WORK * END
#PERS-ID #NAME -------- -------------------- 11100328 BERGHAUS 11100329 BARTHEL 11300313 AECKERLE 11300316 KANTE 11500304 KLUGE 11500308 DIETRICH 11500318 GASSNER 11500343 ROEHM 11600303 BERGER 11600320 BLAETTEL 11500336 JASPER 11100330 BUSH 11500328 EGGERT