On 3/21/2011 1:21 PM, John McKown wrote:
Interesting code. I don't know that I like using C functions to OPEN and
READ the file in COBOL. It seems to bypass some of the normal COBOL
functionality that COBOL programmers would want.

Huh? What sort of functionality can't be used here?

I'd likely use "environment
variable" facility in the ASSIGN clause as documented:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3LR50/4.2.3.1

Yes, I know about using CEEENV or even 'putenv' to dynamically
allocate data sets. I have versions of this code that just use
'display' and 'accept' and then use either putenv or ceeenv to
set up an environment variable.

But I like this example _because_ it uses C functions and
works with either MVS files or HFS files with a minimum of
fuss in the code and runs equally simply under ISPF and zOS
UNIX.


You could prompt the programmer for the dataset/file name the same way.I
don't know if that is easier than just doing a CALL of BPX1RED. Use LE's
CEEENV routine to set the environment variable (which is equivalent to what
we think of as the DD name):

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/CEEA31B0/2.2.5.34

Actually, you need to use a little different syntax if you
are using COBOL's dynamic allocation, checking if you have
been passed an MVS name or an HFS file name; I find it a bit
cumbersome.

All my work with BPX1RED in COBOL has been with CGIs.



==

I don't know exactly what the OP wanted either. But the question did raise
one in my mind. Suppose that I have a batch program. In TSO, I can run the
program by doing some ALLOCATE commands to allocate my files and then invoke
my program using the CALL command. Without changing the program in any way
(do to dynamic allocation or anything else), how can I run this same program
from a UNIX shell prompt?

Well, you can use the techniques included in the original post to have
the shell look in STEPLIB, so under OMVS (or telnet if you prefer):

===> touch app2co3
===> chmod 1755 app2co3

(you only need to do this once)

then when you run have a shell script that issues tso allocate
commands, exports STEPLIB to include the library where the program
is, then simply run the program by naming it. (You need to ensure
_BPX_SHAREAS is set to YES, also).

For a "pure" COBOL program, I think the above can be done by replacing the
ALLOCATE commands with export commands to define the environment variables
(DD names) with the proper dataset names. If you need something like SYSIN
or SYSPRINT to point to the UNIX shell input / output, I think you could do:

export SYSIN='/dev/fd/0'
export SYSPRINT='/dev/fd/1'

The do your method with the chmod 1755 to a filename in the current
directory which is the same as the program name in the PDS and export the
name of the PDS in STEPLIB.

But this wouldn't work in general, like for HLASM programs.

COBOL programs can interact with the terminal user by:
  * DISPLAY and ACCEPT - under ISPF and the shell

PL/I programs can interact with the terminal user by:
  * PUT and GET - under ISPF and the shell

All LE-enabled programs can interact with the terminal user by:
  * printf and scanf - under ISPF and the shell

All programs, LE-enabled or not, can interact with the terminal
user by:
  * bpx1red and bpx1wrt, using fd0 for stdin and fd1 for stdout,
    but it doesn't work under ISPF

I have examples of these scattered about many courses.


--
John McKown


--

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

Reply via email to