View previous topic :: View next topic
|
Author |
Message |
jose.jeyan
New User
Joined: 28 Jul 2006 Posts: 60 Location: Mumbai
|
|
|
|
can anyone pls describe me wats global & external variables in cobol.wats the use of it.with an example
Thanks in advance
Jose |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
Back to top |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
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:
COPY CIPUFMSG.
CopyBook:
01 IFP-MSG-MESSAGES EXTERNAL.
10 MSG-VERARB-ART PIC X(004).
10 MSG-FILLER-001 PIC X(001).
10 MSG-VERARB-CDE PIC X(002).
Then programm-a calls programm-b:
Move blablabla to copybook-fields
Call programm-b End-Call
Regards, UmeySan |
|
Back to top |
|
|
|