PHP Code:
dchangedCmd s 512 inz
dcmdstring s 512 inz
dcmdlength s 10i 0 inz
dcmdAvailLen s 10i 0 inz
dcmdChangeLen s 10i 0 inz
docbDS ds Qualified
d type 10i 0 inz
d DBCSdh 1 inz('0')
d prompt 1 inz('0')
d cmdsyntax 1 inz('0')
d msgrtvkey 4 inz(x'00000000')
d reserve1 9 inz(x'000000000000000000')
d ocblength 10i 0 inz
d formatName 8 inz('CPOP0100')
d chgcmd 1 inz
d lngchgcmd 10i 0 inz
d lngchgrtn 10i 0 inz
d $command pr extpgm('QCAPCMD')
d cmdstring 512 const
d cmdlength 10i 0 const
d ocb likeds(ocbDS)
d ocblength 10i 0 const
d FormatName 8 const
d ChangedCmd 512 const
d LenAvailChgd 10i 0 const
d LenChgdCmd 10i 0 const
d ApiError likeds(APIErrorDS)
d $commandII pr extpgm('QCMDEXC')
d command 512
d Length 10i 0
d APIErrorDS ds Qualified
d BytesP 10I 0 inz(%size(apiErrorDS))
d BytesA 10I 0 inz(0)
d Messageid 7
d Reserved 1
d messagedta 240
* Program Information
d progstatus sds
d parms *parms
d progname *proc
d errmsgID 7 overlay(ProgStatus:40)
d errmsg 80 overlay(ProgStatus:91)
d jobname 10 overlay(ProgStatus:244)
d userid 10 overlay(ProgStatus:254)
d Jobnumber 7 overlay(ProgStatus:264)
/free
// --------------------- QCAPCMD ------------------------
cmdstring = 'ADDLIBLE NOLIBRARY';
cmdlength = %len(%trim(cmdstring));
$command(cmdstring :
cmdlength :
ocbds :
%len(ocbDS) :
'CPOP0100' :
changedCmd :
cmdAvailLen :
cmdChangeLen :
APIErrorDS
);
// after above call APIErrorDS contains:
//APIERRORDS.BYTESP = 256
//APIERRORDS.BYTESA = 26
//APIERRORDS.MESSAGEID = 'CPF2110'
//APIERRORDS.RESERVED = '0'
//APIERRORDS.MESSAGEDTA =
// ....5...10...15...20...2
// 1 'NOLIBRARY
// --------------------- QCMDEXEC ------------------------
cmdstring = 'ADDLIBLE NOLIBII';
cmdlength = %len(%trim(cmdstring));
// error message will be available in SDS Program Information DS
monitor;
$commandII (cmdstring : cmdlength);
on-error;
endmon;
// after above call APIErrorDS contains:
// PROGNAME OF PROGSTATUS = 'MYCMDTEST '
// PARMS OF PROGSTATUS = 000.
// ERRMSGID OF PROGSTATUS = 'CPF0006'
// ERRMSG OF PROGSTATUS =
// ....5...10...15...20...25...30.
// 1 'Errors occurred in command.
// 61 ' '
// JOBNAME OF PROGSTATUS = 'QPADEV0052'
// USERID OF PROGSTATUS = 'RUSSIAN '
// JOBNUMBER OF PROGSTATUS = '773535'
*inlr = *On;
/end-free