The attributes of files that are referenced in a WFL job can be assigned values in file declarations and file assignment statements. One point to be aware of when using a file assignment statement is that the attribute assignments can be executed in any order, not necessarily in the order listed. Thus, file assignment statements such as the following should be avoided:
F (TITLE=(SUPPLIES)COUNTEM,KIND=DISK, DEPENDENTSPECS=TRUE,OPEN=TRUE)
This example is intended to set certain attributes for a file, and then open it. However, the OPEN assignment might be executed before the others, which would not give the desired effect. The preferred method would be to use a separate OPEN statement following the file assignment statement.
The OPEN attribute of a file is implicitly set by the OPEN statement, and reset by the CRUNCH, LOCK, PURGE, RELEASE, and REWIND statements. These statements have additional effects aside from setting or resetting this attribute; see the descriptions of these statements in Statements.
The OPEN statement can have the additional effect of assigning the logical file all attributes of the physical file. This will occur if the physical file was pre-existing (not created by the job) and the file is declared in the job with the DEPENDENTSPECS attribute set to TRUE.
Example
The following file declaration associates the attributes of the physical file, (JACOB)OBJECT/LINE, with the logical file, FILEA, when the file is opened:
FILE FILEA (TITLE=(JACOB)OBJECT/LINE,KIND=DISK, NEWFILE=FALSE,DEPENDENTSPECS=TRUE);
This declaration provides the title and location of the file. The NEWFILE=FALSE assignment indicates that a file with the specified title and location already exists and is to be used rather than creating a new file of the same name.
When a file is declared in this way, the attributes that are not mentioned in the declaration assume their default values until the file is opened. Thereafter, the attributes will have the values of the physical file.
If a global file assignment is used to cause the task to use a file declared in the WFL job, then any changes that the task makes to the file attributes are retained by the file declared in the job. This is useful for making file attribute inquiries possible, but also can cause side effects if the file is reused by another task.
These side effects can arise because tasks might have conflicting expectations about whether a file is open or closed, and where the current record of the file is positioned. WFL does not automatically close a file at the end of a task; however, the task can close or rewind the file, and explicit file closing statements can be included in the WFL job to accomplish the same result.