DBA Data[Home] [Help]

APPS.PA_HR_UPDATE_API SQL Statements

The following lines contain the word 'select', 'insert', 'update' or 'delete':

Line: 23

    pa_debug.write('HR_UPDATE_API', 'log: ' || p_log_msg, 3);
Line: 51

      pa_hr_update_api.check_exp_OU(p_org_id               => p_org_id
                    ,x_return_status      => v_return_status
                    ,x_error_message_code => v_error_message_code
                    );
Line: 140

                SELECT  Job_id
                INTO    v_job_id
                FROM    per_all_assignments_f
                WHERE   Person_id = P_person_id
                 AND    P_date BETWEEN effective_start_date
                               AND effective_end_date
                 AND    job_id is NOT NULL
                 AND    primary_flag = 'Y'
		 and    assignment_type in ('E', 'C');
Line: 153

            SELECT jei_information3
            INTO   utilization_flag
            FROM   per_job_extra_info
           WHERE   job_id = v_job_id
            AND    information_type  = v_job_info_type
	    AND    jei_information3 IS NOT NULL;  -- Bug 2898766
Line: 203

                SELECT  Job_id
                INTO    v_job_id
                FROM    per_all_assignments_f
                WHERE   Person_id = P_person_id
                 AND    P_date BETWEEN effective_start_date
                                   AND effective_end_date
                 AND    job_id is NOT NULL
                 AND    primary_flag = 'Y'
		 AND    assignment_type in ('E', 'C');
Line: 215

            SELECT jei_information2
            INTO   Billable_flag
            FROM   per_job_extra_info
           WHERE   job_id = v_job_id
            AND    information_type  = v_job_info_type
	    AND    jei_information2 IS NOT NULL;  -- Bug 2898766
Line: 260

     SELECT  job_id
       INTO  l_job_id
       FROM  per_all_assignments_f
      WHERE  person_id = p_person_id
        AND  p_date BETWEEN effective_start_date
                        AND effective_end_date
        AND  job_id is NOT NULL
        AND  primary_flag = 'Y'
	AND  assignment_type in ('E', 'C');
Line: 272

     SELECT jei_information6
       INTO l_schedulable_flag
       FROM per_job_extra_info
      WHERE job_id = l_job_id
        AND information_type = l_job_info_type
        AND jei_information6 IS NOT NULL;
Line: 308

        PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.check_exp_OU');
Line: 314

            SELECT 'Y'
             INTO  v_dummy
             FROM  pa_implementations_all
            WHERE  org_id = p_org_id
              AND  rownum = 1;
Line: 339

          FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.check_exp_OU'
                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 375

        PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.call_create_resoruce_denorm');
Line: 383

                end if;                   ----- then assign joblevel to zero when grade is deleted
Line: 400

                      PA_RESOURCE_PVT.update_resource_denorm
                      ( p_resource_denorm_old_rec   => v_resource_rec_old
                       ,p_resource_denorm_new_rec  => v_resource_rec_new
                       ,x_return_status            => x_return_status
                       ,x_msg_data                 => x_msg_data
                       ,x_msg_count                => x_msg_count
                       );
