---
title: "COBOL: EXTERNAL file Vs GLOBAL file"
description: "Within a main program and each of its contained subprograms, data and files are normally private, which means that they are accessible only to the program in which they are contained. However, COBOL h..."
url: https://srinimf.com/2015/06/07/how-cobol-sharing-data-between-main-and-subprograms/
date: 2015-06-07
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2015/06/pexels-photo-131723.jpeg?fit=1880%2C1249&ssl=1
categories: ["COBOL"]
tags: ["COBOL Tips and Tricks"]
type: post
lang: en
---

# COBOL: EXTERNAL file Vs GLOBAL file

Within a main program and each of its contained subprograms, data and files are normally private, which means that they are accessible only to the program in which they are contained.

However, COBOL has provisions for sharing data and files among a main program and its subprograms.

Related[COBOL – How to Use ‘ CANCEL’](https://srinimf.com/2011/02/23/cobol-global-external-initial-common/)

Procedure names and paragraph names are private to a program. They can not be shared by other programs.But, program names must be unique.

PROGRAM-ID. program-name IS COMMON PROGRAM.

A program with COMMON, can be called by all other programs, not limited to by the program containing it.It can not be called by outside programs, since its load is not present in other load module.

In mainframe, a subprogram can be called by itself. It is called recursive calling

**Global concept**

01 data-name IS GLOBAL

Means data item is global to all programs

FD file-name IS GLOBAL

File name and record names are global to all programs

**External Concept**

Related[COBOL – Global, Initial, External,Common](https://srinimf.com/2012/03/18/cobol-global-initial-externalcommon/)

A declaration of EXTERNAL for a file means that anywhere in the run unit that the same file is declared (with the same name and the attribute EXTERNAL), the reference is to the same exact file.

FD file-name IS EXTERNAL

You must define the file in any program that references it. However, an external file does not really “belong” to any particular program—it belongs to the whole run unit.

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2015%2F06%2F07%2Fhow-cobol-sharing-data-between-main-and-subprograms%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2015%2F06%2Fpexels-photo-131723.jpeg%3Ffit%3D1200%252C797%26ssl%3D1&description=COBOL%3A%20EXTERNAL%20file%20Vs%20GLOBAL%20file)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2015/06/07/how-cobol-sharing-data-between-main-and-subprograms/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2015/06/07/how-cobol-sharing-data-between-main-and-subprograms/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2015/06/07/how-cobol-sharing-data-between-main-and-subprograms/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2015/06/07/how-cobol-sharing-data-between-main-and-subprograms/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20COBOL%3A%20EXTERNAL%20file%20Vs%20GLOBAL%20file&body=https%3A%2F%2Fsrinimf.com%2F2015%2F06%2F07%2Fhow-cobol-sharing-data-between-main-and-subprograms%2F&share=email)
-

### Like this:

Like Loading…
