Mike,
If you don't want to muck about with the existing api/procedure
A technique I've used is -- in your RPG program, you can --
set a global error indicator in the subprocedure and test
it's value from the mainline code after the subproc call to see
if the subproc is signaling an error, and subsequently, do the
call to display your message from the mainline code.
<d-specs>
gError
gErrorMsg
</d-specs>
<mainline>
// edit field
Proc1(anyfield)
If gError
// call pgm/api that sends msg to line 24
SendMsg(gErrorMsg)
endif
</mainline>
<proc1> (1 parm in, return nothing)
If yadda yadda
// theres an error
gError = *on
gErrorMsg = 'You have an error.'
endif
</proc1>
awtsac (another way to skin a cat)
John B
------------------------------
message: 2
date: Wed, 27 Aug 2008 11:33:24 -0500
from: "Kurt Anderson" <kjanderson@xxxxxxxxxxxxx>
subject: RE: Subprocedure global/local ?
Jerry's on the nose with the call stack parameter. There was recently a
discussion about this API where I had posted a sample prototype that may
or may not be helpful:
http://archive.midrange.com/rpg400-l/200808/msg00156.html
The message refers to a program in the stack, but the stack also
includes procedures.
Kurt Anderson
Application Developer
Highsmith
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Jerry Adams
Sent: Wednesday, August 27, 2008 8:30 AM
To: RPG programming on the AS400 / iSeries
Subject: RE: Subprocedure global/local ?
G#AddMsg is, I'm guessing, using the QMHSNDPM API. I still use
subroutines for the process you describe, but one of the parms for
QMHSNDPM (I forget which one) has to do with where on the call stack or
such the message is sent. Check the API documentation and modify the
G#AddMsg subprocedure accordingly.
Jerry C. Adams
IBM System i Programmer/Analyst
B&W Wholesale
office: 615-995-7024
email: jerry@xxxxxxxxxxxxxxx
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Smith, Mike
Sent: Wednesday, August 27, 2008 8:03 AM
To: rpg400-l@xxxxxxxxxxxx
Subject: Subprocedure global/local ?
I am trying to make myself use subprocedures more- rather than
subroutines. I have run into a little problem, and I'm not quite sure
what I need to do.
I have a procedure in a service program that is used for displaying
messages in display files. I use this all the time.
Now I have written a data entry program that has quite a bit of
validation. I have written another service program that has the
validation in it. Because there is a lot of validation I put all of
these within a subprocedure in my main program. Here is where the
problem occurs. My messages don't display. If I simply change the
subprocedure to a subroutine, my messages display.
PGM1
CALLP checkvalid
Pr checkvalid
C Eval PaverErr = valid_paver(cscrew)
C If PaverErr = *On
C Move 'RG1010 ' MSGID
C CallP G#AddMsgSF(MSGID:' ':
C 'RGCMSGF')
C EndIf
G#ADDMSGSF is in service program
Valid_paver is in a separate service program.
Checkvalid is subprocedure in main pgm
Any ideas on how to make this work.
Mike
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing
list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing
list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.