Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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: 743
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 Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts Compiler option for override the exte... muralikrishnan_new COBOL Programming 9 Fri Jul 08, 2016 12:09 pm
No new posts Is it possible to pass variables of s... Csongor CLIST & REXX 2 Fri Jun 10, 2016 7:33 pm
No new posts TWS 'global' or 'local' variables Steve Coalbran IBM Tools 2 Thu Mar 17, 2016 7:40 pm
No new posts How to pass a structure to external p... Pedro PL/I & Assembler 8 Tue Jan 19, 2016 7:05 am

Back to Top
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us