Get the name of load library in COBOL at run time.
Get the name of load library in COBOL at run time.
Hello,
In a COBOL program how can we capture the name of the load library that the program was executed from at run time? Is there way outfor this.
Thanks.
In a COBOL program how can we capture the name of the load library that the program was executed from at run time? Is there way outfor this.
Thanks.
-
- Global Moderator
- Posts: 826
- Joined: Wed Sep 11, 2013 3:57 pm
Re: Get the name of load library in COBOL at run time.
what is the business need for it ?
please ... do not answer "that' s the requirement"
please ... do not answer "that' s the requirement"
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Get the name of load library in COBOL at run time.
I agree with enrico. We'd need to know why. Your audit and compliance people (in a financial site) would be very keen to know why as well.
Re: Get the name of load library in COBOL at run time.
Actually there is no business need as such but in a system integration testing we have a module available in different libraries. And the setup is like we can't control the execution library as it is outsourced to other vendor. Now the program is producing a wrong output (older) but the load module in the intended library is up to date... we thought if we can know which library the program was executed it will help us to solve the problem.
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Get the name of load library in COBOL at run time.
OK, so change the emphasis slightly.
Obviously you do the MOVE/DISPLAY only once in any given program.
This will show you the date/time that the program was compiled (same date/time that appears on compile listing).
If you're concerned about only having a two-digit year (in this case a silly concern) FUNCTION WHEN-COMPILED does it with four-digit years.
Code: Select all
WORKING-STORAGE SECTION.
01 W-WHEN-COMPILED PIC X(8)BX(8).
Code: Select all
PROCEDURE DIVISION.
MOVE WHEN-COMPILED TO W-WHEN-COMPILED
DISPLAY "yourprogramname " W-WHEN-COMPILED
This will show you the date/time that the program was compiled (same date/time that appears on compile listing).
If you're concerned about only having a two-digit year (in this case a silly concern) FUNCTION WHEN-COMPILED does it with four-digit years.
Re: Get the name of load library in COBOL at run time.
Thanks WHEN-COMPILED gives a "timestamp" but does not really tell about the load lib. We can have the code in QA and test with the same day compilation date.
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Get the name of load library in COBOL at run time.
If it has the same compilation date/time it does not matter where you run it from. It is the same program, it will produce the same results.
The point of using WHEN=COMPILED is that you know which, compiled, version executed. I thought your problem was one of thinking you were running one thing, but running another.
If you look at the JOBLIB/STEPLIB libraries in order, the first library with that module is the one it will have been loaded from.
How many many datasets do you have on JOBLIB or STEPLIB?
The point of using WHEN=COMPILED is that you know which, compiled, version executed. I thought your problem was one of thinking you were running one thing, but running another.
If you look at the JOBLIB/STEPLIB libraries in order, the first library with that module is the one it will have been loaded from.
How many many datasets do you have on JOBLIB or STEPLIB?
Re: Get the name of load library in COBOL at run time.
Three or more datasets we have on STEPLIB and similar is the number for JOBLIB. Actually, they have some versions of these libs. I think your indication should work but for knowledge is it possible to know the library name? Perhaps not.
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Get the name of load library in COBOL at run time.
You could programatically find the datasetnames from the Control Blocks, and then search them in order. The first dataset you find it on is the one it was loaded from.
The information may be "directly" available somewhere, but if it is I don't know about it.
The information may be "directly" available somewhere, but if it is I don't know about it.
Re: Get the name of load library in COBOL at run time.
Once you know whether your job-step is using the STEPLIB or the JOBLIB (read the manual) you can easily find which library is being used - tehy are searched in the order coded so start at the top and work down. The first one containing the load module is the one where that load module is loaded from.
Regards
Nic
Nic
Re: Get the name of load library in COBOL at run time.
Thanks William. I thought it would be easy to cpature the library name but it is not. Reading control block is a tough thing for me.William Collins wrote:You could programatically find the datasetnames from the Control Blocks, and then search them in order. The first dataset you find it on is the one it was loaded from.
The information may be "directly" available somewhere, but if it is I don't know about it.
Thanks for all the help and guidance.
Re: Get the name of load library in COBOL at run time.
That is right nicc but we have UAT, QA and Test library concatenated. Ideally they all should have the same code once in UAT but once it happened that code was not there and perhaps was in between the transistion from one library to other while the job executed or may be something else. This caused a confusion. To avoid this we thought of picking up the lib name at execution time.nicc wrote:Once you know whether your job-step is using the STEPLIB or the JOBLIB (read the manual) you can easily find which library is being used - tehy are searched in the order coded so start at the top and work down. The first one containing the load module is the one where that load module is loaded from.
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute