Skip to main content

Problem:

The simplest way is to retrieve the contents of the environment variable USERNAME, as in the code pasted below

Others ways are to use the WIN32 APIs  GetUSerName or WNetGetUser, as described in MF NeXx sample page

getuser.zip :    Using WIN 32 Api to get the current user logged using the win 32 api in Cobol

getnuser.zip:   Using WIN 32 Api to get the current user logged on the network using the win 32    api in cobol  

Resolution:

        working-storage section.

       01  ENV-value                pic x(200).

       01  ENV-name.                pic x(11) value "USERNAME".

       procedure division.

      ****************************************************

      *--> read the value of environment variable USERNAME

            display ENV-name upon environment-name

            accept env-value from environment-value.

            display "After read "  ENV-NAME " = " env-value

            stop run.

in

Old KB# 6999