Line: 424

          FND_MSG_PUB.add_exc_msg( p_pkg_name       => 'PA_HR_UPDATE_API.call_create_resource_denorm'
                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 437

PROCEDURE update_job_level_res_denorm
                ( P_job_id_old         per_jobs.job_id%type
                 ,P_job_id_new         per_jobs.job_id%type
                 ,P_job_level_old      NUMBER
                 ,P_job_level_new      NUMBER
                 ,x_return_status      OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
                 ,x_msg_data           OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
                 ,x_msg_count          OUT NOCOPY NUMBER --File.Sql.39 bug 4440895
                 ) IS

        l_resource_rec_old     PA_RESOURCE_PVT.Resource_Denorm_Rec_Type;
Line: 457

        PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.update_job_level_res_denorm');
Line: 479

        PA_RESOURCE_PVT.update_resource_denorm
              ( p_resource_denorm_old_rec  => l_resource_rec_old
               ,p_resource_denorm_new_rec  => l_resource_rec_new
               ,x_return_status            => x_return_status
               ,x_msg_data                 => x_msg_data
               ,x_msg_count                => x_msg_count
              );
Line: 498

          FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.update_job_level_res_denorm'
                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 503

END update_job_level_res_denorm;
Line: 507

PROCEDURE update_all_jobs
                      (  P_job_id                     per_jobs.job_id%type
                        ,P_job_level_old              pa_resources_denorm.resource_job_level%type
                        ,P_job_level_new              pa_resources_denorm.resource_job_level%type
                        ,x_return_status              OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
                        ,x_msg_data                   OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
                        ,x_msg_count                  OUT NOCOPY NUMBER --File.Sql.39 bug 4440895
                       ) IS

        l_job_id               PER_JOBS.JOB_ID%type;
Line: 526

              SELECT l_job_id  effected_job_id
              FROM   sys.dual
                    ,per_job_groups  pjg
              WHERE   pjg.master_flag = 'Y'
                AND   pjg.job_group_id = get_job_group_id(l_job_id)
            UNION
              SELECT distinct pjr.from_job_id  effected_job_id
              FROM   pa_job_relationships pjr
                    ,per_job_groups pjg
              WHERE   pjg.master_flag = 'Y'
                AND   pjr.to_job_id = l_job_id
                AND   pjr.to_job_group_id = pjg.job_group_id
            UNION
              SELECT distinct pjr.to_job_id   effected_job_id
              FROM  pa_job_relationships pjr
                   ,per_job_groups pjg
              WHERE   pjg.master_flag = 'Y'
                AND   pjr.from_job_id = l_job_id
                AND   pjr.from_job_group_id = pjg.job_group_id;
Line: 552

        PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.update_all_jobs');
Line: 577

                      update_job_level_res_denorm
                              ( P_job_id_old     =>  l_job_id
                               ,P_job_id_new     =>  l_job_id
                               ,P_job_level_old  =>  l_job_level_old
                               ,P_job_level_new  =>  l_job_level_new
                               ,x_return_status  =>  x_return_status
                               ,x_msg_data       =>  x_msg_data
                               ,x_msg_count      =>  x_msg_count
                              );
Line: 602

          FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.update_all_jobs'
                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 607

END update_all_jobs;
Line: 634

        PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.pa_job_relation_job_id');
Line: 646

        If P_calling_mode = 'INSERT' OR P_calling_mode = 'UPDATE' Then

              IF P_DEBUG_MODE = 'Y' THEN
                 log_message('P_calling_mode = ' || P_calling_mode);
Line: 740

                   update_job_level_res_denorm
                              ( P_job_id_old     =>  NULL
                               ,P_job_id_new     =>  l_PRJG_job_id
                               ,P_job_level_old  =>  NULL
                               ,P_job_level_new  =>  l_job_level_new
                               ,x_return_status  =>  x_return_status
                               ,x_msg_data       =>  x_msg_data
                               ,x_msg_count      =>  x_msg_count
                              );
Line: 753

                   update_all_jobs
                            (  P_job_id          =>  l_master_job_id
                              ,P_job_level_old   =>  NULL
                              ,P_job_level_new   =>  l_job_level_new
                              ,x_return_status   =>  x_return_status
                              ,x_msg_data        =>  x_msg_data
                              ,x_msg_count       =>  x_msg_count
                            );
Line: 769

                    update_job_level_res_denorm
                              ( P_job_id_old     =>  NULL
                               ,P_job_id_new     =>  l_job_id
                               ,P_job_level_old  =>  NULL
                               ,P_job_level_new  =>  l_job_level_new
                               ,x_return_status  =>  x_return_status
                               ,x_msg_data       =>  x_msg_data
                               ,x_msg_count      =>  x_msg_count
                              );
Line: 781

        Elsif  P_calling_mode = 'UPDATE' then

              IF P_DEBUG_MODE = 'Y' THEN
                 log_message('P_calling_mode = UPDATE');
Line: 788

        Elsif  P_calling_mode = 'DELETE' then

              IF P_DEBUG_MODE = 'Y' THEN
                 log_message('P_calling_mode = DELETE');
Line: 864

                 update_all_jobs
                            (  P_job_id          =>  l_master_job_id
                              ,P_job_level_old   =>  NULL
                              ,P_job_level_new   =>  NULL
                              ,x_return_status   =>  x_return_status
                              ,x_msg_data        =>  x_msg_data
                              ,x_msg_count       =>  x_msg_count
                            );
Line: 880

                  update_job_level_res_denorm
                              ( P_job_id_old     =>  NULL
                               ,P_job_id_new     =>  l_job_id
                               ,P_job_level_old  =>  NULL
                               ,P_job_level_new  =>  NULL
                               ,x_return_status  =>  x_return_status
                               ,x_msg_data       =>  x_msg_data
                               ,x_msg_count      =>  x_msg_count
                              );
Line: 909

          FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.pa_job_relation_job_id'
                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 920

PROCEDURE perform_job_updates
                     (   P_job_id                     per_jobs.job_id%type
                        ,P_job_level_old              pa_resources_denorm.resource_job_level%type
                        ,P_job_level_new              pa_resources_denorm.resource_job_level%type
                        ,P_job_group_id               per_job_groups.job_group_id%type
                        ,x_return_status              OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
                        ,x_msg_data                   OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
                        ,x_msg_count                  OUT NOCOPY NUMBER --File.Sql.39 bug 4440895
                      ) IS

        l_job_id               PER_JOBS.JOB_ID%type;
Line: 943

              SELECT  distinct pjr.from_job_id  effected_job_id
              FROM    pa_job_relationships pjr
              WHERE   pjr.to_job_id = l_job_id
              AND     pjr.to_job_group_id = l_job_group_id
           UNION
              SELECT  distinct pjr.to_job_id   effected_job_id
              FROM    pa_job_relationships pjr
              WHERE   pjr.from_job_id = l_job_id
              AND     pjr.from_job_group_id = l_job_group_id;
Line: 956

        PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.perform_job_updates');
Line: 959

           log_message('**** Performing Job Level Updates ****');
Line: 971

        update_job_level_res_denorm
                ( P_job_id_old     =>  l_job_id
                 ,P_job_id_new     =>  l_job_id
                 ,P_job_level_old  =>  l_job_level_old
                 ,P_job_level_new  =>  l_job_level_new
                 ,x_return_status  =>  x_return_status
                 ,x_msg_data       =>  x_msg_data
                 ,x_msg_count      =>  x_msg_count
                );
Line: 996

                  update_all_jobs
                            (  P_job_id          =>  l_master_job_id
                              ,P_job_level_old   =>  l_job_level_old
                              ,P_job_level_new   =>  l_job_level_new
                              ,x_return_status   =>  x_return_status
                              ,x_msg_data        =>  x_msg_data
                              ,x_msg_count       =>  x_msg_count
                            );
Line: 1012

              update_all_jobs
                            (  P_job_id          =>  l_job_id
                              ,P_job_level_old   =>  l_job_level_old
                              ,P_job_level_new   =>  l_job_level_new
                              ,x_return_status   =>  x_return_status
                              ,x_msg_data        =>  x_msg_data
                              ,x_msg_count       =>  x_msg_count
                            );
Line: 1032

	  FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API',
				  p_procedure_name => 'perform_job_updates',
				  p_error_text => x_msg_data );
Line: 1036

END perform_job_updates;
Line: 1043

PROCEDURE update_job_level_dff
                     (   P_job_id                     per_jobs.job_id%type
                        ,P_job_level_old              pa_resources_denorm.resource_job_level%type
                        ,P_job_level_new              pa_resources_denorm.resource_job_level%type
                        ,x_return_status              OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
                        ,x_msg_data                   OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
                        ,x_msg_count                  OUT NOCOPY NUMBER --File.Sql.39 bug 4440895
                      ) IS

        l_job_id               PER_JOBS.JOB_ID%type;
Line: 1062

        PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.update_job_level_dff');
Line: 1075

                log_message('Update Denorm for the Job Id and Job Level');
Line: 1078

             update_job_level_res_denorm
                      ( P_job_id_old     =>  l_job_id
                       ,P_job_id_new     =>  l_job_id
                       ,P_job_level_old  =>  l_job_level_old
                       ,P_job_level_new  =>  l_job_level_new
                       ,x_return_status  =>  x_return_status
                       ,x_msg_data       =>  x_msg_data
                       ,x_msg_count      =>  x_msg_count
                      );
Line: 1121

                 perform_job_updates
                        ( P_job_id             => l_job_id
                         ,P_job_level_old      => l_job_level_old
                         ,P_job_level_new      => l_job_level_new
                         ,P_job_group_id       => l_job_group_id
                         ,x_return_status      => x_return_status
                         ,x_msg_data           => x_msg_data
                         ,x_msg_count          => x_msg_count
                        );
Line: 1145

          FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API',
                                  p_procedure_name => 'update_job_level_dff',
                                  p_error_text => x_msg_data );
Line: 1149

END update_job_level_dff;
Line: 1175

            SELECT l_job_id  effected_job_id
             FROM  sys.dual
                  ,per_job_groups  pjg
            WHERE pjg.master_flag = 'Y'
             AND  pjg.job_group_id = get_job_group_id(l_job_id)
            UNION
            SELECT distinct pjr.from_job_id  effected_job_id
             FROM   pa_job_relationships pjr
                    ,per_job_groups pjg
           WHERE    pjg.master_flag = 'Y'
            AND     pjr.to_job_id = l_job_id
            AND     pjr.to_job_group_id = pjg.job_group_id
           UNION
            SELECT distinct pjr.to_job_id   effected_job_id
             FROM  pa_job_relationships pjr
                  ,per_job_groups pjg
           WHERE    pjg.master_flag = 'Y'
            AND     pjr.from_job_id = l_job_id
            AND     pjr.from_job_group_id = pjg.job_group_id
           UNION
           SELECT  l_job_id   effected_job_id
             FROM  sys.dual
                  ,per_job_groups pjg
           WHERE    pjg.master_flag = 'N'
            AND     pjg.job_group_id = get_job_group_id(l_job_id)
            AND     NOT EXISTS (
                             SELECT  'Y'
                             FROM   per_job_groups
                             WHERE  master_flag = 'Y'
                             AND job_group_id = get_job_group_id(l_job_id)
                              );
Line: 1209

        PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.per_valid_grades_job_id');
