HP OpenVMS Systems

ask the wizard
Content starts here

Introduction to COBOL Programming?

» close window

The Question is:

 
I am calling system services routines from a COBOL program, specifically
 SYS$SNDJBCW and SYS$GETQUI.  I have declared the appropriate items and return
 values as external constants.  Example:
 
 01 W96_JBC_AUTONOTSTART PIC S9(9) COMP VALUE EXTERNAL JBC$_AUTONOTSTART.
 
and
 
 01  WS_QUI$_DISPLAY_ENTRY PIC S9(4) COMP VALUE EXTERNAL QUI$_DISPLAY_ENTRY.
 
However, at link time all these external symbols remain undefined.  What do I
 need to do to resolve the external symbols?
 
 
 


The Answer is :

 
  Please read the COBOL manual for assistance with this and with other
  similar COBOL programming questions, and please also read the OpenVMS
  Programming Concepts manual for information on OpenVMS programming.
  The former is specific to COBOL programming, while the latter OpenVMS
  documentation targets on OpenVMS programming interfaces and details.
 
  The OpenVMS COBOL programming documentation and the OpenVMS operating
  system documentation contain information and details for accessing
  system services from various languages.  You must read these manuals.
 
  Properly-declared system service calls are resolved automatically during
  the OpenVMS LINK operation.
 
  For general programming information and for pointers to the COBOL
  programming materials, please see:
 
  http://www.openvms.compaq.com/doc/
 
  http://www.openvms.compaq.com/doc/73final/cobol/
    cobum_004.htm#link_sec
 
  http://www.openvms.compaq.com/doc/73final/cobol/
    cobum_040.htm#vms_ssr_sec
 
  http://www.openvms.compaq.com/doc/73final/cobol/
    cobum_041.htm#ret_stat_con_val_sec
 
  COBOL does not provide a mechanism for language-specific include files
  akin to that of Macro32, C, Fortran or other languages, and thus COBOL
  relies on external references and linking with object modules built
  using other languages (such as the Macro32 assembler or the Macro32
  compiler) for access to these and other OpenVMS definitions.
 
  http://www.openvms.compaq.com/doc/73final/cobol/
    cobum_041.htm#inter_ex_sec
 
  The OpenVMS Wizard strongly encourages you to become familar with the
  AskQ website referenced in the OpenVMS FAQ, with the other COBOL-related
  discussions here in the Ask The Wizard area -- including topics (1091),
  (1134), (2228), (3061), (6353), and (8137), and particularly to become
  familiar with the available COBOL and OpenVMS Programming Documentation.
 
 
 
  --  here is SETSYM.COB
 
  identification division.
  program-id. SETSYM.
  environment division.
 
  data division.
  working-storage section.
  01 LOCAL-SYM  pic S9(9) comp value external LIB$K_CLI_LOCAL_SYM.
  01 GLOBAL-SYM pic S9(9) comp value external LIB$K_CLI_GLOBAL_SYM.
  01 COND-VAL   pic S9(9) comp.
  88 COND-NORMAL               value external SS$_NORMAL.
  88 COND-AMBSYMDEF            value external LIB$_AMBSYMDEF.
  procedure division.
  1.      call "LIB$SET_SYMBOL" using
                  by descriptor "XSET*SYM"
                  by descriptor "Test1A"
                  by reference  LOCAL-SYM
                  giving        COND-VAL.
          if      COND-AMBSYMDEF display "Ambiguous"
          else if COND-NORMAL    display "OK"
          else                   display "Not OK".
  2.      call "LIB$SET_SYMBOL" using
                  by descriptor "XSETS"
                  by descriptor "Test1B"
                  by reference  LOCAL-SYM
                  giving        COND-VAL.
          if      COND-AMBSYMDEF display "Ambiguous"
          else if COND-NORMAL    display "OK"
          else                   display "Not OK".
  3.      call "LIB$SET_SYMBOL" using
                  by descriptor "XSETS"
                  by descriptor "Test1C"
                  by reference  GLOBAL-SYM
                  giving        COND-VAL.
          if      COND-AMBSYMDEF display "Ambiguous"
          else if COND-NORMAL    display "OK"
          else                   display "Not OK".
 
  9.      stop run.
 
 
  --  here is HLPDEF.MAR
 
  .TITLE hlpdef
  $HLPDEF GLOBAL  ; case sensitive!
  .END
 
  --  here is SETSYM.COM
 
  $ cobol setsym
  $ macro hlpdef
  $ link  setsym,hlpdef
  $ run   setsym
  $ show symbol xset*
 
  --  here is the output of SETSYM.COM
 
  OK
  Ambiguous
  OK
    XSETS == "Test1C"
    XSET*SYM = "Test1A"
 

answer written or last revised on ( 21-JAN-2003 )

» close window