Hallo Peter,
obwohl damals für R510 ist es auch für R530 gültig:

PWS0005 Error When Stored Procedure Returns an Escape Message
Technote

Problem Description

After upgrading to R510 IBM OS/400, applications with External Stored Procedures that return escape messages may receive a PWS0005 "Error occurred in the OS/400 database server code " error message.

Problem Detail

OS/400 allows external procedures to return a custom error message in place of the generic SQL0443. The SQL reference states that the procedure needs to send an escape message to operating system program QSQCALL which invokes the procedure. QSQCALL will then map the error to SQLSTATE 38501 (SQLCODE -443) and return the specified message ID and text as the error message text.

For example, an ODBC application that calls a procedure that returns CPF9898 with replacement text of "1234567890" would receive the error:

szSqlState = "HY000",
*pfNativeError = -443,
MessageText = "[IBM][Client Access Express ODBC Driver (32-bit)][DB2/400 SQL]CPF9898 - 1234567890."

Prior to R450 of OS/400, QSQCALL was implemented as a OPM program. In R510, QSQCALL is implemented as an ILE program. Depending on the programming language used for the external procedure and how the escape message is sent, the external procedure program may need to be modified.

For example consider a CL program that used the following in R450:
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +
MSGDTA('My escape message') TOPGMQ(*PRV) +
MSGTYPE(*ESCAPE)

The help text for the SNDPGMMSG command states:
The message is sent to the message queue of the call stack entry that is immediately previous to the one identified by the second value. However, if the message queue immediately previous to the one identified by the Program or Qualified Procedures values is for an Integrated Language Environment (ILE) program entry procedure (PEP), the message is sent to the message queue that precedes the PEP message queue in the stack.

In R510, QSQCALL is an ILE PEP. Therefore, the message is sent to QZDASQL rather then QSQCALL resulting in the MSGPWS0005 error.

Problem Resolution

Modify the program to send the escape message to the proper program (QSQCALL). Each language has methods for signalling conditions and sending messages. Refer to the respective language reference to determine the appropriate way to signal a message.

In the example listed above, the CL program would need to be modified as shown below. Note that this works for all releases:
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +
MSGDTA('my escape message') TOPGMQ(*SAME +
(QSQCALL)) MSGTYPE(*ESCAPE)