> -----Original Message-----
> From: IBM Mainframe Discussion List
> [mailto:[email protected]] On Behalf Of Jim McAlpine
> Sent: Wednesday, May 20, 2009 8:51 AM
> To: [email protected]
> Subject: checking for the existence of a file in batch REXX
>
> We have a REXX program which is called from COBOL in batch in
> which we need
> to check for the existence of a file. Obviously there is no
> TSO environment
> here so no commands like LISTDS. Is there anyway to acheive
> this without
> the TSO environment.
>
> Jim McAlpine
Jim,
Is is a requirement to test for existance in the REXX program? Would it be
acceptable to test for existance in the COBOL program? Are you aware that it is
possible to set up Enterprise COBOL to do a dynamic allocation for a dataset?
It is not really very difficult and is documented in the current COBOL manuals.
<code type="example" format="cut-down">
FILE-CONTROL.
SELECT CONTROL-CARD ASSIGN TO DSNAME
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS CONTROL-CARD-FILE-STATUS-1.
...
WORKING-STORAGE SECTION.
77 CONTROL-CARD-FILE-STATUS-1 PIC XX.
77 RETURN-DATA PIC X(4).
01 ENV-DATA.
05 FILLER PIC X(11) VALUE 'DSNAME=DSN('.
05 DSN PIC X(110) VALUE IS LOW-VALUES.
01 P POINTER.
01 RC PIC S9(9) BINARY.
01 EOF-SWITCH PIC X VALUE IS LOW-VALUES.
88 EOF VALUE IS HIGH-VALUES.
LINKAGE SECTION.
01 MVS-PARM.
05 MVS-PARM-LENGTH PIC S999 USAGE BINARY.
05 MVS-PARM-VALUE PIC X(120) .
...
MOVE MVS-PARM-VALUE(1:MVS-PARM-LENGTH) TO
DSN(1:MVS-PARM-LENGTH)
MOVE ') SHR' TO DSN(MVS-PARM-LENGTH + 1:5)
MOVE LOW-VALUES TO DSN(MVS-PARM-LENGTH + 6:1)
SET P TO ADDRESS OF ENV-DATA
CALL 'PUTENV' USING BY VALUE P RETURNING RC
IF RC > 0 THEN
DISPLAY 'PUTENV FAILED RC=' RC UPON SYSOUT
MOVE +8 TO RETURN-CODE
STOP RUN
END-IF
OPEN INPUT CONTROL-CARD
IF CONTROL-CARD-FILE-STATUS-1 NOT = 0 THEN
DISPLAY 'CANNOT OPEN FILE RC=' CONTROL-CARD-FILE-STATUS-1
UPON SYSOUT
MOVE +8 TO RETURN-CODE
STOP RUN
END-IF
</code>
The above is some code in which the DSN is passed into the COBOL program via
the PARM=. It could just as easily be read from another file. If the file fails
to OPEN, then it is not available for some reason. It might be "in use" or "not
found" or something else.
ref: http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/igy3pg40/1.8.3
--
John McKown
Systems Engineer IV
IT
Administrative Services Group
HealthMarkets(r)
9151 Boulevard 26 * N. Richland Hills * TX 76010
(817) 255-3225 phone * (817)-961-6183 cell
[email protected] * www.HealthMarkets.com
Confidentiality Notice: This e-mail message may contain confidential or
proprietary information. If you are not the intended recipient, please contact
the sender by reply e-mail and destroy all copies of the original message.
HealthMarkets(r) is the brand name for products underwritten and issued by the
insurance subsidiaries of HealthMarkets, Inc. -The Chesapeake Life Insurance
Company(r), Mid-West National Life Insurance Company of TennesseeSM and The
MEGA Life and Health Insurance Company.SM
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html