How can we know from which program my RPGLE program is called from.

695 pts.
Tags:
AS/400
RPG ILE
RPGLE
Hi All,

I have one RPGLE program (PROG1)is calling from 10 programs,

I got one requirement i.e if my program PROG1 called from 10 different programs my program PROG1 should perform 10 different functionality in my PROG1.

So if i want to write code for 10 different functionalities in PROG1, first of all i should know from which program it is calling from.

Can anyone please help me how can i retrive called program name in my RPGLE program at runtime into a variable of length 10 char to do some specific functions if it calls from 10 different programs.

I tried to use Program status data structure in my RPGLE program to determine from which program it is calling from but i am not able to find out the called program. it is giving me only current program name where we defined our Program status data structure.

Thanks in Advance,

Mohan K

 

Answer Wiki

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

three ways to go
1. calling program writes program name to LDA
called program reads it from LDA
2. (simplest) Pass Program name as a parameter to called program

3. Write a program to check the call stack for a program name
here is the start of that

http://www.rudas.at/Tips112000.htm

Phil
———————————————————————————–
here is a procedure to return the calling program’s name that you can add to your program

<pre>
d getCaller pr 10a

d qwvrcstk pr extpgm(‘QWVRCSTK’)
d 2000a
d 10i 0
d 8a const
d 56a
d 8a const
d 15a

d psds sds
d program 10 overlay(psds:1)

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Procedure getCaller contains the code to retrieve the calling program’s name
* * * * * * * * *</pre>

Discuss This Question: 6  Replies

 
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
  • tjgm88
    Hi Mohan, Phil has given a detailed solution to you request above. I agree will all the solutions, but always take the simple approach, unless warranted otherwise. Pass a parameter from the calling program to tell the called program what to do. Cheers! Gopal
    995 pointsBadges:
    report
  • Mohan K
    Thank you very much Phil for your detail explination.
    695 pointsBadges:
    report
  • BigKat
    actually, this sounds more like you need a Service Program to do your 10 different functions. Then you bind it into the programs that need them, and call the function directly from the program.
    7,935 pointsBadges:
    report
  • TomLiotta
    The suggestion to ignore the call stack and to create a service program with an entry point for each of the ten functions is a good one. Any programmer can give the same name to more than one program. Programs can be renamed. Libraries can be renamed. IBM can change the call stack structure -- as they did with ILE. Do it the right way to start and save a lot of trouble. Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    Also note that TFRCTL to your program will replace the "calling program" in the call stack with your program. If you look up the stack, you won't find the program that called yours. You can't guarantee what happened before your program started. Tom
    125,585 pointsBadges:
    report
  • RVP400
    HI all, You may find the article below interesting. It includes a service program to perform the requested task and a few other things. Check it out: http://systeminetwork.com/article/harvest-call-stack-information Regards, RVP
    270 pointsBadges:
    report

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