Infolinks

Thursday, 21 June 2012

hr_employee_api

set define off

create or replace Package hr_employee_api AUTHID CURRENT_USER as
/* $Header: peempapi.pkh 115.24 2003/10/23 02:41:13 jpthomas ship $ */
--
-- ----------------------------------------------------------------------------
-- |--------------------------< create_employee >-----------------------------|
-- ----------------------------------------------------------------------------
--
-- {Start Of Comments}
--
-- Description:
--   This API creates a new employee, including a default primary assignment
--   and a period of service for the employee.
--

--   Secure user functionality is included in this version of the API. The
--   employee will be visible to secure users in the business group.
--
--   The following parameters are currently unsupported and must have a null
--   value :
--    p_fast_path_employee
--    p_projected_start_date
--
-- Prerequisites
--   If person_type_id is supplied, it must have a corresponding system person
--   type of 'EMP', must be active and be in the same business group as that
--   of the employee being created.
--

-- In Parameters:
--   Name                           Reqd Type     Description
--   p_validate                     No   boolean  If true, the database
--                          remains unchanged. If false
--                          then the employee will be
--                                                created in the database.
--   p_hire_date                    Yes  date     The employee hire date and
--                          thus the effective start
--                          date of the person, primary
--                          assignment and period of
--                          service.
--   p_business_group_id            Yes  number   The employee's business
--                          group.

--   p_last_name                    Yes  varchar2 Employee's last name.
--   p_sex                          Yes  varchar2 Employee sex.
--   p_person_type_id               No   number   Person type id. If this value
--                                                is omitted then the
--                                                person_type_id of the default
--                                                `EMP' system person type in
--                                                the employee's business group
--                                                is used.
--   p_per_comments                 No   varchar2 Comments for person record.
--   p_date_employee_data_verified  No   date     The date on which the
--                          employee data was last
--                          verified.
--   p_date_of_birth                No   date     Date of birth.

--   p_email_address                No   date     Email address.
--   p_employee_number              No   varchar2 Employee number.
--   p_expense_check_send_to_addres No   varchar2 Address to use as mailing
--                          address.
--   p_first_name                   No   varchar2 Employee's first name.
--   p_known_as                     No   varchar2 Alternative name.
--   p_marital_status               No   varchar2 Marital status.
--   p_middle_names                 No   varchar2 Employee's middle name(s).
--   p_nationality                  No   varchar2 Employee's nationality.
--   p_national_identifier          No   varchar2 National identifier.
--   p_previous_last_name           No   varchar2 Previous last name.
--   p_registered_disabled_flag     No   varchar2 Registered disabled flag.
--   p_title                        No   varchar2 Employee's title.

--   p_vendor_id                    No   number   Foreign key to PO_VENDORS.
--   p_work_telephone               No   varchar2 Work telephone.
--   p_attribute_category           No   varchar2 Determines the context of
--                          the descriptive flexfield
--                          in the parameter list.
--   p_attribute1                   No   varchar2 Descriptive flexfield.
--   p_attribute2                   No   varchar2 Descriptive flexfield.
--   p_attribute3                   No   varchar2 Descriptive flexfield.
--   p_attribute4                   No   varchar2 Descriptive flexfield.
--   p_attribute5                   No   varchar2 Descriptive flexfield.
--   p_attribute6                   No   varchar2 Descriptive flexfield.
--   p_attribute7                   No   varchar2 Descriptive flexfield.
--   p_attribute8                   No   varchar2 Descriptive flexfield.

--   p_attribute9                   No   varchar2 Descriptive flexfield.
--   p_attribute10                  No   varchar2 Descriptive flexfield.
--   p_attribute11                  No   varchar2 Descriptive flexfield.
--   p_attribute12                  No   varchar2 Descriptive flexfield.
--   p_attribute13                  No   varchar2 Descriptive flexfield.
--   p_attribute14                  No   varchar2 Descriptive flexfield.
--   p_attribute15                  No   varchar2 Descriptive flexfield.
--   p_attribute16                  No   varchar2 Descriptive flexfield.
--   p_attribute17                  No   varchar2 Descriptive flexfield.
--   p_attribute18                  No   varchar2 Descriptive flexfield.
--   p_attribute19                  No   varchar2 Descriptive flexfield.
--   p_attribute20                  No   varchar2 Descriptive flexfield.
--   p_attribute21                  No   varchar2 Descriptive flexfield.

--   p_attribute22                  No   varchar2 Descriptive flexfield.
--   p_attribute23                  No   varchar2 Descriptive flexfield.
--   p_attribute24                  No   varchar2 Descriptive flexfield.
--   p_attribute25                  No   varchar2 Descriptive flexfield.
--   p_attribute26                  No   varchar2 Descriptive flexfield.
--   p_attribute27                  No   varchar2 Descriptive flexfield.
--   p_attribute28                  No   varchar2 Descriptive flexfield.
--   p_attribute29                  No   varchar2 Descriptive flexfield.
--   p_attribute30                  No   varchar2 Descriptive flexfield.
--   p_per_information_category     No   varchar2 Determines the context of
--                           the developer descriptive
--                          flexfield.
--   p_per_information1             No   varchar2 Developer descriptive

--                          flexfield.
--   p_per_information2             No   varchar2 Developer descriptive
--                          flexfield.
--   p_per_information3             No   varchar2 Developer descriptive
--                          flexfield.
--   p_per_information4             No   varchar2 Developer descriptive
--                          flexfield.
--   p_per_information5             No   varchar2 Developer descriptive
--                          flexfield.
--   p_per_information6             No   varchar2 Developer descriptive
--                          flexfield.
--   p_per_information7             No   varchar2 Developer descriptive
--                          flexfield.

--   p_per_information8             No   varchar2 Developer descriptive
--                          flexfield.
--   p_per_information9             No   varchar2 Developer descriptive
--                          flexfield.
--   p_per_information10            No   varchar2 Developer descriptive
--                          flexfield.
--   p_per_information11            No   varchar2 Developer descriptive
--                          flexfield.
--   p_per_information12            No   varchar2 Developer descriptive
--                          flexfield.
--   p_per_information13            No   varchar2 Developer descriptive
--                          flexfield.
--   p_per_information14            No   varchar2 Developer descriptive

--                          flexfield.
--   p_per_information15            No   varchar2 Developer descriptive
--                          flexfield.
--   p_per_information16            No   varchar2 Developer descriptive
--                          flexfield.
--   p_per_information17            No   varchar2 Developer descriptive
--                          flexfield.
--   p_per_information18            No   varchar2 Developer descriptive
--                          flexfield.
--   p_per_information19            No   varchar2 Developer descriptive
--                          flexfield.
--   p_per_information20            No   varchar2 Developer descriptive
--                          flexfield.

--   p_per_information21            No   varchar2 Developer descriptive
--                                                flexfield
--   p_per_information22            No   varchar2 Developer descriptive
--                                                flexfield
--   p_per_information23            No   varchar2 Developer descriptive
--                                                flexfield
--   p_per_information24            No   varchar2 Developer descriptive
--                                                flexfield
--   p_per_information25            No   varchar2 Developer descriptive
--                                                flexfield
--   p_per_information26            No   varchar2 Developer descriptive
--                                                flexfield
--   p_per_information27            No   varchar2 Developer descriptive

--                                                flexfield
--   p_per_information28            No   varchar2 Developer descriptive
--                                                flexfield
--   p_per_information29            No   varchar2 Developer descriptive
--                                                flexfield
--   p_per_information30            No   varchar2 Developer descriptive
--                                                flexfield
--   p_date_of_death                No   varchar2 Date of death
--   p_background_check_status      No   varchar2 Y/N flag indicates whether
--                                                background check has been
--                                                performed
--   p_background_date_check        No   date     Date background check was
--                                                performed

--   p_blood_type                   No   varchar2 Blood type
--   p_correspondence_language      No   varchar2 Preferred language for
--                                                correspondance
--   p_fast_path_employee           No   varchar2 Currently unsupported
--   p_fte_capacity                 No   number   Full time/part time
--                                                availability for work
--   p_honors                       No   varchar2 Honors or degrees awarded
--   p_internal_location            No   varchar2 Internal location of office
--   p_last_medical_test_by         No   varchar2 Name of physician who
--                                                performed last medical test
--   p_last_medical_test_date       No   date     Date of last medical test
--   p_mailstop                     No   varchar2 Office identifier for
--                                                internal mail

--   p_office_number                No   varchar2 Number of office
--   p_on_military_service          No   varchar2 Y/N flag indicating whether
--                                                person is employed in
--                                                military service
--   p_pre_name_adjunct             No   varchar2 First part of surname such
--                                                as Van or De
--   p_rehire_recommendation        No   varchar2 The employee can be rehired
--                                                or not after termination.
--   p_projected_start_date         No   date     Currently unsupported
--   p_resume_exists                No   varchar2 Y/N flag indicating whether
--                                                resume is on file
--   p_resume_last_updated          No   date     Date resume last updated
--   p_second_passport_exists       No   varchar2 Y/N flag indicaing whether

--                                                person has multiple passports
--   p_student_status               No   varchar2 Full time/part time status
--                                                of student
--   p_work_schedule                No   varchar2 Type of work schedule
--                                                inndicating which days
--                                                person works
--   p_suffix                       No   varchar2 Employee's suffix
--   p_benefit_group_id             No   number   Benefit group id.
--   p_receipt_of_death_cert_date   No   date     Date the death certificate
--                                                is received.
--   p_coord_ben_med_pln_no         No   varchar2 Coordinated benefit medical
--                                                plan number
--   p_coord_ben_no_cvg_flag        No   varchar2 Coordinated benefit no other

--                                                coverage flag
--   p_coord_ben_med_ext_er         No   varchar2 Secondary medical coverage external
--                                                employer
--   p_coord_ben_med_pl_name        No   varchar2 Secondary medical coverage name
--   p_coord_ben_med_insr_crr_name  No   varchar2 Secondary medical coverage insurance
--                                                carrier
--   p_coord_ben_med_insr_crr_ident No   varchar2 Secondary medical coverage insurance
--                                                carrier id
--   p_coord_ben_med_cvg_strt_dt    No   varchar2 Secondary medical coverage effective
--                                                start date
--   p_coord_ben_med_cvg_end_dt     No   varchar2 Secondary medical coverage effective
--                                                end date
--   p_uses_tobacco_flag            No   varchar2 Uses tobacco list of values

--   p_dpdnt_adoption_date          No   date     Dependent's adoption date
--   p_dpdnt_vlntry_svce_flag       No   varchar2 Dependent's voluntary service
--                                                flag
--   p_original_date_of_hire        No   date     Original date of hire
--   p_adjusted_svc_date            No   date     Adjusted service date
--   p_town_of_birth                No   varchar2 Town or city of birth
--   p_region_of_birth              No   varchar2 Geographical region of birth
--   p_country_of_birth             No   varchar2 Country of birth
--   p_global_person_id             No   varchar2 Global ID for the person
--
--
-- Post success:
--   When the person, primary assignment and period of service have been

--   successfully inserted, the following OUT parameters are set:
--
--   Name                           Type     Description
--   p_employee_number              varchar2 If p_validate is false this will
--                                           be set to the employee number of
--                                           the person created. If
--                                           p_validate is true this will be
--                                           set to the same value as passed
--                                           in.
--   p_person_id                    number   If p_validate is false, this
--                         uniquely identifies the person
--                         created. If p_validate is true
--                         this parameter will be null.

--   p_assignment_id                number   If p_validate is false, this
--                         uniquely identifies the primary
--                         assignment created. If
--                         p_validate is true this parameter
--                         will be null.
--   p_per_object_version_number    number   If p_validate is false, this will
--                         be set to the version number of
--                          the person created. If
--                         p_validate is true this parameter
--                         will be set to null.
--   p_asg_object_version_number    number   If p_validate is false, this will
--                         be set to the version number of
--                          the default assignment created.

--                         If p_validate is true this
--                         parameter will be set to null.
--   p_per_effective_start_date     date     If p_validate is false, this will
--                                           be set to the effective start
--                                           date of the person. If
--                                           p_validate is true this will be
--                                           null.
--   p_per_effective_end_date       date     If p_validate is false, this will
--                                           be set to the effective end
--                                           date of the person. If
--                                           p_validate is true this will be
--                                           null.
--   p_full_name                    varchar2 If p_validate is false, this will

--                                           be set to the complete full name
--                                           of the person. If p_validate is
--                                           true this will be null.
--   p_per_comment_id               number   If p_validate is false this will
--                                           be set to the id of the
--                                           corresponding person comment row,
--                                           if any comment text exists. If
--                                           p_validate is true this will be
--                                           null.
--   p_assignment_sequence          number   If p_validate is false this will
--                                           be set to the sequence number of
--                                           the primary assignment. If
--                                           p_validate is true this will be

--                                           null.
--   p_assignment_number            varchar2 If p_validate is false this will
--                                           be set to the assignment number
--                                           of the primary assignment. If
--                                           p_validate is true this will be
--                                           null.
--   p_name_combination_warning     boolean  Set to true if the combination
--                                           of last name, first name and date
--                         of birth already existed prior
--                         to the person being created.
--   p_assign_payroll_warning       boolean  Set to true if the date of birth
--                         has not been set.
--   p_orig_hire_warning            boolean  Set to true if the original date

--                                           of hire is not null and the
--                                           person type is not EMP,EMP_APL,
--                                           EX_EMP or EX_EMP_APL.
--
-- Post Failure:
--   The API does not create the person, primary assignment or period of
--   service and raises an error.
--
-- Access Status:
--   Public.
--
-- {End Of Comments}
--

procedure create_employee
  (p_validate                      in     boolean  default false
  ,p_hire_date                     in     date
  ,p_business_group_id             in     number
  ,p_last_name                     in     varchar2
  ,p_sex                           in     varchar2
  ,p_person_type_id                in     number   default null
  ,p_per_comments                  in     varchar2 default null
  ,p_date_employee_data_verified   in     date     default null
  ,p_date_of_birth                 in     date     default null
  ,p_email_address                 in     varchar2 default null
  ,p_employee_number               in out nocopy varchar2
  ,p_expense_check_send_to_addres  in     varchar2 default null

  ,p_first_name                    in     varchar2 default null
  ,p_known_as                      in     varchar2 default null
  ,p_marital_status                in     varchar2 default null
  ,p_middle_names                  in     varchar2 default null
  ,p_nationality                   in     varchar2 default null
  ,p_national_identifier           in     varchar2 default null
  ,p_previous_last_name            in     varchar2 default null
  ,p_registered_disabled_flag      in     varchar2 default null
  ,p_title                         in     varchar2 default null
  ,p_vendor_id                     in     number   default null
  ,p_work_telephone                in     varchar2 default null
  ,p_attribute_category            in     varchar2 default null
  ,p_attribute1                    in     varchar2 default null

  ,p_attribute2                    in     varchar2 default null
  ,p_attribute3                    in     varchar2 default null
  ,p_attribute4                    in     varchar2 default null
  ,p_attribute5                    in     varchar2 default null
  ,p_attribute6                    in     varchar2 default null
  ,p_attribute7                    in     varchar2 default null
  ,p_attribute8                    in     varchar2 default null
  ,p_attribute9                    in     varchar2 default null
  ,p_attribute10                   in     varchar2 default null
  ,p_attribute11                   in     varchar2 default null
  ,p_attribute12                   in     varchar2 default null
  ,p_attribute13                   in     varchar2 default null
  ,p_attribute14                   in     varchar2 default null

  ,p_attribute15                   in     varchar2 default null
  ,p_attribute16                   in     varchar2 default null
  ,p_attribute17                   in     varchar2 default null
  ,p_attribute18                   in     varchar2 default null
  ,p_attribute19                   in     varchar2 default null
  ,p_attribute20                   in     varchar2 default null
  ,p_attribute21                   in     varchar2 default null
  ,p_attribute22                   in     varchar2 default null
  ,p_attribute23                   in     varchar2 default null
  ,p_attribute24                   in     varchar2 default null
  ,p_attribute25                   in     varchar2 default null
  ,p_attribute26                   in     varchar2 default null
  ,p_attribute27                   in     varchar2 default null

  ,p_attribute28                   in     varchar2 default null
  ,p_attribute29                   in     varchar2 default null
  ,p_attribute30                   in     varchar2 default null
  ,p_per_information_category      in     varchar2 default null
  ,p_per_information1              in     varchar2 default null
  ,p_per_information2              in     varchar2 default null
  ,p_per_information3              in     varchar2 default null
  ,p_per_information4              in     varchar2 default null
  ,p_per_information5              in     varchar2 default null
  ,p_per_information6              in     varchar2 default null
  ,p_per_information7              in     varchar2 default null
  ,p_per_information8              in     varchar2 default null
  ,p_per_information9              in     varchar2 default null

  ,p_per_information10             in     varchar2 default null
  ,p_per_information11             in     varchar2 default null
  ,p_per_information12             in     varchar2 default null
  ,p_per_information13             in     varchar2 default null
  ,p_per_information14             in     varchar2 default null
  ,p_per_information15             in     varchar2 default null
  ,p_per_information16             in     varchar2 default null
  ,p_per_information17             in     varchar2 default null
  ,p_per_information18             in     varchar2 default null
  ,p_per_information19             in     varchar2 default null
  ,p_per_information20             in     varchar2 default null
  ,p_per_information21             in     varchar2 default null
  ,p_per_information22             in     varchar2 default null

  ,p_per_information23             in     varchar2 default null
  ,p_per_information24             in     varchar2 default null
  ,p_per_information25             in     varchar2 default null
  ,p_per_information26             in     varchar2 default null
  ,p_per_information27             in     varchar2 default null
  ,p_per_information28             in     varchar2 default null
  ,p_per_information29             in     varchar2 default null
  ,p_per_information30             in     varchar2 default null
  ,p_date_of_death                 in     date     default null
  ,p_background_check_status       in     varchar2 default null
  ,p_background_date_check         in     date     default null
  ,p_blood_type                    in     varchar2 default null
  ,p_correspondence_language       in     varchar2 default null

  ,p_fast_path_employee            in     varchar2 default null
  ,p_fte_capacity                  in     number   default null
  ,p_honors                        in     varchar2 default null
  ,p_internal_location             in     varchar2 default null
  ,p_last_medical_test_by          in     varchar2 default null
  ,p_last_medical_test_date        in     date     default null
  ,p_mailstop                      in     varchar2 default null
  ,p_office_number                 in     varchar2 default null
  ,p_on_military_service           in     varchar2 default null
  ,p_pre_name_adjunct              in     varchar2 default null
  ,p_rehire_recommendation         in     varchar2 default null  -- Bug3210500
  ,p_projected_start_date          in     date     default null
  ,p_resume_exists                 in     varchar2 default null

  ,p_resume_last_updated           in     date     default null
  ,p_second_passport_exists        in     varchar2 default null
  ,p_student_status                in     varchar2 default null
  ,p_work_schedule                 in     varchar2 default null
  ,p_suffix                        in     varchar2 default null
  ,p_benefit_group_id              in     number   default null
  ,p_receipt_of_death_cert_date    in     date     default null
  ,p_coord_ben_med_pln_no          in     varchar2 default null
  ,p_coord_ben_no_cvg_flag         in     varchar2 default 'N'
  ,p_coord_ben_med_ext_er          in     varchar2 default null
  ,p_coord_ben_med_pl_name         in     varchar2 default null
  ,p_coord_ben_med_insr_crr_name   in     varchar2 default null
  ,p_coord_ben_med_insr_crr_ident  in     varchar2 default null

  ,p_coord_ben_med_cvg_strt_dt     in     date default null
  ,p_coord_ben_med_cvg_end_dt      in     date default null
  ,p_uses_tobacco_flag             in     varchar2 default null
  ,p_dpdnt_adoption_date           in     date     default null
  ,p_dpdnt_vlntry_svce_flag        in     varchar2 default 'N'
  ,p_original_date_of_hire         in     date     default null
  ,p_adjusted_svc_date             in     date     default null
  ,p_town_of_birth                in      varchar2 default null
  ,p_region_of_birth              in      varchar2 default null
  ,p_country_of_birth             in      varchar2 default null
  ,p_global_person_id             in      varchar2 default null
  ,p_party_id                     in      number default null
  ,p_person_id                        out nocopy number

  ,p_assignment_id                    out nocopy number
  ,p_per_object_version_number        out nocopy number
  ,p_asg_object_version_number        out nocopy number
  ,p_per_effective_start_date         out nocopy date
  ,p_per_effective_end_date           out nocopy date
  ,p_full_name                        out nocopy varchar2
  ,p_per_comment_id                   out nocopy number
  ,p_assignment_sequence              out nocopy number
  ,p_assignment_number                out nocopy varchar2
  ,p_name_combination_warning         out nocopy boolean
  ,p_assign_payroll_warning           out nocopy boolean
  ,p_orig_hire_warning                out nocopy boolean
  );

-- ----------------------------------------------------------------------------
--
-- Begin fix for bug 899720
--
-- ----------------------------------------------------------------------------
-- |--------------------------< create_employee >-----------------------------|
-- ----------------------------------------------------------------------------
--
-- {Start Of Comments}
--
-- Description:
--   This procedure is an overload version of the above procedure
--   create_employee without the parameter 'p_orig_hire_warning'.

--   Therefore the user documentation is the same.
--
-- {End Of Comments}
--
procedure create_employee
  (p_validate                      in     boolean  default false
  ,p_hire_date                     in     date
  ,p_business_group_id             in     number
  ,p_last_name                     in     varchar2
  ,p_sex                           in     varchar2
  ,p_person_type_id                in     number   default null
  ,p_per_comments                  in     varchar2 default null
  ,p_date_employee_data_verified   in     date     default null

  ,p_date_of_birth                 in     date     default null
  ,p_email_address                 in     varchar2 default null
  ,p_employee_number               in out nocopy varchar2
  ,p_expense_check_send_to_addres  in     varchar2 default null
  ,p_first_name                    in     varchar2 default null
  ,p_known_as                      in     varchar2 default null
  ,p_marital_status                in     varchar2 default null
  ,p_middle_names                  in     varchar2 default null
  ,p_nationality                   in     varchar2 default null
  ,p_national_identifier           in     varchar2 default null
  ,p_previous_last_name            in     varchar2 default null
  ,p_registered_disabled_flag      in     varchar2 default null
  ,p_title                         in     varchar2 default null

  ,p_vendor_id                     in     number   default null
  ,p_work_telephone                in     varchar2 default null
  ,p_attribute_category            in     varchar2 default null
  ,p_attribute1                    in     varchar2 default null
  ,p_attribute2                    in     varchar2 default null
  ,p_attribute3                    in     varchar2 default null
  ,p_attribute4                    in     varchar2 default null
  ,p_attribute5                    in     varchar2 default null
  ,p_attribute6                    in     varchar2 default null
  ,p_attribute7                    in     varchar2 default null
  ,p_attribute8                    in     varchar2 default null
  ,p_attribute9                    in     varchar2 default null
  ,p_attribute10                   in     varchar2 default null

  ,p_attribute11                   in     varchar2 default null
  ,p_attribute12                   in     varchar2 default null
  ,p_attribute13                   in     varchar2 default null
  ,p_attribute14                   in     varchar2 default null
  ,p_attribute15                   in     varchar2 default null
  ,p_attribute16                   in     varchar2 default null
  ,p_attribute17                   in     varchar2 default null
  ,p_attribute18                   in     varchar2 default null
  ,p_attribute19                   in     varchar2 default null
  ,p_attribute20                   in     varchar2 default null
  ,p_attribute21                   in     varchar2 default null
  ,p_attribute22                   in     varchar2 default null
  ,p_attribute23                   in     varchar2 default null

  ,p_attribute24                   in     varchar2 default null
  ,p_attribute25                   in     varchar2 default null
  ,p_attribute26                   in     varchar2 default null
  ,p_attribute27                   in     varchar2 default null
  ,p_attribute28                   in     varchar2 default null
  ,p_attribute29                   in     varchar2 default null
  ,p_attribute30                   in     varchar2 default null
  ,p_per_information_category      in     varchar2 default null
  ,p_per_information1              in     varchar2 default null
  ,p_per_information2              in     varchar2 default null
  ,p_per_information3              in     varchar2 default null
  ,p_per_information4              in     varchar2 default null
  ,p_per_information5              in     varchar2 default null

  ,p_per_information6              in     varchar2 default null
  ,p_per_information7              in     varchar2 default null
  ,p_per_information8              in     varchar2 default null
  ,p_per_information9              in     varchar2 default null
  ,p_per_information10             in     varchar2 default null
  ,p_per_information11             in     varchar2 default null
  ,p_per_information12             in     varchar2 default null
  ,p_per_information13             in     varchar2 default null
  ,p_per_information14             in     varchar2 default null
  ,p_per_information15             in     varchar2 default null
  ,p_per_information16             in     varchar2 default null
  ,p_per_information17             in     varchar2 default null
  ,p_per_information18             in     varchar2 default null

  ,p_per_information19             in     varchar2 default null
  ,p_per_information20             in     varchar2 default null
  ,p_per_information21             in     varchar2 default null
  ,p_per_information22             in     varchar2 default null
  ,p_per_information23             in     varchar2 default null
  ,p_per_information24             in     varchar2 default null
  ,p_per_information25             in     varchar2 default null
  ,p_per_information26             in     varchar2 default null
  ,p_per_information27             in     varchar2 default null
  ,p_per_information28             in     varchar2 default null
  ,p_per_information29             in     varchar2 default null
  ,p_per_information30             in     varchar2 default null
  ,p_date_of_death                 in     date     default null

  ,p_background_check_status       in     varchar2 default null
  ,p_background_date_check         in     date     default null
  ,p_blood_type                    in     varchar2 default null
  ,p_correspondence_language       in     varchar2 default null
  ,p_fast_path_employee            in     varchar2 default null
  ,p_fte_capacity                  in     number   default null
  ,p_honors                        in     varchar2 default null
  ,p_internal_location             in     varchar2 default null
  ,p_last_medical_test_by          in     varchar2 default null
  ,p_last_medical_test_date        in     date     default null
  ,p_mailstop                      in     varchar2 default null
  ,p_office_number                 in     varchar2 default null
  ,p_on_military_service           in     varchar2 default null

  ,p_pre_name_adjunct              in     varchar2 default null
  ,p_rehire_recommendation         in     varchar2 default null  -- Bug3210500
  ,p_projected_start_date          in     date     default null
  ,p_resume_exists                 in     varchar2 default null
  ,p_resume_last_updated           in     date     default null
  ,p_second_passport_exists        in     varchar2 default null
  ,p_student_status                in     varchar2 default null
  ,p_work_schedule                 in     varchar2 default null
  ,p_suffix                        in     varchar2 default null
  ,p_benefit_group_id              in     number   default null
  ,p_receipt_of_death_cert_date    in     date     default null
  ,p_coord_ben_med_pln_no          in     varchar2 default null
  ,p_coord_ben_no_cvg_flag         in     varchar2 default 'N'

  ,p_coord_ben_med_ext_er          in     varchar2 default null
  ,p_coord_ben_med_pl_name         in     varchar2 default null
  ,p_coord_ben_med_insr_crr_name   in     varchar2 default null
  ,p_coord_ben_med_insr_crr_ident  in     varchar2 default null
  ,p_coord_ben_med_cvg_strt_dt     in     date default null
  ,p_coord_ben_med_cvg_end_dt      in     date default null
  ,p_uses_tobacco_flag             in     varchar2 default null
  ,p_dpdnt_adoption_date           in     date     default null
  ,p_dpdnt_vlntry_svce_flag        in     varchar2 default 'N'
  ,p_original_date_of_hire         in     date     default null
  ,p_adjusted_svc_date             in     date     default null
  ,p_town_of_birth                in      varchar2 default null
  ,p_region_of_birth              in      varchar2 default null

  ,p_country_of_birth             in      varchar2 default null
  ,p_global_person_id             in      varchar2 default null
  ,p_party_id                     in      number default null
  ,p_person_id                        out nocopy number
  ,p_assignment_id                    out nocopy number
  ,p_per_object_version_number        out nocopy number
  ,p_asg_object_version_number        out nocopy number
  ,p_per_effective_start_date         out nocopy date
  ,p_per_effective_end_date           out nocopy date
  ,p_full_name                        out nocopy varchar2
  ,p_per_comment_id                   out nocopy number
  ,p_assignment_sequence              out nocopy number
  ,p_assignment_number                out nocopy varchar2

  ,p_name_combination_warning         out nocopy boolean
  ,p_assign_payroll_warning           out nocopy boolean
  );
--
-- End of fix for bug 899720
--
-- ----------------------------------------------------------------------------
-- |-------------------------< create_gb_employee >---------------------------|
-- ----------------------------------------------------------------------------
--
-- {Start Of Comments}
--
-- Description:

--   This API creates a new GB employee, including a default primary
--   assignment and a period of service for the employee.
--   The API calls the generic API create_employee, with the parameters set
--   as appropriate for a GB employee.
--
--   Secure user functionality is included in this version of the API. The
--   employee will be visible to secure users in the business group.
--
--   As this API is effectively an alternative to the API create_employee,
--   see that API for further explanation.
--
-- Prerequisites:
--   See API create_employee.

--
-- In Parameters:
--   Name                           Reqd Type     Description
--   p_validate                     No   boolean  If true, the database
--                          remains unchanged. If false
--                          then the employee will be
--                                                created in the database.
--   p_hire_date                    Yes  date     The employee hire date and
--                          thus the effective start
--                          date of the person, primary
--                          assignment and period of
--                          service.
--   p_business_group_id            Yes  number   The employee's business

--                          group.
--   p_last_name                    Yes  varchar2 Employee's last name.
--   p_sex                          Yes  varchar2 Employee sex.
--   p_person_type_id               No   number   Person type id. If this value
--                                                is omitted then the
--                                                person_type_id of the active
--                                                default `EMP' system person
--                                                type in the employee's
--                                                business group is used.
--   p_comments                     No   varchar2 Comments for person record.
--   p_date_employee_data_verified  No   date     The date on which the
--                          employee data was last
--                          verified.

--   p_date_of_birth                No   date     Date of birth.
--   p_email_address                No   date     Email address.
--   p_employee_number              No   varchar2 Employee number.
--   p_expense_check_send_to_addres No   varchar2 Address to use as mailing
--                          address.
--   p_first_name                   No   varchar2 Employee's first name.
--   p_known_as                     No   varchar2 Alternative name.
--   p_marital_status               No   varchar2 Marital status.
--   p_middle_names                 No   varchar2 Employee's middle name(s).
--   p_nationality                  No   varchar2 Employee's nationality.
--   p_ni_number                    No   varchar2 N.I. Number.
--   p_previous_last_name           No   varchar2 Previous last name.
--   p_registered_disabled_flag     No   varchar2 Registered disabled flag.

--   p_title                        No   varchar2 Employee's title.
--   p_vendor_id                    No   number   Foreign key to PO_VENDORS.
--   p_work_telephone               No   varchar2 Work telephone.
--   p_attribute_category           No   varchar2 Determines the context of
--                          the descriptive flexfield
--                          in the parameter list.
--   p_attribute1                   No   varchar2 Descriptive flexfield.
--   p_attribute2                   No   varchar2 Descriptive flexfield.
--   p_attribute3                   No   varchar2 Descriptive flexfield.
--   p_attribute4                   No   varchar2 Descriptive flexfield.
--   p_attribute5                   No   varchar2 Descriptive flexfield.
--   p_attribute6                   No   varchar2 Descriptive flexfield.
--   p_attribute7                   No   varchar2 Descriptive flexfield.

--   p_attribute8                   No   varchar2 Descriptive flexfield.
--   p_attribute9                   No   varchar2 Descriptive flexfield.
--   p_attribute10                  No   varchar2 Descriptive flexfield.
--   p_attribute11                  No   varchar2 Descriptive flexfield.
--   p_attribute12                  No   varchar2 Descriptive flexfield.
--   p_attribute13                  No   varchar2 Descriptive flexfield.
--   p_attribute14                  No   varchar2 Descriptive flexfield.
--   p_attribute15                  No   varchar2 Descriptive flexfield.
--   p_attribute16                  No   varchar2 Descriptive flexfield.
--   p_attribute17                  No   varchar2 Descriptive flexfield.
--   p_attribute18                  No   varchar2 Descriptive flexfield.
--   p_attribute19                  No   varchar2 Descriptive flexfield.
--   p_attribute20                  No   varchar2 Descriptive flexfield.

--   p_attribute21                  No   varchar2 Descriptive flexfield.
--   p_attribute22                  No   varchar2 Descriptive flexfield.
--   p_attribute23                  No   varchar2 Descriptive flexfield.
--   p_attribute24                  No   varchar2 Descriptive flexfield.
--   p_attribute25                  No   varchar2 Descriptive flexfield.
--   p_attribute26                  No   varchar2 Descriptive flexfield.
--   p_attribute27                  No   varchar2 Descriptive flexfield.
--   p_attribute28                  No   varchar2 Descriptive flexfield.
--   p_attribute29                  No   varchar2 Descriptive flexfield.
--   p_attribute30                  No   varchar2 Descriptive flexfield.
--   p_ethnic_origin                No   varchar2 Employee's ethnic origin.
--   p_director                     No   varchar2 Director flag. Defaulted
--                                                to 'N'.

--   p_pensioner                    No   varchar2 Pensioner flag. Defaulted
--                                                to 'N'.
--   p_permit_work_number           No   varchar2 Permit work number.
--   p_addl_pension_years           No   varchar2 Additional Pension years
--   p_addl_pension_months          No   varchar2 Additional Pension months
--   p_addl_pension_days            No   varchar2 Additional Pension days
--   p_ni_multiple_asg              No   varchar2 NI multiple Assigments.
--                                                Defaulted to 'N'.
--   p_date_of_death                No   varchar2 Date of death
--   p_background_check_status      No   varchar2 Y/N flag indicates whether
--                                                background check has been
--                                                performed
--   p_background_date_check        No   date     Date background check was

--                                                performed
--   p_blood_type                   No   varchar2 Blood type
--   p_correspondence_language      No   varchar2 Preferred language for
--                                                correspondance
--   p_fast_path_employee           No   varchar2 Currently unsupported
--   p_fte_capacity                 No   number   Full time/part time
--                                                availability for work
--   p_honors                       No   varchar2 Honors or degrees awarded
--   p_internal_location            No   varchar2 Internal location of office
--   p_last_medical_test_by         No   varchar2 Name of physician who
--                                                performed last medical test
--   p_last_medical_test_date       No   date     Date of last medical test
--   p_mailstop                     No   varchar2 Office identifier for

--                                                internal mail
--   p_office_number                No   varchar2 Number of office
--   p_on_military_service          No   varchar2 Y/N flag indicating whether
--                                                person is employed in
--                                                military service
--   p_pre_name_adjunct             No   varchar2 First part of surname such
--                                                as Van or De
--   p_projected_start_date         No   date     Currently unsupported
--   p_resume_exists                No   varchar2 Y/N flag indicating whether
--                                                resume is on file
--   p_resume_last_updated          No   date     Date resume last updated
--   p_second_passport_exists       No   varchar2 Y/N flag indicaing whether
--                                                person has multiple passports

--   p_student_status               No   varchar2 Full time/part time status
--                                                of student
--   p_work_schedule                No   varchar2 Type of work schedule
--                                                inndicating which days
--                                                person works
--   p_suffix                       No   varchar2 Employee's suffix
--   p_benefit_group_id             No   number   Benefit group id.
--   p_receipt_of_death_cert_date   No   date     Date the death certificate
--                                                is received.
--   p_coord_ben_med_pln_no         No   varchar2 Coordinated benefit medical
--                                                plan number
--   p_coord_ben_no_cvg_flag        No   varchar2 Coordinated benefit no other
--                                                coverage flag

--   p_coord_ben_med_ext_er         No   varchar2 Secondary medical coverage external
--                                                employer
--   p_coord_ben_med_pl_name        No   varchar2 Secondary medical coverage name
--   p_coord_ben_med_insr_crr_name  No   varchar2 Secondary medical coverage insurance
--                                                carrier
--   p_coord_ben_med_insr_crr_ident No   varchar2 Secondary medical coverage insurance
--                                                carrier id
--   p_coord_ben_med_cvg_strt_dt    No   varchar2 Secondary medical coverage effective
--                                                start date
--   p_coord_ben_med_cvg_end_dt     No   varchar2 Secondary medical coverage effective
--                                                end date
--   p_uses_tobacco_flag            No   varchar2 Uses tobacco list of values
--   p_dpdnt_adoption_date          No   date     Dependent's adoption date

--   p_dpdnt_vlntry_svce_flag       No   varchar2 Dependent's voluntary service
--                                                flag
--   p_original_date_of_hire        No   date     Original date of hire
--   p_adjusted_svc_date            No   date     Adjusted service date
--   p_town_of_birth                No   varchar2 Town or city of birth
--   p_region_of_birth              No   varchar2 Geographical region of birth
--   p_country_of_birth             No   varchar2 Country of birth
--   p_global_person_id             No   varchar2 Global ID for the person
--
-- Post success:
--   When the person, primary assignment and period of service have been
--   successfully inserted, the following OUT parameters are set:
--

--   Name                           Type     Description
--   p_employee_number              varchar2 If p_validate is false this will
--                                           be set to the employee number of
--                                           the person created. If
--                                           p_validate is true this will be
--                                           set to the same value as passed
--                                           in.
--   p_person_id                    number   If p_validate is false, this
--                         uniquely identifies the person
--                         created. If p_validate is true
--                         this parameter will be null.
--   p_assignment_id                number   If p_validate is false, this
--                         uniquely identifies the primary

--                         assignment created. If
--                         p_validate is true this parameter
--                         will be null.
--   p_per_object_version_number    number   If p_validate is false, this will
--                         be set to the version number of
--                          the person created. If
--                         p_validate is true this parameter
--                         will be set to null.
--   p_asg_object_version_number    number   If p_validate is false, this will
--                         be set to the version number of
--                          the primary assignment created.
--                         If p_validate is true this
--                         parameter will be set to null.

--   p_per_effective_start_date     date     If p_validate is false, this will
--                                           be set to the effective start
--                                           date of the person. If
--                                           p_validate is true this will be
--                                           null.
--   p_per_effective_end_date       date     If p_validate is false, this will
--                                           be set to the effective end
--                                           date of the person. If
--                                           p_validate is true this will be
--                                           null.
--   p_full_name                    varchar2 If p_validate is false, this will
--                                           be set to the complete full name
--                                           of the person. If p_validate is

--                                           true this will be null.
--   p_per_comment_id               number   If p_validate is false this will
--                                           be set to the id of the
--                                           corresponding person comment row,
--                                           if any comment text exists. If
--                                           p_validate is true this will be
--                                           null.
--   p_assignment_sequence          number   If p_validate is false this will
--                                           be set to the sequence number of
--                                           the primary assignment. If
--                                           p_validate is true this will be
--                                           null.
--   p_assignment_number            varchar2 If p_validate is false this will

--                                           be set to the assignment number
--                                           of the primary assignment. If
--                                           p_validate is true this will be
--                                           null.
--   p_name_combination_warning     boolean  Set to true if the combination
--                                           of last name, first name and date
--                         of birth already existed prior
--                         to the person being created.
--   p_assign_payroll_warning       boolean  Set to true if the date of birth
--                         has not been set.
--   p_orig_hire_warning            boolean  Set to true if the original date
--                                           of hire is not null and the
--                                           person type is not EMP,EMP_APL,

--                                           EX_EMP or EX_EMP_APL.
--
-- Post Failure:
--   The API does not create the employee, default assignment or period of
--   service and raises an error.
--
-- Access Status:
--   Public.
--
-- {End Of Comments}
--
procedure create_gb_employee
  (p_validate                      in     boolean  default false

  ,p_hire_date                     in     date
  ,p_business_group_id             in     number
  ,p_last_name                     in     varchar2
  ,p_sex                           in     varchar2
  ,p_person_type_id                in     number   default null
  ,p_comments                      in     varchar2 default null
  ,p_date_employee_data_verified   in     date     default null
  ,p_date_of_birth                 in     date     default null
  ,p_email_address                 in     varchar2 default null
  ,p_employee_number               in out nocopy varchar2
  ,p_expense_check_send_to_addres  in     varchar2 default null
  ,p_first_name                    in     varchar2 default null
  ,p_known_as                      in     varchar2 default null

  ,p_marital_status                in     varchar2 default null
  ,p_middle_names                  in     varchar2 default null
  ,p_nationality                   in     varchar2 default null
  ,p_ni_number                     in     varchar2 default null
  ,p_previous_last_name            in     varchar2 default null
  ,p_registered_disabled_flag      in     varchar2 default null
  ,p_title                         in     varchar2 default null
  ,p_vendor_id                     in     number   default null
  ,p_work_telephone                in     varchar2 default null
  ,p_attribute_category            in     varchar2 default null
  ,p_attribute1                    in     varchar2 default null
  ,p_attribute2                    in     varchar2 default null
  ,p_attribute3                    in     varchar2 default null

  ,p_attribute4                    in     varchar2 default null
  ,p_attribute5                    in     varchar2 default null
  ,p_attribute6                    in     varchar2 default null
  ,p_attribute7                    in     varchar2 default null
  ,p_attribute8                    in     varchar2 default null
  ,p_attribute9                    in     varchar2 default null
  ,p_attribute10                   in     varchar2 default null
  ,p_attribute11                   in     varchar2 default null
  ,p_attribute12                   in     varchar2 default null
  ,p_attribute13                   in     varchar2 default null
  ,p_attribute14                   in     varchar2 default null
  ,p_attribute15                   in     varchar2 default null
  ,p_attribute16                   in     varchar2 default null

  ,p_attribute17                   in     varchar2 default null
  ,p_attribute18                   in     varchar2 default null
  ,p_attribute19                   in     varchar2 default null
  ,p_attribute20                   in     varchar2 default null
  ,p_attribute21                   in     varchar2 default null
  ,p_attribute22                   in     varchar2 default null
  ,p_attribute23                   in     varchar2 default null
  ,p_attribute24                   in     varchar2 default null
  ,p_attribute25                   in     varchar2 default null
  ,p_attribute26                   in     varchar2 default null
  ,p_attribute27                   in     varchar2 default null
  ,p_attribute28                   in     varchar2 default null
  ,p_attribute29                   in     varchar2 default null

  ,p_attribute30                   in     varchar2 default null
  ,p_ethnic_origin                 in     varchar2 default null
  ,p_director                      in     varchar2 default 'N'
  ,p_pensioner                     in     varchar2 default 'N'
  ,p_work_permit_number            in     varchar2 default null
  ,p_addl_pension_years            in     varchar2 default null
  ,p_addl_pension_months           in     varchar2 default null
  ,p_addl_pension_days             in     varchar2 default null
  ,p_ni_multiple_asg               in     varchar2 default 'N'
  ,p_date_of_death                 in     date     default null
  ,p_background_check_status       in     varchar2 default null
  ,p_background_date_check         in     date     default null
  ,p_blood_type                    in     varchar2 default null

  ,p_correspondence_language       in     varchar2 default null
  ,p_fast_path_employee            in     varchar2 default null
  ,p_fte_capacity                  in     number   default null
  ,p_honors                        in     varchar2 default null
  ,p_internal_location             in     varchar2 default null
  ,p_last_medical_test_by          in     varchar2 default null
  ,p_last_medical_test_date        in     date     default null
  ,p_mailstop                      in     varchar2 default null
  ,p_office_number                 in     varchar2 default null
  ,p_on_military_service           in     varchar2 default null
  ,p_pre_name_adjunct              in     varchar2 default null
  ,p_rehire_recommendation         in     varchar2 default null  -- Bug3210500
  ,p_projected_start_date          in     date     default null

  ,p_resume_exists                 in     varchar2 default null
  ,p_resume_last_updated           in     date     default null
  ,p_second_passport_exists        in     varchar2 default null
  ,p_student_status                in     varchar2 default null
  ,p_work_schedule                 in     varchar2 default null
  ,p_suffix                        in     varchar2 default null
  ,p_benefit_group_id              in     number   default null
  ,p_receipt_of_death_cert_date    in     date     default null
  ,p_coord_ben_med_pln_no          in     varchar2 default null
  ,p_coord_ben_no_cvg_flag         in     varchar2 default 'N'
  ,p_coord_ben_med_ext_er          in     varchar2 default null
  ,p_coord_ben_med_pl_name         in     varchar2 default null
  ,p_coord_ben_med_insr_crr_name   in     varchar2 default null

  ,p_coord_ben_med_insr_crr_ident  in     varchar2 default null
  ,p_coord_ben_med_cvg_strt_dt     in     date default null
  ,p_coord_ben_med_cvg_end_dt      in     date default null
  ,p_uses_tobacco_flag             in     varchar2 default null
  ,p_dpdnt_adoption_date           in     date     default null
  ,p_dpdnt_vlntry_svce_flag        in     varchar2 default 'N'
  ,p_original_date_of_hire         in     date     default null
  ,p_adjusted_svc_date             in     date     default null
  ,p_town_of_birth                 in     varchar2 default null
  ,p_region_of_birth               in     varchar2 default null
  ,p_country_of_birth              in     varchar2 default null
  ,p_global_person_id              in     varchar2 default null
  ,p_party_id                      in     number default null

  ,p_person_id                        out nocopy number
  ,p_assignment_id                    out nocopy number
  ,p_per_object_version_number        out nocopy number
  ,p_asg_object_version_number        out nocopy number
  ,p_per_effective_start_date         out nocopy date
  ,p_per_effective_end_date           out nocopy date
  ,p_full_name                        out nocopy varchar2
  ,p_per_comment_id                   out nocopy number
  ,p_assignment_sequence              out nocopy number
  ,p_assignment_number                out nocopy varchar2
  ,p_name_combination_warning         out nocopy boolean
  ,p_assign_payroll_warning           out nocopy boolean
  ,p_orig_hire_warning                out nocopy boolean

  );
-- ----------------------------------------------------------------------------
--
-- Begin fix for bug 899720
--
-- ----------------------------------------------------------------------------
-- |-------------------------< create_gb_employee >---------------------------|
-- ----------------------------------------------------------------------------
--
-- {Start Of Comments}
--
-- Description:
--   This procedure is an overload version of the above procedure

--   create_gb_employee without the parameter 'p_orig_hire_warning'.
--   Therefore the user documentation is the same.
--
-- {End Of Comments}
--
procedure create_gb_employee
  (p_validate                      in     boolean  default false
  ,p_hire_date                     in     date
  ,p_business_group_id             in     number
  ,p_last_name                     in     varchar2
  ,p_sex                           in     varchar2
  ,p_person_type_id                in     number   default null
  ,p_comments                      in     varchar2 default null

  ,p_date_employee_data_verified   in     date     default null
  ,p_date_of_birth                 in     date     default null
  ,p_email_address                 in     varchar2 default null
  ,p_employee_number               in out nocopy varchar2
  ,p_expense_check_send_to_addres  in     varchar2 default null
  ,p_first_name                    in     varchar2 default null
  ,p_known_as                      in     varchar2 default null
  ,p_marital_status                in     varchar2 default null
  ,p_middle_names                  in     varchar2 default null
  ,p_nationality                   in     varchar2 default null
  ,p_ni_number                     in     varchar2 default null
  ,p_previous_last_name            in     varchar2 default null
  ,p_registered_disabled_flag      in     varchar2 default null

  ,p_title                         in     varchar2 default null
  ,p_vendor_id                     in     number   default null
  ,p_work_telephone                in     varchar2 default null
  ,p_attribute_category            in     varchar2 default null
  ,p_attribute1                    in     varchar2 default null
  ,p_attribute2                    in     varchar2 default null
  ,p_attribute3                    in     varchar2 default null
  ,p_attribute4                    in     varchar2 default null
  ,p_attribute5                    in     varchar2 default null
  ,p_attribute6                    in     varchar2 default null
  ,p_attribute7                    in     varchar2 default null
  ,p_attribute8                    in     varchar2 default null
  ,p_attribute9                    in     varchar2 default null

  ,p_attribute10                   in     varchar2 default null
  ,p_attribute11                   in     varchar2 default null
  ,p_attribute12                   in     varchar2 default null
  ,p_attribute13                   in     varchar2 default null
  ,p_attribute14                   in     varchar2 default null
  ,p_attribute15                   in     varchar2 default null
  ,p_attribute16                   in     varchar2 default null
  ,p_attribute17                   in     varchar2 default null
  ,p_attribute18                   in     varchar2 default null
  ,p_attribute19                   in     varchar2 default null
  ,p_attribute20                   in     varchar2 default null
  ,p_attribute21                   in     varchar2 default null
  ,p_attribute22                   in     varchar2 default null

  ,p_attribute23                   in     varchar2 default null
  ,p_attribute24                   in     varchar2 default null
  ,p_attribute25                   in     varchar2 default null
  ,p_attribute26                   in     varchar2 default null
  ,p_attribute27                   in     varchar2 default null
  ,p_attribute28                   in     varchar2 default null
  ,p_attribute29                   in     varchar2 default null
  ,p_attribute30                   in     varchar2 default null
  ,p_ethnic_origin                 in     varchar2 default null
  ,p_director                      in     varchar2 default 'N'
  ,p_pensioner                     in     varchar2 default 'N'
  ,p_work_permit_number            in     varchar2 default null
  ,p_addl_pension_years            in     varchar2 default null

  ,p_addl_pension_months           in     varchar2 default null
  ,p_addl_pension_days             in     varchar2 default null
  ,p_ni_multiple_asg               in     varchar2 default 'N'
  ,p_date_of_death                 in     date     default null
  ,p_background_check_status       in     varchar2 default null
  ,p_background_date_check         in     date     default null
  ,p_blood_type                    in     varchar2 default null
  ,p_correspondence_language       in     varchar2 default null
  ,p_fast_path_employee            in     varchar2 default null
  ,p_fte_capacity                  in     number   default null
  ,p_honors                        in     varchar2 default null
  ,p_internal_location             in     varchar2 default null
  ,p_last_medical_test_by          in     varchar2 default null

  ,p_last_medical_test_date        in     date     default null
  ,p_mailstop                      in     varchar2 default null
  ,p_office_number                 in     varchar2 default null
  ,p_on_military_service           in     varchar2 default null
  ,p_pre_name_adjunct              in     varchar2 default null
  ,p_rehire_recommendation         in     varchar2 default null  -- Bug3210500
  ,p_projected_start_date          in     date     default null
  ,p_resume_exists                 in     varchar2 default null
  ,p_resume_last_updated           in     date     default null
  ,p_second_passport_exists        in     varchar2 default null
  ,p_student_status                in     varchar2 default null
  ,p_work_schedule                 in     varchar2 default null
  ,p_suffix                        in     varchar2 default null

  ,p_benefit_group_id              in     number   default null
  ,p_receipt_of_death_cert_date    in     date     default null
  ,p_coord_ben_med_pln_no          in     varchar2 default null
  ,p_coord_ben_no_cvg_flag         in     varchar2 default 'N'
  ,p_coord_ben_med_ext_er          in     varchar2 default null
  ,p_coord_ben_med_pl_name         in     varchar2 default null
  ,p_coord_ben_med_insr_crr_name   in     varchar2 default null
  ,p_coord_ben_med_insr_crr_ident  in     varchar2 default null
  ,p_coord_ben_med_cvg_strt_dt     in     date default null
  ,p_coord_ben_med_cvg_end_dt      in     date default null
  ,p_uses_tobacco_flag             in     varchar2 default null
  ,p_dpdnt_adoption_date           in     date     default null
  ,p_dpdnt_vlntry_svce_flag        in     varchar2 default 'N'

  ,p_original_date_of_hire         in     date     default null
  ,p_adjusted_svc_date             in     date     default null
  ,p_town_of_birth                 in     varchar2 default null
  ,p_region_of_birth               in     varchar2 default null
  ,p_country_of_birth              in     varchar2 default null
  ,p_global_person_id              in     varchar2 default null
  ,p_party_id                      in     number default null
  ,p_person_id                        out nocopy number
  ,p_assignment_id                    out nocopy number
  ,p_per_object_version_number        out nocopy number
  ,p_asg_object_version_number        out nocopy number
  ,p_per_effective_start_date         out nocopy date
  ,p_per_effective_end_date           out nocopy date

  ,p_full_name                        out nocopy varchar2
  ,p_per_comment_id                   out nocopy number
  ,p_assignment_sequence              out nocopy number
  ,p_assignment_number                out nocopy varchar2
  ,p_name_combination_warning         out nocopy boolean
  ,p_assign_payroll_warning           out nocopy boolean
  );
--
-- End of fix for bug 899720
--
-- ----------------------------------------------------------------------------
-- |-------------------------< create_us_employee >---------------------------|
-- ----------------------------------------------------------------------------

--
-- {Start Of Comments}
--
-- Description:
--   This API creates a new US employee, including a default primary
--   assignment and a period of service for the employee.
--   The API calls the generic API create_employee, with the parameters set
--   as appropriate for a US employee.
--
--   Secure user functionality is included in this version of the API. The
--   employee will be visible to secure users in the business group.
--
--   As this API is effectively an alternative to the API create_employee,

--   see that API for further explanation.
--
-- Prerequisites:
--   See API create_employee.
--
-- In Parameters:
--   Name                           Reqd Type     Description
--   p_validate                     No   boolean  If true, the database
--                          remains unchanged. If false
--                          then the employee will be
--                                                created in the database.
--   p_hire_date                    Yes  date     The employee hire date and
--                          thus the effective start

