× 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.



On 08-Dec-2014 12:22 -0600, Vidal, Peter wrote:
On Friday, December 05, 2014 1:56 PM Holger Scherer wrote:
On 05-Dec-2014 12:54 -0600, Vidal, Peter wrote:

There is a CLP (PGMA) that is called by 3 other programs: PGM1,
PGM2 and PGM3. Is there a way to know, from within PGMA, which
program called it but without sending a parameter to it?


Maybe the retrieve call stack API?

<http://www.ibm.com/support/knowledgecenter/ssw_ibm_i_71/apis/qwvrcstk.htm>

Yes, this worked perfectly. Thank you!


The Retrieve Call Stack (QWVRCSTK) API should be generally functional for the described task. Note however, that the program that has called may have been renamed from its original name and\or moved into another library; e.g. per REPLACE(*YES) on a compile. That issue may or may not be something to consider when using that API to answer the question of "Who called?" The /replace object/ feature (RPLOBJ) [using library QRPLOBJ], IIRC, uses a message [something like the msg CPX8105] to modify the object TEXT() attribute to record the original qualified object name; there is no such indication when the change(s) are effected instead by simple Rename Object (RNMOBJ) and\or Move Object (MOVOBJ).

Per having worded the question "... but without sending a parameter", the following concern is probably already understood; but I remind anyhow:

Whenever a programmer discovers\thinks that they need to know the answer to "Who called?", the first reaction should be consideration that there may be a problem with the code; i.e. questioning why a parameter is not defined to ask the program to effect the desired behavior, instead of trying to /infer/ the desired behavior based upon the environment in which the invocation was made. Only niche scenarios [e.g. security or other validation modules] typically should require [or otherwise insist on] knowing the answer to that question.


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.