COBDATA question

I'm running Micro Focus Enterprise Developer and can't seem to get it to recognize the directory where all my data files(.dat) are. I'm running a PowerShell script that sets up an environment variable, i.e.;

$env:dd_MYFILE = "MYFILE.dat"

In the script I also try to set COBDATA, before running the batch program,i.e.;

[Environment]::SetEnvironmentVariable("COBDATA", "c:\data", "User")

Then I run the batch program that opens this file but am getting an error 35 in the file status after the open. In the COBOL, the select looks like:


                                       ORGANIZATION IS INDEXED

If I change the PowerShell script to the full path, i.e.;

$env:dd_MYFILE = "c:\data\MYFILE.dat"

then the file opens successfully.

For Visual COBOL is there a different way to specify data file locations?

  • The problem is that when you are assigning the file to an environment variable as in dd_MYFILE then it will not search the location specified in COBDATA.

    It instead expects you to provide the complete path name including the filename within dd_MYFILE.

    If you assign to just the actual filename in the select assign instead of to an environment variable then it will search COBDATA.



                                           ORGANIZATION IS INDEXED

    and COBDATA is set to c:\data then it will combine them and look for c:\data\myfile.dat

  • So is there no way to combine an environment variable with COBDATA?

  • So is there no way to combine an environment variable with COBDATA?

  • this is exactly what i have been trying to figure out now for three weeks, have tried every single combination known, and still it wont find the file. Looked everywhere on the net, asked in all the forums, still none have even suggested an answer.  I finally called overseas and asked tech support, but something like this should be easy, it like asking how can you do a binary sort in Algol. If i run this in GNUCOBOL will run, with no directives first time, but here no matter what directive you enter, for windows, like ;  or "path/file" or "path" nothing works.

  • Chris this is exactly what i have. 


    Then in my properties for the project in the 

    Micro Focus -> Build Configurations -> Build Environment I have


    and all i constantly get is

    I/O error : file 'SALES.DAT'
    error code: 3/5 (ANS85), pc=0, call=1, seg=0
    13 File not found



  • How are you expecting it to find the file, specifying the fully qualified name directly or via a variable as part of the select assign or via an environment variable at run time. Both are supported but the compiler option you specify will vary based on your answer.

    Is this is a managed code project or native code project
  • Wow Steve if you can help me, youll save me 3 weeks of constant frustration with this stuff. So Here is the part from  the File-Control Paragraph.

    SELECT PRINT-FILE ASSIGN TO "salesreport.dat".

    Now I crated a simple Native Cobol Program in VC. the cbl program and the dat files are under that folder.

    And its called tictac, so if i go to properties of the Navtive project -> Mcro Focus -> Build Configurations -> Build Environment -> 

    I have "c:\users\wizto\workspace\tictac" for the variable COBDATA

    and all im getting again and again is

    I/O error : file 'sales.dat'
    error code: 3/5 (ANS85), pc=0, call=1, seg=0
    13 File not found

    Press any key to continue . . .



  • Steve when i first got here, last week, my question was how do i get VC to work with Eclipse. Well a long story short, in my  current situation, i was never going to work, only due to either Eclipse or VC being so sensitive, with my current pc config, of many linux distros, wsl, upgrades to Windows 20 and such, spent weeks on that, at the same time also tried to set up files in Visual Studio VC, and couldn't get files to work.

    So formatted PC, removed about 500 gigs of apps, including distros, office, adobe, SQL versions, Ruby, Phython, Visual Studio versions, VSCode you name all gone.  Installed Eclipse for Java and VC, now i finally got VC to work. But now couldnt get the Eclipse preferences to work as they show in the MF videos, well turns out, its quite different in latest version of Eclipse, and doesnt work at all the way described in videos.  Also instead used Eclipse for Enterprise seems a bit more pleasant. So, now the last issue is this COBDATA. Thats where im stuck now, not really for weeks in Eclipse, but have tried to access files now in VC for weeks starting first with Visual Studio, with no luck.

  • Here is a simple command line program and bat file to compile.

    *set assign(external)

    identification division.

    program-id. fileio.

    environment division.

    input-output section.


    select file-out assign to "TEST.DAT".

    select file-in assign to "TEST.DAT"

    file status is file-in-status.

    data division.

    file section.

    fd file-in.

    01 input-record pic x(80).

    fd file-out.

    01 output-record pic x(80).

    working-storage section.

    01 sub1 pic 99 value 0.

    01 file-in-status pic xx value '00'.

    procedure division.

    open output file-out.

    display 'Writing file'.

    perform varying sub1 from 1 by 1

    until sub1 = 11

    move all 'A' to output-record

    display 'Writing record ' sub1

    write output-record


    close file-out.

    open input file-in.

    display 'Reading input file'.

    perform until file-in-status not equal '00'

    read file-in

    if file-in-status = '00'

    display input-record



    close file-in.


    BAT File to Compile and Run


    cbllink -V fileio.cbl -UCOBOL.DIR



    Writes out a file with 10 record, reads it back in displaying them. File will be in current directory.

  • ok so instead of using cobdata i simply entered the full path and file in the file-control paragraph, and now it can find the files, but it stops as soon as it tries to write to the file. well i think the cobdata may not work, again is since im using latest version of eclipse with latest version of VC