Might want to use the complete/correct prototype for QCMDEXC--yours is good
enough, but the complete prototype is as follows:
D QCMDEXC PR ExtPgm('QCMDEXC')
D szCmdStr 32702A Const OPTIONS(*VARSIZE)
D nCmdLen 15P 5 Const
D dbcsFlag 3A Const OPTIONS(*NOPASS)
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [
mailto:rpg400-l-bounces@xxxxxxxxxxxx] On
Behalf Of Jim Wiant
Sent: Wednesday, May 30, 2007 2:33 PM
To: RPG programming on the AS400 / iSeries
Subject: RE: Does Qcmdexc return an error ??
When working with QCMDEXC I've set it up as a prototyped procedure, and
use the SDS to help me trap errors.
So first I include the SDS
D ProgSDS SDS QUALIFIED
D ExceptAll 40 46A
etc...
Then I include the prototype to QCMDEXC:
D QCMDEXC PR ExtPgm('QCMDEXC')
D Cmd 2048A Options(*Varsize)
D CmdLen 15P 5
Then when I issue a command I do this:
C Eval MyCmd = 'DSPFD FILE(XYXYXYZ) ' +
C 'OUTPUT(*PRINT)'
C Eval MyCmdLen = %LEN(%TRIM(MyCmd))
C CallP(E) QCMDEXC(MyCmd:MyCMdLen)
C If %ERROR
C Eval MyErrMsg = ProgSDS.ExceptAll
C Else
C Eval MyErrMsg = 'OK'
C EndIf
C MyErrMsg Dsply
~
The system data structure will have the error code in positions 40 to 46
As far as handling the file problem during the override, I agree with
others (yes Joe, you too *grin*) that adding USROPN to the file then
opening with Open(E) will allow you to trap any errors when opening the
file.
As an alternative to overriding to the file, you could add the keyword
EXTMBR(X) to the file definition where X is the member you want to
override too (note that the contents of X are case sensitive). This can
be a literal or a variable. You would probably still want to have USROPN
and test for errors to trap them.
Hope it helps
James P. Wiant
Testing Coordinator
Foodstuffs, Auckland, Ltd.
This message has been sent from Foodstuffs (Auckland) Limited ("Foodstuffs").
The information contained in this message and or attachments
is intended only for the person or entity to which it is
addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other
use of, or taking of any action in reliance upon, this
information by persons or entities other than the intended
recipient is prohibited. If you received this in error,
please contact the sender and delete the material from any
system and destroy any copies.
The views and opinions expressed in this message may be those
of the individual and not necessarily those of Foodstuffs,
and are not given or endorsed by it.
Please note that this communication does not designate an
information system for the purposes of the Electronic
Transactions Act 2002.
As an Amazon Associate we earn from qualifying purchases.