I started writing this as a comment, but as I typed, it is both asking for clarification and providing answers.
What type of message are you retrieving with *ANY and fldkey
? If the message is a *REQUEST message, that is your problem. *FIRST, *NEXT, and *PRV all skip request messages.
Or, it is possible that you are retrieving a message somewhere in the job log, but not the active program or procedure when you retrieve by key. *FIRST, *NEXT, and *PRV only retrieve messages for the active program or procedure on the queue. See the documentation for an explanation in the description of *NXTJLMSG or *PRVJLMSG.
I also find in the documentation under the description for Message Key:
If you know the message key of a message you want to receive, you can receive that message without regard to the call message queue containing the message. You can do this by specifying the key in this parameter, the special value '*' for the Call stack entry parameter and the value '0' for the call stack counter parameter. This is useful if the message was sent to a call stack entry that is no longer in the call stack.
Maybe what would work for you, based on the description of *NXTJLMSG would be to use *NXTJLMSG and a key of *TOP or x'00000000'
.