View previous topic :: View next topic
|
Author |
Message |
ajaehnert
New User
Joined: 05 Dec 2007 Posts: 13 Location: Germany
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
No.
Suggeest you search in the forum (SEARCH in the blue bar above) as this has been discussed fairly recently. . . |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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. . . |
|
Back to top |
|
|
ajaehnert
New User
Joined: 05 Dec 2007 Posts: 13 Location: Germany
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
ajaehnert
New User
Joined: 05 Dec 2007 Posts: 13 Location: Germany
|
|
|
|
hi,
an this program name ist the name of the maim program?
Andreas |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
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 |
|
|
ajaehnert
New User
Joined: 05 Dec 2007 Posts: 13 Location: Germany
|
|
|
|
hi
i want to know the name of the main program when i executing the sub programm( not dynamily linked)
Thanke |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
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 |
|
|
MBabu
Active User
Joined: 03 Aug 2008 Posts: 400 Location: Mumbai
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
or maybe:
***a pain***
Hmmmm. . .
Either way - A pain in the asterisks. . .
|
|
Back to top |
|
|
|