View previous topic :: View next topic |
Author |
Message |
ravikumar_sri2001 Beginner
Joined: 06 Dec 2002 Posts: 117 Topics: 44 Location: Chennai,India
|
Posted: Tue Nov 25, 2003 4:25 am Post subject: Sub program : INITIAL state |
|
|
My shop is using Cobol compiler "IBM Enterprise COBOL for z/OS and OS/390 3.2.0."
In a manual it is given that "in dynamic call, sub program will be in
initial state every time it is called".
But contrary to this, i had a sub program which was not set to initial state. The main program did not execute CANCEL statement. The "DYNAM" compiler option was in effect while compiling main program.
I tried a simple sub program. Following is the code.
IDENTIFICATION DIVISION.
PROGRAM-ID. SUB1.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 I PIC 9(02) VALUE 0.
PROCEDURE DIVISION.
ADD 1 TO I
DISPLAY I
GOBACK.
The following is the main program.
IDENTIFICATION DIVISION.
PROGRAM-ID. MAIN.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
CALL 'SUB1'.
CALL 'SUB1'.
STOP RUN.
O/P of the program
==============
01
02
Thanks,
Ravikumar. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Tue Nov 25, 2003 7:07 am Post subject: |
|
|
Ravikumar,
Your call seems to be a static call to me.Also the NOREUS linkage-editor or binder option is needed to ensure a fresh copy of the program on a subsequent CALL.
Hope this helps...
cheers
kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Tue Nov 25, 2003 10:31 am Post subject: |
|
|
Ravikumar,
I see a a couple of errors in your post. I just took your code and compiled it. As I said earlier your are making a STATIC call to the subprogram. Also you are not using the linkage section( as such you are not passing any parameters to it). Since the program is static linked , your program is not in the initial state. This is confirmed from the load module listing.
The best way to determine if the program is linked static or dynamic is to check the load module listing of the main program. You can use IBM's pgm AMBLIST to get the load module listing.
Code: |
//STEP0100 EXEC PGM=AMBLIST
//SYSPRINT DD SYSOUT=*
//SYSLIB DD DSN=YOUR LOADLIB,
// DISP=SHR
//SYSIN DD *
LISTIDR MEMBER=YOUR PGM NAME
//*
|
In the above JCL you will give your MAIN program for the member name.Once you run this job, in the output listing you will find CSECTS which are entry points for programs. If there is a CSECT for your subroutine, then that program is statically linked.
You can also get the same listing using FILEAID.
On the fileaid main menu choose the option UTILITIES which is option 3. once you in the utilities menu choose the option LIBRARY which is option 1. once you are in the library option choose option A or N (Map CSECTs ) by specifying your loadlib and the member name.
Hope this helps...
cheers
kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
ravikumar_sri2001 Beginner
Joined: 06 Dec 2002 Posts: 117 Topics: 44 Location: Chennai,India
|
Posted: Wed Nov 26, 2003 3:48 am Post subject: |
|
|
Kolusu,
Thanks for your explanation. Sorry, i am not aware of CSECT. My subprogram name is "SUB1". I could not find string "SUB1" in SYSPRINT listing of program AMBLIST. Please let me know your mail id. I will send you the SYSPRINT listing of program AMBLIST.
Thanks,
Ravikumar. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Wed Nov 26, 2003 5:44 am Post subject: |
|
|
Ravikumar,
Did you give the name of the main pgm as input for AMBLIST? . Just post the JCL you used to run and also the sysprint here itself.
Thanks
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Wed Nov 26, 2003 8:37 am Post subject: |
|
|
Ravikumar,
I looked at your sysprint which you sent me offline. The reason you don't see a CSECT for the sub1 pgm is that you have DYNAM compiler option on the main pgm also. So Compile the main pgm with NODYNAM and then run the AMBLIST. You can over write the DYNAM option from the program it self.
Hope this helps...
cheers
kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
ravikumar_sri2001 Beginner
Joined: 06 Dec 2002 Posts: 117 Topics: 44 Location: Chennai,India
|
Posted: Wed Nov 26, 2003 9:21 am Post subject: |
|
|
Kolusu,
Thanks for your explanation.
My question is this.
"I expected that when main program calls a sub-program dynamically, the subprogram has to be in initial state. That is output should be "01" for both the calls. But i got "01" in first call and "02" in second call."
I tried giiving link editor option "NOREUS" for both main and sub programs.
But i got the same result (i.e, 01 and 02 ).
Please let me know if i am missing anything.
Thanks,
Ravikumar. |
|
Back to top |
|
|
slade Intermediate
Joined: 07 Feb 2003 Posts: 266 Topics: 1 Location: Edison, NJ USA
|
Posted: Wed Nov 26, 2003 12:01 pm Post subject: |
|
|
Hi Ravikumar,
My understanding was that a DYNAMic CALL without an intervening CANCEL will NOT reinit WS.
Can you try your test code with a CANCEL between the 2 CALLs?
Regards, Jack. |
|
Back to top |
|
|
|
|