× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Michael,



I can think of a couple of ways without changing the PLIST. One is to send a specific escape message from COMMPGM to DRIVERA. DRIVERA will need the program status data structure to check for the returned error message.



Something like this in DRIVERA...



callp(E) COMMPGM();



if %error;



if (PgmSDSMsgID = 'COM0110'); // this is the message ID sent by COMMPGM when "BAD STUFF HAPPENED"

// Do expected failure stuff

iter;

else;

// Do unexpected failure stuff

iter;

endif;



else;



// Do other stuff



endif;





Another possibility is to use a user space. When you obtain a pointer to a user space the contents of the user space is accessible until the pointer is lost.



In DRIVERA...



D getSpacePointer PR *

D userSpaceName 10A

D userSpaceLib 10A



D ptrToSpace S *



D someDataStruct DS based(ptrToSpace)

D errorIDInCOMM 7A



ptrToSpace = getSpacePointer(youruserspacename:youruserspacelib);



errorIDInCOMM = *Blanks;



// Do some stuff



callp(E) COMMPGM();



if (errorIDInCOMM = 'COM0110'); // Some "BAD STUFF HAPPENED"

// Do expected failure stuff

iter;

else;

// Do unexpected failure stuff

iter;

endif;



// Continue processing



In COMMPGM



D getSpacePointer PR *

D userSpaceName 10A

D userSpaceLib 10A



D ptrToSpace S *



D someDataStruct DS based(ptrToSpace)

D errorIDInCOMM 7A



ptrToSpace = getSpacePointer(youruserspacename:youruserspacelib);



// Do some stuff



// Oops! SOMETHING BAD HAPPENED!!



errorIDInCOMM = 'COM0101';



// return to DRIVERA





You can get as fancy with the structure of the user space as needed.



HTH.



Gary Monnier





-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Koester, Michael
Sent: Wednesday, September 28, 2011 3:01 PM
To: RPG400-L@xxxxxxxxxxxx
Subject: Changing a called sqlrpgle program to return a value



I'm trying to get my head around this, but failing...

I have a driver program (DRIVERA) that does a bunch of stuff, runs a bunch of private subprocedures, calls some service programs, and calls another program (COMMPGM) that handles some communications with another platform, calls other relevant service programs, runs private subprocedures, etc. Both DRIVERA and COMMPGM are *PGMs (created from SQLRPGLE source), with *INLR and all that. COMMPGM is something of a driver program itself, handling sockets connections, throwing lots of transactions to the other platform, receiving results, writing records to a logfile, etc. Its only caller is DRIVERA.



Now I have a need to return a value from COMMPGM, back to DRIVERA, so DRIVERA can deal appropriately with abnormal situations encountered in COMMPGM. Since I'd set COMMPGM up with a Prototype instead of a *entry PLIST, I figured I'd just adjust that prototype and Procedure Interface to include the return value definition and I'd be well on my way... until the source editor reminded me that extpgm was not compatible with a return value. Apparently I need to use extproc instead? I expect that means other things will need to change, but I don't know exactly what, and that's where I need help.



Essentially the process should look like this:

DRIVERA:

...Do some stuff...

DOU done;

If not done;

...Do more stuff...

If COMMPGM(a : b : c) = 'TYPE-A BAD STUFF HAPPENED';

...Do failure stuff...

ITER;

else;

...Do other stuff...

endif;

endif;

enddo;

...Do cleanup stuff...

INLR = *on;



I'd really rather not go back to the PLIST approach, but I don't get to spend a week figuring out how to get a compiled object, and another week finding & fixing the run-time issues brought on by my naiveté. Is there hope? Should be simple, right? We're running v6.1



Thanks.

Michael

--

This is the RPG programming on the IBM i / System i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx <mailto:RPG400-L@xxxxxxxxxxxx> To subscribe, unsubscribe, or change list options,

visit: http://lists.midrange.com/mailman/listinfo/rpg400-l <http://lists.midrange.com/mailman/listinfo/rpg400-l>

or email: RPG400-L-request@xxxxxxxxxxxx <mailto:RPG400-L-request@xxxxxxxxxxxx>

Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l <http://archive.midrange.com/rpg400-l> .




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 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.