PROCEDURE activate_network, actn (
  status)


*IF $variable(rav$proc_doc,declared)<>'UNKNOWN'

" PURPOSE:
"   This procedure activates the network by activating NAM/VE and executing the network activation
"   prolog and epilog.
"
" NOTES:
"   One of the restrictions placed on NAM/VE activation is that it cannot occur after the activation of
"   RHFAM because of shared buffer problems.
"   Margins have been turned off (set to 0) until all messages can be properly aligned together.  To
"   turn the margins back on replace the 0's with a 2.
*IFEND


*copy rav$margin
*copy rav$system_paths

  "$FORMAT=OFF
  VAR
    ignore_status: status
    local_status: status
    proc_status: status
    rav$event_message: (XDCL) status
  VAREND
  "$FORMAT=ON"


  IF $substring($string($job(sjn)),12,8) <> 'AAA_0000' THEN
    EXIT procedure WITH $status(FALSE, 'NA', nae$insufficient_privilege)
  IFEND

  local_status.normal=true
  proc_status.normal=true

  rap$display_message mm=initiation_messages mn=activating_network m=rav$margin t=$response ..
        status=ignore_status
  rav$margin=rav$margin + 0

  IF NOT $namve_active THEN
    rap$check_rhfam_for_namve status=local_status
    IF NOT local_status.normal THEN
      rap$handle_status si=local_status so=proc_status
    IFEND
  IFEND

  rap$verify_configuration status=local_status
  IF NOT local_status.normal THEN
    rap$handle_status si=local_status so=proc_status
  IFEND

  IF proc_status.normal THEN
    rap$run_initiation_commands icn=network_activation_prolog status=local_status
    IF NOT local_status.normal THEN
      rap$handle_status si=local_status so=proc_status
    IFEND

    rap$activate_namve status=local_status
    IF NOT local_status.normal THEN
      rap$handle_status si=local_status so=proc_status
    IFEND
  IFEND

  IF $namve_active THEN
    rap$run_initiation_commands icn=network_activation_epilog status=local_status
    IF NOT local_status.normal THEN
      rap$handle_status si=local_status so=proc_status
    IFEND
  IFEND

  rav$margin=rav$margin - 0

  IF proc_status.normal THEN
    rap$display_message mm=initiation_messages mn=network_activated m=rav$margin t=$response ..
          status=ignore_status
  ELSE
    EXIT procedure WITH $status(false, 'RA', rae$errors_occurred_warning, 'ACTIVATE_NETWORK')
  IFEND

PROCEND activate_network


