Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Avoiding Recursive calls

Status
Not open for further replies.

sburden

Programmer
Dec 4, 2002
35
US
Hello,

I'm having a problem in my interactive RPGIV program with recursive calls. I have program "A" and program "B" and they are both maintenance programs. I need to bounce between the two using command keys. Is there a simple way to avoid recursive calls?


 
Send a message to that program in the stack. If it fails, the program isn't there, so it can be run, otherwise you don't call it.
Call the following CL program from you program.
I found this CL program at .

PGM (&PROGRAM &MSGID)
/* ================================================================= */
/* CHECKPGM: Check call stack for program */
/* If message ID passed back is blank, program is already active */
/* ================================================================= */
DCL VAR(&PROGRAM) TYPE(*CHAR) LEN(10)
DCL VAR(&MSGID) TYPE(*CHAR) LEN(7)
DCL VAR(&KEYVAR) TYPE(*CHAR) LEN(4)
/* ***************************************************************** */
/* Start of mainline code */
/* ***************************************************************** */
/* Set return parameter to blank before starting */
CHGVAR VAR(&MSGID) VALUE(' ')
/* Send a diagnostic message to program passed in as parameter */
SNDPGMMSG MSGID(CPA6A21) MSGF(QCPFMSG) TOPGMQ(*SAME +
(&PROGRAM)) MSGTYPE(*DIAG) KEYVAR(&KEYVAR)
/* If command fails, program is not active in this job */
MONMSG MSGID(CPF0000) EXEC(DO)
RCVMSG MSGTYPE(*LAST) MSGID(&MSGID)
RCVMSG MSGTYPE(*LAST) MSGID(&MSGID)
GOTO CMDLBL(ENDPGM)
ENDDO
/* Remove diagnostic message from queue */
RMVMSG PGMQ(*SAME (&PROGRAM)) MSGKEY(&KEYVAR)
ENDPGM:
RETURN
ENDPGM

T. Bishop
 
That did the trick. Thanks for being helpful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top