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


  • Subject: Re: Program Call Stack
  • From: Scott Klement <klemscot@xxxxxxxxxxxx>
  • Date: Wed, 29 Nov 2000 18:09:49 -0600 (CST)


At the bottom of this message is an example of how to get program names
from the call stack in CL.

You could simply compile this program, and call it when you wanted to 
get your program's name, or you could re-write it in RPG using the
message handling API's.

I'd do it in RPG, myself, but I'm just not that ambitious tonight :)


On Wed, 29 Nov 2000, Daniel Keith wrote:
> 
> A friend of mine needed some help on this. Any ideas?
> 
> 
> Daniel,
> 
> Help!  Is there a way to retrieve the program's name that called the program
> that you are in (if it was ran interactively).  In the program data
> structure it looks like if the job was run interactively it puts the work
> station id.  If the job was run in batch it does give you the program's
> name.
> 
> Do I make any sense?
> 
> Thanks,
> 
> Susan
> 


PGM          PARM(&LEVELS &RTNPGM)

             DCL        VAR(&CALLER) TYPE(*CHAR) LEN(10)
             DCL        VAR(&COUNTER) TYPE(*DEC) LEN(3)
             DCL        VAR(&LEVELS) TYPE(*DEC) LEN(3 0)
             DCL        VAR(&MSGDTA) TYPE(*CHAR) LEN(132)
             DCL        VAR(&MSGF) TYPE(*CHAR) LEN(10)
             DCL        VAR(&MSGFLIB) TYPE(*CHAR) LEN(10)
             DCL        VAR(&MSGID) TYPE(*CHAR) LEN(7)
             DCL        VAR(&MSGKEY) TYPE(*CHAR) LEN(4)
             DCL        VAR(&RTNPGM) TYPE(*CHAR) LEN(10)
             DCL        VAR(&SENDER) TYPE(*CHAR) LEN(80)

             SNDPGMMSG  MSG(X) TOPGMQ(*PRV (*)) MSGTYPE(*INFO) +
                          KEYVAR(&MSGKEY)
             RCVMSG     PGMQ(*PRV (*)) MSGKEY(&MSGKEY) RMV(*YES) +
                          SENDER(&SENDER)
             CHGVAR     VAR(&CALLER) VALUE(%SST(&SENDER 56 10))

LOOP:
             SNDPGMMSG  MSG(X) TOPGMQ(*PRV (&CALLER)) MSGTYPE(*INFO) +
                          KEYVAR(&MSGKEY)
             RCVMSG     PGMQ(*PRV (&CALLER)) MSGKEY(&MSGKEY) +
                          RMV(*YES) SENDER(&SENDER)
             CHGVAR     VAR(&COUNTER) VALUE(&COUNTER + 1)
             IF         COND(&COUNTER *EQ &LEVELS) THEN(DO)
                  CHGVAR VAR(&RTNPGM) VALUE(%SST(&SENDER 56 10))
                  RETURN
             ENDDO
             ELSE CMD(DO)
                  CHGVAR VAR(&CALLER) VALUE(%SST(&SENDER 56 10))
                  GOTO CMDLBL(LOOP)
             ENDDO

ENDPGM

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

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.