Refresh a Changed Program With CEMT SET PROGRAM NEWCOPY
Pick up a recompiled load module in a running CICS region with CEMT SET PROGRAM NEWCOPY or PHASEIN, and learn why the old copy sometimes stays.

You fix a bug, recompile, link the new load module into the library and run the transaction. The old behavior comes back. This is the most common early surprise in CICS, and it has a short explanation: CICS loads a program into storage once and keeps using that copy until you tell it otherwise. This post explains CEMT SET PROGRAM(...) NEWCOPY and its gentler partner PHASEIN in CICS Transaction Server for z/OS 6.1 on z/OS 3.1, shows how to check that the refresh worked and covers the two reasons it silently does not.
Why CICS keeps the old copy
The first time a task needs a program, CICS loads the module from a library in its DFHRPL concatenation into dynamic storage. Later tasks share that copy. CICS never rereads the library on its own, because the whole point of the monitor is to avoid I/O on each request. When you replace the member in the load library, the copy in storage is unchanged.
You can see which copy CICS holds with an inquiry.
CEMT INQUIRE PROGRAM(ORDPROG1) STATUS: RESULTS - OVERTYPE TO MODIFY
Prog(ORDPROG1) Len(0000004568) Cob Ena Pri Cics
Use(0000000012) Ent(08A3C450)
Newcopy count (0003)The layout varies by release, so read it as an illustration. Len is the length of the loaded module, Use is how many times it has been used since the last load and the new-copy count is how many times it has been refreshed. If Len is not the length of your new module, CICS still holds the old one.
NEWCOPY: replace it now
NEWCOPY tells CICS to discard its copy and load the new one on next use.
CEMT SET PROGRAM(ORDPROG1) NEWCOPYWhen it works, the screen shows the program with the refreshed state and a message that the command completed. The next task that needs ORDPROG1 causes a fresh load from the library, and the use count restarts. The new-copy count rises by one.
There is a condition. NEWCOPY works only when no task is currently using the program. If a task is running it, or has it loaded as part of a chain, CICS refuses with a response of INUSE. In a busy region this is common. A heavily used program may never have a quiet moment, so a repeated NEWCOPY request just keeps being refused.
PHASEIN: refresh without waiting
PHASEIN solves that problem. It loads the new copy for all new requests and lets tasks that already hold the old copy finish with it.
CEMT SET PROGRAM(ORDPROG1) PHASEINBecause both versions exist briefly, PHASEIN never needs the program to be idle, and it cannot fail with INUSE. The old copy is removed when its last user ends. Use it in production regions where you cannot stop traffic. The trade is that, for a short period, two versions run side by side. For a program that changes the layout of a record or a commarea, that overlap is dangerous, because the old copy may pass an old-format commarea to a new-format program. In that case choose a quiet window and NEWCOPY, or stop the transaction first with a disable.
Disabling first when you need certainty
To get an exact cut-over, disable the transaction, wait for its tasks to end, refresh and enable it again.
CEMT SET TRANSACTION(ORD1) DISABLED
CEMT INQUIRE TASK
CEMT SET PROGRAM(ORDPROG1) NEWCOPY
CEMT SET TRANSACTION(ORD1) ENABLEDWhile the transaction is disabled, new requests are rejected with a message to the user, which is the right trade for a change that must not overlap. Check with INQUIRE TASK that no task for ORD1 remains before the NEWCOPY.
Why NEWCOPY seems not to work
If the refresh completes and the old behavior stays, two causes account for most cases.
The first is the library lookaside directory, LLA. Many z/OS systems manage their load libraries through LLA, which caches the directory of a library in memory for speed. If your CICS DFHRPL library is LLA-managed, a member you just replaced is not seen until LLA refreshes its copy of that library's directory. The systems programmer or an operator command refreshes it, for example MODIFY LLA,REFRESH or an update for a specific library. After that, NEWCOPY loads the new member. A symptom is a Len that stays the old size after a clean NEWCOPY.
The second is the wrong library. The program you replaced is in USER01.LOAD, but the region searches PROD.LOAD first and finds an older member of the same name. Check the DFHRPL order in the region's JCL or with your CICS systems programmer, and confirm which library supplied the load with the program inquiry's library field where your release shows it.
A third possibility is a copy in the link pack area, which a program defined with USELPACOPY can use. CICS then uses the LPA copy and ignores the DFHRPL library, and refreshing it takes a different procedure with the systems programmer.
The language environment angle
With Language Environment programs, the program is the CICS-managed load module, but the language runtime stays in storage across refreshes. You do not need to refresh the runtime when your own module changes. A change to a called subprogram that is statically linked into the caller needs a NEWCOPY of the caller, not of the subprogram, because the subprogram's code lives inside the caller's load module. This trips people who recompile a subroutine and refresh its name, when the calling program still holds the old routine inside itself.
For dynamic calls, where the subprogram is a separate load module, refresh the subprogram by name.
A checklist for the refresh
Replace the member in the load library and confirm the compile and link return codes.
If the library is LLA-managed, refresh LLA.
Run
CEMT INQUIRE PROGRAMand note theLenand new-copy count.Issue
NEWCOPYorPHASEIN, whichever the traffic allows.Inquire again and check that the length matches the new module and the new-copy count rose.
Run the transaction and test the changed behavior.
Automating the refresh
In a deployment script, the refresh is usually driven through the CICS system programming interface, a console command such as MODIFY jobname,CEMT SET PROGRAM(name) NEWCOPY or a tool your shop provides. Whichever route is used, check the response and fail the deployment if the refresh was refused, because a deployment that reports success while the old code still runs is worse than one that fails loudly.


