In RPG/400 how can I tell what prgrams are in the call stack so I can avoid “called itself recursively” error?

10 pts.
Tags:
AS/400
RPG
RPG/400
In RPG/400 how can I tell what prgrams are in the call stack so I can avoid "called itself recursively" error? Is there an easier way than passing a parm or populating a data area, like is there a system command that could provide this information?

Answer Wiki

Thanks. We'll let you know when a new response is added.

There is an API, QWVRCSTK, which will return the job stack.

——————————————————-

And it so happens that there was recently a series of three articles using the QWVRCSTK API to demonstrate various techniques that can be used with system APIs. The first article can be found at <a href=”http://www.mcpressonline.com/programming/apis/the-api-corner-retrieving-information-part-i.html”>this site</a>.

Hope this helps,
Bruce

===========================================================

There are a couple ways to retrieve the call stack, but it’s essentially pointless in this case.

It essentially means that every program would retrieve the call stack before calling any other program to see if a recursion error was possible. Then each time it found that a program was already in the stack, it would need to look at program attributes to see if the program supported recursion. (A program that runs in a *NEW activation group can be called recursively. The same program might not be called recursively in a named AG. CL supports recursion natively; RPG and COBOL do not. Other considerations apply.)

Rather than retrieving the call stack and doing all of the analysis in order to avoid the CALL, simply execute the CALL and handle the error. Done.

It’s far more efficient, far lass code, far more maintainable and much, much easier to understand.

Tom

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following