/If Defined(*Crtbndrpg) H Dftactgrp(*No) /Endif H Bnddir('QC2LE') // ------------------------------------------------------- Prototypes d GoCmd pr 10I 0 Extproc('system') d CmdString * Value d Options(*String) d $GetMessage pr extpgm('QMHRTVM') d WRcvVar 65535A Options(*VarSize) d WRcvVarLen 10I 0 Const d WFormat 8A Const d WMsgID 7A Const d WQualMsgF 20A Const d WReplData 65535A Const Options(*VarSize) d WReplDataLen 10I 0 Const d WDoReplace 10A Const d WUseCtrlChars 10A Const d WErrorCode 65535A Options(*VarSize) d WRetrOpt 10A Const Options(*NoPass) d WRetrOpt 10A Const Options(*NoPass) d WCCSID_out 10I 0 Const Options(*NoPass) d WCCSID_in 10I 0 Const Options(*NoPass) // program variables d Errmsgid s 7 Import('_EXCP_MSGID') d errorcode s 7 d LibraryNotFound... d c 'CPF2110' d NullString c -1 d ObjectNotFound c 'CPF3142' d ObjectInUse c 'CPF3156' d Returncode s 10I 0 d Success c 0 d Userid s 10a d WReplaceData s 100A Inz(*Blanks) d WMessage s 100a Inz(*blanks) d WMsgFile s 10A d WMsgLibrary s 10A d WMsgFileLib s 20A d WMaxMsgLen s 10i 0 inz(%size(WMessage)) d ErrorDS ds qualified d bytesProv 10i 0 inz(0) d bytesAvail 10i 0 inz(0) d RTVM0100 ds qualified d WMsgLen 10i 0 overlay(RTVM0100:9) d WMsgData 32767a overlay(RTVM0100:25) /Free *inlr = *on; returncode = Gocmd('DLTF MYLIB/MYFILE'); select; when returncode = Success; // Command was successful // ... when returncode = NullString; // Command string was null // ... when errmsgid = ObjectNotFound; // CPF3142 // ... when errMsgid = ObjectInUse; // CPF3156 // ... when errMsgid = LibraryNotFound; // CPF2110 // ... other; // Some other error // ... endsl; // added for fun --- return CPF message text if errMsgid <> *blanks; exsr $getTheMessageDescription; endif; return; //-------------------------------------------------------- // $GetTheMessageDescription - return message description //-------------------------------------------------------- begsr $GetTheMessageDescription; WMsgFile = 'QCPFMSG'; WMsgLibrary = 'QSYS'; WMsgFileLib = WMsgFile + WMsgLibrary; WReplaceData = userid; $GetMessage(RTVM0100 : %size( RTVM0100 ) // return data : 'RTVM0100' // return data : errMsgid // msg id : WMsgFileLib // msg file, : WReplaceData // msg parameter : %size(WReplaceData) // msg parameter : '*YES' // substitute MSG : '*NO' // control chars : ErrorDS ); if (RTVM0100.WMsgLen > *Zeros); if (RTVM0100.WMsgLen > WMaxMsgLen); RTVM0100.WMsgLen = WMaxMsgLen; endif; // retrieve the message with message data inserted WMessage = %subst(RTVM0100.WMsgData : 1 : RTVM0100.WMsgLen); else; WMessage = *Blanks; endif; endsr; /end-free