File Handler behavior in managed code

In native COBOL if you have "SELECT DATA-FILE ASSIGN TO DISK 'OLD\Data.dat'" and "OPEN INPUT DATA-FILE" then the File Handler will look for an environment variable named "dd_OLD" and replace the "OLD" in the SELECT clause literal with the contents of the environment variable (if found). But what happens in managed code? We are getting "File not found". Is the managed-code version of the File Handler looking for "dd_OLD" somewhere other than in the environment, or does this functionality not exist in managed code?
Parents
  • Verified Answer

    Actually a better place to set the environment variables would be within the instantiated RunUnit itself so that this would not be set globally.

    There is a SetEnvironmentVariable method in the RunUnit class:

    Example:

     MicroFocus.COBOL.RuntimeServices.RunUnit myRunUnit =
                  new MicroFocus.COBOL.RuntimeServices.RunUnit();
                try
                {
                    // Call the COBOL program
                    COBPROG cp = new COBPROG();
                    myRunUnit.Add(cp);
                    myRunUnit.SetEnvironmentVariable("dd_NEW", "C:\\temp");
                    
                    myRunUnit.Call("COBPROG", "11111111111111111111");
                }
                finally
                {
                    // Destroy the run unit
                    myRunUnit.StopRun();
                }
    
Reply
  • Verified Answer

    Actually a better place to set the environment variables would be within the instantiated RunUnit itself so that this would not be set globally.

    There is a SetEnvironmentVariable method in the RunUnit class:

    Example:

     MicroFocus.COBOL.RuntimeServices.RunUnit myRunUnit =
                  new MicroFocus.COBOL.RuntimeServices.RunUnit();
                try
                {
                    // Call the COBOL program
                    COBPROG cp = new COBPROG();
                    myRunUnit.Add(cp);
                    myRunUnit.SetEnvironmentVariable("dd_NEW", "C:\\temp");
                    
                    myRunUnit.Call("COBPROG", "11111111111111111111");
                }
                finally
                {
                    // Destroy the run unit
                    myRunUnit.StopRun();
                }
    
Children
No Data