RPG (IBM i / AS/400) · File status code

Status Code 01021

What does Status Code 01021 mean in RPG (IBM i / AS/400)?

A WRITE tried to add a record whose key duplicates one already in the file, or tried to write to a relative record number that's already occupied, and the file doesn't allow duplicates.

Status Code 01021IBM i / OS/400 · ILE RPG

Condition

A WRITE tried to add a record whose key duplicates one already in the file, or tried to write to a relative record number that's already occupied, and the file doesn't allow duplicates.

Fix

CHAIN for an existing record with that key before the WRITE when a duplicate is possible, and decide whether the correct operation is UPDATE rather than WRITE.

Related file status code