Line: 1251

          FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.per_valid_grades_job_id'
                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 1278

            SELECT distinct pvg.job_id
             FROM  per_valid_grades pvg
                  ,per_job_groups  pjg
            WHERE
                  pvg.grade_id = l_grade_id
             AND  pjg.master_flag = 'Y'
             AND  pjg.job_group_id = get_job_group_id(pvg.job_id)
            UNION
            SELECT distinct pjr.from_job_id
             FROM   per_valid_grades pvg
                    ,pa_job_relationships pjr
                    ,per_job_groups pjg
           WHERE    pjg.master_flag = 'Y'
            AND     pjr.to_job_id = pvg.job_id
            AND     pjr.to_job_group_id = pjg.job_group_id
            AND     pvg.grade_id = l_grade_id
           UNION
            SELECT distinct pjr.to_job_id
             FROM   per_valid_grades pvg
                    ,pa_job_relationships pjr
                    ,per_job_groups pjg
           WHERE    pjg.master_flag = 'Y'
            AND     pjr.from_job_id = pvg.job_id
            AND     pjr.from_job_group_id = pjg.job_group_id
            AND     pvg.grade_id = l_grade_id
           UNION
           SELECT  distinct pvg.job_id
             FROM  per_valid_grades pvg
                  ,per_job_groups  pjg
           WHERE    pjg.master_flag = 'N'
            AND     pjg.job_group_id = get_job_group_id(pvg.job_id)
            AND     pvg.grade_id = l_grade_id
            AND     NOT EXISTS (
                             SELECT  'Y'
                             FROM   per_job_groups
                             WHERE  master_flag = 'Y'
                             AND job_group_id = get_job_group_id(pvg.job_id)
                              );
Line: 1322

        PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.per_grades_job_id');
Line: 1362

          FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.per_grades_job_id'
                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 1384

PROCEDURE  update_job_levels
             ( P_calling_mode                  IN VARCHAR2
              ,P_per_grades_grade_id          IN per_grades.grade_id%type        DEFAULT NULL
              ,P_per_grades_sequence_old      IN NUMBER                          DEFAULT NULL
              ,P_per_grades_sequence_new      IN NUMBER                          DEFAULT NULL
              ,P_per_valid_grade_job_id       IN per_valid_grades.valid_grade_id%type  DEFAULT NULL
              ,P_per_valid_grade_id_old       IN per_grades.grade_id%type        DEFAULT NULL
              ,P_per_valid_grade_id_new       IN per_grades.grade_id%type        DEFAULT NULL
              ,P_from_job_id_old              IN pa_job_relationships.from_job_id%type   DEFAULT NULL
              ,P_from_job_id_new              IN pa_job_relationships.from_job_id%type   DEFAULT NULL
              ,P_to_job_id_old                IN pa_job_relationships.to_job_id%type     DEFAULT NULL
              ,P_to_job_id_new                IN pa_job_relationships.to_job_id%type     DEFAULT NULL
              ,P_from_job_group_id            IN pa_job_relationships.to_job_id%type     DEFAULT NULL
              ,P_to_job_group_id              IN pa_job_relationships.to_job_id%type     DEFAULT NULL
              ,x_return_status                IN OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
              ,x_msg_data                     IN OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
              ,x_msg_count                    IN OUT NOCOPY NUMBER --File.Sql.39 bug 4440895
             )IS

        v_return_status        VARCHAR2(2000);
Line: 1411

        PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.Update_job_levels');
Line: 1447

          FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.Update_job_levels'
                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 1452

END update_job_levels;
Line: 1458

PROCEDURE  Update_OU_resource(P_default_OU_old     IN  Pa_all_organizations.org_id%type
                             ,P_default_OU_new     IN  Pa_all_organizations.org_id%type
                             ,P_resource_id        IN  Pa_Resources_denorm.resource_id%type
                                                       default NULL
                             ,P_person_id          IN  Pa_Resources_denorm.person_id%type
                                                       default NULL
                             ,P_start_date         IN  Date  default NULL
                             ,P_end_date_old       IN  Date  default NULL
                             ,P_end_date_new       IN  Date  default NULL
                             ,x_return_status      IN OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
                             ,x_msg_data           IN OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
                             ,x_msg_count          IN OUT NOCOPY NUMBER --File.Sql.39 bug 4440895
                             )IS

	v_return_status        VARCHAR2(2000);
Line: 1480

	    SELECT resource_effective_start_date,
               resource_effective_end_date
        FROM   pa_resources_denorm
        WHERE  person_id = p_person_id
        AND    nvl(p_end_date_new, sysdate) >= resource_effective_start_date
        AND    resource_effective_start_date >= p_start_date
        AND    resource_effective_end_date   <= p_end_date_old
	;
Line: 1501

    PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.Update_OU_resource');
Line: 1510

        PA_RESOURCE_PVT.update_resource_denorm (
            p_resource_denorm_old_rec   => v_resource_rec_old
            ,p_resource_denorm_new_rec  => v_resource_rec_new
            ,x_return_status            => x_return_status
            ,x_msg_data                 => x_msg_data
            ,x_msg_count                => x_msg_count );
Line: 1521

          Update_EndDate(
		p_person_id      => p_person_id,
	        p_old_start_date => p_start_date,
       	        p_new_start_date => p_start_date,
	        p_old_end_date   => p_end_date_old,
	        p_new_end_date   => p_end_date_new,
	        x_return_status  => x_return_status,
	        x_msg_data       => x_msg_data,
                x_msg_count      => x_msg_count);
Line: 1545

          FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.Update_OU_resource'
                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 1549

END  Update_OU_resource;
Line: 1600

             SELECT distinct
                      ind.person_id
                     ,ind.assignment_start_date
                     ,ind.assignment_end_date
                     ,to_number(hoi.org_information1) default_OU
               FROM  pa_r_project_resources_ind_v ind
                     ,hr_organization_information hoi
              WHERE  ind.organization_id                          =
	      /* Changed for Bug 2499051-  l_organization_id */   hoi.organization_id
   		AND  ind.assignment_end_date                     >= sysdate
                AND  hoi.organization_id                          = l_organization_id
                AND  hoi.org_information_context                  = 'Exp Organization Defaults'
                AND  ind.organization_id                          = l_organization_id -- 4898509
           ORDER BY  ind.person_id,ind.assignment_start_date  ;
Line: 1618

        PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.Default_OU_Change');
Line: 1635

                (P_calling_mode       =>  'UPDATE'
                ,P_Organization_id    =>  P_Organization_id
                ,P_Default_OU         =>  P_Default_OU_old
		,P_Default_OU_NEW     =>  v_default_OU
                ,P_inactive_date      =>  trunc(sysdate)
                ,x_return_status      =>  x_return_status
                ,x_msg_data           =>  x_msg_data
                ,x_msg_count          =>  x_msg_count
               ) ;
Line: 1648

       pa_hr_update_api.check_exp_OU
            (p_org_id             => v_default_OU
            ,x_return_status      => v_return_status
            ,x_error_message_code => v_error_message_code
             );
