Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
Global & External variables

Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message

New User

Joined: 28 Jul 2006
Posts: 60
Location: Mumbai

PostPosted: Wed Jan 17, 2007 2:40 pm    Post subject: Global & External variables
Reply with quote

can anyone pls describe me wats global & external variables in cobol.wats the use of it.with an example

Thanks in advance
Back to top
View user's profile Send private message

William Thompson

Global Moderator

Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Wed Jan 17, 2007 3:14 pm    Post subject:
Reply with quote

Look here:
The EXTERNAL clause specifies that the storage associated with a data item is associated with the run unit rather than with any particular program within the run unit. An external data item can be referenced by any program in the run unit that describes the data item. References to an external data item from different programs using separate descriptions of the data item are always to the same data item. In a run unit, there is only one representative of an external data item.
And here:
The GLOBAL clause specifies that a data-name is available to every program contained within the program that declares it, as long as the contained program does not itself have a declaration for that name. All data-names subordinate to or condition-names or indexes associated with a global name are global names.
Back to top
View user's profile Send private message

Active Member

Joined: 22 Aug 2006
Posts: 757
Location: Germany

PostPosted: Wed Jan 17, 2007 3:16 pm    Post subject:
Reply with quote

Hi !

The EXTERNAL and GLOBAL clauses allow you to share data and files between different COBOL subprograms. EXTERNAL is used to access globally declared data, including data declared EXTERNAL by other COBOL programs. GLOBAL is only applicable when sharing data among nested programs in an ANSI85 dialect.

The EXTERNAL clause is used to designate data or a file outside the scope the current program unit. In order for the data or file to share access, you must declare it exactly the same in another program unit. You must put the keyword EXTERNAL on all declarations. Otherwise, those lacking EXTERNAL will be considered regular data and you will not be accessing shared data or files. To ensure that you define EXTERNAL data consistently, define them in a copy file and use the COBOL COPY verb to copy them into the modules that need access to them.

Declarations having the EXTERNAL clause cannot have VALUE clauses. The exception is the 88 level items. The 88 level items can have VALUE clauses associated with them. Using EXTERNAL on a group item makes the group item and all those items subordinate to it externally visible.

Note that INDEX data of a table that are defined as EXTERNAL are not shared. You can override this restriction by using the compiler directive EXTINDEX.

Example of External CopyBook. There the data is present in all the
comunicating programms, which have included the Book.
No Fields in Linkage needed for programm-comunication.

Programm-A / und -B in Working-Strorage:




10 MSG-FILLER-001 PIC X(001).

Then programm-a calls programm-b:

Move blablabla to copybook-fields
Call programm-b End-Call

Regards, UmeySan
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1


Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts ACESSING THE FILE NAME FROM ANOTEHR E... anilkumar922 All Other Mainframe Topics 2 Fri Mar 02, 2018 4:00 pm
No new posts Using indexed variables in EZPLUS SRIDEVI TANTRY CA Products 1 Thu Feb 01, 2018 12:15 pm
No new posts COMP Variables Mismatch gayu7 COBOL Programming 5 Wed Dec 20, 2017 5:06 pm
This topic is locked: you cannot edit posts or make replies. Need help how to pass the ESP variabl... Venkichaitu JCL & VSAM 12 Thu Nov 02, 2017 3:53 am
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 8 Wed Jan 25, 2017 8:24 pm

Back to Top
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us