Bentz Absent Member.
Absent Member.
4872 views

Illegal file name

Jump to solution

[Migrated content. Thread originally posted on 04 April 2011]

Hi Folks,

Were trying to delopy for the first time a simple .net managed application to run under the COBOL 2010 runtime.

I believe my issue is that the DD's in COBOL program are not being set. Were using a bat file to execute the program(shown at bottom). We are getting this error on the first OPEN. Is setting a DD even possible under a managed application via a bat file ? Any or coments are welcome.

Thanks
Dave



Unhandled Exception: COBOLFileHandlingException
'' : 9/004 (ANS74)
4 Illegal file name
at Void SP70._MF_PERFORM_SP70_3(MicroFocus.COBOL.Program.RunUnitThread _MF_THR
EAD_ID)
at Int32 SP70.SP70()
at Int32 SP70._MF_ENTRY()



EM SP70 JOB:


set path=C:\Program Files (x86)\Micro Focus\COBOL 2010 Runtime\bin

set TK="E:\MFCFiles\OSMIS_DATA\PTK.I10"

REM Input Files:
set ISP61="E:\JOBS\SP60\PSP61P01.R44s"
set ISP62="E:\JOBS\SP60\PSP62P01.R44s"
set ISP63="E:\JOBS\SP60\PSP63P01.R44s"

REM Output Files:
set sp70r="E:\JOBS\SP70\SP70R.txt"
set out3="E:\JOBS\SP70\OUT3.txt"
set RDI20A="E:\JOBS\SP70\RDI20A.txt"
set RDI20B="E:\JOBS\SP70\RDI20B.txt"
set RDI20c="E:\JOBS\SP70\RDI20c.txt"


E:\MFCFiles\OSMIS_PGMEXE\sp70Prj
0 Likes
1 Solution

Accepted Solutions
Micro Focus Expert
Micro Focus Expert

RE: Illegal file name

Jump to solution
An alternative to hardcoding the EXTERNAL clause in the SELECT statement is to set the compiler directive ASSIGN"EXTERNAL" on. This will tell the compiler to treat all SELECT statements as if the EXTERNAL clause were specified.

As far as using Visual Studio to debug a program that is started by a .bat file you can do a couple of things.
If your .bat file is only used to setup environment variables for file name assignment then you could replace this with an app.config file or with an mfextmap file. If your .bat file is required for more then you can use dynamic debugging or attach to process.

app.config file:

In Solution Explorer right click on your project name and select Add->New Item->Application Configuration File.
This will add the xml file app.config to your project.
Right click on the app.config file in Solution Explorer and select Edit.
This will start a small editor that lets you set environment variables for the application.
For your test program here you would put DC as the name and then the value would be the physical file name.

When you build your solution these environment variables will be linked into your .EXE and can be used in the same manner that you are using environment variables in your .bat file.
However the values will be static and will not be overwritten by settings in your .bat file.
You can then debug your application starting with the .EXE and these environment variables will be set.

mfextmap file.

This is to setup the MF External File Mapper.
Create a text file called mfextmap.dat.
Enter the name of the environment variable that you want to set starting in the first column of a line and then followed by a space and then the physical name of the file you wish to assign.
Example:
DC c:\testit\filename.dat

save this file in your project folder.

Then create a text file called cobconfig.cfg with the following entry:
set environment_mapper=TRUE

save this file in your project folder.

Set the following environment variables in Control Panel or in an app.config file as sepcified above:
MFEXTMAP=C:\projfolder\projfolder (replace with actual location where file is)
COBCONFIG_=C:\projfolder\projfolder\cobconfig.cfg (replace with actual location where file is)

Rebuild solution.

Dynamic debugging.

Add the following statement to your application at the point where you wish the debugger to start.

CALL "CBL_DEBUGBREAK"

Execute your .bat file and when the program starts and hits this statement you will be prompted to run Visual Studio as the debugger.

You can then debug through your application as normal.

If you cannot figure out the new problem that you are having then you should open up a support incident for it as we will most likely need you to send us a sample...

Thanks.
0 Likes
6 Replies
Micro Focus Expert
Micro Focus Expert

RE: Illegal file name

Jump to solution
I just tested this here and it worked fine from either a .bat file or when it is set in the app.config file for the project.

What does your SELECT statement look like for these files?
Are you using the EXTERNAL clause in the SELECT?

Does the file assignment work when running the program in Visual Studio?
0 Likes
OnorioCatenacci Absent Member.
Absent Member.

RE: Illegal file name

Jump to solution
Bentz originally wrote:
EM SP70 JOB:


set path=C:\Program Files (x86)\Micro Focus\COBOL 2010 Runtime\bin


