View previous topic :: View next topic
|
Author |
Message |
Mike 1304
New User
Joined: 15 Oct 2011 Posts: 46 Location: Germany
|
|
|
|
Hi,
I need to know some Information about my program in the program e.g. to write program Name in error Messages in DISPLAY or WTO.
needed information:
Program name, compile date
and not so urgent: library from which a program is loaded.
If it is important: Language Cobol and if possible Assembler.
Could anybody help me?
Mike |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Since you have to change the code anyway, why not just include the program name as a constant in the program and use WHEN-COMPILED (for COBOL programs) to get the compile date/time? The program name and compile date (and time) could be generated via constants in Assembler as well. This will be MUCH easier than chasing down control blocks (since the control blocks would have to be verified and possibly changed every time a new operating system release is installed). |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Mike,
To get you started, review the WHEN-COMPILED FUNCTION, introduced with COBOL/370, the successor to COBOL II.
Code: |
03 WS-WHEN-COMPILED.
05 WS-WHEN-COMPILED-DATE
PIC X(08).
05 WS-WHEN-COMPILED-TIME
* PIC X(08).
MOVE FUNCTION WHEN-COMPILED TO WS-WHEN-COMPILED.
|
For Batch COBOL, the "Signature Bytes" begin at offset X'84' of the Load Module.
They are documented in the COBOL manual and have been discussed before in the Mainframe COBOL forum.
HTH.... |
|
Back to top |
|
|
Mike 1304
New User
Joined: 15 Oct 2011 Posts: 46 Location: Germany
|
|
|
|
Thanks for the hint to FUNCTION WHEN-COMPILED, this will fit my needs!
But do you have another hint for the program name?
My experience is, that programs are copied and definitions stay unchanged.
So if I define a field with the program name in my program and it is copied,
the name posted in error messages stay my program name instead of the real new program name. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
The Special Register WHEN-COMPILED has ben around longer. Two-digit year.
Program name is tricky. Remember that the value on the PROGRAM-ID need not be relevant in the case of a dynamic CALL. It is simply the loadmodule name, PROGRAM-ID can be anything.
Library it came from. Probably more tricky. The WHEN-COMPILED/FUNCTION WHEN-COMPILED allow confirmation that you're looking at a correct load, but doesn't deal with multiple copies of the same module in different libraries.
There is something I saw with Language Environment which I thought looked interesting, but haven't tried out. I'll try to find it. Might give you some more, perhaps enough. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
Mike 1304 wrote: |
Hi,
I need to know some Information about my program in the program e.g. to write program Name in error Messages in DISPLAY or WTO.
needed information:
Program name, compile date |
Remember that a load module may be derived from a number of source modules, all compiled or assembled on different dates. Will you definitely want to use a compile date, or should you look at link date? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
Back to top |
|
|
Mike 1304
New User
Joined: 15 Oct 2011 Posts: 46 Location: Germany
|
|
|
|
Akatsukami wrote: |
Remember that a load module may be derived from a number of source modules, all compiled or assembled on different dates. Will you definitely want to use a compile date, or should you look at link date? |
I'm working with dynamic called programs, so for me link and compile date is both ok. |
|
Back to top |
|
|
Mike 1304
New User
Joined: 15 Oct 2011 Posts: 46 Location: Germany
|
|
|
|
Hi Bill,
many thanks for the links!
I'll try to make it with the second link, which lists all the programs until the PGM= of the JCL.
But I didn't understand it yet completely:
Example: EXEC PGM=PGMA, PGMA then calls PGMB, which calls PGMC.
Now PGMC want to know its own name.
Going through the CDE-Blocks I'll find PGMC and PGMB and at the end PGMA, but also a lot of other Program like IGZCLNK or CEEBINIT.
How can I safely identify "my own name" PGMC? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Hi Mike,
Just as the PGM= program is at the bottom of the chain, the current program, the one you are interested in most, is at the "top" of the chain.
If you put all this in a sub-program, so that you can easily use it in multiple places, the program you will be interested in most will always be the 2nd from the top. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Mike,
Search this site (as well as Google/IBM) for AMBLIST, which can give you additional information.
Regards, |
|
Back to top |
|
|
Mike 1304
New User
Joined: 15 Oct 2011 Posts: 46 Location: Germany
|
|
|
|
Hi Bill,
my test show me that CDE-Block don't show a caller hierarchy, so I can't find my program at the top. The CDE-Blocks are built in the order the programs are called and if multiple other programs are calling each other, the position of my program is not clear. I can search for my proram if I know the name, but if I search teh name of my program I have no chance. |
|
Back to top |
|
|
Mike 1304
New User
Joined: 15 Oct 2011 Posts: 46 Location: Germany
|
|
|
|
Bill O'Boyle wrote: |
Mike,
Search this site (as well as Google/IBM) for AMBLIST, which can give you additional information.
Regards, |
Hi Bill,
are you sure, I can use AMBLIST out of a running program to get it's name? I think it is a utility to present information about a load module, but you have to tell teh name and the library? |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Mike,
Sorry, I misunderstood your requirements.
AMBLIST is a Batch Utility only.
Regards, |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Mmm... I originally thought there were three articles I'd seen that may be relevant, but my rapid search only found two. Unfortunately I only glanced at them, and assumed that they worked for programs "down the chain" not just for the main program. Maybe the third one does.
There is the Assembler sub-routine to do a LOAD, but you've already pointed to the problem there - how do you know (for sure) the name to LOAD. Bit of a Catch-22.
Are you writing messages for a controlled failure? If so a Language Environment Abend Handler might suit. If not for controlled failure, you might also be able to bend that approach to do what you want, as there is an LE routine which tells you (at least when CALLed from the abend handler) which program (loadmodule) caused the abend. Once you, reliably, know that you can do the LOAD and get at the compile information from the "front" of the COBOL program.
There must be LE Control Blocks that would be of use, as they get used for formatting the LE dump. |
|
Back to top |
|
|
Mike 1304
New User
Joined: 15 Oct 2011 Posts: 46 Location: Germany
|
|
|
|
Hi all,
thanks for your help!
I now found an assembler program, which goes through the savearea chain.
It identities the calling program by comparing the return address with the entry point and length from CDE/extended CDE.
If return address is between entry point and end of module, module name is returned.
It skips all runtime modules like CCE*, ILBO*, IGZ*.
Thanks again, I wouldn't have found it without your hints! |
|
Back to top |
|
|
|