You can’t keep a record locked on a secret window. As soon as the procedure ends, the currently visible window becomes active, which is going to cause your secret window to be deactivated, which will cause any locked record associated with that window to be committed.
DB-A can be visible or secret, either way it doesn’t work with setactivedatabase.
The setactivedatabase statement doesn’t care whether the database is visible or not. It will make the database active without bringing it forward - in other words it makes a temporary “secret” window.
If you search this forum you’ll find that I really don’t like the “secret window” terminology, even though I invented it. There is no “window”. This is simply a special mode of Panorama where the active database is different from the topmost visible window. This special mode is temporary, and can ONLY exist while a procedure is running. As soon as the procedure stops running this temporary mode is cancelled and Panorama goes back to its normal “topmost visible window is the active database” operation. If it didn’t do that, you would get awfully frustrated when you tried to perform interactive operations on what you can see but found Panorama doing strange things with a window you cannot see.
Here’s another way to look at it. Essentially, your procedure is really: