{
{ BAI$VALIDATE_WRITE_ACCESS
{
{ This code does general validation for all writes.
{ Note that working_storage_length is in the same location in the call_block
{ of all put operations.

  IF (call_block.putn.working_storage_length < 0) OR
        (call_block.putn.working_storage_length >
        UPPERVALUE (amt$working_storage_length)) THEN
    amp$set_file_instance_abnormal (file_identifier, ame$improper_wsl_value,
          call_block.operation, error_text, status);
  ELSEIF caller_id.ring > file_instance^.instance_attributes.static_label.
        ring_attributes.r1 THEN
    amp$set_file_instance_abnormal (file_identifier, ame$ring_validation_error,
          call_block.operation, error_text, status);
  ELSEIF (file_instance^.global_file_information^.positioning_info.record_info.
        current_byte_address < file_instance^.global_file_information^.
        eoi_byte_address) THEN
    IF (file_instance^.instance_attributes.static_label.file_organization =
          amc$sequential) AND NOT (pfc$shorten IN
          file_instance^.instance_attributes.dynamic_label.access_mode) THEN

{ Note: A put_direct on sequential access will shorten a file.

      amp$set_file_instance_abnormal (file_identifier,
            ame$improper_access_attempt, call_block.operation, ' SHORTEN',
            status);
    ELSEIF (file_instance^.instance_attributes.static_label.file_organization =
          amc$byte_addressable) AND NOT ((pfc$modify IN
          file_instance^.instance_attributes.dynamic_label.access_mode) OR
          (pfc$shorten IN file_instance^.instance_attributes.dynamic_label.
          access_mode)) THEN
      amp$set_file_instance_abnormal (file_identifier,
            ame$improper_access_attempt, call_block.operation,
            ' MODIFY OR SHORTEN', status);
    IFEND;
  ELSEIF NOT (pfc$append IN file_instance^.instance_attributes.dynamic_label.
        access_mode) THEN
    amp$set_file_instance_abnormal (file_identifier,
          ame$improper_access_attempt, call_block.operation, ' APPEND',
          status);
  IFEND;

{  end of BAI$VALIDATE_WRITE_ACCESS
{
