WRITE
WORK [FILE ] work-file-number
[VARIABLE ]
operand1
|
This document covers the following topics:
For explanations of the symbols used in the syntax diagram, see Syntax Symbols.
Related Statements: DEFINE WORK
FILE
| READ WORK
FILE
| CLOSE WORK
FILE
| DOWNLOAD PC FILE
Belongs to Function Group: Control of Work Files / PC Files
The WRITE WORK FILE
statement is used to write records
to a physical sequential work file.
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 READ WORK
FILE
statement.
Note:
For Unicode and code page support, see Work Files and Print Files on Windows and Linux
Platforms in the Unicode and Code Page
Support documentation.
Operand Definition Table:
Operand | Possible Structure | Possible Formats | Referencing Permitted | Dynamic Definition | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
operand1
|
C | S | A | G | N | A | U | N | P | I | F | B | D | T | L | C | G | yes | no |
Note:
When using the work file types ENTIRECONNECTION
or TRANSFER, operand1 may neither be of format C,
nor G.
Syntax Element Description:
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.
Note:
No format conversion is performed for fields that are written to
a work file.
Examples of field representations:
Field Definition | Output 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 |
For the special considerations that apply when WRITE WORK
FILE
is used for the Natural system function
AVER
,
NAVER
,
SUM
or
TOTAL
, see
Format/Length
Requirements for AVER, NAVER, SUM and TOTAL in the
System Functions documentation.
Work File Type | Handling |
---|---|
|
The work file types ASCII
and ASCII-COMPRESSED can handle dynamic and large variables with a
maximum field/record length of 32766 bytes.
|
|
The work file type SAG
(binary) cannot handle dynamic variables and will produce an error. It can,
however, handle large variables with a maximum field/record length of 32766
bytes.
|
|
The work file type
TRANSFER can handle dynamic variables with a maximum field/record
length of 32766 bytes. The work file type
ENTIRECONNECTION cannot handle dynamic variables.
They can both,
however, handle large variables with a maximum field/record length of
1073741824 bytes.
|
|
Large and dynamic variables can be written into work files
or read from work files using the two work file types For the work file type In the With the |
CSV |
The maximum field/record length is 32766 bytes for dynamic and large variables. Dynamic variables are supported. X-arrays are not allowed and will result in an error message. |
** 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