[an error occurred while processing this directive]

HP OpenVMS Systems

ask the wizard
Content starts here

COBOL calling RTL (lib$) services?

» close window

The Question is:

 
Cobol Version: V2.5-961
 
I have a program which show the image name which is executing by the caller
process:
 
SYS(48)type imagen.cob
identification division.
program-id.  imagen.
environment division.
data division.
working-storage section.
77      item_code pic s9(9) comp value external JPI$_IMAGNAME.
77      texto           pic x(31).
procedure division.
inicio.
        call 'lib$getjpi' using by reference item_code
                            omitted
                            omitted
                            omitted
 
How can I use the LIB$GETJPI function to know the image but the other
process.  How can I define the process id field.  I asked to our local
support, which is SONDA Ltda. but they don`t know either.  The manual
doesn4t have examples. I tried using:
        02 proc_id      pic x(08).
But it doesn4t work.      Thanks a lot
 


The Answer is :

 
  The following is an example of calling lib$getjpi from COBOL, showing
  how to acquire the username.  The JPI$_IMAGNAME itemcode operates quite
  similarly to the JPI$_USERNAME itemcode, though the buffer is (must be)
  rather longer.  (The OpenVMS Wizard would recommend the pic buffer for
  the image name be at least 39 characters.  With the extended file name
  support in V7.2 and later, use of a longer buffer is recommended.  To
  trim the filename for display, please see the LIB$TRIM_FILESPEC call.)
 
 
identification division.
program-id.  jpi_username.
environment division.
 
data division.
working-storage section.
01 jpi$_username pic s9(9) comp value external jpi$_username.
01 stat          pic s9(9) comp.
01 username      pic x(12).
 
procedure division.
begin.
 
* Call LIB$GETJPI and pass JPI$_USERNAME as the item code.
* This will cause GETJPI to retrieve the username.  See the
* documentation for LIB$GETJPI and SYS$GETJPI for more
* information.
 
    call 'lib$getjpi' using by reference jpi$_username
                            omitted,
                            omitted,
                            omitted,
                            by descriptor username
          giving stat.
    if stat is failure call 'lib$stop' using by value stat.
 
    display "Username returned by LIB$GETJPI: " username
    stop run.
 

answer written or last revised on ( 14-SEP-1999 )

» close window