I know Chris tried this and it worked but if I were you I'd try two things (assuming this is your literal bat file):

set PATH="C:\Program Files (x86)\Micro Focus\COBOL 2010 Runtime\bin";%PATH%

I enclosed the directory path in quotes because I've seen a few times that the path will not work correctly with a space in it. And secondly, I appended that directory to the existing path. The way you coded it, it will overwrite the path--instead of appending. You want to append (as opposed to overwriting) because the path is how Windows resolves runtime dll dependencies. I'd try this change and see what happens. Chris may have made that second change without even realizing it; it'd be a simple thing to do without even being aware of it.
0 Likes
Highlighted
Bentz Absent Member.
Absent Member.

RE: Illegal file name

Jump to solution
Thanks Chris

I added the EXTERNAL keyword to the SELECT statement. That worked resovled the DD's.

Chris how can I use the bat script when running within VS ?

Now I have the same error but different cause. Seems to be related to a call to DI20(DLL) and somekind of linkage issue.

Unhandled Exception: COBOLFileHandlingException
'' : 9/004 (ANS74)
4 Illegal file name
at Void DI20._MF_PERFORM_DI20_11(_MF_LCTYPE_1& _MF_LCDATA)
at Void DI20._MF_PERFORM_DI20_1(_MF_LCTYPE_1& _MF_LCDATA)
at Int32 DI20.DI20(MicroFocus.COBOL.Program.Reference DI20-COMAREA)
at Void SP70._MF_PERFORM_SP70_3(MicroFocus.COBOL.Program.RunUnitThread _MF_THR
EAD_ID)
at Int32 SP70.SP70()
at Int32 SP70._MF_ENTRY()
0 Likes
Micro Focus Expert
Micro Focus Expert

RE: Illegal file name

Jump to solution
An alternative to hardcoding the EXTERNAL clause in the SELECT statement is to set the compiler directive ASSIGN"EXTERNAL" on. This will tell the compiler to treat all SELECT statements as if the EXTERNAL clause were specified.

As far as using Visual Studio to debug a program that is started by a .bat file you can do a couple of things.
If your .bat file is only used to setup environment variables for file name assignment then you could replace this with an app.config file or with an mfextmap file. If your .bat file is required for more then you can use dynamic debugging or attach to process.

app.config file:

In Solution Explorer right click on your project name and select Add->New Item->Application Configuration File.
This will add the xml file app.config to your project.
Right click on the app.config file in Solution Explorer and select Edit.
This will start a small editor that lets you set environment variables for the application.
For your test program here you would put DC as the name and then the value would be the physical file name.

When you build your solution these environment variables will be linked into your .EXE and can be used in the same manner that you are using environment variables in your .bat file.
However the values will be static and will not be overwritten by settings in your .bat file.
You can then debug your application starting with the .EXE and these environment variables will be set.

mfextmap file.

This is to setup the MF External File Mapper.
Create a text file called mfextmap.dat.
Enter the name of the environment variable that you want to set starting in the first column of a line and then followed by a space and then the physical name of the file you wish to assign.
Example:
DC c:\testit\filename.dat

save this file in your project folder.

Then create a text file called cobconfig.cfg with the following entry:
set environment_mapper=TRUE

save this file in your project folder.

Set the following environment variables in Control Panel or in an app.config file as sepcified above:
MFEXTMAP=C:\projfolder\projfolder (replace with actual location where file is)
COBCONFIG_=C:\projfolder\projfolder\cobconfig.cfg (replace with actual location where file is)

Rebuild solution.

Dynamic debugging.

Add the following statement to your application at the point where you wish the debugger to start.

CALL "CBL_DEBUGBREAK"

Execute your .bat file and when the program starts and hits this statement you will be prompted to run Visual Studio as the debugger.

You can then debug through your application as normal.

If you cannot figure out the new problem that you are having then you should open up a support incident for it as we will most likely need you to send us a sample...

Thanks.
0 Likes
Bentz Absent Member.
Absent Member.

RE: Illegal file name

Jump to solution
Morning Chris,


Thanks for your update.

I added CALL "CBL_DEBUGBREAK" and the dam application works find. I get the msg box about starting VS. I click YES and the Program start running to normal completeion. VS never comes up.

SP70START.
DISPLAY "*** BEGINNING SP70 ***" UPON SYSOUT.
DISPLAY "*** BEGINNING SP70 ***" UPON CONSOLE.
CALL "CBL_DEBUGBREAK".
0 Likes
Bentz Absent Member.
Absent Member.

RE: Illegal file name

Jump to solution
Chris,

The Application is working now without the debug statement. Not sure what fix the problem could have been recompiling not sure.

You guys can close 2509098.

Thanks You
Dave.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.