Skip to main content

 I need a solution without a C routine.  I am already using a dll and cannot execute another with this program.  So I need a way from cobol to check to see if a file exists.  This file is not a cobol indexed file it is simple a file on the hard drive I need to look for.  Does anyone have a good suggestion? Tom if you are listing thanks in advance.


#RMCOBOL

 I need a solution without a C routine.  I am already using a dll and cannot execute another with this program.  So I need a way from cobol to check to see if a file exists.  This file is not a cobol indexed file it is simple a file on the hard drive I need to look for.  Does anyone have a good suggestion? Tom if you are listing thanks in advance.


#RMCOBOL
Create a FD that is a universal match for any file: binary sequential, with a record definition of a single character - PIC X.

In the SELECT statement, designate a file status.

Create a USE procedure for the file.

OPEN INPUT the file. If the file does not exist, the USE procedure will be invoked and you will get the appropriate status - 35. See RM/COBOL User Guide page 424. If the file does exist, simply close it.

 I need a solution without a C routine.  I am already using a dll and cannot execute another with this program.  So I need a way from cobol to check to see if a file exists.  This file is not a cobol indexed file it is simple a file on the hard drive I need to look for.  Does anyone have a good suggestion? Tom if you are listing thanks in advance.


#RMCOBOL
I can create a file with a single picture clause? What about the select statement? This particular file is a tiff image something cobol would not know anything about. What would be the best select statement to use? I don't use many binary files with cobol I use them with c# and c . Thanks

 I need a solution without a C routine.  I am already using a dll and cannot execute another with this program.  So I need a way from cobol to check to see if a file exists.  This file is not a cobol indexed file it is simple a file on the hard drive I need to look for.  Does anyone have a good suggestion? Tom if you are listing thanks in advance.


#RMCOBOL
I can create a file with a single picture clause? What about the select statement? This particular file is a tiff image something cobol would not know anything about. What would be the best select statement to use? I don't use many binary files with cobol I use them with c# and c . Thanks

 I need a solution without a C routine.  I am already using a dll and cannot execute another with this program.  So I need a way from cobol to check to see if a file exists.  This file is not a cobol indexed file it is simple a file on the hard drive I need to look for.  Does anyone have a good suggestion? Tom if you are listing thanks in advance.


#RMCOBOL

The following is typed, not tested.  But the general idea is to define a file that has as little structure as possible.  A binary sequential, fixed length.file has no overhead structure, and if you use a record length of one (1), then you can test any type of file without the COBOL file manager making assumptions about file structure.

 

SELECT TEST-FILE ASSIGN pathname
   ORGANIZATION BINARY SEQUENTIAL
   FILE STATUS file-stat.

...

FD  TEST-FILE.
01  TEST-REC PIC X.

...

 

01  FILE-STAT  PIC XX.
...

 

PROCEDURE DIVISION.
DECLARATIVES.
TEST-FIL SECTION USE AFTER STANDARD ERROR PROCEDURE TEST-FILE.
A.   EXIT.
END DECLARATIVES.


...

set up the pathname
OPEN INPUT TEST-FILE.
IF FILE-STAT = "35"
    handle file does not exist here
ELSE
    CLOSE TEST-FILE.
 


 I need a solution without a C routine.  I am already using a dll and cannot execute another with this program.  So I need a way from cobol to check to see if a file exists.  This file is not a cobol indexed file it is simple a file on the hard drive I need to look for.  Does anyone have a good suggestion? Tom if you are listing thanks in advance.


#RMCOBOL
"Hello" from Russell. Here is how I do it (Tom taught me)


SELECT TMPTXFILE ASSIGN TO WK-TMPTXT
ORGANIZATION BINARY SEQUENTIAL
FILE STATUS IS FILE-STATUS.
*
FD TMPTXFILE.
01 TT-RECORD PIC X.
*
01 FILE-STATUS-CODES PIC XX.
88 RECORD-OK VALUE "00".
88 AT-END VALUE "10".
88 DUPLICATE-RECORD VALUE "22".
88 NOT-FOUND VALUE "23".
88 BOUNDARY-VIOLATION VALUE "24".
88 PERMANENT-ERROR VALUE "30".
88 NO-FILE VALUES ARE "35", "05".
88 SECTOR-LOCK VALUE "99".
*
INITIALIZE WK-TMPTXT
MOVE "soap_to_cobol.xsl" TO WK-TMPTXT
OPEN INPUT TMPTXFILE
MOVE FILE-STATUS TO FILE-STATUS-CODES
IF NO-FILE
DISPLAY "System Stylesheet not found"
END-IF.
CLOSE TMPTXFILE.