The need for "temporary" files arises in nearly every application system at one time or another. Temporary files are commonly used for holding summarized data, passing large amounts of information between programs, or for preparing "flat" files for transfer to other systems (such as PCs).
The technique described in the following example is not new, but the application of it within LANSA yields some useful results.
Given that you identify a need for a temporary file called WRKFILE which contains the fields A, B and C, the suggested technique is as follows:
1.Define fields A, B and C in the Repository (if not already defined).
2.Define file WRKFILE as a normal LANSA database file in the default data library of the current partition. Then make it operational.
Note that this version of the file will never actually contain any data.
3.When you want to use WRKFILE in an RDML program, code the following starting lines into the program:
CHANGE FIELD(#LIB) TO(*PARTDTALIB)
EXEC_OS400 COMMAND('CRTDUPOBJ OBJ(WRKFILE) FROMLIB(#LIB) +
POINT FILE(WRKFILE) TO_LIBRARY(QTEMP)
This code will cause a duplicate version of file WRKFILE to be created in library QTEMP (your job's temporary library), and will then "point" all I/O commands involving file WRKFILE to the version of the file in QTEMP.
The best features of using work files in special library QTEMP are: