PROCEDURE activate_cartridge_library, actcl (
  job_class, jc: name = system
  job_termination_interval, jti: time_increment = 00:02:00
  client_create_timeout, cct: integer = 10
  client_send_timeout, cst: integer = 10
  server_select_timeout, sst: integer = 35
  debug_mode, dm: (HIDDEN) boolean = FALSE
  status)

  VAR
    application_job_name: name
    portmap_job_name: name = $name('PORTMAP'//$mainframe(id))
    selected_jobs: list 0..$max_list of name
    select_status: status
  VAREND

  IF ($job(lu) <> $name($system)) OR ($family <> :$system) THEN
    display_value '--ERROR-- ACTivate_Cartridge_Library must be invoked from the system job.'
    display_value '--ERROR-- ACTivate_Cartridge_Library must be invoked from the system job.' ..
          o=$job_log
    EXIT activate_cartridge_library
  IFEND

  application_job_name = $name('$5744_interface_'//$substring($mainframe(id),9,9))
  manage_jobs
    select_job ..
         login_family=$system login_user=$system name=application_job_name ..
         job_selection_list=selected_jobs status=select_status
    qui
  IF NOT select_status.normal THEN
    EXIT activate_cartridge_library with select_status
  IFEND

  IF $size(selected_jobs)=0 THEN
    manage_jobs
      select_job ..
           login_user=$system login_family=$system name=portmap_job_name job_state=initiated ..
           job_selection_list=selected_jobs
      qui
    IF NOT select_status.normal THEN
      EXIT activate_cartridge_library with select_status
    IFEND

    IF $size(selected_jobs)=0 THEN
        put_line ('  ', ..
          ' --ERROR-- Unable to activate $5744_interface_job: PORTMAP is not active.', ..
          ' Use the ACTIVATE_PORTMAP command to start PORTMAP.') ..
          o=$response

    ELSE
      JOB job_recovery_disposition=terminate ..
          output_disposition=$system.cartridge_system_5744.$5744_interface_job_log.$next ..
          substitution_mark='?' ..
          job_execution_ring=6 ..
          job_class=job_class ..
          job_name=application_job_name

"       tcv$clnt_create_timeout_seconds is a value in seconds for an RPC clntudp_create
"         to wait for a reply before declaring a timeout.
"       tcv$clnt_call_timeout_seconds is a value in seconds for an RPC clnt_call
"         to wait for a reply before declaring a timeout.
"       tcv$debug_mode enables logging of debug messages in $local.$5744_debug_file
"         if it set to TRUE
"       tcv$job_termination_interval allows this job to be terminated from the input queue
"         before it restarts itself after a previous termination.
"       tcv$srv_select_timeout_seconds is a value in seconds for a server to
"         timeout a network file if response from workstation does not arrive.

        VAR
          tcv$clnt_create_timeout_seconds: (job) integer=?$string(client_create_timeout)?
          tcv$clnt_call_timeout_seconds: (job) integer=?$string(client_send_timeout)?
          tcv$debug_mode: (job) boolean=?$string(debug_mode)?
          tcv$job_termination_interval: (job) time_increment=?$string(job_termination_interval)?
          tcv$srv_select_timeout_seconds: (job) integer=?$string(server_select_timeout)?
        VAREND

        VAR
          nfv$socket_status: (job) status
        VAREND

        set_working_catalog $system
        create_command_list_entry $system.cartridge_system_5744.server
        cartridge_library_interface ?$string(job_class)? ?$string(application_job_name)?
      JOBEND
    IFEND

  ELSE
    display_value '--ERROR-- $5744_interface_job is already executing!'
  IFEND
PROCEND activate_cartridge_library
