Global variables can seem like a handy way to pass state information around in a program, but the use of global variables only works well in very
small programs. As the code base grows, you’ll need to understand every subprocedure’s impact on the global state in order to understand how the
program works. This is a task that quickly becomes impossible.
To control the situation, only the main procedure should be allowed access to global variables; it can then pass that state information to
subprocedures as parameters.
Noncompliant code example
     D FirstName       S             20A
     D LastName        S             20A
      /free
       FirstName = 'John';
       LastName = 'Smith';
       DSPLY FullName();
      /end-free
     P FullName        B
     D FullName        PI            41A
      /free
       return FirstName + ' ' + LastName;
      /end-Free
     P                 E
Compliant solution
      /free
       DSPLY FullName('John':'Smith');
      /end-free
     P FullName        B
     D FullName        PI            41A
     D  FirstName                    20A   Const
     D  LastName                     20A   Const
      /free
       return FirstName + ' ' + LastName;
      /end-Free
     P                 E