To name a work file
Using the Job Definition (jobdef) utility, users can override the default work file path that you define using the Work Definition (workdef) utility.
-
On the Work File Definition form, type an internal
name and prefix in the fields shown below.
In this field Type or Select (F4) File Name The internal work file name that is to be used to access the file in a COBOL program. The file is not stored on disk with this name; see the following description of external names for work file storage. Prefix The three-character prefix for the fields in the work file. This is the prefix used when using the work file fields in a program.
For example, if the prefix is WK1 and a field is COMPANY, the field in the program is WK1-COMPANY.
Note: Do not use prefixes SF, SF1 - SF9, and S10. They are reserved for system use (sort files). The system overwrites any existing files that use these prefixes if it needs to use them for naming sort files.External names (paths for work files) are created by the Lawson batch job system or are stored in a variable by the COBOL program. There are four methods of specifying work file external names: COMMON, WSFLD, LOCAL, and SORT.
Location Explanation COMMON When a shell is built for the COBOL program (bldsh), a call to BldCommonFileName made from 000-START-UP-JOB creates the name and path: $LAWDIR/productline/work/VALUE-ID/VALUE-ID
VALUE-ID is the text in the Value/WsFld Id field in workdef when "Value" is marked. For example, if you type APCHECKS in this field and the $LAWDIR directory is /lawson, the work file is stored as
/lawson/productline/work/APCHECKS/APCHECKS
.VALUE-ID secures users from file deletion privileges. If a user has no permissions to a file, they can still delete the file if they have access to the work directory. The work directory can be secured so that users cannot delete these files.
If no text is entered, the LOCAL method is used.
LOCAL When a COBOL program shell is built, a call to BldLocalFileName from the 000-START-UP-JOB section creates the file:
$LAWDIR/print/username/jobname/stepnbr.
Value or WsFld ID may be marked, but no text is entered in the Value/WsFld Id field in workdef.
WSFLD When a shell is built for the COBOL program (bldsh), a call to 900-BUILD-TMP-FILE-NAME moves a file name and path to WS-TMP-FILE. WS-TMP-FILE is then moved to the WS-FIELD defined in the program.
Case 1: WsFld Marked; path not stored by program
When WsFld is marked in workdef but the program does not store a path in the Value/WsFld Id field variable, the program stores this name and path in this working storage variable:
$LAWDIR/productline/work/tmp<#>.<pid>.
This option is often used for programs that run concurrently so that more than one program cannot access the same work file.
# is a running count of temporary files already built.
pid is the Process ID of the COBOL program.
Note: If a program stores several work files that use the same work file description, you need to store each of them under a different name. You could type the variable WS-WORK-FILE-NAME in this field and code the program to move a different name to this variable each time the program opens a work file.Case 2: WsFld Marked; path stored by program
When WsFld is marked in workdef and the program stores a file name or path in the Value/WsFld Id field variable, there are two possible locations.
If a file name only (not a full path) is stored, then the file opens under the standard print directory:
$LAWDIR/print/username/jobname/stepnbr/WorkDir
.For more information on print files, see Getting Started with the Lawson Interface Desktop.
If a path is stored, the file opens in that directory.
Note: No checking is done to ensure the path exists, and a program error occurs if it does not.SORT The TMPDIR environment variable specifies the file name and location. The default (often
/tmp
,/user/tmp
, or/var/tmp
) depends upon the operating system.Sort files are temporary and are deleted when the sort finishes.
-
Press Mark on Value
ID (left side of the field) or WsFld ID (right side of the field)
to specify an external file name and location.
- or -
Select Yes for Sort File, to use a COBOL SORT.
Sort files are used with a COBOL SORT statement. Work File Definition causes the appropriate code to be generated for the File Division (FD) of the program shell; the programmer must add the logic to use the file.
If you select Yes for Sort File, do not type a value in the File Media and Value/WsFld ID fields. The program creates a name and path for sort files. You are now ready to select fields. Skip the rest of this subsection and continue at Selecting Fields for Work File Records.
-
In the Name field type a name or path to determine
where the work file is stored.
For this selection Type Value ID The external name for the work file, or this field may be left blank.
If a name is entered, the system stores the file as described in the COMMON method.
If this field is blank, the system stores the file as described in the LOCAL method.
WsFld ID The working storage variable for the work file name and path. This field may be left blank. For more information, see the WSFLD method description. - Move to the File Status field (optional).
- Type a name or path to create a file that stores the status of the work file (whether it is open or closed).