MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sub program : INITIAL state

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
ravikumar_sri2001
Beginner


Joined: 06 Dec 2002
Posts: 117
Topics: 44
Location: Chennai,India

PostPosted: Tue Nov 25, 2003 4:25 am    Post subject: Sub program : INITIAL state Reply with quote

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


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Nov 25, 2003 7:07 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Nov 25, 2003 10:31 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
ravikumar_sri2001
Beginner


Joined: 06 Dec 2002
Posts: 117
Topics: 44
Location: Chennai,India

PostPosted: Wed Nov 26, 2003 3:48 am    Post subject: Reply with quote

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


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Wed Nov 26, 2003 5:44 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Wed Nov 26, 2003 8:37 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
ravikumar_sri2001
Beginner


Joined: 06 Dec 2002
Posts: 117
Topics: 44
Location: Chennai,India

PostPosted: Wed Nov 26, 2003 9:21 am    Post subject: Reply with quote

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


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Wed Nov 26, 2003 12:01 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group