Skip to main content

Problem:

Sample demonstration which uses:

>> a File Share Server on Windows side,

   This File Share server using a 'Virtual File Handler' thru the use of the FS Server /ap option

   for files having to ne printed on the winfows default printer

>> a File Share client on UNIX or Windows side ( both work ),

   File Share client which writes on the FS server described above to print on the windows default    printer

Resolution:

1) Environnent

On Windows

Net Express ( Test was done with NE 5.0 Websync4 )

On Unix

Server Express 5.0 ( Test was done with SE 5.0 Websync4 )

Acronym used: FS = File Share

2) Launching of the demonstration

Unzip the demonstration on a Working directory

21) Launch File Share Server on windows

Launch FSDB.bat from a Net Express command prompt

22) Launch FS client on Windows

Open the Net Express project

Control that the first line of prttofs.cbl =  $SET constant UNIXorWindows 'xU'    

(A value NOT = to U means Windows OS)

Rebuild the project

set CCITCP2 environment variable so it's equal to the PC name where FS

  server activated or to the IP address where FS server activated

Run debug\\prttofs from a Net Express command prompt

Or just run it within the project

23) Launch FS client on Unix

Open the Net Express project

Control that the first line of prttofs.cbl =  $SET constant UNIXorWindows 'U'

(A value = to U means Unix OS)

ftp prttofs.cbl to Unix

compile it ( cob -ia prttofs.cbl)

set CCITCP2 environment variable so it's equal to the PC name where FS server

activated or to the IP address where FS server activated

launch prttofs ( cobrun prttofs )

You should see that all the files which pathname begin by C:\\FSWD\\FITOPRT_ are printed on the default printer

3) Some more details

FS server uses a database reference in which the /ap parameter of FS server is used

________________________________________

Extract of Net Express DOC:

Virtual File Handler Interface                                                                   

The Fileshare Server can pass I/O requests to a program specified by you, rather than by the     

Micro Focus File Handler, as long as the program that you specify conforms to the call           

interface used by the File Handler.                                                              

                                                                                                

You do not need to change the configuration of the Fileshare Client to use the Virtual File      

Handler Interface.                                                                               

                                                                                                

Fileshare Server                                                                                 

To specify a virtual file handler, use the /ap (application program) option with the /f option in

the database reference file to specify the program to which I/O requests for a particular data   

file are passed by the Fileshare Server.                                                         

                                                                                                

Example:                                                                                         

fs /d dbase.ref /f user1.dat /ap myprog                                                          

This adds entries to the database reference file, dbase.ref which specify that the Fileshare     

Server should pass all I/O requests for the data file user1.dat to the program myprog.           

________________________________________

4)

Launch of FS server = FSDB.BAT

set FSDB=database.ref

set FSSERVERname=FSSERVER

set FSWD=C:\\FSWD

set pfxFitoPrt=FitoPrt_

rd %FSWD% /S /Q

md %FSWD%

FS /D %FSWD%\\%FSDB% /f %FSWD%\\%pfxFitoPrt%* /ap MYMFFH

FS /S %FSSERVERname% /d %FSWD%\\%FSDB%

________________________________________

Test program used on FS client side: prttofs.cbl

The important details here are:

>This program does some I-Os thru File share and others thru classical MF EXTFH

