Question & Answer
Question
How do you delete old and unused display devices programmatically.
Answer
This procedure can be used to delete old/unused devices from the system when the Subsystem jobs are receiving error message CPF146F.
- The message CPI146F indicates that the subsystem device table is full.
- The maximum number of devices on a device table is 74,000 as current releases.
- In order to recover from this issue, old and unused devices must be deleted from the system.
- Once the devices have been deleted, the subsystems getting the error CPI146F will attempt to reuse the entries that were cleaned from the tables, if an existing device is failing to obtain a Signon display, the device must be deleted and recreated. This is only applies to releases R730 and above.
- For older releases, a restart of the Subsystem is required to rebuild the device tables. If the QCTL subsystem is getting the error, the system must be IPLed in order for the subsystem to rebuild the table.
To get a count on the Number of Devices on the System follow the steps:
Step 1: Using the Run SQL Scripts tool, run the following SQL Statement:
SELECT COUNT(*) AS Number_Of_Display_Devices
FROM TABLE (
QSYS2.OBJECT_STATISTICS('QSYS', '*DEVD')
)
WHERE OBJATTRIBUTE = 'DSPVRT'

Method 1: Using the Last Used Date on the Device Description Object.
The date of last use is updated when a device, controller status, or both go beyond vary-on pending, the date of last use does not accurately reflect the use of the device . For example, if you set virtual devices, controllers, or both to ONLINE(*YES), although no data transfer or communications are established on the device, the date of last use is updated when an initial program load (IPL) is processing and the device is varied on
To programmatically delete devices that have not been used in 1 year, follow the steps:
Step 1: Using the Run SQL Scripts tool, run the following SQL Statement:
WITH TEMPDEV (OBJNAME, OBJTYPE, CREATED, LASTUSED, DAYSUSED, Attribute) AS (
SELECT OBJNAME,
OBJTYPE,
OBJCREATED,
LAST_USED_TIMESTAMP,
DAYS_USED_COUNT,
OBJATTRIBUTE
FROM TABLE (
QSYS2.OBJECT_STATISTICS('QSYS', '*DEVD')
)
WHERE OBJATTRIBUTE = 'DSPVRT'
AND LAST_USED_TIMESTAMP < CURRENT_DATE - 1 YEAR
)
SELECT OBJNAME,
OBJTYPE,
CREATED,
LASTUSED,
DAYSUSED,
Attribute,
QSYS2.QCMDEXC('DLTDEVD DEVD(' || OBJNAME || ') ') AS "Success"
FROM TEMPDEV;

NOTE 1: Adjust the the CURRENT_DATE value to the period. In our sample, the SQL will delete all devices that have not been used in more than 1 year.
NOTE 2: The SQL has no confirmation screen and will automatically delete all devices that match the criteria.
NOTE 3: The above SQL only works on Release R730 and above.
NOTE 4: A '1' on the Success column indicates that the DLTDEVD completed normally, a '-1' indicates the it failed.
Method 2: Using the Last Activity Date on Device Description.
Date of last activity is the last date for which data transfer, session or conversation establishment, or use of the hardware associated with a device description occurred.
Date of last activity is more accurate as it identifies devices that are being used by end users.
This Method is only available for releases 7.4 and 7.5 with the following PTF levels:
- Version 7.5 - SF99950 Level 8
- Version 7.4 - SF99704 Level 29
To programmatically delete devices that have not been used in 60 days, follow the steps:
Step 1: Using the Run SQL Scripts tool, run the following SQL Statement:
WITH TEMPDEV (OBJECT_NAME, OBJECT_ATTRIBUTE, STATUS_DESCRIPTION, LAST_USED_TIMESTAMP, TEXT_DESCRIPTION) AS (
SELECT OBJECT_NAME,
OBJECT_ATTRIBUTE,
STATUS_DESCRIPTION,
LAST_USED_TIMESTAMP,
TEXT_DESCRIPTION
FROM SYSTOOLS.CONFIGURATION_STATUS
WHERE OBJECT_TYPE = '*DEVD'
AND object_attribute = 'DSPVRT'
AND LAST_USED_TIMESTAMP < CURRENT_DATE - 60 DAYS
)
SELECT OBJECT_NAME,
OBJECT_ATTRIBUTE,
STATUS_DESCRIPTION,
LAST_USED_TIMESTAMP,
TEXT_DESCRIPTION,
QSYS2.QCMDEXC('DLTDEVD DEVD(' || OBJECT_NAME || ') ') AS "Success"
FROM TEMPDEV;

NOTE 1: Adjust the the CURRENT_DATE value to the period. In our sample, the SQL will delete all devices that have not been used in more than 60 Days year.
NOTE 2: The SQL has no confirmation screen and will automatically delete all devices that match the criteria.
NOTE 3: A '1' on the Success column indicates that the DLTDEVD completed normally, a '-1' indicates the it failed.
[{"Type":"MASTER","Line of Business":{"code":"LOB68","label":"Power HW"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CHjAAM","label":"Job and Work Management"}],"ARM Case Number":"TS013983088","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.3.0;7.4.0;7.5.0"}]
Was this topic helpful?
Document Information
Modified date:
26 March 2025
UID
ibm17029857