Accessing Environment Variables from COBOL

Use the following construct to access environment variables from the COBOL source code:

working-storage section.
01 val pic x(100).
Procedure division.
       
display "USERNAME" upon environment-name 
accept val from environment-value
display val
goback.
...
Important: It is unsafe to modify or add environment variables in a threaded application on Linux systems. This is due to limitations of the underlying system libraries. It is however safe to read values from environment variables.