Highlighted
Absent Member.
Absent Member.
2438 views

Data área like "sesión data".

Jump to solution

The scenario is as follows:


Within a run-unit, we run a program that calls others (many others).
We would need to have a data area visible by all programs running within that run unit.
Eventually, some program also would update the data in this area, as if it were the "session data".
Any idea how we could implement this requirement?

We are using Visual Cobol 2.2 under Unix.

Any collaboration will be appreciated.

0 Likes
3 Solutions

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Data área like "sesión data".

Jump to solution

Hi Jose,

It sounds like EXTERNAL data would probably work for you.

If you define a data area in all of your programs and use the EXTERNAL keyword then that data area does not belong to any one program but instead it belongs to the run-unit and is shared by all programs within that run-unit that also have it defined.

prog1:

01 my-ext-data   external.
   05 field-1    pic x(10).
   05 field-2    pic x(20).
  move "TEST" to field-1

  call "prog2"
  display field-1 *> will display PROG2

prog2:

01 my-ext-data   external.
   05 field-1    pic x(10).
   05 field-2    pic x(20).

  display field-1   *> will display TEST
  move "PROG2" to field-1
  goback.

View solution in original post

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Data área like "sesión data".

Jump to solution

All you have to do is define it as external in each of your programs that will require it and then it will automatically be created as external data when the program runs just like any other data defined in working-storage.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Data área like "sesión data".

Jump to solution

Thanks Chris.

We'll do a test.

View solution in original post

0 Likes
6 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Data área like "sesión data".

Jump to solution

Hi Jose,

It sounds like EXTERNAL data would probably work for you.

If you define a data area in all of your programs and use the EXTERNAL keyword then that data area does not belong to any one program but instead it belongs to the run-unit and is shared by all programs within that run-unit that also have it defined.

prog1:

01 my-ext-data   external.
   05 field-1    pic x(10).
   05 field-2    pic x(20).
  move "TEST" to field-1

  call "prog2"
  display field-1 *> will display PROG2

prog2:

01 my-ext-data   external.
   05 field-1    pic x(10).
   05 field-2    pic x(20).

  display field-1   *> will display TEST
  move "PROG2" to field-1
  goback.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Data área like "sesión data".

Jump to solution

OK. Clear and concise.

But, what we must do to create that variable EXTERNAL?

COBOL automatically create it or we need to do something extra?

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Data área like "sesión data".

Jump to solution

All you have to do is define it as external in each of your programs that will require it and then it will automatically be created as external data when the program runs just like any other data defined in working-storage.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Data área like "sesión data".

Jump to solution

Thanks Chris.

We'll do a test.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Data área like "sesión data".

Jump to solution

Hi Chris

When you 're saying "same run-unit" you mean the same executable?

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Data área like "sesión data".

Jump to solution

Not necessarily the same executable. A run-unit consists of the main COBOL program and all subprograms that it may call so these subprograms could be in separate executable files like .int, gnt,.dlls, .so's...

The run-unit would then be made up of all of these executables.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.