Line: 1686

                 If  P_calling_mode = 'UPDATE' then

                     -- check for whether the default OU is changed if so call
                     -- check OU change api to update the resource OU entity
                     If (NVL(P_default_OU_old,-99) <> nvl(P_default_OU_new,-99)) then
                        -- if OU is updated then call resource denorm api to
                        -- reflect  the changes in pa_resources_denorm entity
                         If v_person_id is NOT NULL then


                             Update_OU_resource
                               (P_default_OU_old      => p_default_OU_old
                                ,p_default_OU_new     => p_default_OU_new
                                ,P_person_id          => v_person_id
                                ,P_start_date         => v_assn_start_date
                                ,P_end_date_old       => v_assn_end_date
                                ,x_return_status      => x_return_status
                                ,x_msg_data           => x_msg_data
                                ,x_msg_count          => x_msg_count
                                );
Line: 1779

                 Elsif P_calling_mode = 'INSERT' then
                    -- the P_calling_mode is 'INSERT'
                    -- this  api is called to populate resources  whenever a new record is added in
                    -- in Hr_organizatioin_information entity
                    -- or due to insert in pa_all_organizations entity

                    PA_R_PROJECT_RESOURCES_PUB.CREATE_RESOURCE (
                                P_API_VERSION    => L_API_VERSION
                                ,P_COMMIT        => v_commit
                                ,P_VALIDATE_ONLY => v_validate_only
                                ,P_INTERNAL      => v_internal
                                ,P_PERSON_ID     => v_person_id
                                ,P_INDIVIDUAL    => v_individual
                                ,P_RESOURCE_TYPE => v_resource_type
                                ,X_RETURN_STATUS => x_return_status
                                ,X_RESOURCE_ID   => v_dummy
                                ,X_MSG_COUNT     => x_msg_count
                                ,X_MSG_DATA      => x_msg_data
                                );
Line: 1857

          FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.Default_OU_Change'
                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 1887

          SELECT job_id
          FROM per_jobs
          WHERE job_group_id = l_proj_job_group_new
            AND business_group_id = p_organization_id;
Line: 1893

          SELECT job_id
          FROM per_jobs
          WHERE job_group_id = l_proj_job_group_old
            AND business_group_id = p_organization_id;
Line: 1901

      PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.Proj_Res_Job_Group_Change');
Line: 1913

      IF p_calling_mode = 'INSERT' and fnd_profile.value('HR_CROSS_BUSINESS_GROUP') = 'N' THEN

           -- When Insert, we update all resource denorm records with job_id that
           -- belongs to the new Project Resource Job Group Id
           OPEN get_new_job_ids;
Line: 1928

              update_job_level_dff
                         (P_job_id             => l_job_id
                         ,P_job_level_old      => NULL
                         ,P_job_level_new      => l_job_level
                         ,x_return_status      => x_return_status
                         ,x_msg_data           => x_msg_data
                         ,x_msg_count          => x_msg_count
                        );
Line: 1939

       ELSIF p_calling_mode = 'UPDATE' and fnd_profile.value('HR_CROSS_BUSINESS_GROUP') = 'N' THEN

           -- When update we have to set the resource denorm records job level to NULL for job id
           -- that belongs to the old Project Resource Job Group Id
           OPEN get_old_job_ids;
Line: 1957

              perform_job_updates
                         (P_job_id             => l_job_id
                         ,P_job_level_old      => NULL
                         ,P_job_level_new      => l_job_level
                         ,P_job_group_id       => l_job_group_id
                         ,x_return_status      => x_return_status
                         ,x_msg_data           => x_msg_data
                         ,x_msg_count          => x_msg_count
                        );
Line: 1985

              update_job_level_dff
                         (P_job_id             => l_job_id
                         ,P_job_level_old      => NULL
                         ,P_job_level_new      => l_job_level
                         ,x_return_status      => x_return_status
                         ,x_msg_data           => x_msg_data
                         ,x_msg_count          => x_msg_count
                        );
Line: 1998

       ELSIF p_calling_mode = 'DELETE' and fnd_profile.value('HR_CROSS_BUSINESS_GROUP') = 'N' THEN

           -- When Delete, we have to set the resource denorm records job level to NULL for job id
           -- that belongs to the old Project Resource Job Group Id

           OPEN get_old_job_ids;
Line: 2014

              update_job_level_dff
                         (P_job_id             => l_job_id
                         ,P_job_level_old      => NULL
                         ,P_job_level_new      => l_job_level
                         ,x_return_status      => x_return_status
                         ,x_msg_data           => x_msg_data
                         ,x_msg_count          => x_msg_count
                        );
Line: 2040

          FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.Proj_Res_Job_Group_Change'
                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 2072

             SELECT distinct ind.person_id
               FROM  pa_r_project_resources_ind_v ind
                     ,hr_organization_information hoi
              WHERE  ind.organization_id                          =
	       /* Changed for Bug 2499051-  l_organization_id */   hoi.organization_id
   		AND  ind.assignment_end_date                     >= sysdate
                AND  hoi.organization_id                          = l_organization_id
                AND  hoi.org_information_context                  = 'Exp Organization Defaults'
           ORDER BY  ind.person_id;
Line: 2084

        PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.pull_resources');
