Housekeeping AS400 File PART 1 – Clear Data

Housekeeping is an important part of a system or data. With housekeeping, we expected to maintain system stability and reliability.

The housekeeping method that will be discussed first is to clear files or to clear the entire contents of the record. For this section, if we have several files that can be done by deleting all the data in the file, then the following methods can be used:

Using SQL statement


Using Command CLRPFM

If the file is large enough, it is advisable to submit a job with SBMJOB. This command will be executed if there is no locking in the file.

Using Swap Empty File

Prepare a blank file using the CRTDUPOBJ command to another library / temporary library. In the example below, duplicate FILEA from LIBA to LIBB.

Ensure the following conditions:

  • If the file does not contain multiple logical files, duplicate the logical files to a temporary library. To check the logical file in the file, use the DSPDBR command
  • If files in the source library are journaled, the files in the temporary libraries are journalized using the STRJRNPF command

Swap files using the MOVOBJ command, with steps, Move File FILE along with logical files (if any) in LIBA to LIBC (second temporary library), then move FILEA along with logical files (if any) in LIBB to LIBA (empty files are moved to source library).

Of the three methods above in the clear file, I prefer to use the swap object method. But it also depends on how long your application downtime can be accepted. Doing a study first is highly recommended.

Removing Deleted Record on AS400 Physical File

When we delete a record using SQL, the record does not actually disappear immediately from the table / file. There are several ways to delete a deleted record in a file, including:

Using the RGZPFM command, with exclusive lock. This command is suitable for processing files that are not locked continuously.

Pastikan tidak ada locking pada File yang akan di reorganize.

RGZPFM with Share Update, is used if the file to be reorganized has a continuous locks and requires downtime to release the locks.

Copy File (CPYF) Command

AS400 table is a *FILE object, the CPYF command is used to copy all or part of the table structure in the database to another table. The following is the copy file command that I usually use:

Member Option > MBROPT

# MBROPT(*ADD) - Copy all record source files to the target file
# MBROPT(*REPLACE) - Copy all the record source files to the target file starting with delete member files first

Create File > CRTFILE

# CRTFILE(*YES) - Create a new file in the target library
# CRTFILE(*NO) - If file is already available in the target library

Copy From – To Record Number > FROMRCD – TORCD

# FROMRCD (*START/<rrn>) - *START if you want to copy the first record from the source file, or <rrn> relative record number if you want from a specific record number
# TORCD (*END/<rrn>) - *END if you want to copy until the last record from the source file, or <rrn> relative record number if you want to reach a certain record number

Record Format Field Mapping – FMTOPT

This parameter is used if the source file format is different from the target file format
# FMTOPT (*NOCHK) - Copy files based on the length of the existing records
# FMTOPT (*MAP *DROP) - Copy files based on existing field names (*MAP) and ignore non-existent fields (*DROP)



Recovery Point Object and Recovery Time Object

Disaster Recovery always been associated with Recovery Point Objects and Recovery Time Objects (RPO and RTO).

Source: MIMIX Documentation

Recovery Point Object (RPO) is the last point in time that an IT system can be recovered. In this section, the technology used determines how far behind the data or even the loss of a company when there is a disruption to the main system. RPO is used in technologies such as backup, storage replication, data replication and others.

Recovery Time Object (RTO) is related to the time it takes for an IT system to operate normally again when a planned / unplanned interruption occurs. For unplanned interruptions, error detection, data recovery and bringing the application back online are included in RTO.

AIX Create Volume Group, Logical Volume dan File System From New Disk /LUN

Create Volume Group (VG)

Use the cfgmgr command to scan and identify all installed configurations.


Use lspv command to see the pv configuration.


hdisk18         00f86d5fa9781a05                    rootvg          active
hdisk27         00f86d5fa99e3994                    datavg          active
hdisk30         none                                None            active

Based on the example above, there is a hdisk30 on the system that has not been configured anything. Use the command bootinfo -s hdiskxx to find out the size of the LUN.

#bootinfo -s hdisk30

Continue reading AIX Create Volume Group, Logical Volume dan File System From New Disk /LUN

Backup, Restore and Check the History of DB2 AIX

Backup, restore and check history that I often use. Login using DB2 user.

Interactively backup database and logs:

db2 backup database <dbname> online to </filesystem> include logs

To submit into background job:

nohup db2 backup database <dbname> online to </filesystem> include logs &

To restore, you can use:

db2 restore database RP1 from </filesystem> taken at <yyyymmddhhmmss>
or for background job:
nohup db2 restore database RP1 from </filesystem> taken at <yyyymmddhhmmss> &

To check backup/restore process:

db2top and then press u
db2 list utilities show detail

To find out the history of backup activities by:

db2 list history backup since <yyyymmdd> for <dbname>

Logika Bergantung Logistik