IBM i message

CPF2112: Object already exists

CPF2112 means the command tried to put an object into a library that already holds an object with the same name and type. The message gives the object name, library and type.

Other names for this code

Also written as CPF2112 object already exists, MSGID CPF2112, MONMSG CPF2112, RNMOBJ CPF2112, object already exists in library.

What it means

CPF2112 is an escape message from QCPFMSG with the text "Object &1 in &2 type *&3 already exists". Within one library on IBM i, the name and the type together must be unique. A file and a program can share a name, but two files can't.

Commands that create a name in a library check this first. RNMOBJ sends CPF2112 when the new name is already taken in that library. Commands that move or copy an object into another library, such as MOVOBJ and CRTDUPOBJ, hit the same rule when the target library already has an object of that name and type. None of these commands replaces the existing object. The command stops and leaves both objects as they were.

When CRTDUPOBJ copies many objects at once, it reports each one it couldn't copy in the job log and then ends with a summary message, so you may see CPF2112 for some objects without the whole command looking failed at first glance.

Common causes

  • A program renames, moves or copies an object, and an earlier run already put an object with that name in the target library.
  • A work object in QTEMP is created again in the same job without being deleted first, for example when a menu option runs twice in one session.
  • RNMOBJ was given a new name that is already used by another object of the same type in that library.
  • A promotion or deployment step copies objects into a library that still holds the old versions.

How to find the problem

  1. Open the job log with DSPJOBLOG, put the cursor on CPF2112 and press F1. The help names the object, library and type. The command logged just before it shows what the program was trying to do.
  2. Run WRKOBJ OBJ(ACCTLIB/PAYWORK) to see the object that is already there, with its type, owner and creation date.
  3. Use DSPOBJD on the existing object to see when it was created and by whom. That tells you whether it is a leftover from an earlier run or something else entirely.

How to fix it

  • Delete the old object first when the program owns it, for example DLTF FILE(QTEMP/PAYWORK) with MONMSG MSGID(CPF2105), then run the copy or move.
  • Rename the existing object to keep a backup copy, then repeat the command.
  • Choose a different name or a different target library if the existing object belongs to something else.
  • In a CL program where an existing object is acceptable, monitor for CPF2112 after the command and carry on.

What it looks like

Object PAYWORK in QTEMP type *FILE already exists.

IBM documentation

IBM Display Message Descriptions (DSPMSGD). Use the documentation for your installed release.

This link opens the relevant IBM reference library or lookup instructions. Match the complete code and your installed product release; it is not a code-specific review.

Read the installed message description:

DSPMSGD MSGID(CPF2112) MSGF(QSYS/QCPFMSG)

Also inspect the full job log and second-level message text, including substitution values.

Report a correction to WND Software.

Questions

Can two objects in one library have the same name?

Yes, if they are different types. A *FILE and a *PGM can both be called PAYWORK. Two objects of the same name and the same type can't share a library.

Does CRTDUPOBJ or MOVOBJ overwrite an existing object?

No. They leave the existing object alone and report it. Delete or rename the old object first if you want to replace it.

Why does my QTEMP work file already exist?

QTEMP lasts as long as the job. If the same interactive session runs the program twice, the work file from the first run is still there.