The Remove All Logical File Members tool is designed for the
situation where a batch program will add many records to a physical
file and one or more keyed logical files exist over the physical.
In this case, it is faster to remove the logical file members before
the batch program runs and then add them back after the batch
program.
The tool provides both the Remove and Add commands. A typical
sequence of commands would be:
RMVALLLFM FILE(FILEX)
CALL PGM(PGMA) /* Adds records to FILEX */
ADDALLLFM FILE(FILEX)
Note that the physical file is named on the RMV/ADDALLLFM commands.
The RMV command uses DSPDBR to determine the dependent logical files.
A spooled file is output by each of the commands identifying the
logical files used and the members removed and added.
The physical file is locked to an *EXCL during the processing of
either command.
When the ADDALLLFM command is run, adding the member causes any keyed
access path to be built.
SQL Indexes and Encoded Vector Indexes
--------------------------------------
Logical files created by SQL cannot be removed by RMVM. To support
the need to do this, RMVALLLFM saves the file and then deletes it.
ADDALLLFM restores the file.
The files are saved to save files in the TAAWORK library.
Monitoring for errors on the Call
---------------------------------
In the previous code shown, if the CALL command fails, the ADDALLLFM
command will not run. To ensure that the logical file members would
be added back, the following is suggested code:
DCL &FAIL *CHAR LEN(1)
.
RMVALLLFM FILE(FILEB)
CALL PGM(PGMA) /* Adds records to FILEX */
MONMSG MSGID(CPF0000) EXEC(DO) /* Some failure */
CHGVAR &FAIL 'X'
ENDDO /* Some failure */
ADDALLLFM FILE(FILEB)
IF (&FAIL *EQ 'X') DO /* Failure occurred */
SNDESCMSG MSG('A failure occurred ...')
ENDDO /* Failure occurred */
Other comments about RMVALLLFM
------------------------------
A logical file can have 0, 1, or many members. The same member name,
text description, and SHARE parameter value is used when the member
is added. A restriction exists in that the DTAMBRS parameter on
ADDLFM is used with a default of *ALL. This means that all members
of the physical file will be considered in the logical file member.
It is considered an error if no members are removed or added.
However, it would be considered valid to have multiple dependent
logical files, some with and some without members. As long as one
member is removed or added to any logical file and no errors occur,
the commands will complete successfully.
The TAARMVMBRS file is placed in QTEMP by the RMVALLLFM command and
contains one record for each member removed. The file is used by the
ADDALLLFM command to add the members back. It is invalid to specify:
RMVALLLFM FILE(FILEX)
CALL PGM(PGMA) /* Adds records to FILEX */
ADDALLLFM FILE(FILEY)
When ADDALLLFM begins to process the TAARMVMBRS file in QTEMP, it
recognizes that the file named on the command (FILEY) is not the same
as was used by RMVALLLFM (FILEX). The consecutive use of ADDALLLFM
and RMVALLLFM to the same file is required.
Similarly, you cannot use RMVALLLFM on two different physical files
without an intervening ADDALLLFM.
If you want to use RMVALLLFM in one job and ADDALLLFM in a second
job, you must move or copy the TAARMVMBRS file from QTEMP to a
permanent library after ADDALLLFM is run and then move it back to
QTEMP for use by RMVALLLFM in the separate job.
SQL Indexes and Encoded Vector Indexes
--------------------------------------
These objects are logical files that contain a single member that
cannot be removed. RMVALLLFM simulates removing of the member by
saving the file to a save file in library TAAWORK. ADDALLLFM
restores the save file.
If a special logical file exists, a data area (RMVALLLFM) is also
created in TAAWORK to help control the save files.
The save files are named 'S' followed by up to a 9 digit number.
RMVALLLFM Command parameters *CMD
----------------------------
FILE The qualified file name of the physical file which
will be checked for dependent logical files. Any
logical file members will be removed. The members
removed are written to the TAARMVMBRS file in QTEMP.
The library value defaults to *LIBL. *CURLIB may
also be used.
ADDALLLFM Command parameters *CMD
----------------------------
FILE The qualified file name of the physical file which
will have members added to dependent logical files.
The members to be added are found in the TAARMVMBRS
file in QTEMP as created by RMVALLLFM.
The library value defaults to *LIBL. *CURLIB may
also be used.
CLNALLLFM Command parameters *CMD
----------------------------
JOBNBR A list of up to 25 job numbers to be used to cleanup
the save files in TAAWORK. This is only required if
SQL indexes or encoded vector indexes exist for the
physical file.
*CURRENT is the default to delete the save files for
the current job.
Restrictions
------------
The DTAMBRS parameter on ADDLFM is used with a default of *ALL. This
means that all members of the physical file will be considered in the
logical file member.
Prerequisites
-------------
The following TAA Tools must be on your system:
CRTDUPPF Create duplicate physical file
EDTVAR Edit variable
PRINT Print
RTVDIAGMSG Retrieve diagnostic message
SNDCOMPMSG Send completion message
SNDESCMSG Send escape message
SNDSTSMSG Send status message
Implementation
--------------
None, the tool is ready to use.
Objects used by the tool
------------------------
Object Type Attribute Src member Src file
------ ---- --------- ---------- ----------
RMVALLLFM *CMD TAADBHL QATTCMD
ADDALLLFM *CMD TAADBHL2 QATTCMD
CLNALLLFM *CMD TAADBHL3 QATTCMD
TAADBHLC *PGM CLP TAADBHLC QATTCL
TAADBHLC2 *PGM CLP TAADBHLC2 QATTCL
TAADBHLC3 *PGM CLP TAADBHLC3 QATTCL
TAADBHLC9 *PGM CLP TAADBHLC9 QATTCL
TAADBHLR9 *PGM RPG TAADBHLR9 QATTRPG
TAADBHLP *FILE PF TAADBHLP QATTDDS
Structure
---------
RMVALLLFM Cmd
TAADBHLC CL pgm
TAADBHLC9 CL pgm
TAADBHLR9 RPG pgm
TAADBHLP file (TAARMVMBRS in QTEMP)
ADDALLLFM Cmd
TAADBHLC2 CL pgm
TAADBHLP file (TAARMVMBRS in QTEMP)
CLNALLLFM Cmd
TAADBHLC3 CL pgm
|