• Subject: Re: Who pulled the trigger? / Call stack
  • From: John P Carr <jpcarr@xxxxxxxxxxxx>
  • Date: Fri, 17 Sep 1999 23:01:28 -0400

Here it goes,  This is a low tech solution and can be made into Procedures
using Message API's if you want to make it real fancy.   But as is,  it will

also work for the average Joe/Jane programmer too. 

For trigger's
In your *INZSR subroutine repeatedly call a CLP to retrieve the program
name of the caller.  You can "walk up the Stack" past the programs(OS/400's
that begin with "Q")  to the program you're looking for. 

Just call the below program repeatedly(in a loop in your *INZSR),  First
pass your trigger program name(the program who's *inzsr you are
currently in that is)  as the &CALLED, and who ever called your 
trigger will be returned in the &CALLER variable.  This will undoubtedly be
a "Q" 
OS/400 program.  Call the CLP again this time pass what was returned the
first time to find out who called him, and so on.  up the stack till *EXT.

Stop at the first program name(&CALLER) doesn't begin with a "Q". 
That's the application program that kicked off the trigger..


DCL   &CALLER  *CHAR  10  
DCL   &M1KEY   *CHAR   4
DCL   &M1MDTA  *CHAR  80



CHGVAR   &CALLER    %SST(&M1MDTA  56 10)


So,   Just call it with a program name(&CALLED) and it will tell you who
that program(&CALLER) ,  next time pass it what was returned the previous
to find out who called him, and so on up the stack.   Look at the name
(&CALLER)  if the first position of the name is a "Q"  it's an OS/400
(Unless you are ,  hmm shall we we say,  Dumb enough to start your program 
names with the letter Q ?)

John Carr

Visit  www.400school.com  for classroom education information.

| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com

This thread ...

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

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