View previous topic :: View next topic
|
Author |
Message |
anu2 Warnings : 1 New User
Joined: 10 Jun 2007 Posts: 36 Location: Chennai
|
|
|
|
Hi,
When a program calls another program without passing any parameter then how would one know seeing the called program that it has been called by some other program ?
Regards,
anu |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
anu2 wrote: |
When a program calls another program without passing any parameter then how would one know seeing the called program that it has been called by some other program ? |
I can't see any way to "know".....except possibly by the called program's logical expectation of events or conditions to have already occured or been met..... |
|
Back to top |
|
|
pcoreddy
New User
Joined: 14 Mar 2007 Posts: 24 Location: Mysore
|
|
|
|
called program should be end with EXIT,it wont end with other than this
but in cae of calling program it should be end with STPORUN or GOBACK |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
GOBACK works just fine for both cases. |
|
Back to top |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
anu2 wrote: |
Hi,
When a program calls another program without passing any parameter then how would one know seeing the called program that it has been called by some other program ?
Regards,
anu |
Have it abended and check the static storage of that module in your dump. You may also check the trace list there. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
This
Quote: |
called program should be end with EXIT,it wont end with other than this |
is at least misleading if not completely untrue.
Your organizatin may have a standard that dictates the use of EXIT, but it is not a COBOL requirement. |
|
Back to top |
|
|
TG Murphy
Active User
Joined: 23 Mar 2007 Posts: 148 Location: Ottawa Canada
|
|
|
|
Anu2,
To better help you, let me ask you this: Why do you care who your caller is? Do you want to know whether your program was invoked directly from the JCL or from a COBOL program?
One of the guys I work with is working on some logic that walks some system control blocks in order to answer the question: What programs are in memory and how much memory are they using? Maybe that approach might be helpful to you. |
|
Back to top |
|
|
anu2 Warnings : 1 New User
Joined: 10 Jun 2007 Posts: 36 Location: Chennai
|
|
|
|
Hi,
Let me put it in more simple words.
How can one make out seeing a program that it has been called from some other program and given a case it doesn't accept any parameters .
Regards,
anu. |
|
Back to top |
|
|
Raphael Bacay
New User
Joined: 04 May 2007 Posts: 58 Location: Manila, Philippines
|
|
|
|
I don't think it is possible for the called program to access the program calling it. You can put the name of the calling program in a file accessible to both programs i guess... |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
anu2 wrote: |
How can one make out seeing a program that it has been called from some other program and given a case it doesn't accept any parameters . |
Like TG Murphy pointed out, the only way would be to walk back up system control blocks to find who or what initiated you. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Quote: |
How can one make out seeing a program that it has been called from some other program and given a case it doesn't accept any parameters . |
let me put it this way,
You can make sure that it doesn't accept any parameters if PROCEDURE DIVISION doesn't include USING phrase. ( I assume passing parameter = passing variables)
If it is getting called then you have to scan all of your program code for the program name you want to find out. This is also not foolproof because I have seen some programs getting called dynamically using a parameter table.
Usually subprogram end is indicated by GOBACK instead of STOP RUN.
( However it is not mandatory, you can use STOP RUN as well. A main program can end with a GOABCK too )
If you are sure that all subprograms end with GOBACK and all subprograms are getting called through some main program and PROCEDURE division does not contain USING clause then you can say
"a program that it has been called from some other program and given a case it doesn't accept any parameters ." |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1049 Location: Richmond, Virginia
|
|
|
|
I see lots of answers, but I for one have no idea what the question actually is, or the motivation for the question. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hi Phil,
If i understood correctly, the original question was "if you look at a program (that uses no parameters/linkage section), how would you know if the program was called".
Maybe Anu will post what generated the question. . . |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1049 Location: Richmond, Virginia
|
|
|
|
I also think that's the question, but I must be missing something, because I don't see what the parameter issue is. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
I believe the issue with the parameter (or lack thereof) is that without any parameter/linkage, how would you know a program was called (i.e that it was the "callee"). |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
dick scherrer wrote: |
I believe the issue with the parameter (or lack thereof) is that without any parameter/linkage, how would you know a program was called (i.e that it was the "callee"). |
I think the op has disappeared. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Quite possibly. Maybe tomorrow. . . |
|
Back to top |
|
|
anu2 Warnings : 1 New User
Joined: 10 Jun 2007 Posts: 36 Location: Chennai
|
|
|
|
yes, that is the question....... |
|
Back to top |
|
|
anu2 Warnings : 1 New User
Joined: 10 Jun 2007 Posts: 36 Location: Chennai
|
|
|
|
yes, that's right ..., that's what i would like to know... |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1049 Location: Richmond, Virginia
|
|
|
|
Still dense here - even with parms, how do I know it was called without some kind of action:
1. obviously, modify parm, and have caller show that somehow
2. but parm might just be input, so I need some other file change or output by callee
I must be missing something here. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hi Phil,
No i don't think you are missing things. . . It is just one of those questions that very seldom comes up.
Anu - why is this of interest? If we knew the reason behind the question, we might be able to better reply.
As i believe someone mentionied earlier, one way to do this might be to chase control blocks, but unless there was a strong reason to do so, that would be a considerable bit of work for an unknown as yet requirement. |
|
Back to top |
|
|
Santoshdorge
New User
Joined: 27 Jun 2006 Posts: 48 Location: Pune
|
|
|
|
HI,
It's not at all possible to identify the calling program of the subroutine by looking at itself.But if you wants to find the same anyhow here is the possible way
You can search the library of the all programs for the subroutine name.
(for particular string) using file-aid. may be supper search.
Thanks,
Santosh. |
|
Back to top |
|
|
TG Murphy
Active User
Joined: 23 Mar 2007 Posts: 148 Location: Ottawa Canada
|
|
|
|
I think Santo is on to something.
Anu2 is doing impact analysis. He just wants to know which programs use program A.
My original read on the question was that he wanted program A itself to be able to find out who its caller is - this taking place when the program executes.
Searching your source libraries should help answer this question but as someone already mentioned, searching is not foolproof. Program names are often built dynamically (ie. STRING this and that) or retrieved from a database. We have a 2 DB2 tables here that contain program names and doing a search of source libraries will not uncover these...
Anu2 - are we on the right track here? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Yup, it might be impact analysis.
When i read this
Quote: |
My original read on the question was that he wanted program A itself to be able to find out who its caller is - this taking place when the program executes.
|
one of my thoughts was that there was interest in seeing what might have called an already running (sub)program (say it was detected by some monitoring process). Another was that there might be interest in the program being able to determine how it was invoked - called or executed - then the info would be available without requiring a change to any callers.
I didn't read this a something that might be impact analysis. Very likely my misunderstanding
Hopefully, Anu will set me straight |
|
Back to top |
|
|
|