Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

how can i get the name of a mainprogram from a subprogram

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
ajaehnert

New User


Joined: 05 Dec 2007
Posts: 13
Location: Germany

PostPosted: Tue Mar 16, 2010 9:17 pm    Post subject: how can i get the name of a mainprogram from a subprogram
Reply with quote

I want the name of a main program from a subprogram( all in cobol)

The subprogram is linked to with the main program.

Can i use a function in cobol ???

thanks
Back to top
View user's profile Send private message

dick scherrer

Site Director


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

PostPosted: Tue Mar 16, 2010 9:29 pm    Post subject:
Reply with quote

Hello,

No.

Suggeest you search in the forum (SEARCH in the blue bar above) as this has been discussed fairly recently. . .
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Tue Mar 16, 2010 11:03 pm    Post subject:
Reply with quote

If you pass the calling program name as a part of linkage section/commarea this can be achieved. From what I understand, your requirement is-
If calling prog = proga
do something
else
do something else.
Please elaborate if you wanted something else so that we can come up with better suggestions.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Tue Mar 16, 2010 11:06 pm    Post subject:
Reply with quote

Hello,

Quote:
If you pass the calling program name as a part of linkage section/commarea this can be achieved.
But that would require changing every calling program. . . icon_wink.gif
Back to top
View user's profile Send private message
ajaehnert

New User


Joined: 05 Dec 2007
Posts: 13
Location: Germany

PostPosted: Tue Mar 16, 2010 11:06 pm    Post subject:
Reply with quote

i cant pass the program name as part of the linkage section, because this is a migration an the old linkage section is to small and i do not want to change the calling programs.

it was a ASM program, which ask the name of the maim program via a macro.

Andreas
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Tue Mar 16, 2010 11:37 pm    Post subject:
Reply with quote

Hello,

How did the assembler code accomplish this (what did the macro do)?

If you understand how the assembler works, you could possibly do something like this in the called replacement code.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Tue Mar 16, 2010 11:37 pm    Post subject: Reply to: how can i get the name of a mainprogram from a sub
Reply with quote

I am not a COBOL programmer; I believe that recent versions of COBOL can handle pointers/addresses, but I don't know if they can be manipulated. It may be necessary to write the external sub-routine/function in PL/I, C/370, HLASM, or smilar language.

Get the TCB (always at address 540 decimal, IIRC). The address of the last LLE is at offset 36 decimal from the TCB; the address of the CDE is at offset 4 from the LLE. The program name is the 8-byte string beginning at offset 8 from the CDE.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Tue Mar 16, 2010 11:50 pm    Post subject:
Reply with quote

Hello,

Quote:
I believe that recent versions of COBOL can handle pointers/addresses
Yup, one can "chase control blocks" with cobol now (actually for quite some time). . .
Back to top
View user's profile Send private message
ajaehnert

New User


Joined: 05 Dec 2007
Posts: 13
Location: Germany

PostPosted: Wed Mar 17, 2010 12:28 am    Post subject:
Reply with quote

hi,

an this program name ist the name of the maim program?


Andreas
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Wed Mar 17, 2010 12:35 am    Post subject:
Reply with quote

Yes; note, however, if the "main" program is really a dynamically-linked (or attached, fetched, etc.) subroutine of a genuine main program as IJKEFTxx, DFSRRC00, etc., that the latter will be returned.
Back to top
View user's profile Send private message
ajaehnert

New User


Joined: 05 Dec 2007
Posts: 13
Location: Germany

PostPosted: Wed Mar 24, 2010 1:23 pm    Post subject:
Reply with quote

hi

i want to know the name of the main program when i executing the sub programm( not dynamily linked)

Thanke
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Wed Mar 24, 2010 4:49 pm    Post subject:
Reply with quote

You have three choices:

1. Pass the calling program name as a parameter to the subprogram.
2. Chase z/OS control blocks to get this data -- search the forum for exactly what you have to in this case.
3. Accept that what you want is not otherwise possible. There is no COBOL way to get this data, for example -- you have to directly read memory areas for the control blocks.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Mar 24, 2010 6:48 pm    Post subject:
Reply with quote

Quote:
when i executing the sub programm
And, as the sub-programs can not be directly executed - I'm little skeptical about the origin of this question itself!
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 401
Location: Mumbai

PostPosted: Wed Mar 24, 2010 11:56 pm    Post subject:
Reply with quote

Chasing control blocks isn't necessarily good though. If load module A has routines M1 and M2 and they call S1, then finding the CDE will show A but you still don't know if M1 or M2 made the call. If you Really want to do this accurately, you might be able to find the CDE, run AMBLIST to get the offsets for the various CSECTs in the load module and do the math. But that sort of thing is still probably imperfect and would be a *real* pain in the *** and implies that you know the address of the subroutine and have access to the save areas and that the compiler is using standard linkage or some other chaining mechanism you can trace. In assembler programs this isn't as bad because most programs use a standard base register, and often have an eyecatcher at at the module, so all you need to do is find the previous save area, grab its 1st base register and use that to find the eye catcher. COBOL though? I wouldn't go there.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Thu Mar 25, 2010 12:01 am    Post subject: Reply to: how can i get the name of a mainprogram from a sub
Reply with quote

Quote:
pain in the ***
or maybe:

***a pain***

Hmmmm. . .

Either way - A pain in the asterisks. . .

icon_cool.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Is possible to call subprogram from c... cmsmoon COBOL Programming 3 Fri Aug 05, 2016 6:46 pm
No new posts Difference of COMMIT in main program ... dejunzhu DB2 11 Thu Nov 07, 2013 3:11 pm
No new posts Could not extract Natural Subprogram(s) jptools Java & MQSeries 0 Mon Jun 10, 2013 9:37 pm
No new posts CICS program issuing a CALL statement... kunal jain COBOL Programming 4 Fri Dec 21, 2012 6:06 pm
No new posts Geeting -924 when subprogram is calle... javed132 IMS DB/DC 4 Thu Aug 23, 2012 7:07 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us