Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

MicroFocus cobol how to set a .cbi file

MicroFocus cobol how to set a .cbi file

MicroFocus cobol how to set a .cbi file


see below, both are valid in fujitsu cobol, problem is in MicroFocus i cannot use Type1. i think F1 is set in a cbi file, im not sure. my question is how/what to set up so that file assignment Type 1 is valid.

Type 1.
Select Infile assign to F1

Type 2.
Select Infile assign to "C:\MFCOBOL\Train\acfy.txt"

RE: MicroFocus cobol how to set a .cbi file

Do you see an error in the compile or at runtime?

When i worked with MicroFocus COBOL on a UNIX system (quite some time ago<g>), F1 was defined as a variable that contained the directory/filename.

We used what you call "type 1" for all of our SELECT/ASSIGNs. I don't remember doing anything special when i installed the compiler. . .   

RE: MicroFocus cobol how to set a .cbi file

If you have not defined F1 anywhere, it is implicitly defined as a 77-level PIC X variable in WORKING STORAGE with no initial value, which normally defaults to SPACES unless you change the default value with the appropriate option.  I don't remember the size of the variable, I think it is 44, but not sure.

RE: MicroFocus cobol how to set a .cbi file

thanks papadba and webrabbit for your replies.

there's no eror at compile time, however i got this at runtime.

I/O error: file "
error code: 9/004 (ANS74), pc=0, call=1,seg=0
4 Illegal file name.


Type 1.
Select Infile assign to F1

F1 is defined in an ini file(below is a part of the .ini), so how to set up ini file in MF like this(the ini file is valid and from fujitsu cobol)


RE: MicroFocus cobol how to set a .cbi file

The value in F1 must be the full or relative path name of the file.  The error message indicates that the value is invalid as a file name, i.e. blank.  The value could also point to an Environment Variable, if it starts with an ampersand (&).  But in any case, blank is invalid.

The contents of the .ini file are ilrelevant to a Micro Focus COBOL program.

You could set up a batch file to assign the file names to environment variables and referance those variables in the inial value for the variable.  

Now that I think about it, that & may not be right.  I will research it and get back to you.

RE: MicroFocus cobol how to set a .cbi file

The & has no meaning.  The COBOL system will automatically search the environment for a variable that matches the value of the ASSIGN TO clause, whether a literal value, enclosed in quotes, or the value of the variable.  In other words, if you say ASSIGN TO "F1", the system will look for an environment variable named "F1".  If it finds such an environment variable, it will use the value of that variable as the full or relative path name of the file.  If it does no find and environment variable named F1, it will use "F1" as the full or relative path name of the file.  The same applies if you say ASSIGN TO F1 and give the variable F1 the value "F1".  You can do this by defining it in the data division and giving it an initial value, or by specifying MOVE "F1" TO F1 at any point prior to opening the file.

RE: MicroFocus cobol how to set a .cbi file


The contents of the .ini file are ilrelevant to a Micro Focus COBOL program.

with that said, im stuck. i don't know how to approach this, beacuse the cobol programs we have run perfectly on Fujitsu, with several .ini files. we're moving (planning to move, hence i'm evaluating MF version) from fujitsu to microfocus. (don't ask me why, i don't have the answer.)

the .ini files used in fujitsu stores variables in the progam. Like the ini file below used by several programs, i.e. [setd0ctl], [Rep0ctl], etc...



RE: MicroFocus cobol how to set a .cbi file

How is this file used in the code?

Rather than concentrate on this .ini file that is not needed by MicroFocus, suggest you experiment without it and if it is not needed, document this as something to be handled during a conversion if it happens.

RE: MicroFocus cobol how to set a .cbi file

The .ini file needs to be replaced with a .bat file that has the file assignments in it, e.g set F1=data\Data1.DAT, and the COBOL programs need to be changed to put quotes arround the assign name, e.g ASSIGN TO "F1".  

The last line of the .bat file needs to invoke the COBOL program by referencing the compiled name, that is, the .exe name.  If the source program is named GEORGE.CBL, the executable is probably named GEORGE.EXE.

The .bat (or .cmd) file cannot be named GEORGE as the command processor would then be confused as to whether to execute GEORGE.BAT (or GEORGE.CMD) as opposed to GEORGE.EXE at the appropriate time.  CMD.EXE may be smarter in this respect than COMMAND.COM.

RE: MicroFocus cobol how to set a .cbi file

Unless each program is being EXECUTED individually, and not from within another COBOL program environment variables will not work on this case.

So please ignore the following if you do not use CALL program to open different files.

My advise to you would be to change all your programs so the files are assigned to a working storage variable, and to populate those variables first time program is called with the correct location based on a configuration file storing the path & filename of each individual file on a per program bases.

small sample configuration file based on your data
setd0ctl F1 data\Data1.DAT
setd0ctl F2 data\Data2.DAT
setd0ctl F3 data\Data3.DAT
setd0ctl F4 data\AQIN.DAT
Rep0ctl  F1 report\Report1.RPT
Rep0ctl  F2 report\Report2.RPT

On each program containing files to be opened, a new small program would be called passing the program name, and this program read the configuration file, and then would return the location of each of the files required for that program. Simple then to move the return values to the required WS variables and open the files as normal.

On my programs I have the above configuration file defined as a Indexed file, with a key of program + file_ID, and with the location variable defined as X(200).
My program is called once per file, but could easily be changed to return all the files used by a program on a array in one go.

For the location of the configuration file above, a environment variable could be used, as this would not change.



Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?
FAQ181-2886: How can I maximize my chances of getting an answer?

RE: MicroFocus cobol how to set a .cbi file

You could also write a small program that could read the .cbi file to do the same thing.  Pass it the name of the .cbi file, then name of the file, e.g. "F1", and a pointer to the variable, in this case, F1.


READCBI would then have


  77  CBI-NAME      PIC X(44).
  77  FILE-NAME     PIC X(08).


RE: MicroFocus cobol how to set a .cbi file

thank you all for your inputs.

i'll take these issues to our next staff meeting. i'll leave this post open.

RE: MicroFocus cobol how to set a .cbi file


try adding the device-name class (i.e. "DISK" or similar) before the file name field ("F1").


Type 1.
Select Infile assign to DISK F1


Code what you mean,
and mean what you code!
But by all means post your code!


RE: MicroFocus cobol how to set a .cbi file

If DISK is followed by a data-name or literal, it has no meaning in Micro Focus COBOL.

RE: MicroFocus cobol how to set a .cbi file

bardagol the company I work for moved from an older version of MF to Fujitsu and was (with a little modification) use the same code for loading files.  We don't use the CBI to set file assignments (except for some report parameters).  We use working storage with the external global settings.

01  ws-file-names  external global.
    05  ws-file-name     pic x(50) occurs 100 times.
01  ws-file-names-r redefines ws-file-names.
    05  f1               pic x(50).
    05  f2               pic x(50).

then a text filecontains the filenames

and a load copy file loads the text file into the filenames.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close