>This program does I-Os thru File Share and some files will be printed on the Windows default printers & others NOT

   (This distinction is done on the base of the File Name used)

   (Files which have a pathname beginning by C:\\FSWD\\FITOPRT_ will be printed, others not)

    (Thinking of FS server side, see FSDB.BAT (above) and see that for files beginning by      

   ( C:\\FSWD\\FITOPRT_, the File Handler MYMFFH is called)

>See that Pathnames of files are created dynamically,

   Adding to this name the Hostname and the PID of the process (to prevent any filenames    conflicts)

>In the demonstration, the file name assigned contains The FS server to reach          (   ie:$$FSSERVER\\C:\\FITOPRT_....)

  -> you don't have to use a FHREDIR file to tell the client what FS server to reach

  Assignation could be of the type C:\\FITOPRT_....

    In which case you would have to set a FHREDIR configuration file (fhre.cfg attached to the     demonstration),

      File containing

/S FSSERVER

or -S FSSERVER

                              /CM CCITCP

or -CM CCITCP

...

       78 FSSERVERname value "$$FSSERVER".

       78 FSWD         value "C:" & SEP & "FSWD".                         *> File Share Working Directory

       78 pfxFitoPrt        value "FitoPrt_".

       78 pfxFitoNotToPrt   value "FiNotToPrt_".

      *____________________

      * Below FSDB.bat = script which builds FS Database reference

      * and launches File Share Server

        *> see WSS datas    FSSERVERname & FSWD & fxFitoPrt

        *>     are equal to environment variables below used in the script FSDB.bat

        *>     Envt Var     FSSERVERname & FSWD & pfxFitoPrt

        *> set FSDB=database.ref

        *> set FSSERVERname=FSSERVER

        *>

        *> set FSWD=C:\\FSWD

        *> set pfxFitoPrt=FitoPrt_

        *>

        *> rd %FSWD% /S /Q

        *> md %FSWD%

        *>

        *> FS /D %FSWD%\\%FSDB% /f %FSWD%\\%pfxFitoPrt%* /ap MYMFFH

        *>                                                       

        *> FS /S %FSSERVERname% /d %FSWD%\\%FSDB%                 

...

________________________________________

The File Handler MYMFFH

Classical File Handler

Just see that after the CLOSE of the file a sample PC_PRINT_FILE is used to print the file of the Windows default printer

After a rename of the file, adding a time suffix, to prevent any File Name conflicts

       LINKAGE SECTION.

      *________________________________________________________

      *--> FILE HANDLER zones

      *

       01  FILE-HANDLER-FUNCTION.

           03  FILLER         pic x value x"fa".

           03  EXTFH-OP-CODE  pic x.

      *________________________________________________________

      *

      *--> Parameter block

       01  parameter-block.

           copy "xfhfcd3".

       01 FileName pic x(256).

      *________________________________________________________

      *________________________________________________________

      *

       procedure division using FILE-HANDLER-FUNCTION

                                PARAMETER-BLOCK .

      *--> Function: Call the external file handler

           if EXTFH-OP-CODE =  FHOP-OPEN-OUTPUT

              set  address of

                   FileName to FCD-FILENAME-ADDRESS

              move FCD-NAME-LENGTH  to savFCD-NAME-LENGTH

              move filename         to savFileName

              set address of filename to null

           end-if

           call MF-FILE-HANDLER

               using file-handler-function parameter-block.

      *--> Sortie a securiser

           if fcd-status-key-1 not = "0"

               display "External file handler error"

               display "status = " fcd-file-status

               display "Error during close"

               display "aborting"

           END-IF.

           IF EXTFH-OP-CODE =  FHOP-CLOSE

              AND fcd-status-key-1 = "0"

               AND fcd-status-key-2 = "0"

                 *> File sent to Windows Default printer with MF PC_PRINT_FILE

                 move savFCD-NAME-LENGTH

                       to cblt-pn-name-length of PRTfilename

                          cblt-pn-name-length of PRTdocument-title

                 move savfilename(1:savFCD-NAME-LENGTH)

                       to cblt-pn-name        of PRTfilename

                          cblt-pn-name        of PRTdocument-title

                 *> Just rename the file to Print adding a 'Time' suffix

                 *> to prevent any name conflict / a Client which would  send more 'PRINTs' in a loop...

                 accept wstime from time

                 move "_"    to cblt-pn-name

                              of PRTfilename(savFCD-NAME-LENGTH:1)

                 move wstime to cblt-pn-name

                              of PRTfilename(savFCD-NAME-LENGTH 1 : 8)

                 call "CBL_RENAME_FILE"

                           using savfilename(1:savFCD-NAME-LENGTH)

                                 cblt-pn-name of PRTfilename

                           returning status-code

      *          display "rename: " status-code " / "

                 add 9 to  cblt-pn-name-length of PRTfilename

                           cblt-pn-name-length of PRTdocument-title

                 move cblt-pn-name        of PRTfilename

                   to cblt-pn-name        of PRTdocument-title

                 CALL "PC_PRINT_FILE" using     PRTfilename

                                                PRTdocument-title

                                      by value  flags

                                      by value  window-handle

                                      returning status-code

                 display "Print:  " status-code " / "

                    cblt-pn-name

                    of PRTfilename(1:cblt-pn-name-length of PRTfilename)

           end-if

           goback.  

________________________________________

5) Regards to the File Handler called by FS server thru the use of the /ap parameter

Another scenario, could be,

On the File Handler order 'OPEN OUTPUT'

I use a MF PC_PRINTER_OPEN

On the File Handler order 'WRITE'

I use a MF PC_PRINTER_WRITE

On the File Handler order 'CLOSE'

I use a MF PC_PRINTER_CLOSE

Not invoking on FS server side, in that context, the MF EXTFH file handler

Which in scenario described in previous steps:

Creates a file on the FS server side (OS Windows)

AND

Sends the entire file to the Windows default printer thru a call to the MF

PC_PRINT_FILE

   

Attachments:

prttoFS.zip

Attachments

Old KB# 2295

#COBOL
#ServerExpress
#netexpress
#RMCOBOL
#AcuCobol