--                          date of the person, primary
--                          assignment and period of
--                          service.
--   p_business_group_id            Yes  number   The employee's business
--                          group.
--   p_last_name                    Yes  varchar2 Employee's last name.
--   p_sex                          Yes  varchar2 Employee sex.
--   p_person_type_id               No   number   Person type id. If this value
--                                                is omitted then the
--                                                person_type_id of the active
--                                                default `EMP' system person
--                                                type in the employee's
--                                                business group is used.

--   p_comments                     No   varchar2 Comments for person record.
--   p_date_employee_data_verified  No   date     The date on which the
--                          employee data was last
--                          verified.
--   p_date_of_birth                No   date     Date of birth.
--   p_email_address                No   date     Email address.
--   p_employee_number              No   varchar2 Employee number.
--   p_expense_check_send_to_addres No   varchar2 Address to use as mailing
--                          address.
--   p_first_name                   No   varchar2 Employee's first name.
--   p_known_as                     No   varchar2 Alternative name.
--   p_marital_status               No   varchar2 Marital status.
--   p_middle_names                 No   varchar2 Employee's middle name(s).

--   p_nationality                  No   varchar2 Employee's nationality.
--   p_ss_number                    No   varchar2 Social Security number.
--   p_previous_last_name           No   varchar2 Previous last name.
--   p_registered_disabled_flag     No   varchar2 Registered disabled flag.
--   p_title                        No   varchar2 Employee's title.
--   p_vendor_id                    No   number   Foreign key to PO_VENDORS.
--   p_work_telephone               No   varchar2 Work telephone.
--   p_attribute_category           No   varchar2 Determines the context of
--                          the descriptive flexfield
--                          in the parameter list.
--   p_attribute1                   No   varchar2 Descriptive flexfield.
--   p_attribute2                   No   varchar2 Descriptive flexfield.
--   p_attribute3                   No   varchar2 Descriptive flexfield.

--   p_attribute4                   No   varchar2 Descriptive flexfield.
--   p_attribute5                   No   varchar2 Descriptive flexfield.
--   p_attribute6                   No   varchar2 Descriptive flexfield.
--   p_attribute7                   No   varchar2 Descriptive flexfield.
--   p_attribute8                   No   varchar2 Descriptive flexfield.
--   p_attribute9                   No   varchar2 Descriptive flexfield.
--   p_attribute10                  No   varchar2 Descriptive flexfield.
--   p_attribute11                  No   varchar2 Descriptive flexfield.
--   p_attribute12                  No   varchar2 Descriptive flexfield.
--   p_attribute13                  No   varchar2 Descriptive flexfield.
--   p_attribute14                  No   varchar2 Descriptive flexfield.
--   p_attribute15                  No   varchar2 Descriptive flexfield.
--   p_attribute16                  No   varchar2 Descriptive flexfield.

--   p_attribute17                  No   varchar2 Descriptive flexfield.
--   p_attribute18                  No   varchar2 Descriptive flexfield.
--   p_attribute19                  No   varchar2 Descriptive flexfield.
--   p_attribute20                  No   varchar2 Descriptive flexfield.
--   p_attribute21                  No   varchar2 Descriptive flexfield.
--   p_attribute22                  No   varchar2 Descriptive flexfield.
--   p_attribute23                  No   varchar2 Descriptive flexfield.
--   p_attribute24                  No   varchar2 Descriptive flexfield.
--   p_attribute25                  No   varchar2 Descriptive flexfield.
--   p_attribute26                  No   varchar2 Descriptive flexfield.
--   p_attribute27                  No   varchar2 Descriptive flexfield.
--   p_attribute28                  No   varchar2 Descriptive flexfield.
--   p_attribute29                  No   varchar2 Descriptive flexfield.

--   p_attribute30                  No   varchar2 Descriptive flexfield.
--   p_ethnic_origin                No   varchar2 Ethnic origin.
--   p_I_9                          No   varchar2 I_9 flag. Defaulted to
--                                                'N'.
--   p_I_9_expiration_date          No   varchar2 I_9 expiration date.
--   p_veteran_status               No   varchar2 Veteran status.
--   p_new_hire                     No   varchar2 New hire status.
--   p_exception_reason             No   varchar2 New hire exception reason.
--   p_child_support_obligation     No   varchar2 Child support obligation
--                                                flag. Defaulted to 'N'.
--   p_opted_for_medicare_flag      No   varchar2 Opted for additional medicare.
--   p_date_of_death                No   varchar2 Date of death
--   p_background_check_status      No   varchar2 Y/N flag indicates whether

--                                                background check has been
--                                                performed
--   p_background_date_check        No   date     Date background check was
--                                                performed
--   p_blood_type                   No   varchar2 Blood type
--   p_correspondence_language      No   varchar2 Preferred language for
--                                                correspondance
--   p_fast_path_employee           No   varchar2 Currently unsupported
--   p_fte_capacity                 No   number   Full time/part time
--                                                availability for work
--   p_honors                       No   varchar2 Honors or degrees awarded
--   p_internal_location            No   varchar2 Internal location of office
--   p_last_medical_test_by         No   varchar2 Name of physician who

--                                                performed last medical test
--   p_last_medical_test_date       No   date     Date of last medical test
--   p_mailstop                     No   varchar2 Office identifier for
--                                                internal mail
--   p_office_number                No   varchar2 Number of office
--   p_on_military_service          No   varchar2 Y/N flag indicating whether
--                                                person is employed in
--                                                military service
--   p_pre_name_adjunct             No   varchar2 First part of surname such
--                                                as Van or De
--   p_rehire_recommendation        No   varchar2 The employee can be rehired
--                                                or not after termination.
--   p_projected_start_date         No   date     Currently unsupported

--   p_resume_exists                No   varchar2 Y/N flag indicating whether
--                                                resume is on file
--   p_resume_last_updated          No   date     Date resume last updated
--   p_second_passport_exists       No   varchar2 Y/N flag indicaing whether
--                                                person has multiple passports
--   p_student_status               No   varchar2 Full time/part time status
--                                                of student
--   p_work_schedule                No   varchar2 Type of work schedule
--                                                inndicating which days
--                                                person works
--   p_suffix                       No   varchar2 Employee's suffix
--   p_benefit_group_id             No   number   Benefit group id.
--   p_receipt_of_death_cert_date   No   date     Date the death certificate

--                                                is received.
--   p_coord_ben_med_pln_no         No   varchar2 Coordinated benefit medical
--                                                plan number
--   p_coord_ben_no_cvg_flag        No   varchar2 Coordinated benefit no other
--                                                coverage flag
--   p_coord_ben_med_ext_er         No   varchar2 Secondary medical coverage external
--                                                employer
--   p_coord_ben_med_pl_name        No   varchar2 Secondary medical coverage name
--   p_coord_ben_med_insr_crr_name  No   varchar2 Secondary medical coverage insurance
--                                                carrier
--   p_coord_ben_med_insr_crr_ident No   varchar2 Secondary medical coverage insurance
--                                                carrier id
--   p_coord_ben_med_cvg_strt_dt    No   varchar2 Secondary medical coverage effective

--                                                start date
--   p_coord_ben_med_cvg_end_dt     No   varchar2 Secondary medical coverage effective
--                                                end date
--   p_uses_tobacco_flag            No   varchar2 Uses tobacco list of values
--   p_dpdnt_adoption_date          No   date     Dependent's adoption date
--   p_dpdnt_vlntry_svce_flag       No   varchar2 Dependent's voluntary service
--                                                flag
--   p_original_date_of_hire        No   date     Original date of hire
--   p_adjusted_svc_date            No   date     Adjusted service date
--   p_town_of_birth                No   varchar2 Town or city of birth
--   p_region_of_birth              No   varchar2 Geographical region of birth
--   p_country_of_birth             No   varchar2 Country of birth
--   p_global_person_id             No   varchar2 Global ID for the person

--
-- Post success:
--   When the person, primary assignment and period of service have been
--   successfully inserted, the following OUT parameters are set:
--
--   Name                           Type     Description
--   p_employee_number              varchar2 If p_validate is false this will
--                                           be set to the employee number of
--                                           the person created. If
--                                           p_validate is true this will be
--                                           set to the same value as passed
--                                           in.
--   p_person_id                    number   If p_validate is false, this

--                         uniquely identifies the person
--                         created. If p_validate is true
--                         this parameter will be null.
--   p_assignment_id                number   If p_validate is false, this
--                         uniquely identifies the primary
--                         assignment created. If
--                         p_validate is true this parameter
--                         will be null.
--   p_per_object_version_number    number   If p_validate is false, this will
--                         be set to the version number of
--                          the person created. If
--                         p_validate is true this parameter
--                         will be set to null.

--   p_asg_object_version_number    number   If p_validate is false, this will
--                         be set to the version number of
--                          the primary assignment created.
--                         If p_validate is true this
--                         parameter will be set to null.
--   p_per_effective_start_date     date     If p_validate is false, this will
--                                           be set to the effective start
--                                           date of the person. If
--                                           p_validate is true this will be
--                                           null.
--   p_per_effective_end_date       date     If p_validate is false, this will
--                                           be set to the effective end
--                                           date of the person. If

--                                           p_validate is true this will be
--                                           null.
--   p_full_name                    varchar2 If p_validate is false, this will
--                                           be set to the complete full name
--                                           of the person. If p_validate is
--                                           true this will be null.
--   p_per_comment_id               number   If p_validate is false this will
--                                           be set to the id of the
--                                           corresponding person comment row,
--                                           if any comment text exists. If
--                                           p_validate is true this will be
--                                           null.
--   p_assignment_sequence          number   If p_validate is false this will

--                                           be set to the sequence number of
--                                           the primary assignment. If
--                                           p_validate is true this will be
--                                           null.
--   p_assignment_number            varchar2 If p_validate is false this will
--                                           be set to the assignment number
--                                           of the primary assignment. If
--                                           p_validate is true this will be
--                                           null.
--   p_name_combination_warning     boolean  Set to true if the combination
--                                           of last name, first name and date
--                         of birth already existed prior
--                         to the person being created.

--   p_assign_payroll_warning       boolean  Set to true if the date of birth
--                         has not been set.
--   p_orig_hire_warning            boolean  Set to true if the original date
--                                           of hire is not null and the
--                                           person type is not EMP,EMP_APL,
--                                           EX_EMP or EX_EMP_APL.
--
-- Post Failure:
--   The API does not create the employee, default assignment or period of
--   service and raises an error.
--
-- Access Status:
--   Public.

--
-- {End Of Comments}
--
procedure create_us_employee
  (p_validate                      in     boolean  default false
  ,p_hire_date                     in     date
  ,p_business_group_id             in     number
  ,p_last_name                     in     varchar2
  ,p_sex                           in     varchar2
  ,p_person_type_id                in     number   default null
  ,p_comments                      in     varchar2 default null
  ,p_date_employee_data_verified   in     date     default null
  ,p_date_of_birth                 in     date     default null

  ,p_email_address                 in     varchar2 default null
  ,p_employee_number               in out nocopy varchar2
  ,p_expense_check_send_to_addres  in     varchar2 default null
  ,p_first_name                    in     varchar2 default null
  ,p_known_as                      in     varchar2 default null
  ,p_marital_status                in     varchar2 default null
  ,p_middle_names                  in     varchar2 default null
  ,p_nationality                   in     varchar2 default null
  ,p_ss_number                     in     varchar2 default null
  ,p_previous_last_name            in     varchar2 default null
  ,p_registered_disabled_flag      in     varchar2 default null
  ,p_title                         in     varchar2 default null
  ,p_vendor_id                     in     number   default null

  ,p_work_telephone                in     varchar2 default null
  ,p_attribute_category            in     varchar2 default null
  ,p_attribute1                    in     varchar2 default null
  ,p_attribute2                    in     varchar2 default null
  ,p_attribute3                    in     varchar2 default null
  ,p_attribute4                    in     varchar2 default null
  ,p_attribute5                    in     varchar2 default null
  ,p_attribute6                    in     varchar2 default null
  ,p_attribute7                    in     varchar2 default null
  ,p_attribute8                    in     varchar2 default null
  ,p_attribute9                    in     varchar2 default null
  ,p_attribute10                   in     varchar2 default null
  ,p_attribute11                   in     varchar2 default null

  ,p_attribute12                   in     varchar2 default null
  ,p_attribute13                   in     varchar2 default null
  ,p_attribute14                   in     varchar2 default null
  ,p_attribute15                   in     varchar2 default null
  ,p_attribute16                   in     varchar2 default null
  ,p_attribute17                   in     varchar2 default null
  ,p_attribute18                   in     varchar2 default null
  ,p_attribute19                   in     varchar2 default null
  ,p_attribute20                   in     varchar2 default null
  ,p_attribute21                   in     varchar2 default null
  ,p_attribute22                   in     varchar2 default null
  ,p_attribute23                   in     varchar2 default null
  ,p_attribute24                   in     varchar2 default null

  ,p_attribute25                   in     varchar2 default null
  ,p_attribute26                   in     varchar2 default null
  ,p_attribute27                   in     varchar2 default null
  ,p_attribute28                   in     varchar2 default null
  ,p_attribute29                   in     varchar2 default null
  ,p_attribute30                   in     varchar2 default null
  ,p_ethnic_origin                 in     varchar2 default null
  ,p_I_9                           in     varchar2 default 'N'
  ,p_I_9_expiration_date           in     varchar2 default null
--  ,p_visa_type                     in     varchar2 default null
  ,p_veteran_status                in     varchar2 default null
  ,p_new_hire                      in     varchar2 default null
  ,p_exception_reason              in     varchar2 default null

  ,p_child_support_obligation      in     varchar2 default 'N'
  ,p_opted_for_medicare_flag       in     varchar2 default 'N'
  ,p_date_of_death                 in     date     default null
  ,p_background_check_status       in     varchar2 default null
  ,p_background_date_check         in     date     default null
  ,p_blood_type                    in     varchar2 default null
  ,p_correspondence_language       in     varchar2 default null
  ,p_fast_path_employee            in     varchar2 default null
  ,p_fte_capacity                  in     number   default null
  ,p_honors                        in     varchar2 default null
  ,p_internal_location             in     varchar2 default null
  ,p_last_medical_test_by          in     varchar2 default null
  ,p_last_medical_test_date        in     date     default null

  ,p_mailstop                      in     varchar2 default null
  ,p_office_number                 in     varchar2 default null
  ,p_on_military_service           in     varchar2 default null
  ,p_pre_name_adjunct              in     varchar2 default null
  ,p_rehire_recommendation         in     varchar2 default null  -- Bug3210500
  ,p_projected_start_date          in     date     default null
  ,p_resume_exists                 in     varchar2 default null
  ,p_resume_last_updated           in     date     default null
  ,p_second_passport_exists        in     varchar2 default null
  ,p_student_status                in     varchar2 default null
  ,p_work_schedule                 in     varchar2 default null
  ,p_suffix                        in     varchar2 default null
  ,p_benefit_group_id              in     number   default null

  ,p_receipt_of_death_cert_date    in     date     default null
  ,p_coord_ben_med_pln_no          in     varchar2 default null
  ,p_coord_ben_no_cvg_flag         in     varchar2 default 'N'
  ,p_coord_ben_med_ext_er          in     varchar2 default null
  ,p_coord_ben_med_pl_name         in     varchar2 default null
  ,p_coord_ben_med_insr_crr_name   in     varchar2 default null
  ,p_coord_ben_med_insr_crr_ident  in     varchar2 default null
  ,p_coord_ben_med_cvg_strt_dt     in     date default null
  ,p_coord_ben_med_cvg_end_dt      in     date default null
  ,p_uses_tobacco_flag             in     varchar2 default null
  ,p_dpdnt_adoption_date           in     date     default null
  ,p_dpdnt_vlntry_svce_flag        in     varchar2 default 'N'
  ,p_original_date_of_hire         in     date     default null

  ,p_adjusted_svc_date             in     date     default null
  ,p_town_of_birth                 in     varchar2 default null
  ,p_region_of_birth               in     varchar2 default null
  ,p_country_of_birth              in     varchar2 default null
  ,p_global_person_id              in     varchar2 default null
  ,p_party_id                      in     number default null
  ,p_person_id                        out nocopy number
  ,p_assignment_id                    out nocopy number
  ,p_per_object_version_number        out nocopy number
  ,p_asg_object_version_number        out nocopy number
  ,p_per_effective_start_date         out nocopy date
  ,p_per_effective_end_date           out nocopy date
  ,p_full_name                        out nocopy varchar2

  ,p_per_comment_id                   out nocopy number
  ,p_assignment_sequence              out nocopy number
  ,p_assignment_number                out nocopy varchar2
  ,p_name_combination_warning         out nocopy boolean
  ,p_assign_payroll_warning           out nocopy boolean
  ,p_orig_hire_warning                out nocopy boolean
  );
--
-- ----------------------------------------------------------------------------
--
-- Begin fix for bug 899720
--
-- ----------------------------------------------------------------------------

-- |-------------------------< create_us_employee >---------------------------|
-- ----------------------------------------------------------------------------
--
-- {Start Of Comments}
--
-- Description:
--   This procedure is an overload version of the above procedure
--   create_us_employee without the parameter 'p_orig_hire_warning'.
--   Therefore the user documentation is the same.
--
-- {End Of Comments}
--
procedure create_us_employee

  (p_validate                      in     boolean  default false
  ,p_hire_date                     in     date
  ,p_business_group_id             in     number
  ,p_last_name                     in     varchar2
  ,p_sex                           in     varchar2
  ,p_person_type_id                in     number   default null
  ,p_comments                      in     varchar2 default null
  ,p_date_employee_data_verified   in     date     default null
  ,p_date_of_birth                 in     date     default null
  ,p_email_address                 in     varchar2 default null
  ,p_employee_number               in out nocopy varchar2
  ,p_expense_check_send_to_addres  in     varchar2 default null
  ,p_first_name                    in     varchar2 default null

  ,p_known_as                      in     varchar2 default null
  ,p_marital_status                in     varchar2 default null
  ,p_middle_names                  in     varchar2 default null
  ,p_nationality                   in     varchar2 default null
  ,p_ss_number                     in     varchar2 default null
  ,p_previous_last_name            in     varchar2 default null
  ,p_registered_disabled_flag      in     varchar2 default null
  ,p_title                         in     varchar2 default null
  ,p_vendor_id                     in     number   default null
  ,p_work_telephone                in     varchar2 default null
  ,p_attribute_category            in     varchar2 default null
  ,p_attribute1                    in     varchar2 default null
  ,p_attribute2                    in     varchar2 default null

  ,p_attribute3                    in     varchar2 default null
  ,p_attribute4                    in     varchar2 default null
  ,p_attribute5                    in     varchar2 default null
  ,p_attribute6                    in     varchar2 default null
  ,p_attribute7                    in     varchar2 default null
  ,p_attribute8                    in     varchar2 default null
  ,p_attribute9                    in     varchar2 default null
  ,p_attribute10                   in     varchar2 default null
  ,p_attribute11                   in     varchar2 default null
  ,p_attribute12                   in     varchar2 default null
  ,p_attribute13                   in     varchar2 default null
  ,p_attribute14                   in     varchar2 default null
  ,p_attribute15                   in     varchar2 default null

  ,p_attribute16                   in     varchar2 default null
  ,p_attribute17                   in     varchar2 default null
  ,p_attribute18                   in     varchar2 default null
  ,p_attribute19                   in     varchar2 default null
  ,p_attribute20                   in     varchar2 default null
  ,p_attribute21                   in     varchar2 default null
  ,p_attribute22                   in     varchar2 default null
  ,p_attribute23                   in     varchar2 default null
  ,p_attribute24                   in     varchar2 default null
  ,p_attribute25                   in     varchar2 default null
  ,p_attribute26                   in     varchar2 default null
  ,p_attribute27                   in     varchar2 default null
  ,p_attribute28                   in     varchar2 default null

  ,p_attribute29                   in     varchar2 default null
  ,p_attribute30                   in     varchar2 default null
  ,p_ethnic_origin                 in     varchar2 default null
  ,p_I_9                           in     varchar2 default 'N'
  ,p_I_9_expiration_date           in     varchar2 default null
--  ,p_visa_type                     in     varchar2 default null
  ,p_veteran_status                in     varchar2 default null
  ,p_new_hire                      in     varchar2 default null
  ,p_exception_reason              in     varchar2 default null
  ,p_child_support_obligation      in     varchar2 default 'N'
  ,p_opted_for_medicare_flag       in     varchar2 default 'N'
  ,p_date_of_death                 in     date     default null
  ,p_background_check_status       in     varchar2 default null

  ,p_background_date_check         in     date     default null
  ,p_blood_type                    in     varchar2 default null
  ,p_correspondence_language       in     varchar2 default null
  ,p_fast_path_employee            in     varchar2 default null
  ,p_fte_capacity                  in     number   default null
  ,p_honors                        in     varchar2 default null
  ,p_internal_location             in     varchar2 default null
  ,p_last_medical_test_by          in     varchar2 default null
  ,p_last_medical_test_date        in     date     default null
  ,p_mailstop                      in     varchar2 default null
  ,p_office_number                 in     varchar2 default null
  ,p_on_military_service           in     varchar2 default null
  ,p_pre_name_adjunct              in     varchar2 default null

  ,p_rehire_recommendation         in     varchar2 default null  -- Bug3210500
  ,p_projected_start_date          in     date     default null
  ,p_resume_exists                 in     varchar2 default null
  ,p_resume_last_updated           in     date     default null
  ,p_second_passport_exists        in     varchar2 default null
  ,p_student_status                in     varchar2 default null
  ,p_work_schedule                 in     varchar2 default null
  ,p_suffix                        in     varchar2 default null
  ,p_benefit_group_id              in     number   default null
  ,p_receipt_of_death_cert_date    in     date     default null
  ,p_coord_ben_med_pln_no          in     varchar2 default null
  ,p_coord_ben_no_cvg_flag         in     varchar2 default 'N'
  ,p_coord_ben_med_ext_er          in     varchar2 default null

  ,p_coord_ben_med_pl_name         in     varchar2 default null
  ,p_coord_ben_med_insr_crr_name   in     varchar2 default null
  ,p_coord_ben_med_insr_crr_ident  in     varchar2 default null
  ,p_coord_ben_med_cvg_strt_dt     in     date default null
  ,p_coord_ben_med_cvg_end_dt      in     date default null
  ,p_uses_tobacco_flag             in     varchar2 default null
  ,p_dpdnt_adoption_date           in     date     default null
  ,p_dpdnt_vlntry_svce_flag        in     varchar2 default 'N'
  ,p_original_date_of_hire         in     date     default null
  ,p_adjusted_svc_date             in     date     default null
  ,p_town_of_birth                 in     varchar2 default null
  ,p_region_of_birth               in     varchar2 default null
  ,p_country_of_birth              in     varchar2 default null

  ,p_global_person_id              in     varchar2 default null
  ,p_party_id                      in     number default null
  ,p_person_id                        out nocopy number
  ,p_assignment_id                    out nocopy number
  ,p_per_object_version_number        out nocopy number
  ,p_asg_object_version_number        out nocopy number
  ,p_per_effective_start_date         out nocopy date
  ,p_per_effective_end_date           out nocopy date
  ,p_full_name                        out nocopy varchar2
  ,p_per_comment_id                   out nocopy number
  ,p_assignment_sequence              out nocopy number
  ,p_assignment_number                out nocopy varchar2
  ,p_name_combination_warning         out nocopy boolean

  ,p_assign_payroll_warning           out nocopy boolean
  );
--
-- End of fix for bug 899720
--
-- ----------------------------------------------------------------------------
-- |--------------------------< re_hire_ex_employee >-------------------------|
-- ----------------------------------------------------------------------------
-- {Start Of Comments}
--
-- Description:
--   This API will re-hire an ex-employee as an employee. A person can be
--   re-hired only if their previous period of service has a final process

--   date.
--
--   When an employee is re-hired, the person type is changed to employee, a
--   new period of service record is created and a new primary employee
--   assignment record is created.  All changes are made effective from the
--   hire date, p_hire_date.
--
--   It is now possible to re-hire an employee the day after they were
--   terminated (i.e. hire date can be the day after the final process date)
--
--   The new person type must have a corresponding system type of EMP. If a
--   person type is not specified, the API will use the default EMP type for
--   the business group.

--
--   The security lists will be updated so that this employee will be correctly
--   visible to secure users.
--
-- Prerequisites:
--   The person record, identified by p_person_id and
--   p_per_object_version_number must exist.
--   The person must have a current person type corresponding to a system type
--   of EX_EMP.
--   The most recent previous period of service must have a final process
--   date.
--   The hire date cannot come before the final process date of the previous
--   period of service.

--   The person type, p_person_type_id, if supplied, must exist for the same
--   business groupas the person, must be active and must have a corresponding
--   system type of EMP.
--
-- In Parameters:
--   Name                           Reqd Type     Description
--   p_validate                     No   boolean  If true, the database
--                                                remains unchanged. If false
--                                                then the person record will
--                                                be updated.
--   p_hire_date                    Yes  date     Hire date
--   p_person_id                    Yes  number   ID of the person
--   p_per_object_version_number    Yes  number   Version number of the

--                                                person record
--   p_person_type_id               No   number   Person type id. If this value
--                                                is omitted then the
--                                                person_type_id of the active
--                                                default `EMP' system person
--                                                type in the employee's
--                                                business group is used.
--   p_rehire_reason                No   varchar2 The reason the person is
--                                                being re-hired.
--
-- Post Success:
--   The API will update the person, create a new period of service, create
--   a new primary assignment and set the following out parameters:

--
--   Name                           Type     Description
--   p_per_object_version_number    number   If p_validate is false, set to
--                                           the new version number of the
--                                           updated person record.
--                                           If p_validate is true, set to
--                                           the value passed in.
--   p_assignment_id                number   If p_validate is false, this
--                                           uniquely identifies the primary
--                                           assignment created.
--                                           If p_validate is true, set to
--                                           null.
--   p_asg_object_version_number    number   If p_validate is false, this will

--                                           be set to the version number of
--                                           the primary assignment created.
--                                           If p_validate is true, set to
--                                           null.
--   p_per_effective_start_date     date     If p_validate is false, set to
--                                           the effective start date for this
--                                           person change.
--                                           If p_validate is true, set to
--                                           null.
--   p_per_effective_end_date       date     If p_validate is false, set to
--                                           the effective end date for this
--                                           person change.
--                                           If p_validate is true, set to

--                                           null.
--   p_assignment_sequence          number   If p_validate is false, this will
--                                           be set to the sequence number of
--                                           the primary assignment. If
--                                           p_validate is true, set to null.
--   p_assignment_number            varchar2 If p_validate is false, this will
--                                           be set to the assignment number
--                                           of the primary assignment. If
--                                           p_validate is true, set to null.
--   p_assign_payroll_warning       boolean  Set to true if the date of birth
--                                           has not been set for this person.
--
-- Post Failure:

--   The API does not update the person, or create a period of service, or
--   create an assignment and raises an error.
--
-- Access Status:
--   Public.
--
-- {End Of Comments}
--
procedure re_hire_ex_employee
  (p_validate                      in     boolean  default false
  ,p_hire_date                     in     date
  ,p_person_id                     in     number
  ,p_per_object_version_number     in out nocopy number

  ,p_person_type_id                in     number   default hr_api.g_number
  ,p_rehire_reason                 in     varchar2
  ,p_assignment_id                    out nocopy number
  ,p_asg_object_version_number        out nocopy number
  ,p_per_effective_start_date         out nocopy date
  ,p_per_effective_end_date           out nocopy date
  ,p_assignment_sequence              out nocopy number
  ,p_assignment_number                out nocopy varchar2
  ,p_assign_payroll_warning           out nocopy boolean
  );
--
--
-- ----------------------------------------------------------------------------

-- |-----------------< apply_for_internal_vacancy >---------------------------|
-- ----------------------------------------------------------------------------
--
-- {Start Of Comments}
--
-- Description:
--   This API updates an employee, system person type 'EMP'
--   to an employee and applicant, system person type 'EMP_APL'.
--
--   A new applicant assignment and an application are created for the employee.
--
--   The security lists are updated.
--

--
-- Prerequisites:
--   The employee must have a system person type of 'EMP'.
--
-- In Parameters:
--   Name                           Reqd Type     Description
--   p_validate                     No   boolean  If true, the database
--                          remains unchanged. If false
--                          then the employee person type
--                                                is updated to an 'EMP_APL',
--                                                an application is a secondary
--                                                assignment is created in
--                                                the database.

--   p_effective_date               Yes  date     The effective start date
--                                                of the new person status,
--                          application and secondary
--                                                assignment.
--   p_person_id                    Yes  number.  Person ID.
--   p_applicant_number             No   varchar2 Applicant number. If the
--                          number generation method is
--                                                Manual then this parameter
--                                                is mandatory.  If the number
--                                                generation is Automatic, the
--                                                the value of this parameter
--                                                defaults to null.
--   p_per_object_version_number    Yes  number   Object version number of

--                                                person.
--   p_vacancy_id                   No   number   Vacancy ID. Defaults to null.
--   p_person_type_id               No   number   Person Type ID of 'EMP_APL'.
--                                                Defaults to hr_api.g_number.
--
-- Post success:
--   When the person is successfully updated, applicant assignment and
--   application are successfully inserted, the following OUT parameters are
--   set:
--
--   Name                           Type     Description
--   p_per_object_version_number    number   If p_validate is false, this will
--                         be set to the new version number of

--                          the person updated. If
--                         p_validate is true this parameter
--                         will be set to the value passed in.
--   p_application_id               number   If p_validate is false, this
--                         uniquely identifies the application
--                         created . If p_validate is true this
--                                           parameter is null.
--   p_assignment_id                number   If p_validate is false, this
--                         uniquely identifies the assignment
--                                           created. If p_validate is true
--                                           this parameter is set null.
--   p_apl_object_version_number    number   If p_validate is false, this will
--                         be set to the version number of

--                          the application created. If
--                         p_validate is true this parameter is
--                                           set to null.
--   p_asg_object_version_number    number   If p_validate is false, this will
--                         be set to the version number of
--                          the assignment created. If
--                         p_validate is true this
--                         parameter is set to null.
--   p_assignment_sequence          number   If p_validate is false, this will
--                         be set to the assignment sequence
--                                           of the assignment created.  If
--                                           p_validate is true, this parameter
--                                           is set to null.

--   p_per_effective_start_date     date     If p_validate is false, this is
--                                           set to the effective start
--                                           date of the person. If
--                                           p_validate is true this is
--                                           null.
--   p_per_effective_end_date       date     If p_validate is false, this is
--                                           set to the effective end date
--                                           of the person. If p_validate
--                                           is true this is set null.
--
-- Post Failure:
--   The API does not update the person or create the applicant assignment
--   or application and raises an error.

--
-- Access Status:
--   Public.
--
-- {End Of Comments}
--
procedure apply_for_internal_vacancy
  (p_validate                      in     boolean  default false
  ,p_effective_date                in     date
  ,p_person_id                     in     number
  ,p_applicant_number              in out nocopy varchar2
  ,p_per_object_version_number     in out nocopy number
  ,p_vacancy_id                    in     number   default null

  ,p_person_type_id                in     number   default hr_api.g_number
  ,p_application_id                   out nocopy number
  ,p_assignment_id                    out nocopy number
  ,p_apl_object_version_number        out nocopy number
  ,p_asg_object_version_number        out nocopy number
  ,p_assignment_sequence              out nocopy number
  ,p_per_effective_start_date         out nocopy date
  ,p_per_effective_end_date           out nocopy date
  );
--
-- -----------------------------------------------------------------------------
-- |----------------------------< hire_into_job >------------------------------|
-- -----------------------------------------------------------------------------

--
-- {Start Of Comments}
--
-- Description:
--   This business process converts a person of type EX_APL, EX_EMP or OTHER to
--   a type of EMP.
--   This is achieved by
--     Setting the person type to EMP
--     Creating a period of service
--     Creating a default employee assignment
--     Repopulating the security lists
--
-- In Parameters:

--   Name                           Reqd Type     Description
--   p_validate                     No   boolean  If true, the database remains
--                                                unchanged. If false a valid
--                                                assignment is updated in
--                                                the database.
--   p_effective_date               Yes  date     Effective date of the change
--                                                of status.
--   p_person_id                    Yes  number   Person to become an applicant.
--   p_per_object_version_number    Yes  number   Version number of the person
--                                                record.
--   p_datetrack_update_mode        No   varchar2 Datetrack update mode. Only
--                                                applicable if hiring a person of
--                                                type OTHER, when the values of

--                                                Update or Correction may be used.
--                                                If not set a value of Update is
--                                                used. In all other cases this
--                                                value is ignored and a value of
--                                                Update used.
--   p_employee_number              No   varchar2 Employee number. Ignored if
--                                                the person already has an
--                                                employee number. Required if
--                                                the number generation method
--                                                is manual. Must be NULL if the
--                                                number generation method is
--                                                automatic.
--   p_person_type_id               No   number   Person type id the person is to

--                                                become. If this value is
--                                                omitted the person type id
--                                                of the default system person
--                                                type required in the person's
--                                                business group is used.
--   p_national_identifier          No   varchar2 The national identifier.
--
-- Post Success:
--   The API updates the person and application and set the following out
--   parameters:
--
--   Name                           Type     Description
--   p_per_object_version_number    number   If p_validate is false, set to

--                                           the new version number of the
--                                           person record. If p_validate is
--                                           true, set to the value passed in.
--   p_employee_number              number   If p_validate is false, set to the
--                                           employee number of the person. If
--                                           p_validate is true, set to the
--                                           value passed in.
--   p_effective_start_date         date     If p_validate is false, set to
--                                           the effective start date of the
--                                           updated person record. If
--                                           p_validate is true, set to null.
--   p_effective_end_date           date     If p_validate is false, set to
--                                           the effective end date of the

--                                           updated person record. If
--                                           p_validate is true, set to null.
--   p_assign_payroll_warning       boolean  Set to true if the person's date of
--                                           birth has not been set. Set to
--                                           false if the date of birth has been
--                                           entered. Indicates if it will be
--                                           possible to set the payroll
--                                           component on any of this person's
--                                           assignments.
--   p_orig_hire_warning            boolean  Set to true if the original date of
--                                           hire is not null and the person
--                                           type is not EMP, EMP_APL, EX_EMP or
--                                           EX_EMP_APL.

--
-- Post Failure:
--   The API does not update the person and period of service and raises an error.
--
-- Access Status:
--   Public.
--
-- {End Of Comments}
--
PROCEDURE hire_into_job
  (p_validate                     IN     BOOLEAN  DEFAULT FALSE
  ,p_effective_date               IN     DATE
  ,p_person_id                    IN     NUMBER

  ,p_object_version_number        IN OUT NOCOPY NUMBER
  ,p_employee_number              IN OUT NOCOPY VARCHAR2
  ,p_datetrack_update_mode        IN     VARCHAR2 DEFAULT NULL
  ,p_person_type_id               IN     NUMBER   DEFAULT NULL
  ,p_national_identifier          IN     VARCHAR2 DEFAULT NULL
  ,p_effective_start_date            OUT NOCOPY DATE
  ,p_effective_end_date              OUT NOCOPY DATE
  ,p_assign_payroll_warning          OUT NOCOPY BOOLEAN
  ,p_orig_hire_warning               OUT NOCOPY BOOLEAN
  );
--
end hr_employee_api;
/

create or replace Package Body hr_employee_api as

/* $Header: peempapi.pkb 115.48 2003/10/23 02:41:38 jpthomas ship $ */
  --
  -- Package Variables
  --
  g_package  varchar2(33) := 'hr_employee_api.';
 g_debug boolean := hr_utility.debug_enabled;
  --
  -- Package cursors
  --
  CURSOR csr_future_asgs
    (p_person_id                    IN     per_all_people_f.person_id%TYPE

    ,p_effective_date               IN     DATE
    )
  IS
    SELECT asg.assignment_id
          ,asg.object_version_number
      FROM per_assignments_f asg
     WHERE asg.person_id             = csr_future_asgs.p_person_id
       AND asg.effective_start_date >= csr_future_asgs.p_effective_date;
--
-- -----------------------------------------------------------------------------
-- |--------------------------< future_asgs_count >----------------------------|
-- -----------------------------------------------------------------------------
--

-- {Start Of Comments}
--
-- Description:
--   Determines the number of assignments for a person which start on or after
--   a date.
--
-- Prerequisites:
--   None
--
-- In Parameters:
--   Name                           Reqd Type     Description
--   p_person_id                    No   number   Person id
--   p_effective_date               No   date     Effective date

--
-- Post Success:
--   The number of assignments for the person starting on or after a date is
--   returned.
--
-- Post Failure:
--   An error is raised.
--
-- Access Status:
--   Internal Development Use Only
--
-- {End Of Comments}
--

FUNCTION future_asgs_count
  (p_person_id                    IN     per_all_people_f.person_id%TYPE
  ,p_effective_date               IN     DATE
  )
RETURN INTEGER
IS
  --
  -- Local variables
  --
  l_proc                         VARCHAR2(72);
  --
  l_future_asgs_count            INTEGER := 0;
--

BEGIN
  --
 if g_debug then
  l_proc  := g_package||'future_asgs_count';
  hr_utility.set_location('Entering:'||l_proc,10);
 end if;
  --
  FOR l_future_asgs_rec IN
  csr_future_asgs
    (p_person_id                    => p_person_id
    ,p_effective_date               => p_effective_date
    )
  LOOP

     l_future_asgs_count := l_future_asgs_count + 1;
  END LOOP;
  --
 if g_debug then
  hr_utility.set_location(' Leaving:'||l_proc,100);
 end if;
  --
  RETURN(l_future_asgs_count);
--
EXCEPTION
  WHEN OTHERS
  THEN
    IF csr_future_asgs%ISOPEN

    THEN
      CLOSE csr_future_asgs;
    END IF;
    RAISE;
--
END future_asgs_count;
--
-- ----------------------------------------------------------------------------
-- |--------------------------< create_employee >-----------------------------|
-- ----------------------------------------------------------------------------
--
procedure create_employee
  (p_validate                      in     boolean  default false

  ,p_hire_date                     in     date
  ,p_business_group_id             in     number
  ,p_last_name                     in     varchar2
  ,p_sex                           in     varchar2
  ,p_person_type_id                in     number   default null
  ,p_per_comments                  in     varchar2 default null
  ,p_date_employee_data_verified   in     date     default null
  ,p_date_of_birth                 in     date     default null
  ,p_email_address                 in     varchar2 default null
  ,p_employee_number               in out nocopy varchar2
  ,p_expense_check_send_to_addres  in     varchar2 default null
  ,p_first_name                    in     varchar2 default null
  ,p_known_as                      in     varchar2 default null

  ,p_marital_status                in     varchar2 default null
  ,p_middle_names                  in     varchar2 default null
  ,p_nationality                   in     varchar2 default null
  ,p_national_identifier           in     varchar2 default null
  ,p_previous_last_name            in     varchar2 default null
  ,p_registered_disabled_flag      in     varchar2 default null
  ,p_title                         in     varchar2 default null
  ,p_vendor_id                     in     number   default null
  ,p_work_telephone                in     varchar2 default null
  ,p_attribute_category            in     varchar2 default null
  ,p_attribute1                    in     varchar2 default null
  ,p_attribute2                    in     varchar2 default null
  ,p_attribute3                    in     varchar2 default null

  ,p_attribute4                    in     varchar2 default null
  ,p_attribute5                    in     varchar2 default null
  ,p_attribute6                    in     varchar2 default null
  ,p_attribute7                    in     varchar2 default null
  ,p_attribute8                    in     varchar2 default null
  ,p_attribute9                    in     varchar2 default null
  ,p_attribute10                   in     varchar2 default null
  ,p_attribute11                   in     varchar2 default null
  ,p_attribute12                   in     varchar2 default null
  ,p_attribute13                   in     varchar2 default null
  ,p_attribute14                   in     varchar2 default null
  ,p_attribute15                   in     varchar2 default null
  ,p_attribute16                   in     varchar2 default null

  ,p_attribute17                   in     varchar2 default null
  ,p_attribute18                   in     varchar2 default null
  ,p_attribute19                   in     varchar2 default null
  ,p_attribute20                   in     varchar2 default null
  ,p_attribute21                   in     varchar2 default null
  ,p_attribute22                   in     varchar2 default null
  ,p_attribute23                   in     varchar2 default null
  ,p_attribute24                   in     varchar2 default null
  ,p_attribute25                   in     varchar2 default null
  ,p_attribute26                   in     varchar2 default null
  ,p_attribute27                   in     varchar2 default null
  ,p_attribute28                   in     varchar2 default null
  ,p_attribute29                   in     varchar2 default null

  ,p_attribute30                   in     varchar2 default null
  ,p_per_information_category      in     varchar2 default null
  ,p_per_information1              in     varchar2 default null
  ,p_per_information2              in     varchar2 default null
  ,p_per_information3              in     varchar2 default null
  ,p_per_information4              in     varchar2 default null
  ,p_per_information5              in     varchar2 default null
  ,p_per_information6              in     varchar2 default null
  ,p_per_information7              in     varchar2 default null
  ,p_per_information8              in     varchar2 default null
  ,p_per_information9              in     varchar2 default null
  ,p_per_information10             in     varchar2 default null
  ,p_per_information11             in     varchar2 default null

  ,p_per_information12             in     varchar2 default null
  ,p_per_information13             in     varchar2 default null
  ,p_per_information14             in     varchar2 default null
  ,p_per_information15             in     varchar2 default null
  ,p_per_information16             in     varchar2 default null
  ,p_per_information17             in     varchar2 default null
  ,p_per_information18             in     varchar2 default null
  ,p_per_information19             in     varchar2 default null
  ,p_per_information20             in     varchar2 default null
  ,p_per_information21             in     varchar2 default null
  ,p_per_information22             in     varchar2 default null
  ,p_per_information23             in     varchar2 default null
  ,p_per_information24             in     varchar2 default null

  ,p_per_information25             in     varchar2 default null
  ,p_per_information26             in     varchar2 default null
  ,p_per_information27             in     varchar2 default null
  ,p_per_information28             in     varchar2 default null
  ,p_per_information29             in     varchar2 default null
  ,p_per_information30             in     varchar2 default null
  ,p_date_of_death                 in     date     default null
  ,p_background_check_status       in     varchar2 default null
  ,p_background_date_check         in     date     default null
  ,p_blood_type                    in     varchar2 default null
  ,p_correspondence_language       in     varchar2 default null
  ,p_fast_path_employee            in     varchar2 default null
  ,p_fte_capacity                  in     number   default null

  ,p_honors                        in     varchar2 default null
  ,p_internal_location             in     varchar2 default null
  ,p_last_medical_test_by          in     varchar2 default null
  ,p_last_medical_test_date        in     date     default null
  ,p_mailstop                      in     varchar2 default null
  ,p_office_number                 in     varchar2 default null
  ,p_on_military_service           in     varchar2 default null
  ,p_pre_name_adjunct              in     varchar2 default null
  ,p_rehire_recommendation        in     varchar2 default null  -- Bug 3210500
  ,p_projected_start_date          in     date     default null
  ,p_resume_exists                 in     varchar2 default null
  ,p_resume_last_updated           in     date     default null
  ,p_second_passport_exists        in     varchar2 default null

  ,p_student_status                in     varchar2 default null
  ,p_work_schedule                 in     varchar2 default null
  ,p_suffix                        in     varchar2 default null
  ,p_benefit_group_id              in     number   default null
  ,p_receipt_of_death_cert_date    in     date     default null
  ,p_coord_ben_med_pln_no          in     varchar2 default null
  ,p_coord_ben_no_cvg_flag         in     varchar2 default 'N'
  ,p_coord_ben_med_ext_er          in     varchar2 default null
  ,p_coord_ben_med_pl_name         in     varchar2 default null
  ,p_coord_ben_med_insr_crr_name   in     varchar2 default null
  ,p_coord_ben_med_insr_crr_ident  in     varchar2 default null
  ,p_coord_ben_med_cvg_strt_dt     in     date default null
  ,p_coord_ben_med_cvg_end_dt      in     date default null

  ,p_uses_tobacco_flag             in     varchar2 default null
  ,p_dpdnt_adoption_date           in     date     default null
  ,p_dpdnt_vlntry_svce_flag        in     varchar2 default 'N'
  ,p_original_date_of_hire         in     date     default null
  ,p_adjusted_svc_date             in     date     default null
  ,p_town_of_birth                 in     varchar2 default null
  ,p_region_of_birth               in     varchar2 default null
  ,p_country_of_birth              in     varchar2 default null
  ,p_global_person_id              in     varchar2 default null
  ,p_party_id                      in     number default null
  ,p_person_id                        out nocopy number
  ,p_assignment_id                    out nocopy number
  ,p_per_object_version_number        out nocopy number

  ,p_asg_object_version_number        out nocopy number
  ,p_per_effective_start_date         out nocopy date
  ,p_per_effective_end_date           out nocopy date
  ,p_full_name                        out nocopy varchar2
  ,p_per_comment_id                   out nocopy number
  ,p_assignment_sequence              out nocopy number
  ,p_assignment_number                out nocopy varchar2
  ,p_name_combination_warning         out nocopy boolean
  ,p_assign_payroll_warning           out nocopy boolean
  ,p_orig_hire_warning                out nocopy boolean
  )
is
  --

  -- Declare cursors and local variables
  --
  l_proc                        varchar2(72);
  l_person_type_id              per_person_types.person_type_id%type  := p_person_type_id;
  l_person_type_id1             per_person_types.person_type_id%type;
  l_person_id                   per_people_f.person_id%type;
  l_period_of_service_id        per_periods_of_service.period_of_service_id%type;
  l_employee_number             per_people_f.employee_number%type;
  l_emp_num per_people_f.employee_number%type := p_employee_number;
  l_applicant_number            per_people_f.applicant_number%TYPE;
  l_npw_number                  per_people_f.npw_number%TYPE;
  l_assignment_sequence         per_assignments_f.assignment_sequence%type;
  l_assignment_number           per_assignments_f.assignment_number%type;

  l_hire_date                   date;
  l_discard_number              number;
  l_discard_date                date;
  l_discard_varchar2            varchar2(30);
  l_assignment_id               number;
  l_per_object_version_number   number;
  l_asg_object_version_number   number;
  l_per_effective_start_date    date;
  l_per_effective_end_date      date;
  l_full_name                   per_people_f.full_name%type;
  l_per_comment_id              number;
  l_name_combination_warning    boolean;
  l_assign_payroll_warning      boolean;

  l_orig_hire_warning           boolean;
  l_date_employee_data_verified date;
  l_date_of_birth               date;
  l_phn_object_version_number  per_phones.object_version_number%TYPE;
  l_phone_id                   per_phones.phone_id%TYPE;
  l_date_of_death               date;
  l_receipt_of_death_cert_date  date;
  l_dpdnt_adoption_date         date;
  l_original_date_of_hire       date;
  l_adjusted_svc_date           date;
  --
begin
 if g_debug then

  l_proc := g_package||'create_employee';
  hr_utility.set_location('Entering:'|| l_proc, 10);
 end if;
  --
  -- Issue a savepoint.
  --
  savepoint create_employee;
  --
  --
  -- Truncate the time portion from all date parameters
  -- which are passed in.
  --
  l_hire_date                   := trunc(p_hire_date);

  l_date_employee_data_verified := trunc(p_date_employee_data_verified);
  l_date_of_birth               := trunc(p_date_of_birth);
  l_date_of_death               := trunc(p_date_of_death);
  l_receipt_of_death_cert_date  := trunc(p_receipt_of_death_cert_date);
  l_dpdnt_adoption_date         := trunc(p_dpdnt_adoption_date);
  l_original_date_of_hire       := trunc(p_original_date_of_hire);
  l_adjusted_svc_date           := trunc(p_adjusted_svc_date);
  --
  begin
    --
    -- Start of API User Hook for the before hook of create_employee
    --
    hr_employee_bk1.create_employee_b

      (p_hire_date                    => l_hire_date
      ,p_business_group_id            => p_business_group_id
      ,p_last_name                    => p_last_name
      ,p_sex                          => p_sex
      ,p_person_type_id               => p_person_type_id
      ,p_per_comments                 => p_per_comments
      ,p_date_employee_data_verified  => l_date_employee_data_verified
      ,p_date_of_birth                => l_date_of_birth
      ,p_email_address                => p_email_address
      ,p_employee_number              => p_employee_number
      ,p_expense_check_send_to_addres => p_expense_check_send_to_addres
      ,p_first_name                   => p_first_name
      ,p_known_as                     => p_known_as

      ,p_marital_status               => p_marital_status
      ,p_middle_names                 => p_middle_names
      ,p_nationality                  => p_nationality
      ,p_national_identifier          => p_national_identifier
      ,p_previous_last_name           => p_previous_last_name
      ,p_registered_disabled_flag     => p_registered_disabled_flag
      ,p_title                        => p_title
      ,p_vendor_id                    => p_vendor_id
      ,p_work_telephone               => p_work_telephone
      ,p_attribute_category           => p_attribute_category
      ,p_attribute1                   => p_attribute1
      ,p_attribute2                   => p_attribute2
      ,p_attribute3                   => p_attribute3

      ,p_attribute4                   => p_attribute4
      ,p_attribute5                   => p_attribute5
      ,p_attribute6                   => p_attribute6
      ,p_attribute7                   => p_attribute7
      ,p_attribute8                   => p_attribute8
      ,p_attribute9                   => p_attribute9
      ,p_attribute10                  => p_attribute10
      ,p_attribute11                  => p_attribute11
      ,p_attribute12                  => p_attribute12
      ,p_attribute13                  => p_attribute13
      ,p_attribute14                  => p_attribute14
      ,p_attribute15                  => p_attribute15
      ,p_attribute16                  => p_attribute16

      ,p_attribute17                  => p_attribute17
      ,p_attribute18                  => p_attribute18
      ,p_attribute19                  => p_attribute19
      ,p_attribute20                  => p_attribute20
      ,p_attribute21                  => p_attribute21
      ,p_attribute22                  => p_attribute22
      ,p_attribute23                  => p_attribute23
      ,p_attribute24                  => p_attribute24
      ,p_attribute25                  => p_attribute25
      ,p_attribute26                  => p_attribute26
      ,p_attribute27                  => p_attribute27
      ,p_attribute28                  => p_attribute28
      ,p_attribute29                  => p_attribute29

      ,p_attribute30                  => p_attribute30
      ,p_per_information_category     => p_per_information_category
      ,p_per_information1             => p_per_information1
      ,p_per_information2             => p_per_information2
      ,p_per_information3             => p_per_information3
      ,p_per_information4             => p_per_information4
      ,p_per_information5             => p_per_information5
      ,p_per_information6             => p_per_information6
      ,p_per_information7             => p_per_information7
      ,p_per_information8             => p_per_information8
      ,p_per_information9             => p_per_information9
      ,p_per_information10            => p_per_information10
      ,p_per_information11            => p_per_information11

      ,p_per_information12            => p_per_information12
      ,p_per_information13            => p_per_information13
      ,p_per_information14            => p_per_information14
      ,p_per_information15            => p_per_information15
      ,p_per_information16            => p_per_information16
      ,p_per_information17            => p_per_information17
      ,p_per_information18            => p_per_information18
      ,p_per_information19            => p_per_information19
      ,p_per_information20            => p_per_information20
      ,p_per_information21            => p_per_information21
      ,p_per_information22            => p_per_information22
      ,p_per_information23            => p_per_information23
      ,p_per_information24            => p_per_information24

      ,p_per_information25            => p_per_information25
      ,p_per_information26            => p_per_information26
      ,p_per_information27            => p_per_information27
      ,p_per_information28            => p_per_information28
      ,p_per_information29            => p_per_information29
      ,p_per_information30            => p_per_information30
      ,p_date_of_death                => l_date_of_death
      ,p_background_check_status      => p_background_check_status
      ,p_background_date_check        => p_background_date_check
      ,p_blood_type                   => p_blood_type
      ,p_correspondence_language      => p_correspondence_language
      ,p_fast_path_employee           => p_fast_path_employee
      ,p_fte_capacity                 => p_fte_capacity

      ,p_honors                       => p_honors
      ,p_internal_location            => p_internal_location
      ,p_last_medical_test_by         => p_last_medical_test_by
      ,p_last_medical_test_date       => p_last_medical_test_date
      ,p_mailstop                     => p_mailstop
      ,p_office_number                => p_office_number
      ,p_on_military_service          => p_on_military_service
      ,p_pre_name_adjunct             => p_pre_name_adjunct
      ,p_rehire_recommendation           => p_rehire_recommendation  -- Bug 3210500
      ,p_projected_start_date         => p_projected_start_date
      ,p_resume_exists                => p_resume_exists
      ,p_resume_last_updated          => p_resume_last_updated
      ,p_second_passport_exists       => p_second_passport_exists

      ,p_student_status               => p_student_status
      ,p_work_schedule                => p_work_schedule
      ,p_suffix                       => p_suffix
      ,p_benefit_group_id             => p_benefit_group_id
      ,p_receipt_of_death_cert_date   => l_receipt_of_death_cert_date
      ,p_coord_ben_med_pln_no         => p_coord_ben_med_pln_no
      ,p_coord_ben_no_cvg_flag        => p_coord_ben_no_cvg_flag
      ,p_coord_ben_med_ext_er         => p_coord_ben_med_ext_er
      ,p_coord_ben_med_pl_name        => p_coord_ben_med_pl_name
      ,p_coord_ben_med_insr_crr_name  => p_coord_ben_med_insr_crr_name
      ,p_coord_ben_med_insr_crr_ident => p_coord_ben_med_insr_crr_ident
      ,p_coord_ben_med_cvg_strt_dt    => p_coord_ben_med_cvg_strt_dt
      ,p_coord_ben_med_cvg_end_dt     => p_coord_ben_med_cvg_end_dt

      ,p_uses_tobacco_flag            => p_uses_tobacco_flag
      ,p_dpdnt_adoption_date          => l_dpdnt_adoption_date
      ,p_dpdnt_vlntry_svce_flag       => p_dpdnt_vlntry_svce_flag
      ,p_original_date_of_hire        => l_original_date_of_hire
      ,p_adjusted_svc_date            => l_adjusted_svc_date
      ,p_town_of_birth                => p_town_of_birth
      ,p_region_of_birth              => p_region_of_birth
      ,p_country_of_birth             => p_country_of_birth
      ,p_global_person_id             => p_global_person_id
      ,p_party_id                     => p_party_id
      );
  exception
    when hr_api.cannot_find_prog_unit then

      hr_api.cannot_find_prog_unit_error
        (p_module_name => 'CREATE_EMPLOYEE'
        ,p_hook_type   => 'BP'
        );
    --
    -- End of API User Hook for the before hook of create_employee
    --
  end;
  --
 if g_debug then
  hr_utility.set_location(l_proc, 20);
 end if;
  --

  -- Truncate the time portion from all date parameters
  -- which are passed in.
  --
  l_hire_date                   := trunc(p_hire_date);
  --
  -- Set the original hire date to sysdate if not passed in.

  if (l_original_date_of_hire is null) THEN
    l_original_date_of_hire       := l_hire_date;
  end if;

  --
  -- Validation in addition to Row Handlers

  --
  -- If the specified person type id is not null then check that it
  -- corresponds to type 'EMP', is currently active and is in the correct
  -- business group, otherwise set person type to the active default for EMP
  -- in the current business group.
  --
  per_per_bus.chk_person_type
    (p_person_type_id    => l_person_type_id
    ,p_business_group_id => p_business_group_id
    ,p_expected_sys_type => 'EMP'
    );
 if g_debug then
  hr_utility.set_location(l_proc, 30);

 end if;
  --
  -- Initialise local variables as appropriate
  --
  l_applicant_number := null;
  l_npw_number := null;
  l_employee_number  := p_employee_number;
  --
-- PTU : Changes

  l_person_type_id1   := hr_person_type_usage_info.get_default_person_type_id
                                         (p_business_group_id,
                                          'EMP');

-- PTU : End of Changes

  -- Create the person details
  --
  per_per_ins.ins
    (p_business_group_id            => p_business_group_id
    ,p_person_type_id               => l_person_type_id1
    ,p_last_name                    => p_last_name
    ,p_start_date                   => l_hire_date
    ,p_effective_date          => l_hire_date
    --
    ,p_comments                     => p_per_comments
    ,p_date_employee_data_verified  => l_date_employee_data_verified

    ,p_date_of_birth                => l_date_of_birth
    ,p_email_address                => p_email_address
    ,p_expense_check_send_to_addres => p_expense_check_send_to_addres
    ,p_first_name                   => p_first_name
    ,p_known_as                     => p_known_as
    ,p_marital_status               => p_marital_status
    ,p_middle_names                 => p_middle_names
    ,p_nationality                  => p_nationality
    ,p_national_identifier          => p_national_identifier
    ,p_previous_last_name           => p_previous_last_name
    ,p_registered_disabled_flag     => p_registered_disabled_flag
    ,p_sex                          => p_sex
    ,p_title                        => p_title

    ,p_vendor_id                    => p_vendor_id
--  ,p_work_telephone               => p_work_telephone -- Now Handled by Create_phone
    ,p_attribute_category           => p_attribute_category
    ,p_attribute1                   => p_attribute1
    ,p_attribute2                   => p_attribute2
    ,p_attribute3                   => p_attribute3
    ,p_attribute4                   => p_attribute4
    ,p_attribute5                   => p_attribute5
    ,p_attribute6                   => p_attribute6
    ,p_attribute7                   => p_attribute7
    ,p_attribute8                   => p_attribute8
    ,p_attribute9                   => p_attribute9
    ,p_attribute10                  => p_attribute10

    ,p_attribute11                  => p_attribute11
    ,p_attribute12                  => p_attribute12
    ,p_attribute13                  => p_attribute13
    ,p_attribute14                  => p_attribute14
    ,p_attribute15                  => p_attribute15
    ,p_attribute16                  => p_attribute16
    ,p_attribute17                  => p_attribute17
    ,p_attribute18                  => p_attribute18
    ,p_attribute19                  => p_attribute19
    ,p_attribute20                  => p_attribute20
    ,p_attribute21                  => p_attribute21
    ,p_attribute22                  => p_attribute22
    ,p_attribute23                  => p_attribute23

    ,p_attribute24                  => p_attribute24
    ,p_attribute25                  => p_attribute25
    ,p_attribute26                  => p_attribute26
    ,p_attribute27                  => p_attribute27
    ,p_attribute28                  => p_attribute28
    ,p_attribute29                  => p_attribute29
    ,p_attribute30                  => p_attribute30
    ,p_per_information_category     => p_per_information_category
    ,p_per_information1             => p_per_information1
    ,p_per_information2             => p_per_information2
    ,p_per_information3             => p_per_information3
    ,p_per_information4             => p_per_information4
    ,p_per_information5             => p_per_information5

    ,p_per_information6             => p_per_information6
    ,p_per_information7             => p_per_information7
    ,p_per_information8             => p_per_information8
    ,p_per_information9             => p_per_information9
    ,p_per_information10            => p_per_information10
    ,p_per_information11            => p_per_information11
    ,p_per_information12            => p_per_information12
    ,p_per_information13            => p_per_information13
    ,p_per_information14            => p_per_information14
    ,p_per_information15            => p_per_information15
    ,p_per_information16            => p_per_information16
    ,p_per_information17            => p_per_information17
    ,p_per_information18            => p_per_information18

    ,p_per_information19            => p_per_information19
    ,p_per_information20            => p_per_information20
    ,p_per_information21            => p_per_information21
    ,p_per_information22            => p_per_information22
    ,p_per_information23            => p_per_information23
    ,p_per_information24            => p_per_information24
    ,p_per_information25            => p_per_information25
    ,p_per_information26            => p_per_information26
    ,p_per_information27            => p_per_information27
    ,p_per_information28            => p_per_information28
    ,p_per_information29            => p_per_information29
    ,p_per_information30            => p_per_information30
    ,p_date_of_death                => l_date_of_death

    ,p_background_check_status      => p_background_check_status
    ,p_background_date_check        => p_background_date_check
    ,p_blood_type                   => p_blood_type
    ,p_correspondence_language      => p_correspondence_language
    ,p_fast_path_employee           => p_fast_path_employee
    ,p_fte_capacity                 => p_fte_capacity
    ,p_honors                       => p_honors
    ,p_internal_location            => p_internal_location
    ,p_last_medical_test_by         => p_last_medical_test_by
    ,p_last_medical_test_date       => p_last_medical_test_date
    ,p_mailstop                     => p_mailstop
    ,p_office_number                => p_office_number
    ,p_on_military_service          => p_on_military_service

    ,p_pre_name_adjunct             => p_pre_name_adjunct
    ,p_projected_start_date         => p_projected_start_date
    ,p_rehire_recommendation        => p_rehire_recommendation  -- Bug 3210500
    ,p_resume_exists                => p_resume_exists
    ,p_resume_last_updated          => p_resume_last_updated
    ,p_second_passport_exists       => p_second_passport_exists
    ,p_student_status               => p_student_status
    ,p_work_schedule                => p_work_schedule
    ,p_suffix                       => p_suffix
    ,p_benefit_group_id             => p_benefit_group_id
    ,p_receipt_of_death_cert_date   => l_receipt_of_death_cert_date
    ,p_coord_ben_med_pln_no         => p_coord_ben_med_pln_no
    ,p_coord_ben_no_cvg_flag        => p_coord_ben_no_cvg_flag

    ,p_coord_ben_med_ext_er         => p_coord_ben_med_ext_er
    ,p_coord_ben_med_pl_name        => p_coord_ben_med_pl_name
    ,p_coord_ben_med_insr_crr_name  => p_coord_ben_med_insr_crr_name
    ,p_coord_ben_med_insr_crr_ident => p_coord_ben_med_insr_crr_ident
    ,p_coord_ben_med_cvg_strt_dt    => p_coord_ben_med_cvg_strt_dt
    ,p_coord_ben_med_cvg_end_dt     => p_coord_ben_med_cvg_end_dt
    ,p_uses_tobacco_flag            => p_uses_tobacco_flag
    ,p_dpdnt_adoption_date          => l_dpdnt_adoption_date
    ,p_dpdnt_vlntry_svce_flag       => p_dpdnt_vlntry_svce_flag
    ,p_original_date_of_hire        => l_original_date_of_hire
    ,p_town_of_birth                => p_town_of_birth
    ,p_region_of_birth              => p_region_of_birth
    ,p_country_of_birth             => p_country_of_birth

    ,p_global_person_id             => p_global_person_id
    ,p_party_id                     => p_party_id
    ,p_validate             => false
    --
    ,p_applicant_number             => l_applicant_number
    ,p_employee_number              => p_employee_number

    ,p_person_id                    => l_person_id
    ,p_effective_start_date         => l_per_effective_start_date
    ,p_effective_end_date           => l_per_effective_end_date
    ,p_comment_id                   => l_per_comment_id
    ,p_current_applicant_flag       => l_discard_varchar2
    ,p_current_emp_or_apl_flag      => l_discard_varchar2

    ,p_current_employee_flag        => l_discard_varchar2
    ,p_full_name                    => l_full_name
    ,p_object_version_number        => l_per_object_version_number
    ,p_name_combination_warning     => l_name_combination_warning
    ,p_dob_null_warning             => l_assign_payroll_warning
    ,p_orig_hire_warning            => l_orig_hire_warning
    ,p_npw_number                   => l_npw_number
    );
  --
 if g_debug then
  hr_utility.set_location(l_proc, 40);
 end if;
  --

  -- insert the person in to the security list
  --
  hr_security_internal.populate_new_person(p_business_group_id,l_person_id);
  --
-- PTU : Following Code has been added

hr_per_type_usage_internal.maintain_person_type_usage
(p_effective_date       => l_hire_date
,p_person_id            => l_person_id
,p_person_type_id       => l_person_type_id
);

-- PTU : End of changes


 if g_debug then
  hr_utility.set_location(l_proc, 50);
 end if;
  --
  -- Create the period of service record
  --
  per_pds_ins.ins
    (p_business_group_id            => p_business_group_id
    ,p_person_id                    => l_person_id
    ,p_date_start                   => l_hire_date
    ,p_effective_date               => l_hire_date
    ,p_adjusted_svc_date            => l_adjusted_svc_date

    --
    ,p_validate                     => false
    ,p_validate_df_flex             => false
    --
    ,p_period_of_service_id         => l_period_of_service_id
    ,p_object_version_number        => l_discard_number
    );
 if g_debug then
  hr_utility.set_location(l_proc, 50);
 end if;
  --
  -- Create the default primary employee assignment
  --

  hr_assignment_internal.create_default_emp_asg
    (p_effective_date                => l_hire_date
    ,p_person_id                     => l_person_id
    ,p_business_group_id             => p_business_group_id
    ,p_period_of_service_id          => l_period_of_service_id
    --
    ,p_assignment_id                 => l_assignment_id
    ,p_object_version_number         => l_asg_object_version_number
    ,p_assignment_sequence           => l_assignment_sequence
    ,p_assignment_number             => l_assignment_number
    );
 if g_debug then
  hr_utility.set_location(l_proc, 60);

 end if;
    --
  -- Create a phone row using the newly created person as the parent row.
  -- This phone row replaces the work_telephone column on the person.
  --
  if p_work_telephone is not null then
     hr_phone_api.create_phone
       (p_date_from                 => l_hire_date
       ,p_date_to                   => null
       ,p_phone_type                => 'W1'
       ,p_phone_number              => p_work_telephone
       ,p_parent_id                 => l_person_id
       ,p_parent_table              => 'PER_ALL_PEOPLE_F'

       ,p_validate                  => FALSE
       ,p_effective_date            => l_hire_date
       ,p_object_version_number     => l_phn_object_version_number  --out
       ,p_phone_id                  => l_phone_id                   --out
       );
  end if;
  --
  begin
    --
    -- Start of API User Hook for the after hook of create_employee
    --
    hr_employee_bk1.create_employee_a
      (p_hire_date                    => l_hire_date

      ,p_business_group_id            => p_business_group_id
      ,p_last_name                    => p_last_name
      ,p_sex                          => p_sex
      ,p_person_type_id               => p_person_type_id
      ,p_per_comments                 => p_per_comments
      ,p_date_employee_data_verified  => l_date_employee_data_verified
      ,p_date_of_birth                => l_date_of_birth
      ,p_email_address                => p_email_address
      ,p_employee_number              => p_employee_number
      ,p_expense_check_send_to_addres => p_expense_check_send_to_addres
      ,p_first_name                   => p_first_name
      ,p_known_as                     => p_known_as
      ,p_marital_status               => p_marital_status

      ,p_middle_names                 => p_middle_names
      ,p_nationality                  => p_nationality
      ,p_national_identifier          => p_national_identifier
      ,p_previous_last_name           => p_previous_last_name
      ,p_registered_disabled_flag     => p_registered_disabled_flag
      ,p_title                        => p_title
      ,p_vendor_id                    => p_vendor_id
      ,p_work_telephone               => p_work_telephone
      ,p_attribute_category           => p_attribute_category
      ,p_attribute1                   => p_attribute1
      ,p_attribute2                   => p_attribute2
      ,p_attribute3                   => p_attribute3
      ,p_attribute4                   => p_attribute4

      ,p_attribute5                   => p_attribute5
      ,p_attribute6                   => p_attribute6
      ,p_attribute7                   => p_attribute7
      ,p_attribute8                   => p_attribute8
      ,p_attribute9                   => p_attribute9
      ,p_attribute10                  => p_attribute10
      ,p_attribute11                  => p_attribute11
      ,p_attribute12                  => p_attribute12
      ,p_attribute13                  => p_attribute13
      ,p_attribute14                  => p_attribute14
      ,p_attribute15                  => p_attribute15
      ,p_attribute16                  => p_attribute16
      ,p_attribute17                  => p_attribute17

      ,p_attribute18                  => p_attribute18
      ,p_attribute19                  => p_attribute19
      ,p_attribute20                  => p_attribute20
      ,p_attribute21                  => p_attribute21
      ,p_attribute22                  => p_attribute22
      ,p_attribute23                  => p_attribute23
      ,p_attribute24                  => p_attribute24
      ,p_attribute25                  => p_attribute25
      ,p_attribute26                  => p_attribute26
      ,p_attribute27                  => p_attribute27
      ,p_attribute28                  => p_attribute28
      ,p_attribute29                  => p_attribute29
      ,p_attribute30                  => p_attribute30

      ,p_per_information_category     => p_per_information_category
      ,p_per_information1             => p_per_information1
      ,p_per_information2             => p_per_information2
      ,p_per_information3             => p_per_information3
      ,p_per_information4             => p_per_information4
      ,p_per_information5             => p_per_information5
      ,p_per_information6             => p_per_information6
      ,p_per_information7             => p_per_information7
      ,p_per_information8             => p_per_information8
      ,p_per_information9             => p_per_information9
      ,p_per_information10            => p_per_information10
      ,p_per_information11            => p_per_information11
      ,p_per_information12            => p_per_information12

      ,p_per_information13            => p_per_information13
      ,p_per_information14            => p_per_information14
      ,p_per_information15            => p_per_information15
      ,p_per_information16            => p_per_information16
      ,p_per_information17            => p_per_information17
      ,p_per_information18            => p_per_information18
      ,p_per_information19            => p_per_information19
      ,p_per_information20            => p_per_information20
      ,p_per_information21            => p_per_information21
      ,p_per_information22            => p_per_information22
      ,p_per_information23            => p_per_information23
      ,p_per_information24            => p_per_information24
      ,p_per_information25            => p_per_information25

      ,p_per_information26            => p_per_information26
      ,p_per_information27            => p_per_information27
      ,p_per_information28            => p_per_information28
      ,p_per_information29            => p_per_information29
      ,p_per_information30            => p_per_information30
      ,p_date_of_death                => l_date_of_death
      ,p_background_check_status      => p_background_check_status
      ,p_background_date_check        => p_background_date_check
      ,p_blood_type                   => p_blood_type
      ,p_correspondence_language      => p_correspondence_language
      ,p_fast_path_employee           => p_fast_path_employee
      ,p_fte_capacity                 => p_fte_capacity
      ,p_honors                       => p_honors

      ,p_internal_location            => p_internal_location
      ,p_last_medical_test_by         => p_last_medical_test_by
      ,p_last_medical_test_date       => p_last_medical_test_date
      ,p_mailstop                     => p_mailstop
      ,p_office_number                => p_office_number
      ,p_on_military_service          => p_on_military_service
      ,p_pre_name_adjunct             => p_pre_name_adjunct
      ,p_projected_start_date         => p_projected_start_date
      ,p_rehire_recommendation          => p_rehire_recommendation  -- Bug 3210500
      ,p_resume_exists                => p_resume_exists
      ,p_resume_last_updated          => p_resume_last_updated
      ,p_second_passport_exists       => p_second_passport_exists
      ,p_student_status               => p_student_status

      ,p_work_schedule                => p_work_schedule
      ,p_suffix                       => p_suffix
      ,p_benefit_group_id             => p_benefit_group_id
      ,p_receipt_of_death_cert_date   => l_receipt_of_death_cert_date
      ,p_coord_ben_med_pln_no         => p_coord_ben_med_pln_no
      ,p_coord_ben_no_cvg_flag        => p_coord_ben_no_cvg_flag
      ,p_coord_ben_med_ext_er         => p_coord_ben_med_ext_er
      ,p_coord_ben_med_pl_name        => p_coord_ben_med_pl_name
      ,p_coord_ben_med_insr_crr_name  => p_coord_ben_med_insr_crr_name
      ,p_coord_ben_med_insr_crr_ident => p_coord_ben_med_insr_crr_ident
      ,p_coord_ben_med_cvg_strt_dt    => p_coord_ben_med_cvg_strt_dt
      ,p_coord_ben_med_cvg_end_dt     => p_coord_ben_med_cvg_end_dt
      ,p_uses_tobacco_flag            => p_uses_tobacco_flag

      ,p_dpdnt_adoption_date          => l_dpdnt_adoption_date
      ,p_dpdnt_vlntry_svce_flag       => p_dpdnt_vlntry_svce_flag
      ,p_original_date_of_hire        => l_original_date_of_hire
      ,p_adjusted_svc_date            => l_adjusted_svc_date
      ,p_person_id                    => l_person_id
      ,p_assignment_id                => l_assignment_id
      ,p_per_object_version_number    => l_per_object_version_number
      ,p_asg_object_version_number    => l_asg_object_version_number
      ,p_per_effective_start_date     => l_per_effective_start_date
      ,p_per_effective_end_date       => l_per_effective_end_date
      ,p_full_name                    => l_full_name
      ,p_per_comment_id               => l_per_comment_id
      ,p_assignment_sequence          => l_assignment_sequence

      ,p_assignment_number            => l_assignment_number
      ,p_town_of_birth                => p_town_of_birth
      ,p_region_of_birth              => p_region_of_birth
      ,p_country_of_birth             => p_country_of_birth
      ,p_global_person_id             => p_global_person_id
      ,p_party_id                     => p_party_id
      ,p_name_combination_warning     => l_name_combination_warning
      ,p_assign_payroll_warning       => l_assign_payroll_warning
      ,p_orig_hire_warning            => l_orig_hire_warning
      );
  exception
    when hr_api.cannot_find_prog_unit then
      hr_api.cannot_find_prog_unit_error

        (p_module_name => 'CREATE_EMPLOYEE'
        ,p_hook_type   => 'AP'
        );
    --
    -- End of API User Hook for the after hook of create_employee
    --
  end;
  --
  -- Set all output arguments
  --
  p_person_id                 := l_person_id;
  p_assignment_sequence       := l_assignment_sequence;
  p_assignment_number         := l_assignment_number;

  p_assignment_id             := l_assignment_id;
  p_per_object_version_number := l_per_object_version_number;
  p_asg_object_version_number := l_asg_object_version_number;
  p_per_effective_start_date  := l_per_effective_start_date;
  p_per_effective_end_date    := l_per_effective_end_date;
  p_full_name                 := l_full_name;
  p_per_comment_id            := l_per_comment_id;
  p_name_combination_warning  := l_name_combination_warning;
  p_assign_payroll_warning    := l_assign_payroll_warning;
  p_orig_hire_warning         := l_orig_hire_warning;
  --
  -- When in validation only mode raise the Validate_Enabled exception
  --

  if p_validate then
    raise hr_api.validate_enabled;
  end if;
  --
 if g_debug then
  hr_utility.set_location(' Leaving:'||l_proc, 70);
 end if;
exception
  when hr_api.validate_enabled then
    --
    -- As the Validate_Enabled exception has been raised
    -- we must rollback to the savepoint
    --

    ROLLBACK TO create_employee;
    --
    -- Only set output warning arguments
    -- (Any key or derived arguments must be set to null
    -- when validation only mode is being used.)
    --
    p_employee_number           := l_employee_number;
    p_person_id                 := null;
    p_assignment_id             := null;
    p_per_object_version_number := null;
    p_asg_object_version_number := null;
    p_per_effective_start_date  := null;
    p_per_effective_end_date    := null;

    p_full_name                 := null;
    p_per_comment_id            := null;
    p_assignment_sequence       := null;
    p_assignment_number         := null;
    p_name_combination_warning  := FALSE;
    p_assign_payroll_warning    := FALSE;
    p_orig_hire_warning         := FALSE;
    --
  when others then
    --
    -- A validation or unexpected error has occurred
    --
    -- Added as part of fix to bug 632479

    --
    ROLLBACK TO create_employee;
    --
    -- set in out parameters and set out parameters
    --
    p_employee_number           := l_emp_num;
    p_person_id                 := null;
    p_assignment_id             := null;
    p_per_object_version_number := null;
    p_asg_object_version_number := null;
    p_per_effective_start_date  := null;
    p_per_effective_end_date    := null;
    p_full_name                 := null;

    p_per_comment_id            := null;
    p_assignment_sequence       := null;
    p_assignment_number         := null;
    p_name_combination_warning  := FALSE;
    p_assign_payroll_warning    := FALSE;
    p_orig_hire_warning         := FALSE;
    raise;
    --
    -- End of fix.
    --
end create_employee;
-- --------------------------------------------------------------------------
--

-- Begin fix for bug 899720
--
-- overload procedure for create_employee
--
procedure create_employee
  (p_validate                      in     boolean  default false
  ,p_hire_date                     in     date
  ,p_business_group_id             in     number
  ,p_last_name                     in     varchar2
  ,p_sex                           in     varchar2
  ,p_person_type_id                in     number   default null
  ,p_per_comments                  in     varchar2 default null
  ,p_date_employee_data_verified   in     date     default null

  ,p_date_of_birth                 in     date     default null
  ,p_email_address                 in     varchar2 default null
  ,p_employee_number               in out nocopy varchar2
  ,p_expense_check_send_to_addres  in     varchar2 default null
  ,p_first_name                    in     varchar2 default null
  ,p_known_as                      in     varchar2 default null
  ,p_marital_status                in     varchar2 default null
  ,p_middle_names                  in     varchar2 default null
  ,p_nationality                   in     varchar2 default null
  ,p_national_identifier           in     varchar2 default null
  ,p_previous_last_name            in     varchar2 default null
  ,p_registered_disabled_flag      in     varchar2 default null
  ,p_title                         in     varchar2 default null

  ,p_vendor_id                     in     number   default null
  ,p_work_telephone                in     varchar2 default null
  ,p_attribute_category            in     varchar2 default null
  ,p_attribute1                    in     varchar2 default null
  ,p_attribute2                    in     varchar2 default null
  ,p_attribute3                    in     varchar2 default null
  ,p_attribute4                    in     varchar2 default null
  ,p_attribute5                    in     varchar2 default null
  ,p_attribute6                    in     varchar2 default null
  ,p_attribute7                    in     varchar2 default null
  ,p_attribute8                    in     varchar2 default null
  ,p_attribute9                    in     varchar2 default null
  ,p_attribute10                   in     varchar2 default null

  ,p_attribute11                   in     varchar2 default null
  ,p_attribute12                   in     varchar2 default null
  ,p_attribute13                   in     varchar2 default null
  ,p_attribute14                   in     varchar2 default null
  ,p_attribute15                   in     varchar2 default null
  ,p_attribute16                   in     varchar2 default null
  ,p_attribute17                   in     varchar2 default null
  ,p_attribute18                   in     varchar2 default null
  ,p_attribute19                   in     varchar2 default null
  ,p_attribute20                   in     varchar2 default null
  ,p_attribute21                   in     varchar2 default null
  ,p_attribute22                   in     varchar2 default null
  ,p_attribute23                   in     varchar2 default null

  ,p_attribute24                   in     varchar2 default null
  ,p_attribute25                   in     varchar2 default null
  ,p_attribute26                   in     varchar2 default null
  ,p_attribute27                   in     varchar2 default null
  ,p_attribute28                   in     varchar2 default null
  ,p_attribute29                   in     varchar2 default null
  ,p_attribute30                   in     varchar2 default null
  ,p_per_information_category      in     varchar2 default null
  ,p_per_information1              in     varchar2 default null
  ,p_per_information2              in     varchar2 default null
  ,p_per_information3              in     varchar2 default null
  ,p_per_information4              in     varchar2 default null
  ,p_per_information5              in     varchar2 default null

  ,p_per_information6              in     varchar2 default null
  ,p_per_information7              in     varchar2 default null
  ,p_per_information8              in     varchar2 default null
  ,p_per_information9              in     varchar2 default null
  ,p_per_information10             in     varchar2 default null
  ,p_per_information11             in     varchar2 default null
  ,p_per_information12             in     varchar2 default null
  ,p_per_information13             in     varchar2 default null
  ,p_per_information14             in     varchar2 default null
  ,p_per_information15             in     varchar2 default null
  ,p_per_information16             in     varchar2 default null
  ,p_per_information17             in     varchar2 default null
  ,p_per_information18             in     varchar2 default null

  ,p_per_information19             in     varchar2 default null
  ,p_per_information20             in     varchar2 default null
  ,p_per_information21             in     varchar2 default null
  ,p_per_information22             in     varchar2 default null
  ,p_per_information23             in     varchar2 default null
  ,p_per_information24             in     varchar2 default null
  ,p_per_information25             in     varchar2 default null
  ,p_per_information26             in     varchar2 default null
  ,p_per_information27             in     varchar2 default null
  ,p_per_information28             in     varchar2 default null
  ,p_per_information29             in     varchar2 default null
  ,p_per_information30             in     varchar2 default null
  ,p_date_of_death                 in     date     default null

  ,p_background_check_status       in     varchar2 default null
  ,p_background_date_check         in     date     default null
  ,p_blood_type                    in     varchar2 default null
  ,p_correspondence_language       in     varchar2 default null
  ,p_fast_path_employee            in     varchar2 default null
  ,p_fte_capacity                  in     number   default null
  ,p_honors                        in     varchar2 default null
  ,p_internal_location             in     varchar2 default null
  ,p_last_medical_test_by          in     varchar2 default null
  ,p_last_medical_test_date        in     date     default null
  ,p_mailstop                      in     varchar2 default null
  ,p_office_number                 in     varchar2 default null
  ,p_on_military_service           in     varchar2 default null

  ,p_pre_name_adjunct              in     varchar2 default null
  ,p_rehire_recommendation       in     varchar2 default null  -- Bug3210500
  ,p_projected_start_date          in     date     default null
  ,p_resume_exists                 in     varchar2 default null
  ,p_resume_last_updated           in     date     default null
  ,p_second_passport_exists        in     varchar2 default null
  ,p_student_status                in     varchar2 default null
  ,p_work_schedule                 in     varchar2 default null
  ,p_suffix                        in     varchar2 default null
  ,p_benefit_group_id              in     number   default null
  ,p_receipt_of_death_cert_date    in     date     default null
  ,p_coord_ben_med_pln_no          in     varchar2 default null
  ,p_coord_ben_no_cvg_flag         in     varchar2 default 'N'

  ,p_coord_ben_med_ext_er          in     varchar2 default null
  ,p_coord_ben_med_pl_name         in     varchar2 default null
  ,p_coord_ben_med_insr_crr_name   in     varchar2 default null
  ,p_coord_ben_med_insr_crr_ident  in     varchar2 default null
  ,p_coord_ben_med_cvg_strt_dt     in     date     default null
  ,p_coord_ben_med_cvg_end_dt      in     date     default null
  ,p_uses_tobacco_flag             in     varchar2 default null
  ,p_dpdnt_adoption_date           in     date     default null
  ,p_dpdnt_vlntry_svce_flag        in     varchar2 default 'N'
  ,p_original_date_of_hire         in     date     default null
  ,p_adjusted_svc_date             in     date     default null
  ,p_town_of_birth                 in     varchar2 default null
  ,p_region_of_birth               in     varchar2 default null

  ,p_country_of_birth              in     varchar2 default null
  ,p_global_person_id              in     varchar2 default null
  ,p_party_id                      in     number default null
  ,p_person_id                        out nocopy number
  ,p_assignment_id                    out nocopy number
  ,p_per_object_version_number        out nocopy number
  ,p_asg_object_version_number        out nocopy number
  ,p_per_effective_start_date         out nocopy date
  ,p_per_effective_end_date           out nocopy date
  ,p_full_name                        out nocopy varchar2
  ,p_per_comment_id                   out nocopy number
  ,p_assignment_sequence              out nocopy number
  ,p_assignment_number                out nocopy varchar2

  ,p_name_combination_warning         out nocopy boolean
  ,p_assign_payroll_warning           out nocopy boolean
  )
is
--
-- Declare cursors and local variables
--
l_proc                        varchar2(72);
l_orig_hire_warning           boolean := false;
--
begin
--
 if g_debug then

 l_proc := g_package||'create_employee';
hr_utility.set_location('Entering:'||l_proc,111);
 end if;
--
  hr_employee_api.create_employee
  (p_validate                     => p_validate
  ,p_hire_date                    => p_hire_date
  ,p_business_group_id            => p_business_group_id
  ,p_last_name                    => p_last_name
  ,p_sex                          => p_sex
  ,p_person_type_id               => p_person_type_id
  ,p_per_comments                 => p_per_comments
  ,p_date_employee_data_verified  => p_date_employee_data_verified

  ,p_date_of_birth                => p_date_of_birth
  ,p_email_address                => p_email_address
  ,p_employee_number              => p_employee_number
  ,p_expense_check_send_to_addres => p_expense_check_send_to_addres
  ,p_first_name                   => p_first_name
  ,p_known_as                     => p_known_as
  ,p_marital_status               => p_marital_status
  ,p_middle_names                 => p_middle_names
  ,p_nationality                  => p_nationality
  ,p_national_identifier          => p_national_identifier
  ,p_previous_last_name           => p_previous_last_name
  ,p_registered_disabled_flag     => p_registered_disabled_flag
  ,p_title                        => p_title

  ,p_vendor_id                    => p_vendor_id
  ,p_work_telephone               => p_work_telephone
  ,p_attribute_category           => p_attribute_category
  ,p_attribute1                   => p_attribute1
  ,p_attribute2                   => p_attribute2
  ,p_attribute3                   => p_attribute3
  ,p_attribute4                   => p_attribute4
  ,p_attribute5                   => p_attribute5
  ,p_attribute6                   => p_attribute6
  ,p_attribute7                   => p_attribute7
  ,p_attribute8                   => p_attribute8
  ,p_attribute9                   => p_attribute9
  ,p_attribute10                  => p_attribute10

  ,p_attribute11                  => p_attribute11
  ,p_attribute12                  => p_attribute12
  ,p_attribute13                  => p_attribute13
  ,p_attribute14                  => p_attribute14
  ,p_attribute15                  => p_attribute15
  ,p_attribute16                  => p_attribute16
  ,p_attribute17                  => p_attribute17
  ,p_attribute18                  => p_attribute18
  ,p_attribute19                  => p_attribute19
  ,p_attribute20                  => p_attribute20
  ,p_attribute21                  => p_attribute21
  ,p_attribute22                  => p_attribute22
  ,p_attribute23                  => p_attribute23

  ,p_attribute24                  => p_attribute24
  ,p_attribute25                  => p_attribute25
  ,p_attribute26                  => p_attribute26
  ,p_attribute27                  => p_attribute27
  ,p_attribute28                  => p_attribute28
  ,p_attribute29                  => p_attribute29
  ,p_attribute30                  => p_attribute30
  ,p_per_information_category     => p_per_information_category
  ,p_per_information1             => p_per_information1
  ,p_per_information2             => p_per_information2
  ,p_per_information3             => p_per_information3
  ,p_per_information4             => p_per_information4
  ,p_per_information5             => p_per_information5

  ,p_per_information6             => p_per_information6
  ,p_per_information7             => p_per_information7
  ,p_per_information8             => p_per_information8
  ,p_per_information9             => p_per_information9
  ,p_per_information10            => p_per_information10
  ,p_per_information11            => p_per_information11
  ,p_per_information12            => p_per_information12
  ,p_per_information13            => p_per_information13
  ,p_per_information14            => p_per_information14
  ,p_per_information15            => p_per_information15
  ,p_per_information16            => p_per_information16
  ,p_per_information17            => p_per_information17
  ,p_per_information18            => p_per_information18

  ,p_per_information19            => p_per_information19
  ,p_per_information20            => p_per_information20
  ,p_per_information21            => p_per_information21
  ,p_per_information22            => p_per_information22
  ,p_per_information23            => p_per_information23
  ,p_per_information24            => p_per_information24
  ,p_per_information25            => p_per_information25
  ,p_per_information26            => p_per_information26
  ,p_per_information27            => p_per_information27
  ,p_per_information28            => p_per_information28
  ,p_per_information29            => p_per_information29
  ,p_per_information30            => p_per_information30
  ,p_date_of_death                => p_date_of_death

  ,p_background_check_status      => p_background_check_status
  ,p_background_date_check        => p_background_date_check
  ,p_blood_type                   => p_blood_type
  ,p_correspondence_language      => p_correspondence_language
  ,p_fast_path_employee           => p_fast_path_employee
  ,p_fte_capacity                 => p_fte_capacity
  ,p_honors                       => p_honors
  ,p_internal_location            => p_internal_location
  ,p_last_medical_test_by         => p_last_medical_test_by
  ,p_last_medical_test_date       => p_last_medical_test_date
  ,p_mailstop                     => p_mailstop
  ,p_office_number                => p_office_number
  ,p_on_military_service          => p_on_military_service

  ,p_pre_name_adjunct             => p_pre_name_adjunct
  ,p_rehire_recommendation      => p_rehire_recommendation  -- Bug 3210500
  ,p_projected_start_date         => p_projected_start_date
  ,p_resume_exists                => p_resume_exists
  ,p_resume_last_updated          => p_resume_last_updated
  ,p_second_passport_exists       => p_second_passport_exists
  ,p_student_status               => p_student_status
  ,p_work_schedule                => p_work_schedule
  ,p_suffix                       => p_suffix
  ,p_benefit_group_id             => p_benefit_group_id
  ,p_receipt_of_death_cert_date   => p_receipt_of_death_cert_date
  ,p_coord_ben_med_pln_no         => p_coord_ben_med_pln_no
  ,p_coord_ben_no_cvg_flag        => p_coord_ben_no_cvg_flag

  ,p_coord_ben_med_ext_er         => p_coord_ben_med_ext_er
  ,p_coord_ben_med_pl_name        => p_coord_ben_med_pl_name
  ,p_coord_ben_med_insr_crr_name  => p_coord_ben_med_insr_crr_name
  ,p_coord_ben_med_insr_crr_ident => p_coord_ben_med_insr_crr_ident
  ,p_coord_ben_med_cvg_strt_dt    => p_coord_ben_med_cvg_strt_dt
  ,p_coord_ben_med_cvg_end_dt     => p_coord_ben_med_cvg_end_dt
  ,p_uses_tobacco_flag            => p_uses_tobacco_flag
  ,p_dpdnt_adoption_date          => p_dpdnt_adoption_date
  ,p_dpdnt_vlntry_svce_flag       => p_dpdnt_vlntry_svce_flag
  ,p_original_date_of_hire        => p_original_date_of_hire
  ,p_adjusted_svc_date            => p_adjusted_svc_date
  ,p_town_of_birth                => p_town_of_birth
  ,p_region_of_birth              => p_region_of_birth

  ,p_country_of_birth             => p_country_of_birth
  ,p_global_person_id             => p_global_person_id
  ,p_party_id                     => p_party_id
  ,p_person_id                    => p_person_id
  ,p_assignment_id                => p_assignment_id
  ,p_per_object_version_number    => p_per_object_version_number
  ,p_asg_object_version_number    => p_asg_object_version_number
  ,p_per_effective_start_date     => p_per_effective_start_date
  ,p_per_effective_end_date       => p_per_effective_end_date
  ,p_full_name                    => p_full_name
  ,p_per_comment_id               => p_per_comment_id
  ,p_assignment_sequence          => p_assignment_sequence
  ,p_assignment_number            => p_assignment_number

  ,p_name_combination_warning     => p_name_combination_warning
  ,p_assign_payroll_warning       => p_assign_payroll_warning
  ,p_orig_hire_warning            => l_orig_hire_warning
  );
  --
 if g_debug then
hr_utility.set_location('Leaving:'||l_proc,111);
 end if;
--
end create_employee;
--
-- End of fix for bug 899720
--

-- ----------------------------------------------------------------------------
-- |-------------------------< create_gb_employee >---------------------------|
-- ----------------------------------------------------------------------------
--
procedure create_gb_employee
  (p_validate                      in     boolean  default false
  ,p_hire_date                     in     date
  ,p_business_group_id             in     number
  ,p_last_name                     in     varchar2
  ,p_sex                           in     varchar2
  ,p_person_type_id                in     number   default null
  ,p_comments                      in     varchar2 default null
  ,p_date_employee_data_verified   in     date     default null

  ,p_date_of_birth                 in     date     default null
  ,p_email_address                 in     varchar2 default null
  ,p_employee_number               in out nocopy varchar2
  ,p_expense_check_send_to_addres  in     varchar2 default null
  ,p_first_name                    in     varchar2 default null
  ,p_known_as                      in     varchar2 default null
  ,p_marital_status                in     varchar2 default null
  ,p_middle_names                  in     varchar2 default null
  ,p_nationality                   in     varchar2 default null
  ,p_ni_number                     in     varchar2 default null
  ,p_previous_last_name            in     varchar2 default null
  ,p_registered_disabled_flag      in     varchar2 default null
  ,p_title                         in     varchar2 default null

  ,p_vendor_id                     in     number   default null
  ,p_work_telephone                in     varchar2 default null
  ,p_attribute_category            in     varchar2 default null
  ,p_attribute1                    in     varchar2 default null
  ,p_attribute2                    in     varchar2 default null
  ,p_attribute3                    in     varchar2 default null
  ,p_attribute4                    in     varchar2 default null
  ,p_attribute5                    in     varchar2 default null
  ,p_attribute6                    in     varchar2 default null
  ,p_attribute7                    in     varchar2 default null
  ,p_attribute8                    in     varchar2 default null
  ,p_attribute9                    in     varchar2 default null
  ,p_attribute10                   in     varchar2 default null

  ,p_attribute11                   in     varchar2 default null
  ,p_attribute12                   in     varchar2 default null
  ,p_attribute13                   in     varchar2 default null
  ,p_attribute14                   in     varchar2 default null
  ,p_attribute15                   in     varchar2 default null
  ,p_attribute16                   in     varchar2 default null
  ,p_attribute17                   in     varchar2 default null
  ,p_attribute18                   in     varchar2 default null
  ,p_attribute19                   in     varchar2 default null
  ,p_attribute20                   in     varchar2 default null
  ,p_attribute21                   in     varchar2 default null
  ,p_attribute22                   in     varchar2 default null
  ,p_attribute23                   in     varchar2 default null

  ,p_attribute24                   in     varchar2 default null
  ,p_attribute25                   in     varchar2 default null
  ,p_attribute26                   in     varchar2 default null
  ,p_attribute27                   in     varchar2 default null
  ,p_attribute28                   in     varchar2 default null
  ,p_attribute29                   in     varchar2 default null
  ,p_attribute30                   in     varchar2 default null
  ,p_ethnic_origin                 in     varchar2 default null
  ,p_director                      in     varchar2 default 'N'
  ,p_pensioner                     in     varchar2 default 'N'
  ,p_work_permit_number            in     varchar2 default null
  ,p_addl_pension_years            in     varchar2 default null
  ,p_addl_pension_months           in     varchar2 default null

  ,p_addl_pension_days             in     varchar2 default null
  ,p_ni_multiple_asg               in     varchar2 default 'N'
  ,p_date_of_death                 in     date     default null
  ,p_background_check_status       in     varchar2 default null
  ,p_background_date_check         in     date     default null
  ,p_blood_type                    in     varchar2 default null
  ,p_correspondence_language       in     varchar2 default null
  ,p_fast_path_employee            in     varchar2 default null
  ,p_fte_capacity                  in     number   default null
  ,p_honors                        in     varchar2 default null
  ,p_internal_location             in     varchar2 default null
  ,p_last_medical_test_by          in     varchar2 default null
  ,p_last_medical_test_date        in     date     default null

  ,p_mailstop                      in     varchar2 default null
  ,p_office_number                 in     varchar2 default null
  ,p_on_military_service           in     varchar2 default null
  ,p_pre_name_adjunct              in     varchar2 default null
  ,p_rehire_recommendation       in     varchar2 default null  -- Bug 3210500
  ,p_projected_start_date          in     date     default null
  ,p_resume_exists                 in     varchar2 default null
  ,p_resume_last_updated           in     date     default null
  ,p_second_passport_exists        in     varchar2 default null
  ,p_student_status                in     varchar2 default null
  ,p_work_schedule                 in     varchar2 default null
  ,p_suffix                        in     varchar2 default null
  ,p_benefit_group_id              in     number   default null

  ,p_receipt_of_death_cert_date    in     date     default null
  ,p_coord_ben_med_pln_no          in     varchar2 default null
  ,p_coord_ben_no_cvg_flag         in     varchar2 default 'N'
  ,p_coord_ben_med_ext_er          in     varchar2 default null
  ,p_coord_ben_med_pl_name         in     varchar2 default null
  ,p_coord_ben_med_insr_crr_name   in     varchar2 default null
  ,p_coord_ben_med_insr_crr_ident  in     varchar2 default null
  ,p_coord_ben_med_cvg_strt_dt     in     date default null
  ,p_coord_ben_med_cvg_end_dt      in     date default null
  ,p_uses_tobacco_flag             in     varchar2 default null
  ,p_dpdnt_adoption_date           in     date     default null
  ,p_dpdnt_vlntry_svce_flag        in     varchar2 default 'N'
  ,p_original_date_of_hire         in     date     default null

  ,p_adjusted_svc_date             in     date     default null
  ,p_town_of_birth                 in     varchar2 default null
  ,p_region_of_birth               in     varchar2 default null
  ,p_country_of_birth              in     varchar2 default null
  ,p_global_person_id              in     varchar2 default null
  ,p_party_id                      in     number default null
  ,p_person_id                        out nocopy number
  ,p_assignment_id                    out nocopy number
  ,p_per_object_version_number        out nocopy number
  ,p_asg_object_version_number        out nocopy number
  ,p_per_effective_start_date         out nocopy date
  ,p_per_effective_end_date           out nocopy date
  ,p_full_name                        out nocopy varchar2

  ,p_per_comment_id                   out nocopy number
  ,p_assignment_sequence              out nocopy number
  ,p_assignment_number                out nocopy varchar2
  ,p_name_combination_warning         out nocopy boolean
  ,p_assign_payroll_warning           out nocopy boolean
  ,p_orig_hire_warning                out nocopy boolean
  ) is
  --
  -- Declare cursors and local variables
  --
  l_proc                    varchar2(72);
  l_legislation_code        varchar2(2);
  l_hire_date               date := trunc(p_hire_date);

  l_original_date_of_hire   date := trunc(p_original_date_of_hire);
  --
  cursor csr_bg is
    select legislation_code
    from per_business_groups pbg
    where pbg.business_group_id = p_business_group_id;
  --
begin
 if g_debug then
  l_proc := g_package||'create_gb_employee';
  hr_utility.set_location('Entering:'|| l_proc, 5);
 end if;
  --

  -- Validation in addition to Row Handlers
  --
  -- Check that the specified business group is valid.
  --
  open csr_bg;
  fetch csr_bg
  into l_legislation_code;
  if csr_bg%notfound then
    close csr_bg;
    hr_utility.set_message(801, 'HR_7208_API_BUS_GRP_INVALID');
    hr_utility.raise_error;
  end if;
  close csr_bg;

  --
  -- Check that the legislation of the specified business group is 'GB'.
  --
  if l_legislation_code <> 'GB' then
    hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
    hr_utility.set_message_token('LEG_CODE','GB');
    hr_utility.raise_error;
  end if;

 if g_debug then
  hr_utility.set_location(l_proc, 6);
 end if;
  --

  -- set the original date of hire to hire date if null
  --
  if p_original_date_of_hire is null then
     l_original_date_of_hire := l_hire_date;
  end if;
  --
  -- Call the person business process
  --
  hr_employee_api.create_employee
  (p_validate                     => p_validate
  ,p_hire_date                    => p_hire_date
  ,p_business_group_id            => p_business_group_id
  ,p_last_name                    => p_last_name

  ,p_sex                          => p_sex
  ,p_person_type_id               => p_person_type_id
  ,p_per_comments                 => p_comments
  ,p_date_employee_data_verified  => p_date_employee_data_verified
  ,p_date_of_birth                => p_date_of_birth
  ,p_email_address                => p_email_address
  ,p_employee_number              => p_employee_number
  ,p_expense_check_send_to_addres => p_expense_check_send_to_addres
  ,p_first_name                   => p_first_name
  ,p_known_as                     => p_known_as
  ,p_marital_status               => p_marital_status
  ,p_middle_names                 => p_middle_names
  ,p_nationality                  => p_nationality

  ,p_national_identifier          => p_ni_number
  ,p_previous_last_name           => p_previous_last_name
  ,p_registered_disabled_flag     => p_registered_disabled_flag
  ,p_title                        => p_title
  ,p_vendor_id                    => p_vendor_id
  ,p_work_telephone               => p_work_telephone
  ,p_attribute_category           => p_attribute_category
  ,p_attribute1                   => p_attribute1
  ,p_attribute2                   => p_attribute2
  ,p_attribute3                   => p_attribute3
  ,p_attribute4                   => p_attribute4
  ,p_attribute5                   => p_attribute5
  ,p_attribute6                   => p_attribute6

  ,p_attribute7                   => p_attribute7
  ,p_attribute8                   => p_attribute8
  ,p_attribute9                   => p_attribute9
  ,p_attribute10                  => p_attribute10
  ,p_attribute11                  => p_attribute11
  ,p_attribute12                  => p_attribute12
  ,p_attribute13                  => p_attribute13
  ,p_attribute14                  => p_attribute14
  ,p_attribute15                  => p_attribute15
  ,p_attribute16                  => p_attribute16
  ,p_attribute17                  => p_attribute17
  ,p_attribute18                  => p_attribute18
  ,p_attribute19                  => p_attribute19

  ,p_attribute20                  => p_attribute20
  ,p_attribute21                  => p_attribute21
  ,p_attribute22                  => p_attribute22
  ,p_attribute23                  => p_attribute23
  ,p_attribute24                  => p_attribute24
  ,p_attribute25                  => p_attribute25
  ,p_attribute26                  => p_attribute26
  ,p_attribute27                  => p_attribute27
  ,p_attribute28                  => p_attribute28
  ,p_attribute29                  => p_attribute29
  ,p_attribute30                  => p_attribute30
  ,p_per_information_category     => 'GB'
  ,p_per_information1             => p_ethnic_origin

  ,p_per_information2             => p_director
  ,p_per_information4             => p_pensioner
  ,p_per_information5             => p_work_permit_number
  ,p_per_information6             => p_addl_pension_years
  ,p_per_information7             => p_addl_pension_months
  ,p_per_information8             => p_addl_pension_days
  ,p_per_information9             => p_ni_multiple_asg
  ,p_date_of_death                => p_date_of_death
  ,p_background_check_status      => p_background_check_status
  ,p_background_date_check        => p_background_date_check
  ,p_blood_type                   => p_blood_type
  ,p_correspondence_language      => p_correspondence_language
  ,p_fast_path_employee           => p_fast_path_employee

  ,p_fte_capacity                 => p_fte_capacity
  ,p_honors                       => p_honors
  ,p_internal_location            => p_internal_location
  ,p_last_medical_test_by         => p_last_medical_test_by
  ,p_last_medical_test_date       => p_last_medical_test_date
  ,p_mailstop                     => p_mailstop
  ,p_office_number                => p_office_number
  ,p_on_military_service          => p_on_military_service
  ,p_pre_name_adjunct             => p_pre_name_adjunct
  ,p_rehire_recommendation      => p_rehire_recommendation  -- Bug 3210500
  ,p_projected_start_date         => p_projected_start_date
  ,p_resume_exists                => p_resume_exists
  ,p_resume_last_updated          => p_resume_last_updated

  ,p_second_passport_exists       => p_second_passport_exists
  ,p_student_status               => p_student_status
  ,p_work_schedule                => p_work_schedule
  ,p_suffix                       => p_suffix
  ,p_benefit_group_id             => p_benefit_group_id
  ,p_receipt_of_death_cert_date   => p_receipt_of_death_cert_date
  ,p_coord_ben_med_pln_no         => p_coord_ben_med_pln_no
  ,p_coord_ben_no_cvg_flag        => p_coord_ben_no_cvg_flag
  ,p_coord_ben_med_ext_er         => p_coord_ben_med_ext_er
  ,p_coord_ben_med_pl_name        => p_coord_ben_med_pl_name
  ,p_coord_ben_med_insr_crr_name  => p_coord_ben_med_insr_crr_name
  ,p_coord_ben_med_insr_crr_ident => p_coord_ben_med_insr_crr_ident
  ,p_coord_ben_med_cvg_strt_dt    => p_coord_ben_med_cvg_strt_dt

  ,p_coord_ben_med_cvg_end_dt     => p_coord_ben_med_cvg_end_dt
  ,p_uses_tobacco_flag            => p_uses_tobacco_flag
  ,p_dpdnt_adoption_date          => p_dpdnt_adoption_date
  ,p_dpdnt_vlntry_svce_flag       => p_dpdnt_vlntry_svce_flag
  ,p_original_date_of_hire        => l_original_date_of_hire
  ,p_adjusted_svc_date            => p_adjusted_svc_date
  ,p_town_of_birth                => p_town_of_birth
  ,p_region_of_birth              => p_region_of_birth
  ,p_country_of_birth             => p_country_of_birth
  ,p_global_person_id             => p_global_person_id
  ,p_party_id                     => p_party_id
  --
  ,p_person_id                    => p_person_id

  ,p_assignment_id                => p_assignment_id
  ,p_per_object_version_number    => p_per_object_version_number
  ,p_asg_object_version_number    => p_asg_object_version_number
  ,p_per_effective_start_date     => p_per_effective_start_date
  ,p_per_effective_end_date       => p_per_effective_end_date
  ,p_full_name                    => p_full_name
  ,p_per_comment_id               => p_per_comment_id
  ,p_assignment_sequence          => p_assignment_sequence
  ,p_assignment_number            => p_assignment_number
  ,p_name_combination_warning     => p_name_combination_warning
  ,p_assign_payroll_warning       => p_assign_payroll_warning
  ,p_orig_hire_warning            => p_orig_hire_warning
  );

  --
end create_gb_employee;
-- --------------------------------------------------------------------------
--
-- Begin fix for bug 899720
--
-- overload procedure for create_gb_employee
--
procedure create_gb_employee
  (p_validate                      in     boolean  default false
  ,p_hire_date                     in     date
  ,p_business_group_id             in     number
  ,p_last_name                     in     varchar2

  ,p_sex                           in     varchar2
  ,p_person_type_id                in     number   default null
  ,p_comments                      in     varchar2 default null
  ,p_date_employee_data_verified   in     date     default null
  ,p_date_of_birth                 in     date     default null
  ,p_email_address                 in     varchar2 default null
  ,p_employee_number               in out nocopy varchar2
  ,p_expense_check_send_to_addres  in     varchar2 default null
  ,p_first_name                    in     varchar2 default null
  ,p_known_as                      in     varchar2 default null
  ,p_marital_status                in     varchar2 default null
  ,p_middle_names                  in     varchar2 default null
  ,p_nationality                   in     varchar2 default null

  ,p_ni_number                     in     varchar2 default null
  ,p_previous_last_name            in     varchar2 default null
  ,p_registered_disabled_flag      in     varchar2 default null
  ,p_title                         in     varchar2 default null
  ,p_vendor_id                     in     number   default null
  ,p_work_telephone                in     varchar2 default null
  ,p_attribute_category            in     varchar2 default null
  ,p_attribute1                    in     varchar2 default null
  ,p_attribute2                    in     varchar2 default null
  ,p_attribute3                    in     varchar2 default null
  ,p_attribute4                    in     varchar2 default null
  ,p_attribute5                    in     varchar2 default null
  ,p_attribute6                    in     varchar2 default null

  ,p_attribute7                    in     varchar2 default null
  ,p_attribute8                    in     varchar2 default null
  ,p_attribute9                    in     varchar2 default null
  ,p_attribute10                   in     varchar2 default null
  ,p_attribute11                   in     varchar2 default null
  ,p_attribute12                   in     varchar2 default null
  ,p_attribute13                   in     varchar2 default null
  ,p_attribute14                   in     varchar2 default null
  ,p_attribute15                   in     varchar2 default null
  ,p_attribute16                   in     varchar2 default null
  ,p_attribute17                   in     varchar2 default null
  ,p_attribute18                   in     varchar2 default null
  ,p_attribute19                   in     varchar2 default null

  ,p_attribute20                   in     varchar2 default null
  ,p_attribute21                   in     varchar2 default null
  ,p_attribute22                   in     varchar2 default null
  ,p_attribute23                   in     varchar2 default null
  ,p_attribute24                   in     varchar2 default null
  ,p_attribute25                   in     varchar2 default null
  ,p_attribute26                   in     varchar2 default null
  ,p_attribute27                   in     varchar2 default null
  ,p_attribute28                   in     varchar2 default null
  ,p_attribute29                   in     varchar2 default null
  ,p_attribute30                   in     varchar2 default null
  ,p_ethnic_origin                 in     varchar2 default null
  ,p_director                      in     varchar2 default 'N'

  ,p_pensioner                     in     varchar2 default 'N'
  ,p_work_permit_number            in     varchar2 default null
  ,p_addl_pension_years            in     varchar2 default null
  ,p_addl_pension_months           in     varchar2 default null
  ,p_addl_pension_days             in     varchar2 default null
  ,p_ni_multiple_asg               in     varchar2 default 'N'
  ,p_date_of_death                 in     date     default null
  ,p_background_check_status       in     varchar2 default null
  ,p_background_date_check         in     date     default null
  ,p_blood_type                    in     varchar2 default null
  ,p_correspondence_language       in     varchar2 default null
  ,p_fast_path_employee            in     varchar2 default null
  ,p_fte_capacity                  in     number   default null

  ,p_honors                        in     varchar2 default null
  ,p_internal_location             in     varchar2 default null
  ,p_last_medical_test_by          in     varchar2 default null
  ,p_last_medical_test_date        in     date     default null
  ,p_mailstop                      in     varchar2 default null
  ,p_office_number                 in     varchar2 default null
  ,p_on_military_service           in     varchar2 default null
  ,p_pre_name_adjunct              in     varchar2 default null
  ,p_rehire_recommendation       in     varchar2 default null  -- Bug 3210500
  ,p_projected_start_date          in     date     default null
  ,p_resume_exists                 in     varchar2 default null
  ,p_resume_last_updated           in     date     default null
  ,p_second_passport_exists        in     varchar2 default null

  ,p_student_status                in     varchar2 default null
  ,p_work_schedule                 in     varchar2 default null
  ,p_suffix                        in     varchar2 default null
  ,p_benefit_group_id              in     number   default null
  ,p_receipt_of_death_cert_date    in     date     default null
  ,p_coord_ben_med_pln_no          in     varchar2 default null
  ,p_coord_ben_no_cvg_flag         in     varchar2 default 'N'
  ,p_coord_ben_med_ext_er          in     varchar2 default null
  ,p_coord_ben_med_pl_name         in     varchar2 default null
  ,p_coord_ben_med_insr_crr_name   in     varchar2 default null
  ,p_coord_ben_med_insr_crr_ident  in     varchar2 default null
  ,p_coord_ben_med_cvg_strt_dt     in     date default null
  ,p_coord_ben_med_cvg_end_dt      in     date default null

  ,p_uses_tobacco_flag             in     varchar2 default null
  ,p_dpdnt_adoption_date           in     date     default null
  ,p_dpdnt_vlntry_svce_flag        in     varchar2 default 'N'
  ,p_original_date_of_hire         in     date     default null
  ,p_adjusted_svc_date             in     date     default null
  ,p_town_of_birth                 in     varchar2 default null
  ,p_region_of_birth               in     varchar2 default null
  ,p_country_of_birth              in     varchar2 default null
  ,p_global_person_id              in     varchar2 default null
  ,p_party_id                      in     number   default null
  ,p_person_id                        out nocopy number
  ,p_assignment_id                    out nocopy number
  ,p_per_object_version_number        out nocopy number

  ,p_asg_object_version_number        out nocopy number
  ,p_per_effective_start_date         out nocopy date
  ,p_per_effective_end_date           out nocopy date
  ,p_full_name                        out nocopy varchar2
  ,p_per_comment_id                   out nocopy number
  ,p_assignment_sequence              out nocopy number
  ,p_assignment_number                out nocopy varchar2
  ,p_name_combination_warning         out nocopy boolean
  ,p_assign_payroll_warning           out nocopy boolean
  )
is
--
-- Declare cursors and local variables

--
l_proc                        varchar2(72);
l_orig_hire_warning           boolean := false;
--
begin
--
 if g_debug then
 l_proc := g_package||'create_gb_employee';
hr_utility.set_location('Entering:'||l_proc,222);
 end if;
--
  hr_employee_api.create_gb_employee
  (p_validate                     => p_validate

  ,p_hire_date                    => p_hire_date
  ,p_business_group_id            => p_business_group_id
  ,p_last_name                    => p_last_name
  ,p_sex                          => p_sex
  ,p_person_type_id               => p_person_type_id
  ,p_comments                     => p_comments
  ,p_date_employee_data_verified  => p_date_employee_data_verified
  ,p_date_of_birth                => p_date_of_birth
  ,p_email_address                => p_email_address
  ,p_employee_number              => p_employee_number
  ,p_expense_check_send_to_addres => p_expense_check_send_to_addres
  ,p_first_name                   => p_first_name
  ,p_known_as                     => p_known_as

  ,p_marital_status               => p_marital_status
  ,p_middle_names                 => p_middle_names
  ,p_nationality                  => p_nationality
  ,p_ni_number                    => p_ni_number
  ,p_previous_last_name           => p_previous_last_name
  ,p_registered_disabled_flag     => p_registered_disabled_flag
  ,p_title                        => p_title
  ,p_vendor_id                    => p_vendor_id
  ,p_work_telephone               => p_work_telephone
  ,p_attribute_category           => p_attribute_category
  ,p_attribute1                   => p_attribute1
  ,p_attribute2                   => p_attribute2
  ,p_attribute3                   => p_attribute3

  ,p_attribute4                   => p_attribute4
  ,p_attribute5                   => p_attribute5
  ,p_attribute6                   => p_attribute6
  ,p_attribute7                   => p_attribute7
  ,p_attribute8                   => p_attribute8
  ,p_attribute9                   => p_attribute9
  ,p_attribute10                  => p_attribute10
  ,p_attribute11                  => p_attribute11
  ,p_attribute12                  => p_attribute12
  ,p_attribute13                  => p_attribute13
  ,p_attribute14                  => p_attribute14
  ,p_attribute15                  => p_attribute15
  ,p_attribute16                  => p_attribute16

  ,p_attribute17                  => p_attribute17
  ,p_attribute18                  => p_attribute18
  ,p_attribute19                  => p_attribute19
  ,p_attribute20                  => p_attribute20
  ,p_attribute21                  => p_attribute21
  ,p_attribute22                  => p_attribute22
  ,p_attribute23                  => p_attribute23
  ,p_attribute24                  => p_attribute24
  ,p_attribute25                  => p_attribute25
  ,p_attribute26                  => p_attribute26
  ,p_attribute27                  => p_attribute27
  ,p_attribute28                  => p_attribute28
  ,p_attribute29                  => p_attribute29

  ,p_attribute30                  => p_attribute30
  ,p_ethnic_origin                => p_ethnic_origin
  ,p_director                     => p_director
  ,p_pensioner                    => p_pensioner
  ,p_work_permit_number           => p_work_permit_number
  ,p_addl_pension_years           => p_addl_pension_years
  ,p_addl_pension_months          => p_addl_pension_months
  ,p_addl_pension_days            => p_addl_pension_days
  ,p_ni_multiple_asg              => p_ni_multiple_asg
  ,p_date_of_death                => p_date_of_death
  ,p_background_check_status      => p_background_check_status
  ,p_background_date_check        => p_background_date_check
  ,p_blood_type                   => p_blood_type

  ,p_correspondence_language      => p_correspondence_language
  ,p_fast_path_employee           => p_fast_path_employee
  ,p_fte_capacity                 => p_fte_capacity
  ,p_honors                       => p_honors
  ,p_internal_location            => p_internal_location
  ,p_last_medical_test_by         => p_last_medical_test_by
  ,p_last_medical_test_date       => p_last_medical_test_date
  ,p_mailstop                     => p_mailstop
  ,p_office_number                => p_office_number
  ,p_on_military_service          => p_on_military_service
  ,p_pre_name_adjunct             => p_pre_name_adjunct
  ,p_rehire_recommendation      => p_rehire_recommendation  -- Bug 3210500
  ,p_projected_start_date         => p_projected_start_date

  ,p_resume_exists                => p_resume_exists
  ,p_resume_last_updated          => p_resume_last_updated
  ,p_second_passport_exists       => p_second_passport_exists
  ,p_student_status               => p_student_status
  ,p_work_schedule                => p_work_schedule
  ,p_suffix                       => p_suffix
  ,p_benefit_group_id             => p_benefit_group_id
  ,p_receipt_of_death_cert_date   => p_receipt_of_death_cert_date
  ,p_coord_ben_med_pln_no         => p_coord_ben_med_pln_no
  ,p_coord_ben_no_cvg_flag        => p_coord_ben_no_cvg_flag
  ,p_coord_ben_med_ext_er         => p_coord_ben_med_ext_er
  ,p_coord_ben_med_pl_name        => p_coord_ben_med_pl_name
  ,p_coord_ben_med_insr_crr_name  => p_coord_ben_med_insr_crr_name

  ,p_coord_ben_med_insr_crr_ident => p_coord_ben_med_insr_crr_ident
  ,p_coord_ben_med_cvg_strt_dt    => p_coord_ben_med_cvg_strt_dt
  ,p_coord_ben_med_cvg_end_dt     => p_coord_ben_med_cvg_end_dt
  ,p_uses_tobacco_flag            => p_uses_tobacco_flag
  ,p_dpdnt_adoption_date          => p_dpdnt_adoption_date
  ,p_dpdnt_vlntry_svce_flag       => p_dpdnt_vlntry_svce_flag
  ,p_original_date_of_hire        => p_original_date_of_hire
  ,p_adjusted_svc_date            => p_adjusted_svc_date
  ,p_town_of_birth                => p_town_of_birth
  ,p_region_of_birth              => p_region_of_birth
  ,p_country_of_birth             => p_country_of_birth
  ,p_global_person_id             => p_global_person_id
  ,p_party_id                     => p_party_id

  ,p_person_id                    => p_person_id
  ,p_assignment_id                => p_assignment_id
  ,p_per_object_version_number    => p_per_object_version_number
  ,p_asg_object_version_number    => p_asg_object_version_number
  ,p_per_effective_start_date     => p_per_effective_start_date
  ,p_per_effective_end_date       => p_per_effective_end_date
  ,p_full_name                    => p_full_name
  ,p_per_comment_id               => p_per_comment_id
  ,p_assignment_sequence          => p_assignment_sequence
  ,p_assignment_number            => p_assignment_number
  ,p_name_combination_warning     => p_name_combination_warning
  ,p_assign_payroll_warning       => p_assign_payroll_warning
  ,p_orig_hire_warning            => l_orig_hire_warning

  );
--
 if g_debug then
hr_utility.set_location('Leaving:'||l_proc,222);
 end if;
--
end create_gb_employee;
--
-- End of fix for bug 899720
--
-- ----------------------------------------------------------------------------
-- |-------------------------< create_us_employee >---------------------------|
-- ----------------------------------------------------------------------------

--
procedure create_us_employee
  (p_validate                      in     boolean  default false
  ,p_hire_date                     in     date
  ,p_business_group_id             in     number
  ,p_last_name                     in     varchar2
  ,p_sex                           in     varchar2
  ,p_person_type_id                in     number   default null
  ,p_comments                      in     varchar2 default null
  ,p_date_employee_data_verified   in     date     default null
  ,p_date_of_birth                 in     date     default null
  ,p_email_address                 in     varchar2 default null
  ,p_employee_number               in out nocopy varchar2

  ,p_expense_check_send_to_addres  in     varchar2 default null
  ,p_first_name                    in     varchar2 default null
  ,p_known_as                      in     varchar2 default null
  ,p_marital_status                in     varchar2 default null
  ,p_middle_names                  in     varchar2 default null
  ,p_nationality                   in     varchar2 default null
  ,p_ss_number                     in     varchar2 default null
  ,p_previous_last_name            in     varchar2 default null
  ,p_registered_disabled_flag      in     varchar2 default null
  ,p_title                         in     varchar2 default null
  ,p_vendor_id                     in     number   default null
  ,p_work_telephone                in     varchar2 default null
  ,p_attribute_category            in     varchar2 default null

  ,p_attribute1                    in     varchar2 default null
  ,p_attribute2                    in     varchar2 default null
  ,p_attribute3                    in     varchar2 default null
  ,p_attribute4                    in     varchar2 default null
  ,p_attribute5                    in     varchar2 default null
  ,p_attribute6                    in     varchar2 default null
  ,p_attribute7                    in     varchar2 default null
  ,p_attribute8                    in     varchar2 default null
  ,p_attribute9                    in     varchar2 default null
  ,p_attribute10                   in     varchar2 default null
  ,p_attribute11                   in     varchar2 default null
  ,p_attribute12                   in     varchar2 default null
  ,p_attribute13                   in     varchar2 default null

  ,p_attribute14                   in     varchar2 default null
  ,p_attribute15                   in     varchar2 default null
  ,p_attribute16                   in     varchar2 default null
  ,p_attribute17                   in     varchar2 default null
  ,p_attribute18                   in     varchar2 default null
  ,p_attribute19                   in     varchar2 default null
  ,p_attribute20                   in     varchar2 default null
  ,p_attribute21                   in     varchar2 default null
  ,p_attribute22                   in     varchar2 default null
  ,p_attribute23                   in     varchar2 default null
  ,p_attribute24                   in     varchar2 default null
  ,p_attribute25                   in     varchar2 default null
  ,p_attribute26                   in     varchar2 default null

  ,p_attribute27                   in     varchar2 default null
  ,p_attribute28                   in     varchar2 default null
  ,p_attribute29                   in     varchar2 default null
  ,p_attribute30                   in     varchar2 default null
  ,p_ethnic_origin                 in     varchar2 default null
  ,p_I_9                           in     varchar2 default 'N'
  ,p_I_9_expiration_date           in     varchar2 default null
--  ,p_visa_type                     in     varchar2 default null
  ,p_veteran_status                in     varchar2 default null
  ,p_new_hire                      in     varchar2 default null
  ,p_exception_reason              in     varchar2 default null
  ,p_child_support_obligation      in     varchar2 default 'N'
  ,p_opted_for_medicare_flag       in     varchar2 default 'N'

  ,p_date_of_death                 in     date     default null
  ,p_background_check_status       in     varchar2 default null
  ,p_background_date_check         in     date     default null
  ,p_blood_type                    in     varchar2 default null
  ,p_correspondence_language       in     varchar2 default null
  ,p_fast_path_employee            in     varchar2 default null
  ,p_fte_capacity                  in     number   default null
  ,p_honors                        in     varchar2 default null
  ,p_internal_location             in     varchar2 default null
  ,p_last_medical_test_by          in     varchar2 default null
  ,p_last_medical_test_date        in     date     default null
  ,p_mailstop                      in     varchar2 default null
  ,p_office_number                 in     varchar2 default null

  ,p_on_military_service           in     varchar2 default null
  ,p_pre_name_adjunct              in     varchar2 default null
  ,p_rehire_recommendation       in       varchar2 default null  -- Bug 3210500
  ,p_projected_start_date          in     date     default null
  ,p_resume_exists                 in     varchar2 default null
  ,p_resume_last_updated           in     date     default null
  ,p_second_passport_exists        in     varchar2 default null
  ,p_student_status                in     varchar2 default null
  ,p_work_schedule                 in     varchar2 default null
  ,p_suffix                        in     varchar2 default null
  ,p_benefit_group_id              in     number   default null
  ,p_receipt_of_death_cert_date    in     date     default null
  ,p_coord_ben_med_pln_no          in     varchar2 default null

  ,p_coord_ben_no_cvg_flag         in     varchar2 default 'N'
  ,p_coord_ben_med_ext_er          in     varchar2 default null
  ,p_coord_ben_med_pl_name         in     varchar2 default null
  ,p_coord_ben_med_insr_crr_name   in     varchar2 default null
  ,p_coord_ben_med_insr_crr_ident  in     varchar2 default null
  ,p_coord_ben_med_cvg_strt_dt     in     date default null
  ,p_coord_ben_med_cvg_end_dt      in     date default null
  ,p_uses_tobacco_flag             in     varchar2 default null
  ,p_dpdnt_adoption_date           in     date     default null
  ,p_dpdnt_vlntry_svce_flag        in     varchar2 default 'N'
  ,p_original_date_of_hire         in     date     default null
  ,p_adjusted_svc_date             in     date     default null
  ,p_town_of_birth                 in     varchar2 default null

  ,p_region_of_birth               in     varchar2 default null
  ,p_country_of_birth              in     varchar2 default null
  ,p_global_person_id              in     varchar2 default null
  ,p_party_id                      in     number default null
  ,p_person_id                        out nocopy number
  ,p_assignment_id                    out nocopy number
  ,p_per_object_version_number        out nocopy number
  ,p_asg_object_version_number        out nocopy number
  ,p_per_effective_start_date         out nocopy date
  ,p_per_effective_end_date           out nocopy date
  ,p_full_name                        out nocopy varchar2
  ,p_per_comment_id                   out nocopy number
  ,p_assignment_sequence              out nocopy number

  ,p_assignment_number                out nocopy varchar2
  ,p_name_combination_warning         out nocopy boolean
  ,p_assign_payroll_warning           out nocopy boolean
  ,p_orig_hire_warning                out nocopy boolean
  )
is
  --
  -- Declare cursors and local variables
  --
  l_proc                 varchar2(72) ;
  l_legislation_code     varchar2(2);
  l_asg_object_version_number  number(9);
  --

  cursor csr_bg is
    select legislation_code
    from per_business_groups pbg
    where pbg.business_group_id = p_business_group_id;
  --
begin
  --
  -- Validation in addition to Row Handlers
  --
  -- Check that the specified business group is valid.
  --
  open csr_bg;
  fetch csr_bg

  into l_legislation_code;
  if csr_bg%notfound then
    close csr_bg;
    hr_utility.set_message(801, 'HR_7208_API_BUS_GRP_INVALID');
    hr_utility.raise_error;
  end if;
  close csr_bg;
 if g_debug then
  l_proc := g_package||'create_us_employee';
  hr_utility.set_location(l_proc, 20);
 end if;
  --
  -- Check that the legislation of the specified business group is 'US'.

  --
  if l_legislation_code <> 'US' then
    hr_utility.set_message(801, 'HR_7961_PER_BUS_GRP_INVALID');
    hr_utility.set_message_token('LEG_CODE','US');
    hr_utility.raise_error;
  end if;
 if g_debug then
  hr_utility.set_location(l_proc, 30);
 end if;
  --
  -- Call the person business process
  --
  hr_employee_api.create_employee

    (p_validate                     => p_validate
    ,p_hire_date                    => p_hire_date
    ,p_business_group_id            => p_business_group_id
    ,p_last_name                    => p_last_name
    ,p_sex                          => p_sex
    ,p_person_type_id               => p_person_type_id
    ,p_per_comments                 => p_comments
    ,p_date_employee_data_verified  => p_date_employee_data_verified
    ,p_date_of_birth                => p_date_of_birth
    ,p_email_address                => p_email_address
    ,p_employee_number              => p_employee_number
    ,p_expense_check_send_to_addres => p_expense_check_send_to_addres
    ,p_first_name                   => p_first_name

    ,p_known_as                     => p_known_as
    ,p_marital_status               => p_marital_status
    ,p_middle_names                 => p_middle_names
    ,p_nationality                  => p_nationality
    ,p_national_identifier          => p_ss_number
    ,p_previous_last_name           => p_previous_last_name
    ,p_registered_disabled_flag     => p_registered_disabled_flag
    ,p_title                        => p_title
    ,p_vendor_id                    => p_vendor_id
    ,p_work_telephone               => p_work_telephone
    ,p_attribute_category           => p_attribute_category
    ,p_attribute1                   => p_attribute1
    ,p_attribute2                   => p_attribute2

    ,p_attribute3                   => p_attribute3
    ,p_attribute4                   => p_attribute4
    ,p_attribute5                   => p_attribute5
    ,p_attribute6                   => p_attribute6
    ,p_attribute7                   => p_attribute7
    ,p_attribute8                   => p_attribute8
    ,p_attribute9                   => p_attribute9
    ,p_attribute10                  => p_attribute10
    ,p_attribute11                  => p_attribute11
    ,p_attribute12                  => p_attribute12
    ,p_attribute13                  => p_attribute13
    ,p_attribute14                  => p_attribute14
    ,p_attribute15                  => p_attribute15

    ,p_attribute16                  => p_attribute16
    ,p_attribute17                  => p_attribute17
    ,p_attribute18                  => p_attribute18
    ,p_attribute19                  => p_attribute19
    ,p_attribute20                  => p_attribute20
    ,p_attribute21                  => p_attribute21
    ,p_attribute22                  => p_attribute22
  &nb3p; ,p_a4tribute23                  => p_attribute23
    ,p_attribute24     &nbsx; ?           => p_attribute24
    ,p_attribute25                  => p_attribute25
    ,p_attribute26                  => p_attribute26
    ,p_attribute27              nbsp;    => p_attribute27
    ,p_attribute28       3           => p_attribute28

    ,p_attribute29                  => p_attribute29
    ,p_attribute30                  => p_attribute30
    ,p_per_information_category     => 'US'
    ,p_per_information1             => p_ethnic_origin
    ,p_per_information2             => p_I_9
    ,p_per_information3             => p_I_9_expiration_date
--    ,p_per_information4             => p_visa_type
    ,p_per_information5             => p_veteran_status
    ,p_per_information7             => p_new_hire
    ,p_per_information8             => p_exception_reason
    ,p_per_information9             => p_child_support_obligation
    ,p_per_information10            => p_opted_for_medicare_flag
    ,p_date_of_death                => p_date_of_death

    ,p_background_check_status      => p_background_check_status
    ,p_background_date_check        => p_background_date_check
    ,p_blood_type                   => p_blood_type
    ,p_correspondence_language      => p_correspondence_language
    ,p_fast_path_employee           => p_fast_path_employee
    ,p_fte_capacity                 => p_fte_capacity
    ,p_honors                       => p_honors
    ,p_internal_location            => p_internal_location
    ,p_last_medical_test_by         => p_last_medical_test_by
    ,p_last_medical_test_date       => p_last_medical_test_date
    ,p_mailstop                     => p_mailstop
    ,p_office_number                => p_office_number
    ,p_on_military_service          => p_on_military_service

    ,p_pre_name_adjunct             => p_pre_name_adjunct
    ,p_rehire_recommendation        => p_rehire_recommendation  -- Bug 3210500
    ,p_projected_start_date         => p_projected_start_date
    ,p_resume_exists                => p_resume_exists
    ,p_resume_last_updated          => p_resume_last_updated
    ,p_second_passport_exists       => p_second_passport_exists
    ,p_student_status               => p_student_status
    ,p_work_schedule                => p_work_schedule
    ,p_suffix                       => p_suffix
    ,p_benefit_group_id             => p_benefit_group_id
    ,p_receipt_of_death_cert_date   => p_receipt_of_death_cert_date
    ,p_coord_ben_med_pln_no         => p_coord_ben_med_pln_no
    ,p_coord_ben_no_cvg_flag        => p_coord_ben_no_cvg_flag

    ,p_coord_ben_med_ext_er         => p_coord_ben_med_ext_er
    ,p_coord_ben_med_pl_name        => p_coord_ben_med_pl_name
    ,p_coord_ben_med_insr_crr_name  => p_coord_ben_med_insr_crr_name
    ,p_coord_ben_med_insr_crr_ident => p_coord_ben_med_insr_crr_ident
    ,p_coord_ben_med_cvg_strt_dt    => p_coord_ben_med_cvg_strt_dt
    ,p_coord_ben_med_cvg_end_dt     => p_coord_ben_med_cvg_end_dt
    ,p_uses_tobacco_flag            => p_uses_tobacco_flag
    ,p_dpdnt_adoption_date          => p_dpdnt_adoption_date
    ,p_dpdnt_vlntry_svce_flag       => p_dpdnt_vlntry_svce_flag
    ,p_original_date_of_hire        => p_original_date_of_hire
    ,p_adjusted_svc_date            => p_adjusted_svc_date
    ,p_town_of_birth                => p_town_of_birth
    ,p_region_of_birth              => p_region_of_birth

    ,p_country_of_birth             => p_country_of_birth
    ,p_global_person_id             => p_global_person_id
    ,p_party_id                     => p_party_id
    --
    ,p_person_id                    => p_person_id
    ,p_assignment_id                => p_assignment_id
    ,p_per_object_version_number    => p_per_object_version_number
    ,p_asg_object_version_number    => p_asg_object_version_number
    ,p_per_effective_start_date     => p_per_effective_start_date
    ,p_per_effective_end_date       => p_per_effective_end_date
    ,p_full_name                    => p_full_name
    ,p_per_comment_id               => p_per_comment_id
    ,p_assignment_sequence          => p_assignment_sequence

    ,p_assignment_number            => p_assignment_number
    ,p_name_combination_warning     => p_name_combination_warning
    ,p_assign_payroll_warning       => p_assign_payroll_warning
    ,p_orig_hire_warning            => p_orig_hire_warning
  );
  --
 if g_debug then
  hr_utility.set_location(' Leaving:'||l_proc, 40);
 end if;
end create_us_employee;
-- --------------------------------------------------------------------------
--
-- Begin fix for bug 899720

--
-- overload procedure for create_us_employee
--
procedure create_us_employee
  (p_validate                      in     boolean  default false
  ,p_hire_date                     in     date
  ,p_business_group_id             in     number
  ,p_last_name                     in     varchar2
  ,p_sex                           in     varchar2
  ,p_person_type_id                in     number   default null
  ,p_comments                      in     varchar2 default null
  ,p_date_employee_data_verified   in     date     default null
  ,p_date_of_birth                 in     date     default null

  ,p_email_address                 in     varchar2 default null
  ,p_employee_number               in out nocopy varchar2
  ,p_expense_check_send_to_addres  in     varchar2 default null
  ,p_first_name                    in     varchar2 default null
  ,p_known_as                      in     varchar2 default null
  ,p_marital_status                in     varchar2 default null
  ,p_middle_names                  in     varchar2 default null
  ,p_nationality                   in     varchar2 default null
  ,p_ss_number                     in     varchar2 default null
  ,p_previous_last_name            in     varchar2 default null
  ,p_registered_disabled_flag      in     varchar2 default null
  ,p_title                         in     varchar2 default null
  ,p_vendor_id                     in     number   default null

  ,p_work_telephone                in     varchar2 default null
  ,p_attribute_category            in     varchar2 default null
  ,p_attribute1                    in     varchar2 default null
  ,p_attribute2                    in     varchar2 default null
  ,p_attribute3                    in     varchar2 default null
  ,p_attribute4                    in     varchar2 default null
  ,p_attribute5                    in     varchar2 default null
  ,p_attribute6                    in     varchar2 default null
  ,p_attribute7                    in     varchar2 default null
  ,p_attribute8                    in     varchar2 default null
  ,p_attribute9                    in     varchar2 default null
  ,p_attribute10                   in     varchar2 default null
  ,p_attribute11                   in     varchar2 default null

  ,p_attribute12                   in     varchar2 default null
  ,p_attribute13                   in     varchar2 default null
  ,p_attribute14                   in     varchar2 default null
  ,p_attribute15                   in     varchar2 default null
  ,p_attribute16                   in     varchar2 default null
  ,p_attribute17                   in     varchar2 default null
  ,p_attribute18                   in     varchar2 default null
  ,p_attribute19                   in     varchar2 default null
  ,p_attribute20                   in     varchar2 default null
  ,p_attribute21                   in     varchar2 default null
  ,p_attribute22                   in     varchar2 default null
  ,p_attribute23                   in     varchar2 default null
  ,p_attribute24                   in     varchar2 default null

  ,p_attribute25                   in     varchar2 default null
  ,p_attribute26                   in     varchar2 default null
  ,p_attribute27                   in     varchar2 default null
  ,p_attribute28                   in     varchar2 default null
  ,p_attribute29                   in     varchar2 default null
  ,p_attribute30                   in     varchar2 default null
  ,p_ethnic_origin                 in     varchar2 default null
  ,p_I_9                           in     varchar2 default 'N'
  ,p_I_9_expiration_date           in     varchar2 default null
--  ,p_visa_type                     in     varchar2 default null
  ,p_veteran_status                in     varchar2 default null
  ,p_new_hire                      in     varchar2 default null
  ,p_exception_reason              in     varchar2 default null

  ,p_child_support_obligation      in     varchar2 default 'N'
  ,p_opted_for_medicare_flag       in     varchar2 default 'N'
  ,p_date_of_death                 in     date     default null
  ,p_background_check_status       in     varchar2 default null
  ,p_background_date_check         in     date     default null
  ,p_blood_type                    in     varchar2 default null
  ,p_correspondence_language       in     varchar2 default null
  ,p_fast_path_employee            in     varchar2 default null
  ,p_fte_capacity                  in     number   default null
  ,p_honors                        in     varchar2 default null
  ,p_internal_location             in     varchar2 default null
  ,p_last_medical_test_by          in     varchar2 default null
  ,p_last_medical_test_date        in     date     default null

  ,p_mailstop                      in     varchar2 default null
  ,p_office_number                 in     varchar2 default null
  ,p_on_military_service           in     varchar2 default null
  ,p_pre_name_adjunct              in     varchar2 default null
  ,p_rehire_recommendation       in     varchar2 default null  -- Bug 3210500
  ,p_projected_start_date          in     date     default null
  ,p_resume_exists                 in     varchar2 default null
  ,p_resume_last_updated           in     date     default null
  ,p_second_passport_exists        in     varchar2 default null
  ,p_student_status                in     varchar2 default null
  ,p_work_schedule                 in     varchar2 default null
  ,p_suffix                        in     varchar2 default null
  ,p_benefit_group_id              in     number   default null

  ,p_receipt_of_death_cert_date    in     date     default null
  ,p_coord_ben_med_pln_no          in     varchar2 default null
  ,p_coord_ben_no_cvg_flag         in     varchar2 default 'N'
  ,p_coord_ben_med_ext_er          in     varchar2 default null
  ,p_coord_ben_med_pl_name         in     varchar2 default null
  ,p_coord_ben_med_insr_crr_name   in     varchar2 default null
  ,p_coord_ben_med_insr_crr_ident  in     varchar2 default null
  ,p_coord_ben_med_cvg_strt_dt     in     date default null
  ,p_coord_ben_med_cvg_end_dt      in     date default null
  ,p_uses_tobacco_flag             in     varchar2 default null
  ,p_dpdnt_adoption_date           in     date     default null
  ,p_dpdnt_vlntry_svce_flag        in     varchar2 default 'N'
  ,p_original_date_of_hire         in     date     default null

  ,p_adjusted_svc_date             in     date     default null
  ,p_town_of_birth                 in     varchar2 default null
  ,p_region_of_birth               in     varchar2 default null
  ,p_country_of_birth              in     varchar2 default null
  ,p_global_person_id              in     varchar2 default null
  ,p_party_id                      in     number default null
  ,p_person_id                        out nocopy number
  ,p_assignment_id                    out nocopy number
  ,p_per_object_version_number        out nocopy number
  ,p_asg_object_version_number        out nocopy number
  ,p_per_effective_start_date         out nocopy date
  ,p_per_effective_end_date           out nocopy date
  ,p_full_name                        out nocopy varchar2

  ,p_per_comment_id                   out nocopy number
  ,p_assignment_sequence              out nocopy number
  ,p_assignment_number                out nocopy varchar2
  ,p_name_combination_warning         out nocopy boolean
  ,p_assign_payroll_warning           out nocopy boolean
  )
is
--
-- Declare cursors and local variables
--
l_proc                 varchar2(72) ;
l_orig_hire_warning    boolean      := false;
--

begin
--
 if g_debug then
 l_proc := g_package||'create_us_employee';
hr_utility.set_location('Entering:'||l_proc,333);
 end if;
--
  hr_employee_api.create_us_employee
    (p_validate                     => p_validate
    ,p_hire_date                    => p_hire_date
    ,p_business_group_id            => p_business_group_id
    ,p_last_name                    => p_last_name
    ,p_sex                          => p_sex

    ,p_person_type_id               => p_person_type_id
    ,p_comments                     => p_comments
    ,p_date_employee_data_verified  => p_date_employee_data_verified
    ,p_date_of_birth                => p_date_of_birth
    ,p_email_address                => p_email_address
    ,p_employee_number              => p_employee_number
    ,p_expense_check_send_to_addres => p_expense_check_send_to_addres
    ,p_first_name                   => p_first_name
    ,p_known_as                     => p_known_as
    ,p_marital_status               => p_marital_status
    ,p_middle_names                 => p_middle_names
    ,p_nationality                  => p_nationality
    ,p_ss_number                    => p_ss_number

    ,p_previous_last_name           => p_previous_last_name
    ,p_registered_disabled_flag     => p_registered_disabled_flag
    ,p_title                        => p_title
    ,p_vendor_id                    => p_vendor_id
    ,p_work_telephone               => p_work_telephone
    ,p_attribute_category           => p_attribute_category
    ,p_attribute1                   => p_attribute1
    ,p_attribute2                   => p_attribute2
    ,p_attribute3                   => p_attribute3
    ,p_attribute4                   => p_attribute4
    ,p_attribute5                   => p_attribute5
    ,p_attribute6                   => p_attribute6
    ,p_attribute7                   => p_attribute7

    ,p_attribute8                   => p_attribute8
    ,p_attribute9                   => p_attribute9
    ,p_attribute10                  => p_attribute10
    ,p_attribute11                  => p_attribute11
    ,p_attribute12                  => p_attribute12
    ,p_attribute13                  => p_attribute13
    ,p_attribute14                  => p_attribute14
    ,p_attribute15                  => p_attribute15
    ,p_attribute16                  => p_attribute16
    ,p_attribute17                  => p_attribute17
    ,p_attribute18                  => p_attribute18
    ,p_attribute19                  => p_attribute19
    ,p_attribute20                  => p_attribute20

    ,p_attribute21                  => p_attribute21
    ,p_attribute22                  => p_attribute22
    ,p_attribute23                  => p_attribute23
    ,p_attribute24                  => p_attribute24
    ,p_attribute25                  => p_attribute25
    ,p_attribute26                  => p_attribute26
    ,p_attribute27                  => p_attribute27
    ,p_attribute28                  => p_attribute28
    ,p_attribute29                  => p_attribute29
    ,p_attribute30                  => p_attribute30
    ,p_ethnic_origin                => p_ethnic_origin
    ,p_I_9                          => p_I_9
    ,p_I_9_expiration_date          => p_I_9_expiration_date

--    ,p_visa_type                    => p_visa_type
    ,p_veteran_status               => p_veteran_status
    ,p_new_hire                     => p_new_hire
    ,p_exception_reason             => p_exception_reason
    ,p_child_support_obligation     => p_child_support_obligation
    ,p_opted_for_medicare_flag      => p_opted_for_medicare_flag
    ,p_date_of_death                => p_date_of_death
    ,p_background_check_status      => p_background_check_status
    ,p_background_date_check        => p_background_date_check
    ,p_blood_type                   => p_blood_type
    ,p_correspondence_language      => p_correspondence_language
    ,p_fast_path_employee           => p_fast_path_employee
    ,p_fte_capacity                 => p_fte_capacity

    ,p_honors                       => p_honors
    ,p_internal_location            => p_internal_location
    ,p_last_medical_test_by         => p_last_medical_test_by
    ,p_last_medical_test_date       => p_last_medical_test_date
    ,p_mailstop                     => p_mailstop
    ,p_office_number                => p_office_number
    ,p_on_military_service          => p_on_military_service
    ,p_pre_name_adjunct             => p_pre_name_adjunct
    ,p_rehire_recommendation        => p_rehire_recommendation  -- Bug 3210500
    ,p_projected_start_date         => p_projected_start_date
    ,p_resume_exists                => p_resume_exists
    ,p_resume_last_updated          => p_resume_last_updated
    ,p_second_passport_exists       => p_second_passport_exists

    ,p_student_status               => p_student_status
    ,p_work_schedule                => p_work_schedule
    ,p_suffix                       => p_suffix
    ,p_benefit_group_id             => p_benefit_group_id
    ,p_receipt_of_death_cert_date   => p_receipt_of_death_cert_date
    ,p_coord_ben_med_pln_no         => p_coord_ben_med_pln_no
    ,p_coord_ben_no_cvg_flag        => p_coord_ben_no_cvg_flag
    ,p_coord_ben_med_ext_er         => p_coord_ben_med_ext_er
    ,p_coord_ben_med_pl_name        => p_coord_ben_med_pl_name
    ,p_coord_ben_med_insr_crr_name  => p_coord_ben_med_insr_crr_name
    ,p_coord_ben_med_insr_crr_ident => p_coord_ben_med_insr_crr_ident
    ,p_coord_ben_med_cvg_strt_dt    => p_coord_ben_med_cvg_strt_dt
    ,p_coord_ben_med_cvg_end_dt     => p_coord_ben_med_cvg_end_dt

    ,p_uses_tobacco_flag            => p_uses_tobacco_flag
    ,p_dpdnt_adoption_date          => p_dpdnt_adoption_date
    ,p_dpdnt_vlntry_svce_flag       => p_dpdnt_vlntry_svce_flag
    ,p_original_date_of_hire        => p_original_date_of_hire
    ,p_adjusted_svc_date            => p_adjusted_svc_date
    ,p_town_of_birth                => p_town_of_birth
    ,p_region_of_birth              => p_region_of_birth
    ,p_country_of_birth             => p_country_of_birth
    ,p_global_person_id             => p_global_person_id
    ,p_party_id                     => p_party_id
    ,p_person_id                    => p_person_id
    ,p_assignment_id                => p_assignment_id
    ,p_per_object_version_number    => p_per_object_version_number

    ,p_asg_object_version_number    => p_asg_object_version_number
    ,p_per_effective_start_date     => p_per_effective_start_date
    ,p_per_effective_end_date       => p_per_effective_end_date
    ,p_full_name                    => p_full_name
    ,p_per_comment_id               => p_per_comment_id
    ,p_assignment_sequence          => p_assignment_sequence
    ,p_assignment_number            => p_assignment_number
    ,p_name_combination_warning     => p_name_combination_warning
    ,p_assign_payroll_warning       => p_assign_payroll_warning
    ,p_orig_hire_warning            => l_orig_hire_warning
  );
--
 if g_debug then

hr_utility.set_location('Leaving:'||l_proc,333);
 end if;
--
end create_us_employee;
--
-- End of fix for bug 899720
--
-- ----------------------------------------------------------------------------
-- |--------------------------< re_hire_ex_employee >-------------------------|
-- ----------------------------------------------------------------------------
procedure re_hire_ex_employee
  (p_validate                      in     boolean  default false
  ,p_hire_date                     in     date

  ,p_person_id                     in     number
  ,p_per_object_version_number     in out nocopy number
  ,p_person_type_id                in     number   default hr_api.g_number
  ,p_rehire_reason                 in     varchar2
  ,p_assignment_id                    out nocopy number
  ,p_asg_object_version_number        out nocopy number
  ,p_per_effective_start_date         out nocopy date
  ,p_per_effective_end_date           out nocopy date
  ,p_assignment_sequence              out nocopy number
  ,p_assignment_number                out nocopy varchar2
  ,p_assign_payroll_warning           out nocopy boolean
  ) is
  --

  -- declare local variables
  --
  l_proc                      varchar2(72) := g_package||'re_hire_ex_employee';
  l_business_group_id         per_people_f.business_group_id%type;
  l_ovn per_people_f.object_version_number%type := p_per_object_version_number;
  l_name_combination_warning  boolean;
  l_orig_hire_warning         boolean;
  l_person_type_id            per_people_f.person_type_id%type := p_person_type_id;
  l_person_type_id1           per_people_f.person_type_id%type;
  l_comment_id                per_people_f.comment_id%type;
  l_current_applicant_flag    per_people_f.current_applicant_flag%type;
  l_current_emp_or_apl_flag   per_people_f.current_emp_or_apl_flag%type;
  l_current_employee_flag     per_people_f.current_employee_flag%type;

  l_employee_number           per_people_f.employee_number%type;
  l_applicant_number          per_people_f.applicant_number%TYPE;
  l_npw_number                per_people_f.npw_number%type;
  l_full_name                 per_people_f.full_name%type;
  l_object_version_number     per_people_f.object_version_number%type;
  l_period_of_service_id      per_periods_of_service.period_of_service_id%type;
  l_pds_object_version_number per_periods_of_service.object_version_number%type;
  l_datetrack_mode            varchar2(12);
  l_effective_date            date;
  l_hire_date                 date;
  l_assign_payroll_warning    boolean :=FALSE;
--
-- Added local variables for after hook re_hire_ex_employee_a

--
-- Bug 1828850 starts here.
-- The l_assignment_id is declared as per_assignments_f.assignment_id%type.
--
  l_assignment_id                    per_assignments_f.assignment_id%type;
--
-- Bug 1828850 Ends here.
--
  l_asg_object_version_number        number(9);
  l_per_effective_start_date         date;
  l_per_effective_end_date           date;
  l_assignment_sequence              number(15);
  l_assignment_number                varchar2(30);

--

  -- --------------------------------------------------------------------------
  -- |-------------------------< get_person_details >-------------------------|
  -- --------------------------------------------------------------------------
  --
  -- Description
  --   This procedure is used for 2 purposes; to validate that the person
  --   exists as of the specified effective date and to select the
  --   business group, effective start date and system person type information
  --
  -- --------------------------------------------------------------------------
  procedure get_person_details

    (p_person_id                 in     number,
     p_effective_date            in     date,
     p_business_group_id            out nocopy number,
     p_employee_number              out nocopy varchar2,
     p_effective_start_date         out nocopy date,
     p_system_person_type           out nocopy varchar2) is
    --
    l_proc      varchar2(72);
    --
    -- select and validate the person
    --
    cursor csr_chk_person_exists is
      select  per.business_group_id,

              per.employee_number,
              per.effective_start_date,
              pet.system_person_type
      from    per_person_types pet,
              per_people_f per
      where   per.person_id = p_person_id
      and     pet.person_type_id        = per.person_type_id
      and     pet.business_group_id + 0 = per.business_group_id
      and     p_effective_date
      between per.effective_start_date
      and     per.effective_end_date;
    --
  begin

 if g_debug then
  l_proc := g_package||'get_person_details';
    hr_utility.set_location('Entering:'|| l_proc, 5);
 end if;
    --
    open  csr_chk_person_exists;
    fetch csr_chk_person_exists into
      p_business_group_id, p_employee_number, p_effective_start_date,
      p_system_person_type;
    if csr_chk_person_exists%notfound then
      close csr_chk_person_exists;
      --
      -- the person cannot exist as of the supplied effective_date therefore

      -- we must error
      --
      -- This person either does not exist at all or does not exist as of the
      -- date specified.
      --
      hr_utility.set_message(801, 'HR_51011_PER_NOT_EXIST_DATE');
      hr_utility.raise_error;
    end if;
    close csr_chk_person_exists;
 if g_debug then
    hr_utility.set_location(' Leaving:'||l_proc, 10);
 end if;
  end get_person_details;

  -- --------------------------------------------------------------------------
  -- |-------------------------< perform_validation >-------------------------|
  -- --------------------------------------------------------------------------
  --
  -- Description
  --   This procedure controls and performs the following business process
  --   validation:
  --   1) ensure that the p_person_id and p_hire_date parameters are not null.
  --   2) check that this person (p_person_id) exists as of p_hire_date and
  --      the current person type (per_people_f.person_type_id) has a
  --      corresponding system person type of EX_EMP.
  --   3) ensure the most recent period of service for this person has been
  --      completely terminated.

  --
  -- --------------------------------------------------------------------------
  procedure perform_validation
    (p_person_id                 in     number,
     p_hire_date                 in     date,
     p_effective_date               out nocopy date,
     p_business_group_id            out nocopy number,
     p_employee_number              out nocopy varchar2) is
  --
    l_proc                  varchar2(72) := g_package||'perform_validation';
    l_system_person_type    per_person_types.system_person_type%type;
    l_final_process_date    per_periods_of_service.final_process_date%type;
    l_effective_start_date  per_people_f.effective_start_date%type;

    l_dummy_number          number;
    l_dummy_emp_number      varchar2(30);
    l_dummy_date            date;
  --
  cursor csr_chk_period_of_service is
    select pos.final_process_date
    from   per_periods_of_service pos
    where  pos.person_id = p_person_id
    order by pos.date_start desc;
  --
  begin
 if g_debug then
    hr_utility.set_location('Entering:'|| l_proc, 5);

 end if;
    --
    -- Validation Logic
    --
    -- 1. ensure that the mandatory parameters p_hire_date and p_person_id
    --    are not null
    --
    hr_api.mandatory_arg_error
      (p_api_name       => l_proc
      ,p_argument       => 'person id'
      ,p_argument_value => p_person_id);
    --
    hr_api.mandatory_arg_error

      (p_api_name       => l_proc
      ,p_argument       => 'hire date'
      ,p_argument_value => p_hire_date);
    --
    -- 2. check that this person (p_person_id) exists as of p_hire_date and the
    --    the current person type (per_people_f.person_type_id) has a
    --    corresponding system person type of EX_EMP.
    --
    get_person_details
      (p_person_id                 => p_person_id,
       p_effective_date            => p_hire_date,
       p_business_group_id         => p_business_group_id,
       p_employee_number           => p_employee_number,

       p_effective_start_date      => l_effective_start_date,
       p_system_person_type        => l_system_person_type);
    --
    -- ensure that the system person type is 'EX_EMP'
    --
    if (l_system_person_type <> 'EX_EMP') then
      --
      -- the system person type is not 'EX_EMP' therefore error
      -- You cannot Re-Hire a person who is not an Ex-Employee.
      --
      hr_utility.set_message(801, 'HR_51012_REHIRE_NOT_EX_EMP');
      hr_utility.raise_error;
    end if;

 if g_debug then
    hr_utility.set_location(l_proc, 10);
 end if;
    --
    -- 3. ensure the most recent period of service for this person has been
    --    completely terminated. i.e. check that
    --    period_of_service.final_process_date is not null and comes before
    --    p_hire_date.
    --    we only fetch the 1st row (which is the latest pos).
    --
    open csr_chk_period_of_service;
    fetch csr_chk_period_of_service into l_final_process_date;
    if csr_chk_period_of_service%notfound then

      close csr_chk_period_of_service;
      --
      -- a period of service row does not exist for the person therefore
      -- we must error
      --
      -- This person does not have a previous period of service
      --
      hr_utility.set_message(801, 'HR_51013_PDS_NOT_EXIST');
      hr_utility.raise_error;
    end if;
    close csr_chk_period_of_service;
    --
    if (l_final_process_date is null) then

      --
      -- the employee cannot be terminated as the final process date has not
      -- been set
      --
      -- You cannot re-hire a person who does not have a final processing date
      -- set for their most recent period of service
      --
      hr_utility.set_message(801, 'HR_51014_REHIRE_FINAL_DATE');
      hr_utility.raise_error;
    elsif (l_final_process_date >= p_hire_date) then
      --
      -- the re hire date is before the current final process date
      --

      -- You cannot re-hire an Ex-Employee before their final processing date.
      -- Please specify a Re-Hire date which is after the final processing date.
      --
      hr_utility.set_message(801, 'HR_51015_REHIRE_NEW_DATE');
      hr_utility.raise_error;
    end if;
 if g_debug then
    hr_utility.set_location(l_proc, 20);
 end if;
    p_effective_date := l_effective_start_date;
    --

 if g_debug then

    hr_utility.set_location(' Leaving:'||l_proc, 25);
 end if;
  end perform_validation;

begin
 if g_debug then
  hr_utility.set_location('Entering:'|| l_proc, 5);
 end if;
  --
  -- Issue a savepoint.
  --
  savepoint re_hire_ex_employee;
  --

  -- Initialise local variables
  --
  l_object_version_number := p_per_object_version_number;
  l_applicant_number := hr_api.g_varchar2;
  l_npw_number       := hr_api.g_varchar2;
  l_hire_date        := trunc(p_hire_date);
  --
  -- perform business process validation
  --
  perform_validation
    (p_person_id                 => p_person_id,
     p_hire_date                 => l_hire_date,
     p_effective_date            => l_effective_date,

     p_business_group_id         => l_business_group_id,
     p_employee_number           => l_employee_number);
  --
  -- processing logic
  --
 if g_debug then
  hr_utility.set_location(l_proc, 10);
 end if;
  l_person_type_id := p_person_type_id;
  --
 begin
    --
    -- Start of call API User Hook for the before hook of re_hire_ex_employee

    --
hr_employee_bk2.re_hire_ex_employee_b
  (
   p_business_group_id             =>l_business_group_id
  ,p_hire_date                     =>l_hire_date
  ,p_person_id                     =>p_person_id
  ,p_per_object_version_number     =>p_per_object_version_number
  ,p_person_type_id                =>p_person_type_id
  ,p_rehire_reason                 =>p_rehire_reason
   );
  exception
    when hr_api.cannot_find_prog_unit then
      hr_api.cannot_find_prog_unit_error

        (p_module_name => 'RE_HIRE_EX_EMPLOYEE'
        ,p_hook_type   => 'BP'
        );
    --
    -- End of API User Hook for the before hook of re_hire_ex_employee
    --
  end;
  --
  -- derive and/or validate the person type
  --
  per_per_bus.chk_person_type
    (p_person_type_id     => l_person_type_id,
     p_business_group_id  => l_business_group_id,

     p_expected_sys_type  => 'EMP');
  --
 if g_debug then
  hr_utility.set_location(l_proc, 15);
 end if;
  --
  if (l_effective_date = p_hire_date) then
    l_datetrack_mode := 'CORRECTION';
  else
    l_datetrack_mode := 'UPDATE';
  end if;

-- PTU : Added


  l_person_type_id1 := hr_person_type_usage_info.get_default_person_type_id
                                        (l_business_group_id,
                                         'EMP');
-- PTU : End

  -- update the person re-hiring as an employee as of the hire date
  --
  per_per_upd.upd
    (p_person_id                 => p_person_id,
     p_person_type_id            => l_person_type_id1,
     p_effective_date            => l_hire_date,
     p_datetrack_mode            => l_datetrack_mode,

     p_object_version_number     => p_per_object_version_number,
     p_dob_null_warning          => p_assign_payroll_warning,
     p_effective_start_date      => l_per_effective_start_date,
     p_effective_end_date        => l_per_effective_end_date,
     p_rehire_reason             => p_rehire_reason,
     p_name_combination_warning  => l_name_combination_warning,
     p_orig_hire_warning         => l_orig_hire_warning,
     p_comment_id                => l_comment_id,
     p_current_applicant_flag    => l_current_applicant_flag,
     p_current_emp_or_apl_flag   => l_current_emp_or_apl_flag,
     p_current_employee_flag     => l_current_employee_flag,
     p_employee_number           => l_employee_number,
     p_applicant_number          => l_applicant_number,

     p_full_name                 => l_full_name,
     p_npw_number                => l_npw_number);
  --
 if g_debug then
  hr_utility.set_location(l_proc, 20);
 end if;
  --
  -- add to current security list
  -- when in validation only mode raise the Validate_Enabled exception
  --
  hr_security_internal.populate_new_person(l_business_group_id,p_person_id);
-- PTU : Following Code has been added


hr_per_type_usage_internal.maintain_person_type_usage
(p_effective_date        => l_hire_date
,p_person_id             => p_person_id
,p_person_type_id        => l_person_type_id
,p_datetrack_update_mode => l_datetrack_mode
);

-- PTU : End of changes
  --
 if g_debug then
  hr_utility.set_location(l_proc, 22);
 end if;
  --

  -- create a new period of service for the re-hired employee
  --
  per_pds_ins.ins
    (p_business_group_id         => l_business_group_id,
     p_person_id                 => p_person_id,
     p_date_start                => l_hire_date,
     p_period_of_service_id      => l_period_of_service_id,
     p_effective_date            => p_hire_date,
     p_validate_df_flex          => false,
     p_object_version_number     => l_pds_object_version_number);
  --
 if g_debug then
  hr_utility.set_location(l_proc, 25);

 end if;
  --
  -- create a default primary assignment with any corresponding standard
  -- element entries for the re-hired employee
  --
  hr_assignment_internal.create_default_emp_asg
    (p_effective_date         => l_hire_date,
     p_person_id              => p_person_id,
     p_business_group_id      => l_business_group_id,
     p_period_of_service_id   => l_period_of_service_id,
     p_assignment_id          => l_assignment_id,
     p_object_version_number  => l_asg_object_version_number,
     p_assignment_sequence    => l_assignment_sequence,

     p_assignment_number      => l_assignment_number);
  --
  -- when in validation only mode raise the Validate_Enabled exception
  --
  -- 1766066: added call for contact start date enh.
  --
  per_people12_pkg.maintain_coverage(p_person_id      => p_person_id
                                    ,p_type           => 'EMP'
                                    );
  -- 1766066 end.
begin
    --
    -- Start of call API User Hook for the after hook of re_hire_ex_employee

    --
hr_employee_bk2.re_hire_ex_employee_a
  (
   p_business_group_id             =>l_business_group_id
  ,p_hire_date                     =>l_hire_date
  ,p_person_id                     =>p_person_id
  ,p_per_object_version_number     =>p_per_object_version_number
  ,p_person_type_id                =>p_person_type_id
  ,p_rehire_reason                 =>p_rehire_reason
  ,p_assignment_id                 =>l_assignment_id
  ,p_asg_object_version_number     =>l_asg_object_version_number
  ,p_per_effective_start_date      =>l_per_effective_start_date
  ,p_per_effective_end_date        =>l_per_effective_end_date

  ,p_assignment_sequence           =>l_assignment_sequence
  ,p_assignment_number             =>l_assignment_number
  ,p_assign_payroll_warning        =>l_assign_payroll_warning
  );
  exception
    when hr_api.cannot_find_prog_unit then
      hr_api.cannot_find_prog_unit_error
        (p_module_name => 'RE_HIRE_EX_EMPLOYEE'
        ,p_hook_type   => 'BP'
        );
    --
    -- End of API User Hook for the after hook of re_hire_ex_employee
    --

  end;
  --
  if p_validate then
    raise hr_api.validate_enabled;
  end if;
  --
  -- Set all output arguments
  --
   p_assignment_id                    := l_assignment_id;
   p_asg_object_version_number        := l_asg_object_version_number;
   p_per_effective_start_date         := l_per_effective_start_date;
   p_per_effective_end_date           := l_per_effective_end_date;
   p_assignment_sequence              := l_assignment_sequence;

   p_assignment_number                := l_assignment_number;
   p_assign_payroll_warning           := l_assign_payroll_warning;
  --
  -- When in validation only mode raise the Validate_Enabled exception
  --
 if g_debug then
  hr_utility.set_location(' Leaving:'||l_proc, 30);
 end if;
exception
  when hr_api.validate_enabled then
    --
    -- As the Validate_Enabled exception has been raised
    -- we must rollback to the savepoint

    --
    ROLLBACK TO re_hire_ex_employee;
    --
    -- Only set output warning arguments
    -- (Any key or derived arguments must be set to null
    -- when validation only mode is being used.)
    --
    p_per_object_version_number := l_object_version_number;
    p_assignment_id             := null;
    p_asg_object_version_number := null;
    p_per_effective_start_date  := null;
    p_per_effective_end_date    := null;
    p_assignment_sequence       := null;

    p_assignment_number         := null;
    p_assign_payroll_warning    := l_assign_payroll_warning;
    --
  when others then
    --
    -- A validation or unexpected error has occurred
    --
    p_per_object_version_number := l_ovn;
    p_assignment_id             := null;
    p_asg_object_version_number := null;
    p_per_effective_start_date  := null;
    p_per_effective_end_date    := null;
    p_assignment_sequence       := null;

    p_assignment_number         := null;
    p_assign_payroll_warning    := false;
    -- Added as part of fix to bug 632479
    --
    ROLLBACK TO re_hire_ex_employee;
    --
    -- set in out parameters and set out parameters
    --
    raise;
    --
    -- End of fix.
    --
 if g_debug then

    hr_utility.set_location(' Leaving:'||l_proc, 35);
 end if;
end re_hire_ex_employee;
--
-- ----------------------------------------------------------------------------
-- |-----------------< apply_for_internal_vacancy >-------------------------|
-- ----------------------------------------------------------------------------
procedure apply_for_internal_vacancy
  (p_validate                      in     boolean  default false
  ,p_effective_date                in     date
  ,p_person_id                     in     number
  ,p_applicant_number              in out nocopy varchar2
  ,p_per_object_version_number     in out nocopy number

  ,p_vacancy_id                    in     number   default null
  ,p_person_type_id                in     number   default hr_api.g_number
  ,p_application_id                   out nocopy number
  ,p_assignment_id                    out nocopy number
  ,p_apl_object_version_number        out nocopy number
  ,p_asg_object_version_number        out nocopy number
  ,p_assignment_sequence              out nocopy number
  ,p_per_effective_start_date         out nocopy date
  ,p_per_effective_end_date           out nocopy date
  ) is
  --
  -- declare local variables
  --

  l_proc                      varchar2(72) := g_package||'apply_for_internal_vacancy';
  l_business_group_id         per_people_f.business_group_id%type;
  l_name_combination_warning  boolean;
  l_dob_null_warning          boolean;
  l_orig_hire_warning         boolean;
  l_organization_id           per_business_groups.organization_id%type;
  l_legislation_code          per_business_groups.legislation_code%type;
  l_person_type_id            per_people_f.person_type_id%type  := p_person_type_id;
  l_person_type_id1           per_people_f.person_type_id%type;
  l_application_id            per_applications.application_id%type;
  l_comment_id                per_assignments_f.comment_id%type;
  l_assignment_sequence       per_assignments_f.assignment_sequence%type;
  l_assignment_id         per_assignments_f.assignment_id%type;

  l_object_version_number     per_assignments_f.object_version_number%type;
  l_current_applicant_flag    per_people_f.current_applicant_flag%type;
  l_current_emp_or_apl_flag   per_people_f.current_emp_or_apl_flag%type;
  l_current_employee_flag     per_people_f.current_employee_flag%type;
  l_employee_number           per_people_f.employee_number%type;
  l_applicant_number          per_people_f.applicant_number%TYPE;
  l_npw_number                per_people_f.npw_number%TYPE;
  l_per_object_version_number per_people_f.object_version_number%TYPE;
  l_full_name                 per_people_f.full_name%type;
  l_system_person_type        per_person_types.system_person_type%type;
  l_effective_date            date;
  l_effective_start_date      date;
  l_effective_end_date        date;

  l_default_start_time        per_business_groups.default_start_time%type;
  l_default_end_time          per_business_groups.default_end_time%type;
  l_normal_hours              number;
  l_frequency                 per_business_groups.frequency%type;
  l_recruiter_id              per_vacancies.recruiter_id%type;
  l_grade_id                  per_vacancies.grade_id%type;
  l_position_id               per_vacancies.position_id%type;
  l_job_id                    per_vacancies.job_id%type;
  l_location_id               per_vacancies.location_id%type;
  l_people_group_id           per_vacancies.people_group_id%type;
  l_vac_organization_id       per_vacancies.organization_id%type;
  l_vac_business_group_id     per_vacancies.business_group_id%type;
  l_group_name            pay_people_groups.group_name%type;

--
--         Local variable added for the before and after business process
--         apply_for_internal_vacancy
--
  l_apl_object_version_number          number; -- THESE NEED TO BE CHANGED
  l_asg_object_version_number          number; -- THESE NEED TO BE CHANGED
  l_per_effective_start_date           date;
  l_per_effective_end_date             date;
--
    --
    -- select and validate the person
    --
    -- now returns employee number which is needed by upd.upd - thayden

    --
    cursor csr_chk_person_exists is
      select   ppf.business_group_id
              ,ppf.employee_number
              ,ppf.npw_number
              ,ppt.system_person_type
      from     per_person_types ppt
              ,per_people_f ppf
      where   ppf.person_id = p_person_id
      and     ppt.person_type_id        = ppf.person_type_id
      and     ppt.business_group_id + 0 = ppf.business_group_id
      and     l_effective_date
      between ppf.effective_start_date

      and     ppf.effective_end_date;
    --
    --  Get default person type id for a system person type EMP_APL
    --
    cursor csr_get_person_type_id is
      select   person_type_id
      from     per_person_types
      where business_group_id = l_business_group_id
      and   active_flag = 'Y'
      and   default_flag = 'Y'
      and   system_person_type = 'EMP_APL';
    --
    -- Get organization id for business group.

    --
    cursor csr_get_organization_id is
      select  organization_id
             ,legislation_code
             ,default_start_time
             ,default_end_time
             ,fnd_number.canonical_to_number(working_hours)
             ,frequency
              from per_business_groups
      where business_group_id = l_business_group_id;
    --
    -- Get vacancy information.
    --

    cursor csr_get_vacancy_details is
      select  recruiter_id
             ,grade_id
             ,position_id
             ,job_id
             ,location_id
             ,people_group_id
             ,organization_id   -- added org id to cursor. thayden 7/10.
             ,business_group_id  -- added business_group_id to cursor lma 7/11
       from per_vacancies
      where vacancy_id = p_vacancy_id;
    --
  begin

    -- Bug 665566 Savepoint issued before validations start
    --
    -- Issue a savepoint if operating in validation only mode.
    --
    if p_validate then
      savepoint apply_for_internal_vacancy;
    end if;
    -- Bug 665566 End

    if g_debug then
       hr_utility.set_location('Entering:'|| l_proc, 5);
    end if;
    --

    -- Truncate p_effective_date
    --
    l_effective_date := trunc(p_effective_date);
    -- Initialise local variables
    --
    l_applicant_number          := p_applicant_number;
    l_per_object_version_number := p_per_object_version_number;
    --
    --
    -- Validation Logic
    --
    --  Ensure that the mandatory parameter, p_person_id
    --  is not null

    --
    hr_api.mandatory_arg_error
      (p_api_name       => l_proc
      ,p_argument       => 'person id'
      ,p_argument_value => p_person_id);
    --
 if g_debug then
    hr_utility.set_location(' Leaving:'||l_proc, 10);
 end if;
    --
    -- Check that this person (p_person_id) exists as of l_effective_date
    -- the current person type (per_people_f.person_type_id) has a
    -- corresponding system person type of EMP.

    --
    open  csr_chk_person_exists;
    fetch csr_chk_person_exists into
       l_business_group_id
      ,l_employee_number
      ,l_npw_number
      ,l_system_person_type;
    if csr_chk_person_exists%notfound then
      close csr_chk_person_exists;
      hr_utility.set_message(800, 'HR_51011_PER_NOT_EXIST_DATE');
      hr_utility.raise_error;
    end if;
    close csr_chk_person_exists;

    --
    --
    -- ensure that the system person type is 'EMP'
    -- added and l_system_person_type <> 'EMP_APL' to if 15-Jul-97 lma
    if (l_system_person_type <> 'EMP' and l_system_person_type <> 'EMP_APL') then
      --
      -- the system person type is not 'EMP'.
      --
      hr_utility.set_message(800, 'PER_52788_PER_INV_PER_TYPE');
      hr_utility.raise_error;
    end if;
 if g_debug then
    hr_utility.set_location(l_proc, 15);

 end if;

  --
  -- Initialise local variables
  --
  l_applicant_number          := p_applicant_number;
  l_per_object_version_number := p_per_object_version_number;
  --
begin
    --
    -- Start of call API User Hook for the before hook of apply_for_internal_vacancy_b
    --
hr_employee_bk3.apply_for_internal_vacancy_b

   (
    p_business_group_id                => l_business_group_id
   ,p_effective_date                   => l_effective_date
   ,p_person_id                        => p_person_id
   ,p_applicant_number                 => p_applicant_number
   ,p_per_object_version_number        => p_per_object_version_number
   ,p_vacancy_id                       => p_vacancy_id
   ,p_person_type_id                   => p_person_type_id
  );
  exception
    when hr_api.cannot_find_prog_unit then
      hr_api.cannot_find_prog_unit_error
        (p_module_name => 'APPLY_FOR_INTERNAL_VACANCY'

        ,p_hook_type   => 'BP'
        );
    --
    -- End of API User Hook for the before hook of apply_for_internal_vacancy
    --
  end;
  -- processing logic
  --
 if g_debug then
  hr_utility.set_location(l_proc, 20);
 end if;
  --
    -- PTU : Following Code has been added

    -- Validate that the person_type_id passed is a flavour of 'APL' or derive the default
    --
    per_per_bus.chk_person_type
    (p_person_type_id     => l_person_type_id,
     p_business_group_id  => l_business_group_id,
     p_expected_sys_type  => 'APL');
    --
    --  Get default person type id for EMP_APL.
    --
    l_person_type_id1 :=  hr_person_type_usage_info.get_default_person_type_id
            (l_business_group_id,
          'EMP_APL');
    -- PTU end of changes

    --
--  open  csr_get_person_type_id;
--  fetch csr_get_person_type_id into
--      l_person_type_id;
--    if csr_get_person_type_id%notfound then
--      close csr_get_person_type_id;
--      hr_utility.set_message(801, 'HR_7513_PER_TYPE_INVALID');
--      hr_utility.raise_error;
--    end if;
--  close csr_get_person_type_id;
  --
 if g_debug then
  hr_utility.set_location(l_proc, 25);

 end if;
  --
  --  Get organization id
  --
  open  csr_get_organization_id;
  fetch csr_get_organization_id into
      l_organization_id
     ,l_legislation_code
     ,l_default_start_time
     ,l_default_end_time
     ,l_normal_hours
     ,l_frequency;
    if csr_get_organization_id%notfound then

      close csr_get_organization_id;
      hr_utility.set_message(801, 'HR_7208_API_BUS_GRP_INVALID');
      hr_utility.raise_error;
    end if;
    close csr_get_organization_id;
  --
  --  Get vacancy details.
  --
  if p_vacancy_id is not null then
    open  csr_get_vacancy_details;
    fetch csr_get_vacancy_details into
      l_recruiter_id
     ,l_grade_id

     ,l_position_id
     ,l_job_id
     ,l_location_id
     ,l_people_group_id
     ,l_vac_organization_id  -- added org id. thayden 7/10.
     ,l_vac_business_group_id;   -- added business_group_id. thayden 7/11.
    if csr_get_vacancy_details%notfound then
      close csr_get_vacancy_details;
      hr_utility.set_message(801, 'HR_51001_THE_VAC_NOT_FOUND');
      hr_utility.raise_error;
    end if;
    close csr_get_vacancy_details;
    --added if ... end if (Rod's sugguestion)

    if l_vac_organization_id is null then
      l_vac_organization_id := l_vac_business_group_id;
    end if;
  else
   l_vac_organization_id  := l_business_group_id;
  end if;
  --
 if g_debug then
  hr_utility.set_location(l_proc, 30);
 end if;
  --
  if l_system_person_type <> 'EMP_APL' then
    --

    -- update the person from an employee to an employee applicant.
    --
    per_per_upd.upd
      (p_person_id                 => p_person_id
      ,p_person_type_id            => l_person_type_id1
      ,p_effective_date            => l_effective_date
      ,p_datetrack_mode            => 'UPDATE'
      ,p_object_version_number     => p_per_object_version_number
      ,p_effective_start_date      => l_per_effective_start_date
      ,p_effective_end_date        => l_per_effective_end_date
      ,p_name_combination_warning  => l_name_combination_warning
      ,p_dob_null_warning          => l_dob_null_warning
      ,p_orig_hire_warning         => l_orig_hire_warning

      ,p_comment_id                => l_comment_id
      ,p_current_applicant_flag    => l_current_applicant_flag
      ,p_current_emp_or_apl_flag   => l_current_emp_or_apl_flag
      ,p_current_employee_flag     => l_current_employee_flag
      ,p_applicant_number          => p_applicant_number
      ,p_employee_number           => l_employee_number
      ,p_full_name                 => l_full_name
      ,p_npw_number                => l_npw_number
      );
    --
 if g_debug then
    hr_utility.set_location(l_proc, 35);
 end if;

    --
    -- create an application.
    --
    per_apl_ins.ins
      (p_application_id            => l_application_id
      ,p_business_group_id         => l_business_group_id
      ,p_person_id                 => p_person_id
      ,p_date_received             => l_effective_date
      ,p_object_version_number     => l_apl_object_version_number
      ,p_effective_date            => l_effective_date
      );
    --
 if g_debug then

    hr_utility.set_location(l_proc, 40);
 end if;
    --
    -- create an applicant assignment for the employee
    --
    hr_assignment_internal.create_apl_asg
      (p_effective_date               => l_effective_date
      ,p_legislation_code             => l_legislation_code
      ,p_business_group_id            => l_business_group_id
      ,p_person_id                    => p_person_id
      ,p_organization_id              => l_vac_organization_id
      ,p_application_id               => l_application_id
      ,p_recruiter_id                 => l_recruiter_id

      ,p_grade_id                     => l_grade_id
      ,p_position_id                  => l_position_id
      ,p_job_id                       => l_job_id
      ,p_location_id                  => l_location_id
      ,p_people_group_id              => l_people_group_id
      ,p_vacancy_id                   => p_vacancy_id
      ,p_frequency                    => l_frequency
      ,p_manager_flag                 => 'N'
      ,p_normal_hours                 => l_normal_hours
      ,p_time_normal_finish           => l_default_end_time
      ,p_time_normal_start            => l_default_start_time
      ,p_assignment_id                => l_assignment_id
      ,p_object_version_number        => l_asg_object_version_number

      ,p_effective_start_date         => l_effective_start_date
      ,p_effective_end_date           => l_effective_end_date
      ,p_assignment_sequence          => l_assignment_sequence
      ,p_comment_id                   => l_comment_id
      );
    --
    -- add to the security list
    --
    hr_security_internal.add_to_person_list(l_effective_date,l_assignment_id);
    --
    --
 if g_debug then
    hr_utility.set_location(l_proc, 45);

 end if;
  else --l_system_person_type = 'EMP_APL'
    --
    -- create secondary applicant assignment for the employee
    --
    -- Get application_id for this person to link this assignment to...
    --
    select application_id
      into l_application_id
      from per_applications
     where person_id=p_person_id
       and l_effective_date between date_received and
                                    nvl(date_end,hr_general.end_of_time);

    --
    -- create an applicant assignment for the employee
    -- but use the create_apl_asg BSI as we don't have any information,
    -- like PGP keyflex, about the assignment other than the vacancy
    -- details and this one will enable us to by-pass all the flexfield
    -- validation.
    --
    hr_assignment_internal.create_apl_asg
      (p_effective_date               => l_effective_date
      ,p_legislation_code             => l_legislation_code
      ,p_business_group_id            => l_business_group_id
      ,p_person_id                    => p_person_id
      ,p_organization_id              => l_vac_organization_id

      ,p_application_id               => l_application_id
      ,p_recruiter_id                 => l_recruiter_id
      ,p_grade_id                     => l_grade_id
      ,p_position_id                  => l_position_id
      ,p_job_id                       => l_job_id
      ,p_location_id                  => l_location_id
      ,p_people_group_id              => l_people_group_id
      ,p_vacancy_id                   => p_vacancy_id
      ,p_frequency                    => l_frequency
      ,p_manager_flag                 => 'N'
      ,p_normal_hours                 => l_normal_hours
      ,p_time_normal_finish           => l_default_end_time
      ,p_time_normal_start            => l_default_start_time

      ,p_validate_df_flex             => FALSE
      ,p_assignment_id                => l_assignment_id
      ,p_object_version_number        => l_asg_object_version_number
      ,p_effective_start_date         => l_effective_start_date
      ,p_effective_end_date           => l_effective_end_date
      ,p_assignment_sequence          => l_assignment_sequence
      ,p_comment_id                   => l_comment_id
      );
    --
    -- add to the security list
    --
    hr_security_internal.add_to_person_list(l_effective_date,l_assignment_id);
  end if;

  --
  -- PTU: following code added:
  --
  begin
    select ptuf.person_type_id into l_person_type_id1
    from per_person_type_usages_f ptuf,
         per_person_types ppt
    where ptuf.person_id = p_person_id
    and p_effective_date between ptuf.effective_start_date
    and ptuf.effective_end_date
    and ppt.person_type_id = ptuf.person_type_id
    and ppt.system_person_type = 'APL';
  exception

    when no_data_found then
    l_person_type_id1 := hr_api.g_number;
  end;
  --
  if l_system_person_type <> 'EMP_APL'
   OR (l_system_person_type = 'EMP_APL' AND  l_person_type_id <> l_person_type_id1) then
    hr_per_type_usage_internal.maintain_person_type_usage
    (p_effective_date       => l_effective_date
    ,p_person_id            => p_person_id
    ,p_person_type_id       => l_person_type_id
    );
  end if;
  --

  -- PTU end of changes
  --
  begin
    --
    -- Start of call API User Hook for the after hook of re_hire_ex_employee
    --
    hr_employee_bk3.apply_for_internal_vacancy_a
     (
      p_business_group_id             => l_business_group_id
     ,p_effective_date                => l_effective_date
     ,p_person_id                     => p_person_id
     ,p_applicant_number              => p_applicant_number
     ,p_per_object_version_number     => p_per_object_version_number

     ,p_vacancy_id                    => p_vacancy_id
     ,p_person_type_id                => p_person_type_id
     ,p_application_id                => l_application_id
     ,p_assignment_id                 => l_assignment_id
     ,p_apl_object_version_number     => l_apl_object_version_number
     ,p_asg_object_version_number     => l_asg_object_version_number
     ,p_assignment_sequence           => l_assignment_sequence
     ,p_per_effective_start_date      => l_per_effective_start_date
     ,p_per_effective_end_date        => l_per_effective_end_date
    );
   --
   exception
    when hr_api.cannot_find_prog_unit then

      hr_api.cannot_find_prog_unit_error
        (p_module_name => 'APPLY_FOR_INTERNAL_VACANCY'
        ,p_hook_type   => 'BP'
        );
    --
    -- End of API User Hook for the after hook of apply_for_internal_vacancy
    --
  end;
  --
  --  Set all output arguments
  --
   p_application_id                   := l_application_id;
   p_assignment_id                    := l_assignment_id;

   p_apl_object_version_number        := l_apl_object_version_number;
   p_asg_object_version_number        := l_asg_object_version_number;
   p_assignment_sequence              := l_assignment_sequence;
   p_per_effective_start_date         := l_per_effective_start_date;
   p_per_effective_end_date           := l_per_effective_end_date;
  --
  -- when in validation only mode raise the Validate_Enabled exception
  --

  if p_validate then
    raise hr_api.validate_enabled;
  end if;
  --

 if g_debug then
  hr_utility.set_location(' Leaving:'||l_proc, 50);
 end if;
exception
  when hr_api.validate_enabled then
    --
    -- As the Validate_Enabled exception has been raised
    -- we must rollback to the savepoint
    --
    ROLLBACK TO apply_for_internal_vacancy;
    --
    -- Only set output warning arguments
    -- (Any key or derived arguments must be set to null

    -- when validation only mode is being used.)
    --
    p_per_object_version_number := l_per_object_version_number;
    p_applicant_number          := l_applicant_number;
    p_application_id            := null;
    p_assignment_id             := null;
    p_apl_object_version_number := null;
    p_asg_object_version_number := null;
    p_assignment_sequence       := null;
    p_per_effective_start_date  := null;
    p_per_effective_end_date    := null;
 if g_debug then
    hr_utility.set_location(' Leaving:'||l_proc, 55);

 end if;
end apply_for_internal_vacancy;
--
-- ----------------------------------------------------------------------------
-- |----------------------------< hire_into_job >-----------------------------|
-- ----------------------------------------------------------------------------
--
PROCEDURE hire_into_job
  (p_validate                     IN     BOOLEAN  DEFAULT FALSE
  ,p_effective_date               IN     DATE
  ,p_person_id                    IN     NUMBER
  ,p_object_version_number        IN OUT NOCOPY NUMBER
  ,p_employee_number              IN OUT NOCOPY VARCHAR2

  ,p_datetrack_update_mode        IN     VARCHAR2 DEFAULT NULL
  ,p_person_type_id               IN     NUMBER   DEFAULT NULL
  ,p_national_identifier          IN     VARCHAR2 DEFAULT NULL
  ,p_effective_start_date            OUT NOCOPY DATE
  ,p_effective_end_date              OUT NOCOPY DATE
  ,p_assign_payroll_warning          OUT NOCOPY BOOLEAN
  ,p_orig_hire_warning               OUT NOCOPY BOOLEAN
  )
IS
  --
  -- Local variables
  --
  l_proc                         VARCHAR2(72) := g_package||'hire_into_job';

  --
  l_effective_date               DATE;
  --
  l_object_version_number        CONSTANT per_all_assignments_f.object_version_number%TYPE := p_object_version_number;
  l_datetrack_update_mode        VARCHAR2(30) := p_datetrack_update_mode;
  l_employee_number              CONSTANT per_all_people_f.applicant_number%TYPE           := p_employee_number;
  l_emp_num per_all_people_f.applicant_number%TYPE  := p_employee_number;
  l_ovn per_all_people_f.object_version_number%TYPE := p_object_version_number;
  l_per_effective_start_date     per_all_people_f.effective_start_date%TYPE;
  l_per_effective_end_date       per_all_people_f.effective_end_date%TYPE;
  l_assign_payroll_warning       BOOLEAN;
  l_orig_hire_warning            BOOLEAN;
  --

  l_person_type_id               per_person_types.person_type_id%TYPE    := p_person_type_id;
  l_person_type_id1              per_person_types.person_type_id%TYPE;
  --
  l_future_asgs_count            INTEGER;
  l_system_person_type           per_person_types.system_person_type%TYPE;
  l_effective_start_date         DATE;
  l_effective_end_date           DATE;
  l_comment_id                   hr_comments.comment_id%TYPE;
  l_current_applicant_flag       per_all_people_f.current_applicant_flag%TYPE;
  l_current_emp_or_apl_flag      per_all_people_f.current_emp_or_apl_flag%TYPE;
  l_current_employee_flag        per_all_people_f.current_employee_flag%TYPE;
  l_full_name                    per_all_people_f.full_name%TYPE;
  l_name_combination_warning     BOOLEAN;

  l_period_of_service_id         per_periods_of_service.period_of_service_id%TYPE;
  l_pds_object_version_number    per_periods_of_service.object_version_number%TYPE;
  l_assignment_id                per_all_assignments_f.assignment_id%TYPE;
  l_asg_object_version_number    per_all_assignments_f.object_version_number%TYPE;
  l_assignment_sequence          per_all_assignments_f.assignment_sequence%TYPE;
  l_assignment_number            per_all_assignments_f.assignment_number%TYPE;
  l_person_type_usage_id         per_person_type_usages.person_type_usage_id%TYPE;
  l_ptu_object_version_number    per_person_type_usages.object_version_number%TYPE;
  --
  -- Start of fix for bug 3143299
  l_final_process_date      per_periods_of_service.final_process_date%type;
  --
  -- Local cursors

  cursor csr_chk_period_of_service is
  select pos.final_process_date
  from   per_periods_of_service pos
  where  pos.person_id = p_person_id
  order by pos.date_start desc;
  --
  -- End of fix for bug 3143299
  --
  CURSOR csr_per_details
    (p_person_id                    IN     per_all_people_f.person_id%TYPE
    ,p_effective_date               IN     DATE
    )
  IS

    SELECT pet.person_type_id
          ,pet.system_person_type
          ,per.effective_start_date
          ,per.effective_end_date
          ,per.applicant_number
          ,per.employee_number
          ,per.npw_number
          ,bus.business_group_id
          ,bus.legislation_code
      FROM per_people_f per
          ,per_business_groups bus
          ,per_person_types pet
     WHERE per.person_type_id      = pet.person_type_id

       AND per.business_group_id+0 = bus.business_group_id
       AND per.person_id           = csr_per_details.p_person_id
       AND csr_per_details.p_effective_date BETWEEN per.effective_start_date
                                                AND per.effective_end_date;
  l_per_details_rec              csr_per_details%ROWTYPE;
--
BEGIN
  --
 if g_debug then
  hr_utility.set_location('Entering:'||l_proc,10);
 end if;
  --
  -- Ensure mandatory arguments have been passed

  --
  hr_api.mandatory_arg_error
    (p_api_name                     => l_proc
    ,p_argument                     => 'person_id'
    ,p_argument_value               => p_person_id
    );
  --
  hr_api.mandatory_arg_error
    (p_api_name                     => l_proc
    ,p_argument                     => 'effective_date'
    ,p_argument_value               => p_effective_date
    );
  --

  -- Truncate all date parameters passed in
  --
  l_effective_date := TRUNC(p_effective_date);
  --
  -- Issue savepoint
  --
  SAVEPOINT hire_into_job;
  --
 if g_debug then
  hr_utility.set_location(l_proc,20);
 end if;
  --
  -- Get dervied details for person on effective date

  --
  OPEN csr_per_details
    (p_person_id                    => p_person_id
    ,p_effective_date               => p_effective_date
    );
  FETCH csr_per_details INTO l_per_details_rec;
  IF csr_per_details%NOTFOUND
  THEN
    CLOSE csr_per_details;
    hr_utility.set_message(800,'PER_52097_APL_INV_PERSON_ID');
    hr_utility.raise_error;
  END IF;
  CLOSE csr_per_details;

  --
 if g_debug then
  hr_utility.set_location(l_proc,30);
 end if;
  --
  -- Call Before Process User Hook
  --
  BEGIN
    hr_employee_bk4.hire_into_job_b
      (p_effective_date               => l_effective_date
      ,p_person_id                    => p_person_id
      ,p_business_group_id            => l_per_details_rec.business_group_id
      ,p_object_version_number        => p_object_version_number

      ,p_datetrack_update_mode        => p_datetrack_update_mode
      ,p_employee_number              => p_employee_number
      ,p_person_type_id               => p_person_type_id
      ,p_national_identifier          => p_national_identifier
      );
  EXCEPTION
    WHEN hr_api.cannot_find_prog_unit
    THEN
      hr_api.cannot_find_prog_unit_error
        (p_module_name => 'HIRE_INTO_JOB'
        ,p_hook_type   => 'BP'
        );
  END;

  --
 if g_debug then
  hr_utility.set_location(l_proc,40);
 end if;
  --
  -- Check the person is of a correct system person type
  --
  IF l_per_details_rec.system_person_type NOT IN ('EX_APL','EX_EMP','OTHER')
  THEN
 if g_debug then
    hr_utility.set_location(l_proc,50);
 end if;
    hr_utility.set_message(800,'PER_52096_APL_INV_PERSON_TYPE');

    hr_utility.raise_error;
  END IF;
  --
 if g_debug then
  hr_utility.set_location(l_proc,60);
 end if;
  -- Start of fix for bug 3143299.
  --
  -- if the person is of type Ex-employee then ensure the most recent period
  -- of service for this person has been completely terminated. i.e. check
  -- that period_of_service.final_process_date is not null and comes before
  -- p_hire_date. we only fetch the 1st row (which is the latest pos).
  --

  if l_per_details_rec.system_person_type = 'EX_EMP' then
  --
     open csr_chk_period_of_service;
     fetch csr_chk_period_of_service into l_final_process_date;
     if csr_chk_period_of_service%notfound then
        close csr_chk_period_of_service;
        --
        -- a period of service row does not exist for the person therefore
        -- we must error
        --
        -- This person does not have a previous period of service
        --
        hr_utility.set_message(801, 'HR_51013_PDS_NOT_EXIST');

        hr_utility.raise_error;
     end if;
     close csr_chk_period_of_service;
     --
     if (l_final_process_date is null) then
        --
        -- the employee cannot be terminated as the final process date has not
        -- been set
        --
        -- You cannot re-hire a person who does not have a final processing date
        -- set for their most recent period of service
        --
        hr_utility.set_message(801, 'HR_51014_REHIRE_FINAL_DATE');

        hr_utility.raise_error;
     elsif (l_final_process_date >= l_effective_date) then
        --
        -- the re hire date is before the current final process date
        --
        -- You cannot re-hire an Ex-Employee before their final processing date.
        -- Please specify a Re-Hire date which is after the final processing date.
        --
        hr_utility.set_message(801, 'HR_51015_REHIRE_NEW_DATE');
        hr_utility.raise_error;
     end if;
  end if;
 --

 if g_debug then
     hr_utility.set_location(l_proc,65);
 end if;
 -- End of fix for bug 3143299

  -- Ensure the employee number will not be changed if it exists
  --
  IF    l_per_details_rec.employee_number IS NOT NULL
    AND NVL(p_employee_number,hr_api.g_number) <> l_per_details_rec.employee_number
  THEN
 if g_debug then
     hr_utility.set_location(l_proc,70);
 end if;

     p_employee_number := l_per_details_rec.employee_number;
  END IF;
  --
 if g_debug then
  hr_utility.set_location(l_proc,80);
 end if;
  --
  -- Check the person does not have future assignment changes
  --
  l_future_asgs_count := future_asgs_count
                           (p_person_id                    => p_person_id
                           ,p_effective_date               => l_effective_date
                           );

  IF l_future_asgs_count > 0
  THEN
 if g_debug then
    hr_utility.set_location(l_proc,90);
 end if;
    hr_utility.set_message(800,'HR_7975_ASG_INV_FUTURE_ASA');
    hr_utility.raise_error;
  END IF;
  --
 if g_debug then
  hr_utility.set_location(l_proc,100);
 end if;
  --

  -- If person type id is not null check it corresponds to the correct type for
  -- the persons current system person type is currently active and in the
  -- correct business group, otherwise set person type id to the active default
  -- for the correct system person type in the correct business group
  --
 if g_debug then
  hr_utility.set_location(l_proc,110);
 end if;
  l_system_person_type := 'EMP';
  per_per_bus.chk_person_type
    (p_person_type_id               => l_person_type_id
    ,p_business_group_id            => l_per_details_rec.business_group_id
    ,p_expected_sys_type            => l_system_person_type

    );
  --
 if g_debug then
  hr_utility.set_location(l_proc,120);
 end if;
  --
  -- Check the datetrack mode
  --
  IF (l_per_details_rec.system_person_type = 'OTHER')
  THEN
    IF (l_datetrack_update_mode IS NULL)
    THEN
      l_datetrack_update_mode := hr_api.g_update;

    ELSE
      IF (l_datetrack_update_mode NOT IN (hr_api.g_update,hr_api.g_correction))
      THEN
        hr_utility.set_message(800,'HR_7203_DT_UPD_MODE_INVALID');
        hr_utility.raise_error;
      END IF;
    END IF;
  ELSE
    l_datetrack_update_mode := hr_api.g_update;
  END IF;
  --
  -- PTU : Added


  l_person_type_id1 := hr_person_type_usage_info.get_default_person_type_id
                                ( l_per_details_rec.business_group_id,
                                'EMP');
  -- PTU : End

  -- Update the person details to the new person type
  --
  per_per_upd.upd
    (p_person_id                    => p_person_id
    ,p_effective_start_date         => l_per_effective_start_date
    ,p_effective_end_date           => l_per_effective_end_date
    ,p_person_type_id               => l_person_type_id1
    ,p_applicant_number             => l_per_details_rec.applicant_number

    ,p_comment_id                   => l_comment_id
    ,p_current_applicant_flag       => l_current_applicant_flag
    ,p_current_emp_or_apl_flag      => l_current_emp_or_apl_flag
    ,p_current_employee_flag        => l_current_employee_flag
    ,p_employee_number              => p_employee_number
    ,p_national_identifier          => p_national_identifier
    ,p_full_name                    => l_full_name
    ,p_object_version_number        => p_object_version_number
    ,p_effective_date               => l_effective_date
    ,p_datetrack_mode               => l_datetrack_update_mode
    ,p_name_combination_warning     => l_name_combination_warning
    ,p_dob_null_warning             => l_assign_payroll_warning
    ,p_orig_hire_warning            => l_orig_hire_warning

    ,p_npw_number                   => l_per_details_rec.npw_number
    );
  --
 if g_debug then
  hr_utility.set_location(l_proc,130);
 end if;
  --
  -- add to current security list
  --
  hr_security_internal.populate_new_person(l_per_details_rec.business_group_id,p_person_id);
  --
 if g_debug then
  hr_utility.set_location(l_proc,135);

 end if;
  --
  -- Create an period of service for the person
  --
  per_pds_ins.ins
    (p_effective_date               => l_effective_date
    ,p_business_group_id            => l_per_details_rec.business_group_id
    ,p_person_id                    => p_person_id
    ,p_date_start                   => l_effective_date
    ,p_validate_df_flex             => false
    ,p_period_of_service_id         => l_period_of_service_id
    ,p_object_version_number        => l_pds_object_version_number
    );

  --
 if g_debug then
  hr_utility.set_location(l_proc,140);
 end if;
  --
  -- Create a default employee assignment for the person
  --
  hr_assignment_internal.create_default_emp_asg
    (p_effective_date               => l_effective_date
    ,p_business_group_id            => l_per_details_rec.business_group_id
    ,p_person_id                    => p_person_id
    ,p_period_of_service_id         => l_period_of_service_id
    ,p_assignment_id                => l_assignment_id

    ,p_object_version_number        => l_asg_object_version_number
    ,p_assignment_sequence          => l_assignment_sequence
    ,p_assignment_number            => l_assignment_number
    );
  --
 if g_debug then
  hr_utility.set_location(l_proc,150);
 end if;
  --
  -- Create person type usage record
  -- No Longer Required: This is automatically created on insert of
  -- a period of service record above.
  --

/*
  hr_per_type_usage_internal.create_person_type_usage
    (p_effective_date               => l_effective_date
    ,p_person_id                    => p_person_id
    ,p_person_type_id               => l_person_type_id
    ,p_person_type_usage_id         => l_person_type_usage_id
    ,p_effective_start_date         => l_effective_start_date
    ,p_effective_end_date           => l_effective_end_date
    ,p_object_version_number        => l_ptu_object_version_number
    );
*/

-- PTU : Following Code has been added


hr_per_type_usage_internal.maintain_person_type_usage
(p_effective_date       => l_effective_date
,p_person_id            => p_person_id
,p_person_type_id       => l_person_type_id
);

-- PTU : End of changes
  -- 1766066: added call for contact start date enh.
  --
  per_people12_pkg.maintain_coverage(p_person_id      => p_person_id
                                    ,p_type           => 'EMP'
                                    );

  -- 1766066 end.
  --
  -- Call After Process User Hook
  --
  BEGIN
    hr_employee_bk4.hire_into_job_a
      (p_effective_date               => l_effective_date
      ,p_person_id                    => p_person_id
      ,p_business_group_id            => l_per_details_rec.business_group_id
      ,p_object_version_number        => p_object_version_number
      ,p_datetrack_update_mode        => p_datetrack_update_mode
      ,p_employee_number              => p_employee_number
      ,p_person_type_id               => p_person_type_id

      ,p_national_identifier          => p_national_identifier
      ,p_effective_start_date         => l_per_effective_start_date
      ,p_effective_end_date           => l_per_effective_end_date
      ,p_assign_payroll_warning       => l_assign_payroll_warning
      ,p_orig_hire_warning            => l_orig_hire_warning
      );
  EXCEPTION
    WHEN hr_api.cannot_find_prog_unit
    THEN
      hr_api.cannot_find_prog_unit_error
        (p_module_name => 'HIRE_INTO_JOB'
        ,p_hook_type   => 'AP'
        );

  END;
  --
 if g_debug then
  hr_utility.set_location(l_proc,160);
 end if;
  --
  -- When in validation only mode raise validate_enabled exception
  --
  IF p_validate
  THEN
    RAISE hr_api.validate_enabled;
  END IF;
  --

  -- Set OUT parameters
  --
  p_effective_start_date         := l_per_effective_start_date;
  p_effective_end_date           := l_per_effective_end_date;
  p_assign_payroll_warning       := l_assign_payroll_warning;
  p_orig_hire_warning            := l_orig_hire_warning;
  --
 if g_debug then
  hr_utility.set_location(' Leaving:'||l_proc,1000);
 end if;
--
EXCEPTION
  --

  WHEN hr_api.validate_enabled
  THEN
    --
    -- In validation only mode
    -- Rollback to savepoint
    -- Set relevant output warning arguments
    -- Reset any key or derived arguments
    --
    ROLLBACK TO hire_into_job;
    p_object_version_number        := l_object_version_number;
    p_employee_number              := l_employee_number;
    p_effective_start_date         := NULL;
    p_effective_end_date           := NULL;

    p_assign_payroll_warning       := l_assign_payroll_warning;
    p_orig_hire_warning            := l_orig_hire_warning;
  --
  WHEN OTHERS
  THEN
    --
    -- Validation or unexpected error occured
    -- Ensure opened non-local cursors are closed
    -- Rollback to savepoint
    -- Re-raise exception
    --
    ROLLBACK TO hire_into_job;
    --

    -- set in out parameters and set out parameters
    --
    p_object_version_number        := l_ovn;
    p_employee_number              := l_emp_num;
    p_effective_start_date         := NULL;
    p_effective_end_date           := NULL;
    p_assign_payroll_warning       := false;
    p_orig_hire_warning            := false;
    --
    IF csr_per_details%ISOPEN
    THEN
      CLOSE csr_per_details;
    END IF;

    RAISE;
--
END hire_into_job;
--
end hr_employee_api;
/
set define on

No comments:

Post a Comment