IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Finding the Called Program if no parameters passed


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
anu2
Warnings : 1

New User


Joined: 10 Jun 2007
Posts: 36
Location: Chennai

PostPosted: Mon Jun 18, 2007 12:22 pm
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Mon Jun 18, 2007 2:00 pm
Reply with quote

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
View user's profile Send private message
pcoreddy

New User


Joined: 14 Mar 2007
Posts: 24
Location: Mysore

PostPosted: Mon Jun 18, 2007 5:36 pm
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Mon Jun 18, 2007 5:39 pm
Reply with quote

GOBACK works just fine for both cases.
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Mon Jun 18, 2007 6:55 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Jun 18, 2007 9:35 pm
Reply with quote

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
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 148
Location: Ottawa Canada

PostPosted: Tue Jun 19, 2007 12:29 am
Reply with quote

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
View user's profile Send private message
anu2
Warnings : 1

New User


Joined: 10 Jun 2007
Posts: 36
Location: Chennai

PostPosted: Tue Jun 19, 2007 4:00 pm
Reply with quote

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
View user's profile Send private message
Raphael Bacay

New User


Joined: 04 May 2007
Posts: 58
Location: Manila, Philippines

PostPosted: Tue Jun 19, 2007 4:06 pm
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Jun 19, 2007 4:50 pm
Reply with quote

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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Tue Jun 19, 2007 5:00 pm
Reply with quote

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 icon_smile.gif )
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
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1035
Location: Richmond, Virginia

PostPosted: Tue Jun 19, 2007 5:36 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jun 19, 2007 10:22 pm
Reply with quote

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
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1035
Location: Richmond, Virginia

PostPosted: Tue Jun 19, 2007 10:38 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jun 19, 2007 11:38 pm
Reply with quote

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
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Jun 20, 2007 12:46 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jun 20, 2007 2:32 am
Reply with quote

Quite possibly. Maybe tomorrow. . .
Back to top
View user's profile Send private message
anu2
Warnings : 1

New User


Joined: 10 Jun 2007
Posts: 36
Location: Chennai

PostPosted: Wed Jun 20, 2007 12:03 pm
Reply with quote

yes, that is the question.......
Back to top
View user's profile Send private message
anu2
Warnings : 1

New User


Joined: 10 Jun 2007
Posts: 36
Location: Chennai

PostPosted: Wed Jun 20, 2007 3:06 pm
Reply with quote

yes, that's right ..., that's what i would like to know...
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1035
Location: Richmond, Virginia

PostPosted: Wed Jun 20, 2007 5:25 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jun 20, 2007 6:02 pm
Reply with quote

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
View user's profile Send private message
Santoshdorge

New User


Joined: 27 Jun 2006
Posts: 48
Location: Pune

PostPosted: Wed Jun 20, 2007 6:14 pm
Reply with quote

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
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 148
Location: Ottawa Canada

PostPosted: Wed Jun 20, 2007 11:22 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jun 21, 2007 12:41 am
Reply with quote

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 icon_redface.gif

Hopefully, Anu will set me straight icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Finding faulty logic Subscript out of... COBOL Programming 5
No new posts Receiving RC 5 when executing REXX pr... CLIST & REXX 3
No new posts COBOL program logic for comparisipn o... COBOL Programming 2
No new posts Injecting HTTPHEADER parameters in th... PL/I & Assembler 0
No new posts Concurrent writing records to VSAM fr... JCL & VSAM 9
Search our Forums:

Back to Top