uses of global data area(GDA)

hi guys,

plz tell me why global data area(GDA) is accessed only for programme and external subroutine.
not for subprogramme ,internal subroutine and helproutine…

There are two philosopies:

  1. Share data in a GDA and FETCH RETURN
  2. Share data via Parameter and CALLNAT
    So from my point of view the completely separated memory for CALLNAT makes sense.

BTW: If you want to use GDA-like variables in a subprogram use DEFINE DATA INDEPENDENT.

GDA is accessable for an interal subroutine.

A Natural subprogram, in a very real sense, is a “generic” subroutine. The original design philosophy behind “subroutines”, many many years ago, was that they should be independent of the calling programs.

That is, you passed the required arguments to a subroutine, it did its thing, and it passed back the required output.

As a programmer “using a subroutine”, I was free to change anything in my calling program so long as the arguments I passed to the subroutine conformed to expected format and length. Similarly, as a programmer of a subroutine, as long as I did not change the interface, I could do anything I wanted within the subroutine.

Now suppose a Natural program and subprogram “shared” a Global Data Area. All of a sudden, the two routines are no longer independent of one another. If there is a variable in the GDA called #SUM which is used by both a program and a subprogram, and the programmer of the subprogram wants to change the name to something more descriptive like #SUM-OF-MONTHLY-EXPENSES. In order to do that, assuming they had the proper authority, they would change the GDA.

BUT, now everyone who used #SUM from the GDA, whether they called the subprogram or not, would have to change their code. What a nightmare.

That is almost assuredly one reason why subprograms are maintained as an independent entity.

steve