Quantcast
Channel: Visual COBOL
Viewing all articles
Browse latest Browse all 5819

Forum Post: RE: File Handler behavior in managed code

$
0
0
Actually for a C# ASP.NET application I don't believe that you can automatically set environment variables in web.config as the values you set are simply string pairs that can be read by your application. If you are calling a COBOL program from within a C# ASP.NET application then you should be using RunUnits to do this or else the program will not be thread safe. Environment variables that are set prior to the opening of the COBOL files, (in computer environment or in application) will be picked up in the COBOL program. Example: variable dd_NEW could be set in computer's environment also but here it is set by the calling C# program. protected void Button1_Click(object sender, EventArgs e) { System.Environment.SetEnvironmentVariable("dd_NEW", "C:\\temp"); MicroFocus.COBOL.RuntimeServices.RunUnit myRunUnit = new MicroFocus.COBOL.RuntimeServices.RunUnit(); try { // Call the COBOL program COBPROG cp = new COBPROG(); myRunUnit.Add(cp); myRunUnit.Call("COBPROG", "11111111111111111111"); } finally { // Destroy the run unit myRunUnit.StopRun(); } } COBOL program: program-id. COBPROG. environment division. select test-file assign to "NEW\myfile.dat" organization is line sequential file status is file-status. data division. file section. fd test-file. 01 test-record pic x(20). working-storage section. 01 file-status pic x(2) value spaces. 01 myvar string. linkage section. 01 myparams pic x(20). procedure division using by value myparams. open output test-file move myparams to test-record write test-record close test-file goback.

Viewing all articles
Browse latest Browse all 5819

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>