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
 

 

Get program info in a program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
Mike 1304

New User


Joined: 15 Oct 2011
Posts: 43
Location: Germany

PostPosted: Thu Nov 14, 2013 2:01 am    Post subject: Get program info in a program
Reply with quote

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

Robert Sample

Global Moderator


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

PostPosted: Thu Nov 14, 2013 2:11 am    Post subject:
Reply with quote

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

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Nov 14, 2013 2:11 am    Post subject: Reply to: Get program info in a program
Reply with quote

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

New User


Joined: 15 Oct 2011
Posts: 43
Location: Germany

PostPosted: Thu Nov 14, 2013 2:36 am    Post subject: Reply to: Get program info in a program
Reply with quote

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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Thu Nov 14, 2013 3:15 am    Post subject: Reply to: Get program info in a program
Reply with quote

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

Global Moderator


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

PostPosted: Thu Nov 14, 2013 3:59 am    Post subject: Re: Get program info in a program
Reply with quote

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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Thu Nov 14, 2013 5:48 am    Post subject: Reply to: Get program info in a program
Reply with quote

Here, particularly here and here.
Back to top
View user's profile Send private message
Mike 1304

New User


Joined: 15 Oct 2011
Posts: 43
Location: Germany

PostPosted: Thu Nov 14, 2013 9:47 am    Post subject: Re: Get program info in a program
Reply with quote

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

New User


Joined: 15 Oct 2011
Posts: 43
Location: Germany

PostPosted: Thu Nov 14, 2013 10:35 am    Post subject: Re: Reply to: Get program info in a program
Reply with quote

Bill Woodger wrote:
Here, particularly here and here.


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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Thu Nov 14, 2013 12:53 pm    Post subject: Reply to: Get program info in a program
Reply with quote

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

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Nov 14, 2013 6:06 pm    Post subject: Reply to: Get program info in a program
Reply with quote

Mike,

Search this site (as well as Google/IBM) for AMBLIST, which can give you additional information.

Regards,
Back to top
View user's profile Send private message
Mike 1304

New User


Joined: 15 Oct 2011
Posts: 43
Location: Germany

PostPosted: Thu Nov 14, 2013 6:37 pm    Post subject: Re: Reply to: Get program info in a program
Reply with quote

Bill Woodger wrote:
Here, particularly here and here.


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

New User


Joined: 15 Oct 2011
Posts: 43
Location: Germany

PostPosted: Thu Nov 14, 2013 6:40 pm    Post subject: Re: Reply to: Get program info in a program
Reply with quote

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

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Nov 14, 2013 6:44 pm    Post subject: Reply to: Get program info in a program
Reply with quote

Mike,

Sorry, I misunderstood your requirements.

AMBLIST is a Batch Utility only.

Regards,
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Thu Nov 14, 2013 10:57 pm    Post subject: Reply to: Get program info in a program
Reply with quote

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

New User


Joined: 15 Oct 2011
Posts: 43
Location: Germany

PostPosted: Fri Nov 15, 2013 12:32 pm    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts I can not compile my program PL1 V3.R... Miguel Fernandez PL/I & Assembler 3 Tue Dec 06, 2016 8:30 pm
No new posts IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm
No new posts IMS Database backup info ashek15 IMS DB/DC 14 Wed Nov 16, 2016 5:29 am
No new posts A sample of exit program for exit XMN... lind sh CICS 2 Mon Oct 03, 2016 5:07 pm
No new posts Need points to tune IMS Checkpoint Pr... satish.ms10 IMS DB/DC 2 Fri Sep 30, 2016 4:12 pm


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