Over on the mvs-oe list there was a thread about how
to run a program under the z/OS UNIX shell. I was
never quite clear what the OP was trying to accomplish
so I finally just posted a COBOL program and how to
run it.
I was kinda' proud of the code because I think you'll
find most COBOL programmers today pretty unfamiliar
with a lot of points, so I wanted to post the code here
in the hopes you will pass this on to your COBOL
programmers - if you know any in your shop, just to
show what's possible. Here's the post:
Stephen,
Well, I'm still not clear what you are after, but I
thought it might be helpful in general to post a
sample of running a program under the z/OS UNIX shell.
First, I wrote a basic COBOL program, simply under
ISPF 3.4, as a member in a PDS, then compiled and
bound it into a load module library PDSE).
The source code, member name APP2CO3, prompts the user
for a file name (MVS file or HFS/zFS file), opens the
file and reads and displays the first two lines from
the file; not trivial but not earth shaking.
Here's the code:
process dynam xref(short)
Identification division.
Program-id. app2co3.
* Copyright (c) 2004 by Steven H. Comstock Ver2
* COBOL program to dynamically obtain a file name and
* display the first two lines in the file
Environment division.
Data division.
Working-storage section.
01 File-stuff.
02 in-file pic s9(9) binary value 0.
02 rec-len pic s9(9) binary value 0.
02 norecs pic s9(9) binary value 2.
02 read-mode pic x(15) value z'rb,type=record'.
01 in-data pic x(1000).
01 messages.
02 Entry-message pic x(20)
value 'In app2co3 - Ver2'.
02 pic x(2) value x'1500'.
02 Exit-message pic x(20)
value 'Leaving app2co3'.
02 pic x(2) value x'1500'.
02 msg-open-fail.
03 pic x value x'15'.
03 pic x(52)
value 'Cannot open for reading.'.
03 pic x(2) value x'1500'.
02 msg-open-good.
03 pic x value x'15'.
03 pic x(52)
value 'File opened successfully.'.
03 pic x(2) value x'1500'.
02 Line-1.
03 pic x(27)
value 'Enter the name of the file '.
03 pic x(11)
value 'to display.'.
03 pic x(2) value x'1500'.
02 Line-2.
03 pic x(52)
value 'For HFS files, specify the full path name.'.
03 pic x(2) value x'1500'.
02 Line-3.
03 pic x(52)
value 'For z/OS files, specify the name with 2 '.
03 pic x(2) value x'1500'.
02 Line-4.
03 pic x(52)
value 'leading slashes, a single quote, the fully qualified'.d'
03 pic x(2) value x'1500'.
02 Line-5.
03 pic x(52)
value 'name, then a single closing quote, for example:'.
03 pic x(2) value x'1500'.
02 Line-6.
03 pic x(52)
value ' //''stnt329.train.library(inputcs)'''.
03 pic x(2) value x'1500'.
02 Line-7.
03 pic x value x'15'.
03 pic x(19)
value z'Resulting name: %s'.
02 Bytes-line.
03 pic x(12)
value 'Bytes read ='.
03 no-bytes pic zz9.
03 pic x(2) value x'1500'.
02 Data-line.
03 pic x(9)
value 'Data = %s'.
03 pic x(2) value x'1500'.
01 line-in pic x(120) value spaces.
01 in-pat pic x(5) value z'%s'.
procedure division.
mainline.
call 'printf' using entry-message
call 'printf' using Line-1
call 'printf' using Line-2
call 'printf' using Line-3
call 'printf' using Line-4
call 'printf' using Line-5
call 'printf' using Line-6
move all x'00' to line-in
call 'scanf' using in-pat, line-in
call 'printf' using Line-7, line-in
call 'fopen' using line-in, read-mode returning in-file
if in-file > 0
call 'printf' using msg-open-good
perform read-rec norecs times
call 'fclose' using by value in-file
else
call 'printf' using msg-open-fail
end-if
call 'printf' using exit-message
goback.
read-rec.
move all x'00' to in-data
call 'fread' using in-data, by value 1,
length of in-data, in-file
returning rec-len
if rec-len = 0
continue
else
move rec-len to no-bytes
call 'printf' using Bytes-line
call 'printf' using Data-line, in-data
end-if.
I compiled and bound this as RENT into SCOMSTO.TR.PDSE.
First, I tested under ISPF option 6:
==> call 'scomsto.tr.pdse(app2co3)'
* works like a champ for both MVS data sets and z/OS UNIX
text files
Next to run under the shell.
1. from ISPF 6:
==> omvs convert((bpxfx437)) esc('^')
2. the above puts me in my home; next, to create a fresh
environment, I created a subdirectory under my z/OS UNIX
directory, and used the techniques discussed earlier:
===> mkdir demo
===> cd demo
===> touch app2co3
===> chmod 1755 app2co3
===> export STEPLIB=SCOMSTO.TR.PDSE
===> app2co3
runs like a champ for both MVS data sets and z/OS UNIX
text files.
==========================================================
I hope this has given you some insights into the problem
you were trying to solve. Of course, there's lots more
where that came from, covered in our LE courses, our
current COBOL courses, and our z/OS UNIX courses.
--
Kind regards,
-Steve Comstock
The Trainer's Friend, Inc.
303-393-8716
http://www.trainersfriend.com
* To get a good Return on your Investment, first make an investment!
+ Training your people is an excellent investment
* Try our new tool for calculating your Return On Investment
for training dollars at
http://www.trainersfriend.com/ROI/roi.html
----------------------------------------------------------------------
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