Example 1

COBOL Setup

Let's set up a new directory from which we will do our testing with Fileshare:

mkdir read
cd read
cp ../rfspets00.cbl rfspets01.cbl

For the first program, we use a fully qualified filename and include the name of the server to contact. Edit the file rfspets01.cbl and modify the select statement to read as follows (assuming you created the original data file in the /home/test/file_share directory):

FILE-CONTROL.
SELECT pets-file
ASSIGN TO
"$$JSRV01//home/test/file_share/fspets"
ORGANIZATION IS INDEXED
ACCESS IS DYNAMIC
RECORD KEY IS patient-id
FILE STATUS IS pets-file-status.

Now compile and run your program:

cob rfspets01.cbl anim nognt ;
cobrun rfspets01
In the window from which you ran the Fileshare server, you should now see a series of tracing messages.

Micro Focus XDBC Setup

In order to access this file with Micro Focus XDBC, the file description must be added to the system catalog. To add this, from the directory where we originally created the data file, issue the following command:

mfaddfile fspets

Next, instruct Micro Focus XDBC to use Fileshare in the same method as the COBOL program we used in rfspets01. To do this, edit the configuration file located in ${GENESIS_HOME}/mfdbc.cfg and modify the file prefix from:

file_prefix ;/home/test/mf_data;/home/test/sample/mfdbc/mfu_data

to read:

#file_prefix
     ;/home/test/mf_data
     ;/home/test/sample/mfdbc/mfu_data

file_prefix ;/home/test/mf_data
     ;/home/test/sample/mfdbc/mfu_data
     ; $$JSRV01//home/test/file_share

Note that we added the reference to the Fileshare Server to the end of the file_prefix line. This can help improve performance, since the remote network server will be the last item that we check for when attempting to open files.

On the windows environment, the file_prefix might read:

file_prefix ";C:\\test\\mf_data
             ;$$JSRV01\\\\home\\test\\file_share
             ;$$JSRV02\\c:\\testwin\\file_share"

In this example, note that the back slash characters need to be escaped. In the second entry which is intended for a Fileshare server named JSRV01 running on UNIX, note that there are four back slashes after the server name. If only two slashes had been used, fileshare would have based the directory from the location the server was started instead of the root directory. The third entry is for a fileshare server called JSRV02 running on a windows machine. Note that there is only a single escaped backslash between the server name and the drive letter in this case.

Now from within mfsql.sh, issue the command:

SQL (/? for help) ==> select * from fspets; 

In the Fileshare Server window, you should see the tracing information.