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 

External declaration in Cobol

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


Joined: 10 Apr 2005
Posts: 12
Topics: 5
Location: India

PostPosted: Mon Nov 28, 2005 2:20 am    Post subject: External declaration in Cobol Reply with quote

I have some doubts while defining a variable as external in Cobol.

Suppose I have a Main program A which calls a sub-program B. This main program uses a variable WS-TXT whcih is defined in a copybook as EXTERNAL.
Now the main program A and sub-program B will be able to use this variable WS-TXT.

Assume that I have another Main program C which calls a sub-program D. This main program C also uses the same copybook variable WS-TXT defined as EXTERNAL. Also C and D can access this variable WS-TXT.
Assume that both run as different jobs at the same time.

My question is that will this varible WS-TXT be created only once and stored in the common area for both these Main programs or will there be 2 different copies of WS-TXT in each address space and each program will access its own copy. Any change to the value of WS-TXT caued by one program will not affect the other program.

Could you please clarify the same.

Thanks

Gauthaman
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Nov 28, 2005 5:47 am    Post subject: Reply with quote

gauthaman_mech,

If WS-TXT has the same declaration in both pgm's A and C , then it is created only once and it can be referenced by both the programs.

Check these links which explains in detail about sharing data using external clause.

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3PG10/4.2.5?DT=20020923143836

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3LR10/5.3.7?DT=20020920180651

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
gauthaman_mech
Beginner


Joined: 10 Apr 2005
Posts: 12
Topics: 5
Location: India

PostPosted: Mon Nov 28, 2005 6:06 am    Post subject: Reply with quote

Thanks a lot Kolusu.

I have only one more question.
The links say that the variable will be common for that run unit.
What does this run unit mean.
Does it mean a Run JCL which invokes a series of procedures which in turn invoke programs.
Or does it mean a program and its sub programs.

Further if this External variable was used by a cobol program and also by another independent DB2 cobol program, and the DB2 cobol program is excuted from IMS environment, there should be 2 copies of that varible even though both the programs are executed at the same time.
Am I right.

Please correct me if I am wrong.

Thanks
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