Line: 2145

          FND_MSG_PUB.add_exc_msg(p_pkg_name        => 'PA_HR_UPDATE_API.pull_resources'
                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 2190

          SELECT
                distinct
                assn.person_id
                ,assn.effective_start_date
                ,assn.effective_end_date
                , res.resource_id
                , hrinf.org_information1
          FROM  per_all_assignments_f assn
                , hr_organization_information hrinf
          /*      , per_person_types pertypes  Commented for bug#2781713 */
                , per_assignment_status_types  pastype
                , pa_resource_txn_attributes res
                , pa_all_organizations allorgs
                , per_all_people_f pep
         WHERE
                assn.assignment_status_type_id = pastype.assignment_status_type_id
          AND   assn.person_id = res.person_id
          AND   assn.primary_flag = 'Y'
          AND   assn.assignment_type in ('E', 'C') -- CWK Changes
          AND   assn.organization_id = allorgs.organization_id
          AND   assn.organization_id = hrinf.organization_id
          AND   assn.effective_start_date BETWEEN pep.effective_start_date
                                          AND     pep.effective_end_date
          AND   assn.effective_end_date >= trunc(sysdate)
          AND   pastype.per_system_status in  ('ACTIVE_ASSIGN', 'ACTIVE_CWK') -- CWK Changes
          AND   hrinf.org_information_context = 'Exp Organization Defaults'
/*          AND   pertypes.system_person_type = 'EMP'  Commented for bug#2781713 */
          AND   (pep.employee_number is not null OR pep.npw_number IS NOT NULL) -- CWK Changes
/*          AND   pep.person_type_id = pertypes.person_type_id  Commented for bug#2781713 */
          AND (pep.current_employee_flag = 'Y' /* added for bug#2781713 */ OR
               pep.current_npw_flag = 'Y') -- CWK Changes
          AND   pep.person_id = assn.person_id
          AND   allorgs.organization_id = P_organization_id
          AND   allorgs.org_id = P_default_OU
          AND   allorgs.pa_org_use_type = 'EXPENDITURES'
          AND   allorgs.inactive_date is Not null
          AND   (allorgs.organization_id,allorgs.org_id) = (
                SELECT exporg.organization_id, exporg.org_id
                FROM pa_all_organizations exporg
                WHERE exporg.pa_org_use_type = 'EXPENDITURES'
                AND exporg.inactive_date is Not null
                AND exporg.organization_id = allorgs.organization_id
                AND exporg.org_id  = allorgs.org_id
                AND rownum = 1 );
Line: 2241

          SELECT
                distinct
                assn.person_id
                ,assn.effective_start_date
                ,assn.effective_end_date
                , res.resource_id
              --  , hrinf.org_information1
          FROM  per_all_assignments_f assn
                , hr_organization_information hrinf
          /*      , per_person_types pertypes  Commented for bug#2781713 */
                , per_assignment_status_types  pastype
                , pa_resource_txn_attributes res
                , pa_all_organizations allorgs
                , per_all_people_f pep
         WHERE
                assn.assignment_status_type_id = pastype.assignment_status_type_id
          AND   assn.person_id = res.person_id
          AND   assn.primary_flag = 'Y'
          AND   assn.assignment_type in ('E', 'C') -- CWK Changes
          AND   assn.organization_id = allorgs.organization_id
          AND   assn.organization_id = hrinf.organization_id
          AND   assn.effective_start_date BETWEEN pep.effective_start_date
                                          AND     pep.effective_end_date
          AND   assn.effective_end_date >= trunc(sysdate)
          AND   pastype.per_system_status in  ('ACTIVE_ASSIGN', 'ACTIVE_CWK') -- CWK Changes
          AND   hrinf.org_information_context = 'Exp Organization Defaults'
/*          AND   pertypes.system_person_type = 'EMP'  Commented for bug#2781713 */
          AND   (pep.employee_number is not null OR pep.npw_number IS NOT NULL) -- CWK Changes
/*          AND   pep.person_type_id = pertypes.person_type_id  Commented for bug#2781713 */
          AND (pep.current_employee_flag = 'Y' /* added for bug#2781713 */ OR
               pep.current_npw_flag = 'Y') -- CWK Changes
          AND   pep.person_id = assn.person_id
          AND   allorgs.organization_id = P_organization_id
          AND   allorgs.org_id = P_default_OU		      -- Removed the NVL as this is not required.Sunkalya.Bug#5330402
          AND   allorgs.pa_org_use_type = 'EXPENDITURES'
      --    AND   allorgs.inactive_date is Not null
          AND   (allorgs.organization_id,allorgs.org_id) = (  -- Removed the NVL as this is not required.Sunkalya.Bug#5330402
                SELECT exporg.organization_id, exporg.org_id
                FROM pa_all_organizations exporg
                WHERE exporg.pa_org_use_type = 'EXPENDITURES'
              --  AND exporg.inactive_date is Not null
                AND exporg.organization_id = allorgs.organization_id
                AND exporg.org_id          = allorgs.org_id   -- Removed the NVL as this is not required.Sunkalya.Bug#5330402
                AND rownum = 1 );
Line: 2288

        PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.make_resource_inactive');
Line: 2294

       P_Default_OU_NEW will be null when called for orghierarchy update
       P_Default_OU_NEW will not be null when called for nulling out default OU
*/
        IF p_inactive_date is NOT NULL and p_calling_mode = 'UPDATE' then
	     if P_Default_OU_NEW is null then
	          open get_all_inactive_resource;
Line: 2324

		      -- update the resource denorm with end date the resources
                      Update_OU_resource (
                         P_default_OU_old      => v_default_OU
                         ,p_default_OU_new     => v_default_OU
                         ,P_person_id          => v_person_id
                         ,P_start_date         => v_assn_start_date
                         ,P_end_date_old       => v_assn_end_date
                         ,P_end_date_new       => p_inactive_date
                         ,x_return_status      => x_return_status
                         ,x_msg_data           => x_msg_data
                         ,x_msg_count          => x_msg_count );
Line: 2364

          FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.make_resource_inactive'
                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 2402

               SELECT distinct
                      assn.person_id
                     ,assn.effective_start_date
                     ,assn.effective_end_date
          FROM  per_all_assignments_f assn
                , hr_organization_information hrinf
            /*    , per_person_types pertypes   Commented for Bug#2781713 */
                , per_assignment_status_types  pastype
                , per_all_people_f pep
         WHERE
                assn.assignment_status_type_id = pastype.assignment_status_type_id
          AND   assn.primary_flag = 'Y'
          AND   assn.assignment_type in ('E', 'C') -- CWK Changes
          AND   assn.job_id = l_job_id
          AND   assn.organization_id = hrinf.organization_id
          AND   assn.effective_start_date BETWEEN pep.effective_start_date
                                          AND     pep.effective_end_date
          AND   assn.effective_end_date >= trunc(sysdate)
          AND   pastype.per_system_status in  ('ACTIVE_ASSIGN', 'ACTIVE_CWK') -- CWK Changes
          AND   hrinf.org_information_context = 'Exp Organization Defaults'
       /* AND   pertypes.system_person_type = 'EMP'    Commented for Bug#2781713 */
          AND   (pep.employee_number is not null OR pep.npw_number IS NOT NULL) -- CWK Changes
       /*  AND   pep.person_type_id = pertypes.person_type_id   Commented for Bug#2781713 */
          AND (pep.current_employee_flag = 'Y' /* added for bug#2781713 */ OR
               pep.current_npw_flag = 'Y') -- CWK Changes
          AND   pep.person_id = assn.person_id
          AND   assn.organization_id =
                (SELECT exporg.organization_id
                FROM pa_all_organizations exporg
                WHERE exporg.pa_org_use_type = 'EXPENDITURES'
                AND exporg.inactive_date is null
                AND exporg.organization_id = assn.organization_id
                AND rownum = 1 )
          ORDER BY 1,2;
Line: 2440

               SELECT distinct
                      assn.person_id
                     ,assn.effective_start_date
                     ,assn.effective_end_date
          FROM  per_all_assignments_f assn
                , hr_organization_information hrinf
                /* , per_person_types pertypes  Commented for Bug#2781713 */
                , per_assignment_status_types  pastype
                , per_all_people_f pep
         WHERE
                assn.assignment_status_type_id = pastype.assignment_status_type_id
          AND   assn.primary_flag = 'Y'
          AND   assn.assignment_type in ('E', 'C') -- CWK Changes
          AND   assn.organization_id = l_org_id
          AND   assn.organization_id = hrinf.organization_id
          AND   assn.effective_start_date BETWEEN pep.effective_start_date
                                          AND     pep.effective_end_date
          AND   assn.effective_end_date >= trunc(sysdate)
          AND   pastype.per_system_status in  ('ACTIVE_ASSIGN', 'ACTIVE_CWK') -- CWK Changes
          AND   hrinf.org_information_context = 'Exp Organization Defaults'
         /* AND   pertypes.system_person_type = 'EMP'  Commented for Bug#2781713 */
          AND   (pep.employee_number is not null OR pep.npw_number IS NOT NULL) -- CWK Changes
        /*  AND   pep.person_type_id = pertypes.person_type_id   Commented for Bug#2781713 */
          AND (pep.current_employee_flag = 'Y' /* added for bug#2781713 */ OR
               pep.current_npw_flag = 'Y') -- CWK Changes
	  AND   pep.person_id = assn.person_id
          AND   assn.organization_id =
                (SELECT exporg.organization_id
                FROM pa_all_organizations exporg
                WHERE exporg.pa_org_use_type = 'EXPENDITURES'
                AND exporg.inactive_date is null
                AND exporg.organization_id = assn.organization_id
                AND rownum = 1 )
          ORDER BY 1,2;
Line: 2478

        PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.call_forcast_api');
Line: 2574

          FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.call_forcast_api'
                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 2617

        PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.call_billable_resoruce_denorm');
Line: 2670

                      PA_RESOURCE_PVT.update_resource_denorm
                      ( p_resource_denorm_old_rec  => v_resource_rec_old
                       ,p_resource_denorm_new_rec  => v_resource_rec_new
                       ,x_return_status            => x_return_status
                       ,x_msg_data                 => x_msg_data
                       ,x_msg_count                => x_msg_count
                       );
Line: 2691

          FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.call_billable_resoruce_denorm'
                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 2736

    SELECT person_id, min(resource_effective_start_date) resource_effective_start_date,
           max(resource_effective_end_date) resource_effective_end_date
      FROM pa_resources_denorm
     WHERE job_id = p_job_id
  GROUP BY person_id;  */
Line: 2743

    SELECT person_id, min(resource_effective_start_date) resource_effective_start_date,
           max(resource_effective_end_date) resource_effective_end_date
      FROM pa_resources_denorm
     WHERE job_id = p_job_id
     AND resource_effective_end_date = (Select max(resource_effective_end_date)
                                              from pa_resources_denorm rd2
                                              where rd2.job_id = p_job_id
                                              AND (rd2.resource_effective_end_date >= sysdate OR rd2.resource_effective_end_date is null))
  GROUP BY person_id;
Line: 2754

    SELECT DISTINCT res.person_id person_id
      FROM pa_r_project_resources_v res
     WHERE res.job_id = p_job_id;
Line: 2760

 PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.per_job_extra_billability');
Line: 2773

 If P_calling_mode = 'INSERT' THEN
   l_pull_res_flag := 'Y';
Line: 2779

 ELSIF P_calling_mode = 'UPDATE' THEN
   -- If p_utilize_flag_old='N' AND p_utilize_flag_new='Y', we need to
   -- pull the people who have the job
   IF p_utilize_flag_old='N' AND p_utilize_flag_new='Y' THEN
     l_pull_res_flag := 'Y';
Line: 2815

     update_job_level_dff
            (P_job_id             => P_job_id
            ,P_job_level_old      => TO_NUMBER(P_job_level_old)
            ,P_job_level_new      => TO_NUMBER(P_job_level_new)
            ,x_return_status      => x_return_status
            ,x_msg_data           => x_msg_data
            ,x_msg_count          => x_msg_count );
Line: 2823

        log_message('After update_job_level_dff');
Line: 2833

 ELSIF P_calling_mode = 'DELETE' THEN
   IF p_utilize_flag_old ='Y' THEN
     l_end_date_res_flag := 'Y';
Line: 2838

        log_message('P_calling_mode=DELETE, p_utilize_flag_old:'||p_utilize_flag_old
                  ||', l_end_date_res_flag:'||l_end_date_res_flag);
Line: 2855

   update_job_level_dff
                (P_job_id             => P_job_id
                ,P_job_level_old      => TO_NUMBER(P_job_level_old)
                ,P_job_level_new      => NULL
                ,x_return_status      => x_return_status
                ,x_msg_data           => x_msg_data
                ,x_msg_count          => x_msg_count );
Line: 2863

      log_message('After calling update_job_level_dff');
Line: 2932

          Update_EndDate
                   (p_person_id            => rec.person_id,
                    p_old_start_date       => rec.resource_effective_start_date,
                    p_new_start_date       => rec.resource_effective_start_date,
                    p_old_end_date         => rec.resource_effective_end_date,
                    p_new_end_date         => sysdate,
                    x_return_status        => x_return_status,
                    x_msg_count            => x_msg_count,
                    x_msg_data             => x_msg_data);
Line: 2943

             log_message('Return status from Update_EndDate = ' || x_return_status);
Line: 2964

                log_message('error msg from Update_EndDate: ' || substr(x_msg_data,1,200));
Line: 3016

       FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.per_job_extra_billability'
                              ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 3044

        select cand.candidate_id, cand.record_version_number
        from pa_candidates cand,
             pa_project_assignments asgmt,
             pa_project_statuses ps
        where cand.resource_id                   = l_resource_id
          and cand.assignment_id                 = asgmt.assignment_id
          and asgmt.assignment_type              = 'OPEN_ASSIGNMENT'
          and asgmt.status_code                  = ps.project_status_code (+)
          and (ps.project_system_status_code     = 'OPEN_ASGMT'
            OR ps.project_system_status_code is null)
          and asgmt.start_date                   > trunc(p_effective_date)
          and cand.status_code not in
                  (select ps2.project_status_code
                   from pa_project_statuses ps2
                   where ps2.status_type='CANDIDATE'
                     and ps2.project_system_status_code IN
                                   ('CANDIDATE_DECLINED','CANDIDATE_WITHDRAWN'));
Line: 3066

    PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.withdraw_cand_nominations');
Line: 3093

            PA_CANDIDATE_PUB.Update_Candidate
                   (p_candidate_id            => rec.candidate_id,
                    p_status_code             => l_status_code,
                    p_ranking                 => null,
                    p_change_reason_code      => null,
                    p_record_version_number   => rec.record_version_number,
                    p_validate_status         => FND_API.G_FALSE,
                    p_init_msg_list           => FND_API.G_FALSE,
                    x_record_version_number   => l_rec_ver_num,
                    x_return_status           => x_return_status,
                    x_msg_count               => x_msg_count,
                    x_msg_data                => x_msg_data);
Line: 3107

               log_message('Return status from Update Candidate = ' || x_return_status);
Line: 3145

       FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.withdraw_cand_nominations'
                              ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 3152

/* Procedure Update_EndDate calls Update_Resource_Denorm to update the
   end date in pa_resources_denorm and update FI data for the resource.
   This procedure now also handles automatic candidates withdrawal.
   It is called whenever a resource is terminated in HR, whenever
   the change in assignment organization which does not belong to Exp Hier,
   or whenever an organization is taken out from the Exp Hier. In these
   cases, the resource is considered no longer active in PJR.
*/
PROCEDURE Update_EndDate(
    p_person_id          IN   per_all_people_f.person_id%TYPE,
    p_old_start_date     IN   per_all_assignments_f.effective_start_date%TYPE,
    p_new_start_date     IN   per_all_assignments_f.effective_end_date%TYPE,
    p_old_end_date       IN   per_all_assignments_f.effective_start_date%TYPE,
    p_new_end_date       IN   per_all_assignments_f.effective_end_date%TYPE,
    x_return_status      OUT  NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
    x_msg_data           OUT  NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
    x_msg_count	         OUT  NOCOPY NUMBER) IS --File.Sql.39 bug 4440895

    l_resource_rec_old     PA_RESOURCE_PVT.Resource_Denorm_Rec_Type;
Line: 3180

	       SELECT resource_effective_start_date,
               resource_effective_end_date
        FROM   pa_resources_denorm
        WHERE  person_id = p_person_id
     --   AND    p_new_end_date >= resource_effective_start_date
        AND    resource_effective_start_date >= p_old_start_date
        AND    resource_effective_end_date   <= p_old_end_date
    ;
Line: 3196

    PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.Update_EndDate');
Line: 3230

	      PA_RESOURCE_PVT.update_resource_denorm(
	              p_resource_denorm_old_rec  => l_resource_rec_old
	             ,p_resource_denorm_new_rec  => l_resource_rec_new
	             ,x_return_status            => l_return_status
	             ,x_msg_data                 => x_msg_data
	             ,x_msg_count                => x_msg_count);
Line: 3243

	      --Delete this record
              pa_resource_pvt.delete_resource_denorm(
	             p_person_id                  => p_person_id
	             ,p_res_effective_start_date  => rec.resource_effective_start_date
	             ,x_return_status             => l_return_status
                     ,x_msg_data                  => x_msg_data
		     ,x_msg_count                 => x_msg_count);
Line: 3321

          FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.Update_EndDate'
                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 3325

 END Update_EndDate;
Line: 3327

/* Procedure Update_Org calls Update_Resource_Denorm and Create_Forecast_Item to update the organization and org_id for the resources in pa_resources_denorm table and regenerate forecast items for the resource respectively.
*/
 PROCEDURE Update_Org(
     p_person_id	  IN    per_all_people_f.person_id%TYPE,
     p_old_org_id	  IN	per_all_assignments_f.organization_id%TYPE,
     p_new_org_id	  IN	per_all_assignments_f.organization_id%TYPE,
     p_old_start_date     IN	per_all_assignments_f.effective_start_date%TYPE,
     p_new_start_date     IN	per_all_assignments_f.effective_end_date%TYPE,
     p_old_end_date	  IN	per_all_assignments_f.effective_start_date%TYPE,
     p_new_end_date	  IN	per_all_assignments_f.effective_end_date%TYPE,
     x_return_status      OUT   NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
     x_msg_data           OUT   NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
     x_msg_count	  OUT   NOCOPY NUMBER) IS --File.Sql.39 bug 4440895

     l_default_ou_old       pa_resources_denorm.resource_org_id%TYPE;
Line: 3355

	       SELECT resource_effective_start_date,
               resource_effective_end_date
        FROM   pa_resources_denorm
        WHERE  person_id = p_person_id
        AND    resource_effective_start_date >= p_new_start_date
        AND    resource_effective_end_date   <= p_new_end_date
	   ;
Line: 3366

            select decode(substr(USERENV('CLIENT_INFO'),1,1),
                          ' ', NULL,
                          substr(USERENV('CLIENT_INFO'),1,10)) org from dual;  */
Line: 3375

       PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.Update_Org');
Line: 3381

          and update pa_resource_ou.organization.*/

       IF (Belongs_ExpOrg(p_new_org_id) = 'Y') THEN

          -- If the old org Id does not belong to exp hier,
          -- we have to fix data in resource denorm (we end dated that
          -- record previously when the org changes from Exp Hier
          -- to Non Exp Hier). So calling Create_Resource
          IF(Belongs_ExpOrg(p_old_org_id) = 'N') THEN

            pa_r_project_resources_pub.create_resource (
                      p_api_version        => 1.0
                     ,p_init_msg_list      => NULL
                     ,p_commit             => FND_API.G_FALSE
                     ,p_validate_only      => NULL
                     ,p_max_msg_count      => NULL
                     ,p_internal           => 'Y'
                     ,p_person_id          => p_person_id
                     ,p_individual         => 'Y'
                     ,p_resource_type      => NULL
                     ,x_return_status      => l_return_status
                     ,x_msg_count          => x_msg_count
                     ,x_msg_data           => x_msg_data
                     ,x_resource_id        => l_resource_id);
Line: 3469

	         PA_RESOURCE_PVT.update_resource_denorm(
                     p_resource_denorm_old_rec   => l_resource_rec_old
            	     ,p_resource_denorm_new_rec  => l_resource_rec_new
            	     ,x_return_status            => l_return_status
            	     ,x_msg_data                 => x_msg_data
            	     ,x_msg_count                => x_msg_count);
Line: 3503

            Update_EndDate(
                    p_person_id      => p_person_id,
                    p_old_start_date => p_old_start_date,
         	    p_new_start_date => p_new_start_date,
                    p_old_end_date   => p_old_end_date,
                    p_new_end_date   => sysdate,
                    x_return_status  => l_return_status,
                    x_msg_data       => x_msg_data,
                    x_msg_count      => x_msg_count);
Line: 3532

          FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.Update_Org'
          	,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 3536

 END Update_Org;
Line: 3546

        SELECT 'Y' FROM dual WHERE exists
         (SELECT 'Y' FROM hr_organization_information
                     WHERE organization_id = P_Organization_id
                     and org_information_context = 'Exp Organization Defaults'
                     and org_information1 = P_Default_OU_new);
Line: 3586

        SELECT 'x'
	FROM dual
	WHERE exists
		(select organization_id
	        FROM pa_all_organizations
	        WHERE organization_id = p_org_id
	        AND inactive_date is null
		AND pa_org_use_type = 'EXPENDITURES');
Line: 3625

	select to_number(org_information1)
	into l_default_ou
	from hr_organization_information
	where organization_id = p_org_id
	and org_information_context = 'Exp Organization Defaults';
Line: 3642

   Procedure Update_Job retrieves the job level for the job and calls
   Update_Resource_Denorm and Create_Forecast_Item to update the denorm
   table and regenerate forecast items for the resource respectively.
 */
 PROCEDURE Update_Job(
    p_person_id          IN   per_all_people_f.person_id%TYPE,
    p_old_job            IN   per_all_assignments_f.job_id%TYPE,
    p_new_job            IN   per_all_assignments_f.job_id%TYPE,
    p_new_start_date     IN   per_all_assignments_f.effective_start_date%TYPE,
    p_new_end_date       IN   per_all_assignments_f.effective_end_date%TYPE,
    x_return_status      OUT  NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
    x_msg_data           OUT  NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
    x_msg_count	     OUT  NOCOPY NUMBER) IS --File.Sql.39 bug 4440895

    l_resource_rec_old     PA_RESOURCE_PVT.Resource_Denorm_Rec_Type;
Line: 3677

    SELECT resource_effective_start_date,
           resource_effective_end_date
      FROM pa_resources_denorm
     WHERE person_id = p_person_id
       AND resource_effective_start_date >= p_new_start_date
       AND resource_effective_end_date   <= p_new_end_date;
Line: 3685

    SELECT min(resource_effective_start_date) resource_effective_start_date,
           max(resource_effective_end_date) resource_effective_end_date
      FROM pa_resources_denorm
     WHERE job_id = p_old_job
       AND person_id = p_person_id
  GROUP BY person_id;
Line: 3694

    PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.Update_Job');
Line: 3697

       log_message('beginning of Update_Job');
Line: 3759

       Update_EndDate
                   (p_person_id            => p_person_id,
                    p_old_start_date       => l_resource_start_date,
                    p_new_start_date       => l_resource_start_date,
                    p_old_end_date         => l_resource_end_date,
                    p_new_end_date         => sysdate,
                    x_return_status        => x_return_status,
                    x_msg_count            => x_msg_count,
                    x_msg_data             => x_msg_data);
Line: 3770

          log_message('Return status from Update_EndDate = ' || x_return_status);
Line: 3801

	  PA_RESOURCE_PVT.update_resource_denorm(
	     p_resource_denorm_old_rec  => l_resource_rec_old
            ,p_resource_denorm_new_rec  => l_resource_rec_new
            ,x_return_status            => l_return_status
            ,x_msg_data                 => x_msg_data
            ,x_msg_count                => x_msg_count);
Line: 3847

        FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.Update_Job'
                               ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 3851

 END Update_Job;
Line: 3853

/* Procedure Update_Supervisor calls Update_Resource_Denorm to update
the resource's supervisor in the denorm table.
*/
PROCEDURE Update_Supervisor(
	p_person_id          IN per_all_people_f.person_id%TYPE,
	p_old_supervisor     IN per_all_assignments_f.supervisor_id%TYPE,
	p_new_supervisor     IN per_all_assignments_f.supervisor_id%TYPE,
	p_new_start_date     IN per_all_assignments_f.effective_start_date%TYPE,
    p_new_end_date       IN per_all_assignments_f.effective_end_date%TYPE,
	x_return_status      OUT  NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
    x_msg_data           OUT  NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
    x_msg_count	         OUT  NOCOPY NUMBER) IS --File.Sql.39 bug 4440895

	l_resource_rec_old     PA_RESOURCE_PVT.Resource_Denorm_Rec_Type;
Line: 3873

	    SELECT resource_effective_start_date,
               resource_effective_end_date
        FROM   pa_resources_denorm
        WHERE  person_id = p_person_id
        AND    p_new_end_date >= resource_effective_start_date
        AND    resource_effective_start_date >= p_new_start_date
        AND    resource_effective_end_date   <= p_new_end_date
	;
Line: 3883

    	SELECT DISTINCT resource_name
    	FROM pa_resources_denorm
	    WHERE person_id = p_new_supervisor
    ;
Line: 3891

    PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.Update_Supervisor');
Line: 3911

        PA_RESOURCE_PVT.update_resource_denorm(
             p_resource_denorm_old_rec  => l_resource_rec_old
            ,p_resource_denorm_new_rec  => l_resource_rec_new
            ,x_return_status            => l_return_status
            ,x_msg_data                 => x_msg_data
            ,x_msg_count                => x_msg_count);
Line: 3933

        FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.Update_Supervisor'
          ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 3937

 END Update_Supervisor;
Line: 3939

/* Procedure Update_PrimaryFlag calls Update_EndDate to end date the
record for which the assignment record's primary flag has changed form
yes to no and then calls Create_Forecast_Item to regenerate
the forecast items for this resource.
*/
 PROCEDURE Update_PrimaryFlag(
	p_person_id          IN per_all_people_f.person_id%TYPE,
	p_old_start_date     IN per_all_assignments_f.effective_start_date%TYPE,
	p_new_start_date     IN per_all_assignments_f.effective_end_date%TYPE,
	p_old_end_date       IN per_all_assignments_f.effective_start_date%TYPE,
	p_new_end_date       IN per_all_assignments_f.effective_end_date%TYPE,
	x_return_status      OUT  NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
        x_msg_data           OUT  NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
        x_msg_count	     OUT  NOCOPY NUMBER) IS --File.Sql.39 bug 4440895

	l_return_status        VARCHAR2(1);
Line: 3958

        PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.Update_PrimaryFlag');
Line: 3961

	--Call Update_EndDate to end date the resource_ou record.
        -- Commented the end date change in PA as this is not required
        -- Solves bug 1608837
/*	Update_EndDate(p_person_id => p_person_id,
		p_old_start_date => p_old_start_date,
		p_new_start_date => p_new_start_date,
		p_old_end_date => p_old_end_date,
		p_new_end_date => p_new_end_date,
		x_return_status => x_return_status,
	        x_msg_data      => x_msg_data,
	        x_msg_count	=> x_msg_count);
Line: 3997

          FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.Update_PrimaryFlag'
                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 4001

 END Update_PrimaryFlag;
Line: 4003

/* Procedure Update_Name calls updates the resource's name in pa_resources.
*/
 PROCEDURE Update_Name(
    p_person_id     IN  per_all_people_f.person_id%TYPE,
    p_old_name	     IN  per_all_people_f.full_name%TYPE,
    p_new_name	     IN  per_all_people_f.full_name%TYPE,
    x_return_status OUT  NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
    x_msg_data      OUT  NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
    x_msg_count	    OUT  NOCOPY NUMBER) IS --File.Sql.39 bug 4440895

    l_resource_id	     pa_resources.resource_id%TYPE;
Line: 4021

        PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.Update_Name');
Line: 4032

	UPDATE pa_resources
	SET name = p_new_name
	WHERE resource_id = l_resource_id;
Line: 4044

	PA_RESOURCE_PVT.update_resource_denorm(
		              p_resource_denorm_old_rec   => l_resource_rec_old
                ,p_resource_denorm_new_rec  => l_resource_rec_new
                ,x_return_status            => l_return_status
                ,x_msg_data                 => x_msg_data
                ,x_msg_count                => x_msg_count);
Line: 4064

          FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.Update_Name'
                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 4068

 END Update_Name;
Line: 4141

    SELECT territory_short_name
      INTO l_country_code
      FROM fnd_territories_vl
     WHERE territory_code = p_country_code ;
Line: 4165

      SELECT name
        INTO l_job_name
        FROM per_jobs
       WHERE job_id = P_job_id;
Line: 4188

      SELECT name
        INTO l_org_name
        FROM hr_all_organization_units_tl
       WHERE organization_id = P_org_id
         AND language = USERENV('LANG');
Line: 4208

      SELECT name
        INTO l_grade_name
        FROM per_grades
       WHERE grade_id = P_grade_id;
Line: 4224

PROCEDURE Delete_PA_Resource_Denorm(
    p_person_id          IN   per_all_people_f.person_id%TYPE,
    p_old_start_date     IN   per_all_assignments_f.effective_start_date%TYPE,
    p_old_end_date       IN   per_all_assignments_f.effective_end_date%TYPE,
    x_return_status      OUT  NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
    x_msg_data           OUT  NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
    x_msg_count	         OUT  NOCOPY NUMBER) IS --File.Sql.39 bug 4440895


    CURSOR res_denorm_recs IS
	       SELECT resource_effective_start_date,
               resource_effective_end_date
        FROM   pa_resources_denorm
        WHERE  person_id = p_person_id
        AND    resource_effective_start_date >= p_old_start_date
        AND    resource_effective_end_date   <= p_old_end_date
    ;
Line: 4244

    PA_DEBUG.init_err_stack('PA_HR_UPDATE_API.Delete_PA_Resource_Denorm');
Line: 4248

	      --Delete the record
               DELETE FROM PA_RESOURCES_DENORM
                 WHERE person_id = p_person_id
                 AND resource_effective_start_date = rec.resource_effective_start_date;
Line: 4268

          FND_MSG_PUB.add_exc_msg(p_pkg_name => 'PA_HR_UPDATE_API.Delete_PA_Resource_Denorm'
                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
Line: 4272

 END Delete_PA_Resource_Denorm;