COBOL VARIABLE ACCESSIBLE IN OTHER PROGRAM



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

COBOL VARIABLE ACCESSIBLE IN OTHER PROGRAM

Postby rbarnach1 » Fri Oct 25, 2013 5:50 pm

Hi,

Is it possible to declare a variable in a COBOL program that is accessible in another non-cobol program?

Another question, how can I access an EXTERNAL VARIABLE declared to a C Program from COBOL?

Thanks,
rbarnach1
 
Posts: 7
Joined: Sat Sep 21, 2013 4:35 am
Has thanked: 0 time
Been thanked: 0 time

Re: COBOL VARIABLE ACCESSIBLE IN OTHER PROGRAM

 

Re: COBOL VARIABLE ACCESSIBLE IN OTHER PROGRAM

Postby Robert Sample » Fri Oct 25, 2013 5:57 pm

The z/OS Language Environment bookshelf has a book titled Writing Interlanguage Communication (ILC) Applications, and this book has a chapter specifically on C and COBOL communications. If you have not yet read this book and chapter, I recommend you start there.
Robert Sample
Global moderator
 
Posts: 3378
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 225 times

Re: COBOL VARIABLE ACCESSIBLE IN OTHER PROGRAM

Postby rbarnach1 » Fri Oct 25, 2013 6:21 pm

Robert Sample wrote:The z/OS Language Environment bookshelf has a book titled Writing Interlanguage Communication (ILC) Applications, and this book has a chapter specifically on C and COBOL communications. If you have not yet read this book and chapter, I recommend you start there.


Thanks, already browsed this source unfortunately, I don't see any answer to my inquiry.

I'm looking for similar functionality of C EXTERNAL VARIABLE declaration and applied it to COBOL. External variable declaration of COBOL is different than C.
rbarnach1
 
Posts: 7
Joined: Sat Sep 21, 2013 4:35 am
Has thanked: 0 time
Been thanked: 0 time

Re: COBOL VARIABLE ACCESSIBLE IN OTHER PROGRAM

Postby Robert Sample » Fri Oct 25, 2013 6:39 pm

Is it possible to declare a variable in a COBOL program that is accessible in another non-cobol program?

Another question, how can I access an EXTERNAL VARIABLE declared to a C Program from COBOL?
If you read the manual I referenced, you would find that the answer to your questions is contained in (and I highlighted the key point)
4.4.3 Name Scope of External Data In programming languages, the name scope is defined as the portion of an application within which a particular declaration applies or is known. The name scope of external data differs between C and COBOL. The scope of external data under C is the load module; under COBOL, it is the enclave (or run unit). Figure 7 in topic 4.4.3.2 and Figure 8 in topic 4.4.3.3 illustrate these differences. Because the name scope for C and COBOL is different, external variables do not map between C and COBOL; external variables with the same name are considered separate between C and COBOL. If your application relies on the separation of external data, do not give the data the same name in both languages within a single application. If you give the data in each load module a different name, you can change the language mix in the application later, and your application still behaves as you expect it to.

4.4.3.1 DLL Considerations
4.4.3.2 Name Scope of External Data in a C Application
4.4.3.3 Name Scope of External Data in a COBOL Run Unit
So you pretty much need to pass variables between C and COBOL if you want to access the values -- using an EXTERNAL VARIABLE will not allow the C and COBOL programs to interact with the same data.
Robert Sample
Global moderator
 
Posts: 3378
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 225 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post