Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MicroFocus cobol how to set a .cbi file 3

Status
Not open for further replies.

bardagol

Programmer
Feb 19, 2010
11
US

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
 
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. . .
 
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.
 
thanks papadba and webrabbit for your replies.

@papadba
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.

NOTE:

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)

@MessOutFile=d022d_err.msg
;@WinCloseMSG=OFF
@CBR_TRAILING_BLANK_RECORD=REMOVE
D1=logs\acrun.dsp
;
[setd0ctl]
@WinCloseMSG=OFF
F1=data\Data1.DAT
F2=data\Data2.DAT
F3=data\Data3.DAT
F4=data\AQIN.DAT
;
 
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.
 
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.
 

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...

[setd0ctl]
@WinCloseMSG=OFF
F1=data\Data1.DAT
F2=data\Data2.DAT
F3=data\Data3.DAT
F4=data\AQIN.DAT

[Rep0ctl]
@WinCloseMSG=OFF
F1=report\Report1.RPT
F2=report\Report2.RPT
:
:
 
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.
 
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.
 
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.



Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
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.

Syntax would be CALL READCBI USING "GEORGE.CBI" "F1" F1

READCBI would then have
Code:
  LINKAGE SECTION.
  77  CBI-NAME      PIC X(44).
  77  FILE-NAME     PIC X(08).
  77  FILE-VARIABLE PIC X(44).
  PROCEDURE DIVISION USING CBI-NAME FILE-NAME FILE-VARIABLE.

 
thank you all for your inputs.

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

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

Code:
Type 1.
Select Infile assign to [b]DISK[/b] F1



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

Razalas
 
If DISK is followed by a data-name or literal, it has no meaning in Micro Focus COBOL.
 
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
\data\data1.dat
\data\data2.dat

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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top