|
Dave,
You might try the MONITOR op code. Check for the status after the call. If
the call fails retrieve the error information.
Having said that I use the QCAPCMD API to run commands. I've included the code
below for the wrapper module I use. You might be able to use it as is or as a
guide to write your own.
HTH.
h nomain
*-----------------------------------------------------------------------------------------
* Program . . : PRCCMD Author . . : Rick Chevalier
* Date . . . . : 1/19/2000
* Purpose . . : Process or run a command.
*-----------------------------------------------------------------------------------------
* Modifications: Date/Prgrmmr
*-----------------------------------------------------------------------------------------
* None to this point.
*-----------------------------------------------------------------------------------------
* Required Parameter Group:
* 1 Source command string Input Char(*)
* Optional Parameter Group:
* 2 Processing type Input Char(1)
* '0' - Never prompt the command
* '1' - Always prompt the command
* Dft '2' - Prompt the command if selective prompting characters are
present in the command
* '3' - Show help
*-----------------------------------------------------------------------------------------
* Internal procedure prototypes
*---------------------------------------------------------------------------------------------
* Prototype for process command procedure (PrcCmd)
d PrcCmd pr *
d 32702
Command
d 1 options(*nopass: *omit)
Prompt type
*-----------------------------------------------------------------------------------------
* External procedure prototypes.
*-----------------------------------------------------------------------------------------
* Send program message.
dsndpgmmsg pr 4
d##_msgid 7
d##_msgf 20
d##_msgdta@ * const
d##_msgtyp 10 options(*nopass)
Defaults to *DIAG
*-----------------------------------------------------------------------------------------
* Process command (QCAPCMD) API. Check or run a CL command.
*-----------------------------------------------------------------------------------------
pprccmd b export
dprccmd pi *
d##_cmd 32702
d##_pmttyp 1 options(*nopass: *omit)
Default = 2
* 1 Length of source command string Input Binary(4)
* 2 Options control block Input
Char(*)
* 3 Options control block length Input
Binary(4)
* 4 Options control block format Input
Char(8)
* 5 Changed command string Output
Char(*)
* 6 Length available for changed command string Input
Binary(4)
* 7 Length of changed command string available to return Output
Binary(4)
* 8 Error code I/O
Char(*)
d##_cmdlen s 9b 0
d##_ocb ds
d ##_typprc 9b 0 inz(2) Type
of processing
d ##_dbcs 1 inz('0') DBCS
data handling
d ##_pmtact 1
Prompter action
d ##_cmdstx 1 inz('0')
Command syntax
d ##_msgkey 4 inz(*blanks) Msg
retrieve key
d ##_reserve 9 inz(x'000000000000000000')
Reserved
d##_ocblen s 9b 0 inz(20)
d##_ocbfmt s 8 inz('CPOP0100')
d##_chgcmd s 32702
d##_chglen s 9b 0
d##_chgavl s 9b 0 inz(32702)
d##_error ds
d ##_erbp 1 4B 0 inz(128)
Bytes provided
d ##_erba 5 8B 0
Bytes available
d ##_erexid 9 15
Exception ID
d ##_erexdta 17 116
Exception data
d##_msgf s 20 inz('QCPFMSG *LIBL ')
* Parameter list for API call.
c qcapcmd plist
c parm ##_cmd
c parm ##_cmdlen
c parm ##_ocb
c parm ##_ocblen
c parm ##_ocbfmt
c parm ##_chgcmd
c parm ##_chglen
c parm ##_chgavl
c parm ##_error
* Determine the length of the command string to process.
c eval ##_cmdlen = %len(%trim(##_cmd))
* Determine the length of the command string to process.
c if (%parms = 2 and %addr(##_pmttyp) = *null) or
c %parms = 1
c eval ##_pmtact = '2'
c else
c eval ##_pmtact = ##_pmttyp
c endif
* Process command.
c call 'QCAPCMD' qcapcmd
* If no error return address of attribute information.
c if ##_erexid = *blanks
c return %addr(##_chgcmd)
* Send error message to job log and return null address.
c else
c callp sndpgmmsg(##_erexid: ##_msgf:
c %addr(##_erexdta))
c return *null
c endif
pprccmd e
Rick Chevalier
AmeriCredit AITS
(817) 525-7178
rick.chevalier@xxxxxxxxxxxxxxx
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of David & Eileen Keck
Sent: Sunday, January 04, 2004 6:12 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Error Handling for QCMDEXC
What's a good way to retrieve the full message or message data associated
with a failed call to QCMDEXC ?
In the code below at the point labeled ZZZ I would like to have access to
the full error message in effect at that time. However, by definition, the
exception data in the program status data structure is only available when
the status is 9999. In the code below, when commitment control is already
active before the call to this program, the new attempt to start commitment
control correctly generates a CPF8351 (commit control already active),
however it yields a status code = 00202 "Called program or procedure
failed". So the exception data is blank (even though the PSDS has the
desired message ID of CPF8351).
Thanks - Dave K.
C *INZSR BegSR
* start commitment control
C eval cmdStr = 'STRCMTCTL LCKLVL *CHG'
C eval cmdLen = %len( cmdStr )
C* the procedure 'command' is a prototyped call to QCMDEXC
C callp(e) command(cmdStr : cmdLen)
C if %error
C* CPF8351 indicates commitment control is already active
C if psds_MsgID = 'CPF8351'
C rolbk
C else
C* ZZZ Friendly error handler goes here
C endif
C endif
note: the procedure "command" is defined as follows ...
D Command PR ExtPgm('QCMDEXC')
D CmdStr 32702 const options(*varsize)
D CmdLen 15p 5 const
* Program Status Data Structure
D psds esds extname(PSDS) prefix(psds_)
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.