This document covers the following topics:
For an explanation of the symbols used in the syntax diagram, see Syntax Symbols.
Belongs to Function Group: Control of Work Files / PC Files
WRITE WORK FILE statement is used to write records to a
physical sequential work file.
This statement can only be used within a program to be executed
under Com-plete, CICS, 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
It is possible to create a work file in one program or processing loop
and to read the same file in a subsequent independent processing loop or in a
subsequent program using the
For Unicode and code page support, see Work Files and Print Files on Mainframe Platforms in the Unicode and Code Page Support documentation.
Operand Definition Table:
|Operand||Possible Structure||Possible Formats||Referencing Permitted||Dynamic Definition|
Neither Format C nor Format G is valid for Natural Connection.
Syntax Element Description:
Work File Number:
The work file number (as defined to Natural) to be used.
It is possible to write records with different fields to the same
work file with different
When the operand list includes a dynamic variable (that could
change in size for different executions of the
Variable Index Range:
When writing an array to a work file, you can specify a variable index range for the array. For example:
WRITE WORK FILE work-file-number VARIABLE #ARRAY (I:J)
Fields to Be Written:
An array may be referenced completely or partially to select the occurrences that are to be written to the work file.
Group Operands to be Written:
A group may be referenced using the group name. All fields belonging to the referenced group will be written to the work file, the sequence is determined by the sequence of the fields in the group. Fields resulting from a redefinition of the referenced group are not written to the work file. If the referenced group is defined as an array, the individual fields of the group are written to the work file as arrays in the definition sequence.
For the group definition
1 GROUP1 (1:3) 2 FIELD1 (A2) 2 FIELD2 (A3) 1 REDEFINE GROUP1 2 FIELD3 (A15)
WRITE WORK FILE 1 GROUP1(*)
is equivalent to
WRITE WORK FILE 1 GROUP1.FIELD1(*) GROUP1.FIELD2(*)
WRITE WORK FILE 1 GROUP1.FIELD3
is equivalent to
WRITE WORK FILE 1 GROUP1.FIELD1(1) GROUP1.FIELD2(1) GROUP1.FIELD1(2) GROUP1.FIELD2(2) GROUP1.FIELD1(3) GROUP1.FIELD2(3)
Fields written with a
WRITE WORK FILE statement are
represented in the external file according to their internal definition. No
editing is performed on the field values.
For fields of format A and B, the number of bytes in the external file is the same as the internal length definition as defined in the Natural program. No editing is performed and a decimal point is not represented in the value.
For fields of format N, the number of bytes on the external file is the sum of internal positions before and after the decimal point. The decimal point is not represented on the external file.
For fields of format P, the number of bytes on the external file is the sum of positions before and after the decimal point, plus 1 for the sign, divided by 2, rounded upward to a full byte.
No format conversion is performed for fields that are written to a work file.
Examples of Field Representation:
|Field Definition||Output Record|
When the Natural system functions
numeric fields (format N or P) are written to a work file, the internal length
of these fields is increased by one digit (for example,
SUM of a
field of format P3 is increased to P4). This has to be taken into consideration
when reading the work file.
|Work File Type||Handling|
||Work file type
||A dynamic variable is written in its currently defined length (including length 0).|
** Example 'WWFEX1': WRITE WORK FILE ************************************************************************ DEFINE DATA LOCAL 1 EMPLOY-VIEW VIEW OF EMPLOYEES 2 PERSONNEL-ID 2 NAME END-DEFINE * FIND EMPLOY-VIEW WITH CITY = 'LONDON' WRITE WORK FILE 1 PERSONNEL-ID NAME END-FIND * END