McKown, John wrote:
-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[EMAIL PROTECTED] On Behalf Of Steve Comstock
Sent: Friday, February 08, 2008 7:04 AM
To: [email protected]
Subject: Re: Two COBOL questions


[snip]


      call 'putenv' using by value file-ptr returning rc


[snip]


Kind regards,

-Steve Comstock
The Trainer's Friend, Inc.


Easier to use CEEENV than calling the C subroutine putenv(), IMO.

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/CEEA3180/2.2.
5.34

Actually, I went back and tried some code; here's
my results:

1. Using a call to putenv():

select persnnl assign to people.
...
01 file-stuff.
   02 file-ptr pointer.
   02 file-name.
      03 pic x(12) value 'PEOPLE=DSN('.
      03 dsname pic x(60) value spaces.
      03 pic xx value z' '.
   02 rc pic s9(9) binary value 0.
...
linkage section.
01 in-name pic x(55).

procedure division using in-name.
    string in-name delimited by space
        ') SHR ' delimited by size into dsname
    set file-ptr to address of file-name
    call 'putenv' using by value file-ptr returning rc
    if rc = -1
      continue
    else
      display 'Setting environment variable failed'
      stop run
    endif
    open input persnnl

-------------------------

2. Using a call to ceeenv:

select persnnl assign to people.
...
01 file-stuff.
   02 update-req pic s9(9) binary value 5.
   02 six pic s9(9) binary value 6.
   02 file-name pic x(6) value 'PEOPLE'.
   02 val-length pic s9(9) binary value 64.
   02 val-ptr pointer.
   02 env-val
      03 pic x(4) value 'DSN('.
      03 dsname pic x(60) value spaces.
   02 fc pic x(12) value low-values.
...
linkage section.
01 in-name pic x(55).

procedure division using in-name.
    string in-name delimited by space
        ') SHR ' delimited by size into dsname
    set val-ptr to address of env-val
    call 'ceeenv' using update-req, six, file-name,
         val-length, val-ptr, fc
    if fc = low-values
      continue
    else
      display 'Setting environment variable failed'
      stop run
    endif
    open input persnnl

---------

You decide.


Kind regards,

-Steve Comstock
The Trainer's Friend, Inc.

303-393-8716
http://www.trainersfriend.com

  z/OS Application development made easier
    * Our classes include
       + How things work
       + Programming examples with realistic applications
       + Starter / skeleton code
       + Complete working programs
       + Useful utilities and subroutines
       + Tips and techniques

----------------------------------------------------------------------
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