PROCEDURE rap$write_order (
  order_catalog, oc: file = $required
  external_vsn, evsn: any of
      key
        all
      keyend
      list of string 1..6
      list of name 1..6
    anyend = $optional
  disk_file, df: file = $optional
  list, l: file = $list
  tape_file, tf: (BY_NAME, HIDDEN) file = $optional
  request_tape_labeling, request_tape_labelling, rtl: (BY_NAME, HIDDEN) boolean = false
  unload_volume, uv: boolean = true
  verify_option, vo: (BY_NAME, HIDDEN) key
      (brief, b)
      (full, f)
      (manufacturing, m)
    keyend = brief
  volume_overflow_allowed, voa: (BY_NAME, HIDDEN) boolean = false
  tape_permit, tp: (BY_NAME, HIDDEN) any of
      key
        public, private, (release_tapes, release), none
      keyend
      name 1..13
    anyend = none
  status)


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

"
" PURPOSE:
"   This procedure writes an order to a list of tapes or to a
"   disk file.
"
" DESIGN:
"   The order is defined by the order data file in the specified order catalog.
"   Either the VSNS or the DISK_FILE parameter must be specified, but not both.
"   The appropriate procedure is called to write the order to disk or tape.
"
" NOTES:
"
*IFEND
"$FORMAT=OFF
  VAR
    ignore_status: status
    local_status: status
    order_data: name = raf$order_data
    packing_list: name = raf$packing_list
  VAREND
"$FORMAT=ON


  IF (NOT $specified(disk_file)) AND (NOT $specified(external_vsn)) THEN
    local_status = $status(false, 'RA', rae$parameter_disk_or_vsn_req)
    EXIT procedure WITH local_status
  ELSEIF $specified(disk_file) AND $specified(external_vsn) THEN
    local_status = $status(false, 'RA', rae$only_one_param_disk_or_vsn)
    EXIT procedure WITH local_status
  ELSEIF $specified(disk_file) AND $specified(tape_file) THEN
    local_status = $status(false, 'RA', rae$tape_file_param_incorrect)
    EXIT procedure WITH local_status
  IFEND

  IF NOT $file(order_catalog//order_data, permanent) THEN
    local_status = $status(false, 'RA', rae$file_missing_from_order_cat, $string(order_catalog//order_data))
    EXIT procedure WITH local_status
  ELSEIF NOT $file(order_catalog//packing_list, permanent) THEN
    local_status = $status(false, 'RA', rae$file_missing_from_order_cat, $string(order_catalog//packing_list))
    EXIT procedure WITH local_status
  IFEND

  PUSH command_list

  delete_command_list_entry :$system.$system.osf$builtin_library status=ignore_status
  create_command_list_entry :$system.$system.osf$builtin_library status=local_status
  EXIT procedure WITH local_status WHEN NOT local_status.normal

  IF $specified(external_vsn) THEN
    IF (NOT $generic_type(external_vsn) = KEY) THEN
      external_vsn = $string(external_vsn)
    IFEND
    rap$write_tape_order oc=order_catalog evsn=external_vsn l=list tf=tape_file vo=verify_option rtl=request_tape_labeling ..
          uv=unload_volume voa=volume_overflow_allowed tape_permit=tape_permit status=local_status

  ELSEIF $specified(disk_file) THEN

    rap$write_disk_order oc=order_catalog df=disk_file l=list vo=verify_option status=local_status

  IFEND

  POP command_list

  EXIT procedure WITH local_status WHEN NOT local_status.normal

PROCEND rap$write_order
