I need to replace OS400 command RUNRMTCMD where I have used it many times in many programs over the past years (due to security concerns). I found that using SQL seems to be an efficient method, but diagnosing errors is hard. If errors do occur I get this message "Trigger program or external routine detected an error." That comes from the field MESSAGE_TEXT below. And the message IDs are SQL0443 and CPF2817. I can look up CPF2817 and find that is "Copy command ended because of error", but what is the error? Is that information hidden somewhere I might be able to use it?
PHP Code:
command = "CPYF FROMFILE(SANTEST/CBBOREP) TOFILE(SANTEST/CBBOREP_BK)
FROMMBR(*FIRST) TOMBR(*FIRST) MBROPT(*REPLACE) CRTFILE(*YES)";
connect_system = %trim(REMOTESYS);
exec SQL connect reset;
exec SQL disconnect all;
exec SQL connect to :connect_system;
exec SQL call QSYS2/QCMDEXC(:command);
exec SQL Get Diagnostics Condition 1
:RtnSqlCode = DB2_RETURNED_SQLCODE,
:RtnSQLState = RETURNED_SQLSTATE,
:MessageLength = MESSAGE_LENGTH,
:MessageText = MESSAGE_TEXT,
:MessageId = DB2_MESSAGE_ID,
:MessageId1 = DB2_MESSAGE_ID1,
:MessageId2 = DB2_MESSAGE_ID2 ;
exec SQL connect reset;
exec SQL disconnect all;
exec SQL connect to :localsys;
Comment