DBA Data[Home] [Help]

APPS.PA_FUND_REVAL_PVT SQL Statements

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

Line: 28

   |                                   Values are 'SINGLE', 'RANGE', 'DELETE'                |
   |     x_return_status       OUT     Return status of this procedure                       |
   |     x_msg_count           OUT     Error message count                                   |
   |     x_msg_data            OUT     Error message                                         |
   |     ==================================================================================  |
   +----------------------------------------------------------------------------------------*/


   PROCEDURE Revaluate_funding(
             p_project_id        IN    NUMBER,
             p_project_type_id   IN    NUMBER,
             p_from_proj_number  IN    VARCHAR2,
             p_to_proj_number    IN    VARCHAR2,
             p_thru_date         IN    DATE,
             p_rate_type         IN    VARCHAR2	,
             p_rate_date         IN    DATE,
             p_baseline_flag     IN    VARCHAR2,
             p_debug_mode        IN    VARCHAR2,
             p_run_mode          IN    VARCHAR2,
             x_return_status     OUT   NOCOPY VARCHAR2,
             x_msg_count         OUT   NOCOPY NUMBER,
             x_msg_data          OUT   NOCOPY VARCHAR2)   IS

         l_FromProjNum              VARCHAR2(25);
Line: 131

         IF p_run_mode = 'DELETE' THEN

            get_delete_projects(
                p_project_type_id   => l_ProjTypeId,
                p_from_proj_number  => l_FromProjNum,
                p_to_proj_number    => l_ToProjNum,
                p_run_mode          => p_run_mode,
                x_return_status     => l_return_status,
                x_msg_count         => l_msg_count,
                x_msg_data          => l_msg_data);
Line: 190

         END IF; /* p_run_mode = DELETE */
Line: 326

            Insert_distribution_warnings(p_project_id     => p_project_id,
                                    p_reason_code    => l_ReasonCode,
                                    x_return_status  => l_return_status,
                                    x_msg_count      => l_msg_count,
                                    x_msg_data       => l_msg_data) ;
Line: 364

               Delete_unbaselined_adjmts(p_project_id     => p_project_id,
                                         p_run_mode       => p_run_mode,
                                         x_return_status  => l_return_status,
                                         x_msg_count      => l_msg_count,
                                         x_msg_data       => l_msg_data) ;
Line: 384

               Insert_distribution_warnings(p_project_id     => p_project_id,
                                       p_reason_code    => l_ReasonCode,
                                       x_return_status  => l_return_status,
                                       x_msg_count      => l_msg_count,
                                       x_msg_data       => l_msg_data) ;
Line: 466

       /* This CURSOR selects all reporting set of books enabled for the primary set of book id
          in PA */

       /* R12 :  Ledger Architecture Changes : The table gl_mc_reporting_options will  obsoleted, replace with
          new table gl_alc_ledger_rships_v and corresponding columns */

       /* CURSOR rsob is SELECT rep.reporting_set_of_books_id reporting_set_of_books_id ,
                             rep.reporting_currency_code, rep.conversion_type
                      FROM   gl_mc_reporting_options rep, pa_implementations imp
                      WHERE  rep.primary_set_of_books_id = imp.set_of_books_id
                      AND    enabled_flag = 'Y'
                      AND    rep.org_id = imp.org_id
                      AND    application_id = 275;  */
Line: 480

          CURSOR rsob is SELECT rep.ledger_id   reporting_set_of_books_id ,
                             rep.currency_code reporting_currency_code,
                             rep.alc_default_conv_rate_type conversion_type
                      FROM   gl_alc_ledger_rships_v rep, pa_implementations imp
                      WHERE  rep.source_ledger_id = imp.set_of_books_id
                      AND    rep.relationship_enabled_flag  = 'Y'
                      AND    (rep.org_id = -99 OR rep.org_id = imp.org_id)
                      AND    rep.application_id = 275;
Line: 492

       /* This CURSOR selects all reporting set of books enabled for the primary set of book id
          in AR */

       /* R12 :  Ledger Architecture Changes : The table gl_mc_reporting_options will  obsoleted, replace with
          new table gl_alc_ledger_rships_v and corresponding columns */


      /*  CURSOR rsob_ar_mc is SELECT rep.reporting_set_of_books_id reporting_set_of_books_id ,
                             rep.reporting_currency_code, rep.conversion_type
                      FROM   gl_mc_reporting_options rep, pa_implementations imp
                      WHERE  rep.primary_set_of_books_id = imp.set_of_books_id
                      AND    enabled_flag = 'Y'
                      AND    rep.org_id = imp.org_id
                      AND    application_id = PA_FUND_REVAL_UTIL.get_ar_application_id;  */
Line: 508

          CURSOR rsob_ar_mc is SELECT rep.ledger_id reporting_set_of_books_id ,
                             rep.currency_code reporting_currency_code,
                             rep.alc_default_conv_rate_type conversion_type
                      FROM   gl_alc_ledger_rships_v  rep, pa_implementations imp
                      WHERE  rep.source_ledger_id  = imp.set_of_books_id
                      AND    rep.relationship_enabled_flag  = 'Y'
                      AND    (rep.org_id = -99 OR rep.org_id = imp.org_id)
                      AND    application_id = PA_FUND_REVAL_UTIL.get_ar_application_id;
Line: 543

         SELECT set_of_books_id, nvl(ENABLE_MRC_FOR_FUND_FLAG , 'N')
         into G_SET_OF_BOOKS_ID, G_MRC_FUND_ENABLED_FLAG FROM pa_implementations;
Line: 547

         SELECT set_of_books_id, 'N' -- nvl(REVAL_MRC_FUNDING_FLAG , 'N')
         into G_SET_OF_BOOKS_ID, G_MRC_FUND_ENABLED_FLAG FROM pa_implementations;
Line: 732

           SELECT p.segment1, pt.project_type_id
           INTO l_FromProjNum, l_ProjTypeId
           FROM pa_projects p, pa_project_types pt
           WHERE p.project_id = p_project_id
           AND pt.project_type = p.project_type;
Line: 746

                 SELECT MIN(P.segment1)
                 INTO l_FromProjNum
                 FROM PA_PROJECTS P , PA_PROJECT_TYPES T
                 WHERE  T.project_type_id (+) = l_ProjTypeId
                 AND    P.Project_type = T.Project_type
                 AND    T.Project_type_class_code = 'CONTRACT';
Line: 755

               SELECT proj.seg1
               INTO l_FromProjNum
               FROM (
                       SELECT t.project_type_class_code, MIN(P.segment1) seg1
                       FROM PA_PROJECTS P , PA_PROJECT_TYPES T
                       WHERE  T.project_type_id  = NVL(l_ProjTypeId,0)
                       AND    P.Project_type  = T.Project_type
                       AND    T.Project_type_class_code = 'CONTRACT'
                       AND    NVL(l_ProjTypeId,0) <> 0
                       GROUP BY t.project_type_class_code
                       UNION
                       SELECT t.project_type_class_code, MIN(P.segment1) seg1
                       FROM PA_PROJECTS P , PA_PROJECT_TYPES T
                       WHERE P.Project_type  = T.Project_type
                       AND    T.Project_type_class_code = 'CONTRACT'
                       AND nvl(l_ProjTypeId,0) = 0
                        group by t.project_type_class_code
                       )  proj;
Line: 786

                 SELECT MAX(P.segment1)
                 INTO l_ToProjNum
                 FROM PA_PROJECTS P , PA_PROJECT_TYPES T
                 WHERE  T.project_type_id (+) = l_ProjTypeId
                 AND    P.Project_type = T.Project_type
                 AND    T.Project_type_class_code = 'CONTRACT';
Line: 795

               SELECT proj.seg1
               INTO l_ToProjNum
               FROM (
                       SELECT t.project_type_class_code, MAX(P.segment1) seg1
                       FROM PA_PROJECTS P , PA_PROJECT_TYPES T
                       WHERE  T.project_type_id  = NVL(l_ProjTypeId,0)
                       AND    P.Project_type  = T.Project_type
                       AND    T.Project_type_class_code = 'CONTRACT'
                       AND    NVL(l_ProjTypeId,0) <> 0
                       GROUP BY t.project_type_class_code
                       UNION
                       SELECT t.project_type_class_code, MAX(P.segment1) seg1
                       FROM PA_PROJECTS P , PA_PROJECT_TYPES T
                       WHERE P.Project_type  = T.Project_type
                       AND    T.Project_type_class_code = 'CONTRACT'
                       AND nvl(l_ProjTypeId,0) = 0
                        group by t.project_type_class_code
                       )  proj;
Line: 922

            SELECT 'T' INTO x_exist_flag
            FROM DUAL
            WHERE EXISTS ( SELECT NULL
                       FROM pa_draft_revenues r
                       WHERE r.project_id = p_project_id
                       AND   r.released_date IS NULL);
Line: 949

               SELECT 'T' INTO x_exist_flag
               FROM DUAL
               WHERE EXISTS ( SELECT NULL
                              FROM   pa_draft_invoices i
                              WHERE  i.project_id = p_project_id
                              and    i.released_by_person_id IS NULL);
Line: 1020

         SELECT 'T' INTO l_ExistFlag
         FROM DUAL
         WHERE EXISTS (SELECT NULL
                       FROM pa_project_fundings
                       WHERE project_id = p_project_id
                       AND funding_category = 'REVALUATION'
                       AND budget_type_code = 'DRAFT');
Line: 1045

   |   Procedure  :   Delete_unbaselined_adjmts                                              |
   |   Purpose    :   To delete (if any) unbaselined revaluation adjutment lines             |
   |   Parameters :                                                                          |
   |     ==================================================================================  |
   |     Name                             Mode    Description                                |
   |     ==================================================================================  |
   |     p_project_id          IN      Project ID                                            |
   |     p_run_mode            IN      Run Mode - SINGLE,RANGE, DELETE                       |
   |     x_return_status       OUT     Return status of this procedure                       |
   |     x_msg_count           OUT     Error message count                                   |
   |     x_msg_data            OUT     Error message                                         |
   |     ==================================================================================  |
   +----------------------------------------------------------------------------------------*/

   PROCEDURE Delete_Unbaselined_Adjmts (
             p_project_id        IN    NUMBER,
             p_run_mode          IN    VARCHAR2,
             x_return_status     OUT   NOCOPY VARCHAR2,
             x_msg_count         OUT   NOCOPY NUMBER,
             x_msg_data          OUT   NOCOPY VARCHAR2)   IS

         CURSOR fund_recs is
                SELECT project_funding_id, agreement_id, project_id, task_id, projfunc_allocated_amount,
                       projfunc_realized_gains_amt, projfunc_realized_losses_amt, invproc_allocated_amount,
                       revproc_allocated_amount
                FROM pa_project_fundings
                WHERE project_id = p_project_id
                AND funding_category = 'REVALUATION'
                AND budget_type_code = 'DRAFT';
Line: 1102

            PA_DEBUG.g_err_stage := '-----------Entering PA_FUND_REVAL_PVT.Delete_Unbaselined_Adjmts-----------' ;
Line: 1126

                        DELETE FROM pa_events
                        WHERE project_funding_id = l_FundingIdTab(i)
			AND   Project_ID         = l_ProjectIdTab(i);
Line: 1131

                        DELETE FROM pa_project_fundings
                        WHERE project_funding_id = l_FundingIdTab(i);
Line: 1135

                        UPDATE pa_summary_project_fundings
                        SET    projfunc_unbaselined_amount =
                                      nvl(projfunc_unbaselined_amount,0) - nvl(l_ProjfuncAllocTab(i),0),
                               invproc_unbaselined_amount =
                                      nvl(invproc_unbaselined_amount,0) - nvl(l_InvprocAllocTab(i),0),
                               revproc_unbaselined_amount =
                                      nvl(revproc_unbaselined_amount,0) - nvl(l_RevprocAllocTab(i),0),
                               projfunc_realized_gains_amt =
                                      nvl(projfunc_realized_gains_amt,0) - nvl(l_ProjfuncGainsTab(i),0),
                               projfunc_realized_losses_amt =
                                      nvl(projfunc_realized_losses_amt,0) - nvl(l_ProjfuncLossTab(i),0)
                        WHERE agreement_id = l_AgreementIdTab(i)
                        AND   project_id = l_ProjectIdTab(i)
                        AND   nvl(task_id,-99) = nvl(l_TaskIdTab(i),-99);
Line: 1150

                 /* Insert the details of project funding line deleted as delete process requires output */

                 IF p_run_mode = 'DELETE' THEN

                    l_ReasonCode := NULL;
Line: 1158

                        Insert_distribution_warnings(
                               p_project_id     => p_project_id,
                               p_task_id        => l_TaskIdTab(j),
                               p_agreement_id   => l_AgreementIdTab(j),
                               p_reason_code    => l_ReasonCode,
                               x_return_status  => l_return_status,
                               x_msg_count      => l_msg_count,
                               x_msg_data       => l_msg_data) ;
Line: 1180

                 END IF; /*p_run_mode = 'DELETE' */
Line: 1185

              l_FundingIdTab.DELETE;
Line: 1186

              l_AgreementIdTab.DELETE;
Line: 1187

              l_ProjectIdTab.DELETE;
Line: 1188

              l_TaskIdTab.DELETE;
Line: 1189

              l_ProjfuncAllocTab.DELETE;
Line: 1190

              l_ProjfuncGainsTab.DELETE;
Line: 1191

              l_ProjfuncLossTab.DELETE;
Line: 1192

              l_InvprocAllocTab.DELETE;
Line: 1193

              l_RevprocAllocTab.DELETE;
Line: 1204

            PA_DEBUG.g_err_stage := '-----------Exiting PA_FUND_REVAL_PVT.Delete_Unbaselined_Adjmts-----------' ;
Line: 1228

                PA_DEBUG.g_err_stage := 'Delete_Unbaselined_Adjmts:' || x_msg_data ;
Line: 1233

   END Delete_Unbaselined_Adjmts;
Line: 1237

   |   Procedure  :   Insert_distribution_warnings                                                |
   |   Purpose    :   To insert rejection reasons in distribution table                      |
   |   Parameters :                                                                          |
   |     ==================================================================================  |
   |     Name                             Mode    Description                                |
   |     ==================================================================================  |
   |     p_project_id          IN      Project ID                                            |
   |     p_agreement_id        IN      Agreement ID                                          |
   |     p_task_id             IN      Task id of summary project funding                    |
   |     p_reason_code         IN      Rejection Reason                                      |
   |     x_return_status       OUT     Return status of this procedure                       |
   |     x_msg_count           OUT     Error message count                                   |
   |     x_msg_data            OUT     Error message                                         |
   |     ==================================================================================  |
   +----------------------------------------------------------------------------------------*/

   PROCEDURE Insert_distribution_warnings(
             p_project_id        IN    NUMBER,
             p_agreement_id      IN    NUMBER DEFAULT NULL,
             p_task_id           IN    NUMBER DEFAULT NULL,
             p_reason_code       IN    VARCHAR2,
             x_return_status     OUT   NOCOPY VARCHAR2,
             x_msg_count         OUT   NOCOPY NUMBER,
             x_msg_data          OUT   NOCOPY VARCHAR2)   IS


         l_return_status             VARCHAR2(30) := NULL;
Line: 1270

         CURSOR rej_reason IS SELECT meaning FROM PA_LOOKUPS
                WHERE lookup_type =  'FUNDING REVAL REJECTION'
                AND   lookup_code = p_reason_code;
Line: 1280

            PA_DEBUG.g_err_stage := '-----------Entering PA_FUND_REVAL_PVT.Insert_distribution_warnings-----------' ;
Line: 1296

         INSERT INTO PA_DISTRIBUTION_WARNINGS
         (
              PROJECT_ID, AGREEMENT_ID, TASK_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY,
              CREATION_DATE, CREATED_BY, REQUEST_ID, PROGRAM_APPLICATION_ID,
              PROGRAM_ID, PROGRAM_UPDATE_DATE, WARNING_MESSAGE_CODE, WARNING_MESSAGE
         )
         VALUES
         (
              p_project_id, p_agreement_id, p_task_id, SYSDATE, G_LAST_UPDATED_BY,
              SYSDATE, G_LAST_UPDATED_BY, G_REQUEST_ID, G_PROGRAM_APPLICATION_ID,
              G_PROGRAM_ID, SYSDATE, p_reason_code, l_reason
         );
Line: 1311

            PA_DEBUG.g_err_stage := '-----------Exiting PA_FUND_REVAL_PVT.Insert_distribution_warnings-----------' ;
Line: 1335

                PA_DEBUG.g_err_stage := 'Insert_distribution_warnings:' || x_msg_data ;
Line: 1340

   END Insert_distribution_warnings;
Line: 1365

         G_LAST_UPDATE_LOGIN := fnd_global.login_id;
Line: 1369

         G_LAST_UPDATED_BY := fnd_global.user_id;
Line: 1415

       /* This CURSOR selects all projects with the following criteria
              a) should be contract  projects
              b) revaluate_funding_flag is enabled
              c) Falls within the given range start/end project numbers */

         CURSOR open_projects IS
                SELECT P.project_id, P.baseline_funding_flag,
                       P.include_gains_losses_flag include_gains_losses_flag,
                       P.carrying_out_organization_id,
                       P.projfunc_bil_rate_type projfunc_bil_rate_type,
                       P.projfunc_bil_exchange_rate projfunc_bil_exchange_rate,
                       DECODE(P.invproc_currency_type,
                              'PROJECT_CURRENCY', P.project_bil_rate_type,
                              'PROJFUNC_CURRENCY', P.projfunc_bil_rate_type,
                              'FUNDING_CURRENCY', P.funding_rate_type) invproc_rate_type,
                       DECODE(P.invproc_currency_type,
                              'PROJECT_CURRENCY', P.project_bil_exchange_rate,
                              'PROJFUNC_CURRENCY', P.projfunc_bil_exchange_rate,
                              'FUNDING_CURRENCY', P.funding_exchange_rate) invproc_exchange_rate,
                       T.RLZD_GAINS_EVENT_TYPE_ID,
                       T.RLZD_LOSSES_EVENT_TYPE_ID
                FROM pa_projects P, pa_project_types T
                WHERE P.segment1 BETWEEN p_from_proj_number
                               AND p_to_proj_number
                AND   P.PROJECT_TYPE = T.PROJECT_TYPE
                AND   T.DIRECT_FLAG = 'Y'
                AND   T.PROJECT_TYPE_ID  = NVL(P_PROJECT_TYPE_ID ,T.project_type_id)
                AND   NVL(P.revaluate_funding_flag, 'N') = 'Y'
                AND   NVL(P.template_flag, 'N') = 'N'
                ORDER BY segment1 ;
Line: 1449

                SELECT event_type, description from pa_event_types
                WHERE event_type_id  = l_EventTypeId;
Line: 1520

                G_InvCompTab.DELETE;
Line: 1521

                G_RetnApplAmtTab.DELETE;
Line: 1522

                G_RevalCompTab.DELETE;
Line: 1580

                      Insert_distribution_warnings(
                             p_project_id     => G_ProjLvlGlobRec.project_id,
                             p_reason_code    => l_ReasonCode,
                             x_return_status  => l_return_status,
                             x_msg_count      => l_msg_count,
                             x_msg_data       => l_msg_data) ;
Line: 1622

                            /*Bug 3986205 : Replaced p_project_id with G_ProjLvlGlobRec.project_id in the following INSERT statement */

                            INSERT INTO PA_DISTRIBUTION_WARNINGS
                            (
                                 PROJECT_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY,
                                 CREATION_DATE, CREATED_BY, REQUEST_ID, PROGRAM_APPLICATION_ID,
                                 PROGRAM_ID, PROGRAM_UPDATE_DATE, WARNING_MESSAGE_CODE, WARNING_MESSAGE
                            )
                            VALUES
                            (
                                 G_ProjLvlGlobRec.project_id, SYSDATE, G_LAST_UPDATED_BY,
                                 SYSDATE, G_LAST_UPDATED_BY, G_REQUEST_ID, G_PROGRAM_APPLICATION_ID,
                                 G_PROGRAM_ID, SYSDATE, 'BASELINE ERROR', l_msg_data
                            );
Line: 1704

         /* This CURSOR selects the summary project funding lines with non-zero baselined amount
            for the given project in primary set of book id only*/

         CURSOR get_spf_lines (l_ProjectId NUMBER) is
                SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                       SPF.agreement_id   agreement_id,
                       SPF.task_id   task_id,
                       SPF.funding_currency_code funding_currency_code,
                       SPF.project_currency_code project_currency_code,
                       SPF.projfunc_currency_code projfunc_currency_code,
                       SPF.invproc_currency_code invproc_currency_code,
                       SPF.total_baselined_amount total_baselined_amount,
                       SPF.projfunc_baselined_amount projfunc_baselined_amount,
                       SPF.invproc_baselined_amount invproc_baselined_amount,
                       SPF.projfunc_realized_gains_amt projfunc_realized_gains_amt,
                       SPF.projfunc_realized_losses_amt projfunc_realized_losses_amt,
                       SPF.projfunc_accrued_amount projfunc_accrued_amount,
                       SPF.invproc_billed_amount invproc_billed_amount,
                       PC.retention_level_code retention_level_code,
                       PC.customer_id customer_id
                FROM   pa_summary_project_fundings SPF, pa_agreements_all A, pa_project_customers PC
                WHERE  SPF.project_id = l_ProjectId
                AND    A.agreement_id = SPF.agreement_id
                AND    PC.customer_id = A.customer_id
                AND    PC.project_id = SPF.project_id
                AND    (NVL(SPF.total_baselined_amount,0) <> 0)
                ORDER BY PC.customer_id, SPF.agreement_id, SPF.task_id , set_of_books_id;
Line: 1732

         /* This CURSOR selects the summary project funding lines with non-zero baselined amount
            for the given project in primary and reporting set of book ids */


        /* R12 :  Ledger Architecture Changes : The table gl_mc_reporting_options will  obsoleted, replace with
           new table gl_alc_ledger_rships_v and corresponding columns */

/* mrc migration to SLA bug 4571438
         CURSOR get_all_spf_lines (l_ProjectId NUMBER) is
                (SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                        SPF.agreement_id   agrmt_id,
                        SPF.task_id   task_id,
                        SPF.funding_currency_code funding_currency_code,
                        SPF.project_currency_code project_currency_code,
                        SPF.projfunc_currency_code projfunc_currency_code,
                        SPF.invproc_currency_code invproc_currency_code,
                        SPF.total_baselined_amount total_baselined_amount,
                        SPF.projfunc_baselined_amount projfunc_baselined_amount,
                        SPF.invproc_baselined_amount invproc_baselined_amount,
                        SPF.projfunc_realized_gains_amt projfunc_realized_gains_amt,
                        SPF.projfunc_realized_losses_amt projfunc_realized_losses_amt,
                        SPF.projfunc_accrued_amount projfunc_accrued_amount,
                        SPF.invproc_billed_amount invproc_billed_amount,
                        PC.retention_level_code retention_level_code,
                        PC.customer_id cust_id
                 FROM   pa_summary_project_fundings SPF, pa_agreements_all A, pa_project_customers PC
                 WHERE  SPF.project_id = l_ProjectId
                 AND    A.agreement_id = SPF.agreement_id
                 AND    PC.customer_id = A.customer_id
                 AND    PC.project_id = SPF.project_id
                 AND    (NVL(SPF.total_baselined_amount,0) <> 0)
                UNION
                 SELECT SPF_mc.set_of_books_id,
                        SPF.agreement_id   agrmt_id,
                        SPF.task_id   task_id,
                        SPF.funding_currency_code funding_currency_code,
                        'NA' project_currency_code,
                        SPF_mc.currency_code projfunc_currency_code,
                        SPF.invproc_currency_code invproc_currency_code,
                        SPF.total_baselined_amount total_baselined_amount,
                        SPF_mc.total_baselined_amount projfunc_baselined_amount,
                        SPF.invproc_baselined_amount invproc_baselined_amount,
                        SPF_mc.realized_gains_amt projfunc_realized_gains_amt,
                        SPF_mc.realized_losses_amt projfunc_realized_losses_amt,
                        SPF_mc.total_accrued_amount projfunc_accrued_amount,
                        SPF.invproc_billed_amount invproc_billed_amount,
                        PC.retention_level_code retention_level_code,
                        PC.customer_id cust_id
                 FROM   pa_mc_sum_proj_fundings SPF_mc,  pa_summary_project_fundings SPF,
                        pa_agreements_all A, pa_project_customers PC,
                        gl_alc_ledger_rships_v  rep, pa_implementations imp
                 WHERE SPF.project_id = l_ProjectId
                 AND   A.agreement_id = SPF.agreement_id
                 AND   PC.customer_id = A.customer_id
                 AND   PC.project_id = SPF.project_id
                 AND   (NVL(SPF.total_baselined_amount,0) <> 0)
                 AND   rep.source_ledger_id = imp.set_of_books_id
                 AND   rep.relationship_enabled_flag  = 'Y'
                 AND   (rep.org_id = -99 OR rep.org_id = imp.org_id)
                 AND   rep.application_id = 275
                 AND   spf_mc.set_of_books_id =rep.ledger_id
                 AND   spf_mc.project_id = spf.project_id
                 AND   spf_mc.agreement_id = spf.agreement_id
                 AND   nvl(spf_mc.task_id,0) = nvl(spf.task_id,0)
                )
                ORDER BY cust_id, agrmt_id, task_id , set_of_books_id; */
Line: 1854

         G_RevalCompTab.DELETE; /* Intialize for each project */
Line: 1910

                      G_RevalCompTab.DELETE; /* Initialize for next SPF record */
Line: 1927

               l_SetOfBookIdTab.DELETE;
Line: 1928

               l_AgreementIdTab.DELETE;
Line: 1929

               l_TaskIdTab.DELETE;
Line: 1930

               l_FCCurrTab.DELETE;
Line: 1931

               l_PCCurrTab.DELETE;
Line: 1932

               l_PFCCurrTab.DELETE;
Line: 1933

               l_IPCCurrTab.DELETE;
Line: 1934

               l_FCBaseAmtTab.DELETE;
Line: 1935

               l_PFCBaseAmtTab.DELETE;
Line: 1936

               l_IPCBaseAmtTab.DELETE;
Line: 1937

               l_PFCGainAmtTab.DELETE;
Line: 1938

               l_PFCLossAmtTab.DELETE;
Line: 1939

               l_PFCAccruedAmtTab.DELETE;
Line: 1940

               l_IPCBilledAmtTab.DELETE;
Line: 1941

               l_RetnLevelTab.DELETE;
Line: 1942

               l_CustomerIdTab.DELETE;
Line: 1998

                          G_RevalCompTab.DELETE;
Line: 2049

                        G_RevalCompTab.DELETE;
Line: 2068

               l_SetOfBookIdTab.DELETE;
Line: 2069

               l_AgreementIdTab.DELETE;
Line: 2070

               l_TaskIdTab.DELETE;
Line: 2071

               l_FCCurrTab.DELETE;
Line: 2072

               l_PCCurrTab.DELETE;
Line: 2073

               l_PFCCurrTab.DELETE;
Line: 2074

               l_IPCCurrTab.DELETE;
Line: 2075

               l_FCBaseAmtTab.DELETE;
Line: 2076

               l_PFCBaseAmtTab.DELETE;
Line: 2077

               l_IPCBaseAmtTab.DELETE;
Line: 2078

               l_PFCGainAmtTab.DELETE;
Line: 2079

               l_PFCLossAmtTab.DELETE;
Line: 2080

               l_PFCAccruedAmtTab.DELETE;
Line: 2081

               l_IPCBilledAmtTab.DELETE;
Line: 2082

               l_RetnLevelTab.DELETE;
Line: 2083

               l_CustomerIdTab.DELETE;
Line: 2117

            Insert_distribution_warnings(
                  p_project_id     => G_ProjLvlGlobRec.project_id,
                  p_reason_code    => l_ReasonCode,
                  x_return_status  => l_return_status,
                  x_msg_count      => l_msg_count,
                  x_msg_data       => l_msg_data) ;
Line: 2259

               G_InvCompTab.DELETE;
Line: 2260

               G_RetnApplAmtTab.DELETE;
Line: 2505

              SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     di.draft_invoice_num,
                     dii.projfunc_currency_code,
                     dii.funding_currency_code,
                     di.inv_currency_code,
                     di.system_reference,
                     di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND di.transfer_status_code = 'A'
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND nvl(di.retention_invoice_flag, 'N') = 'Y'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num, dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code,
                       di.system_reference,di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y');
Line: 2542

              (SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.projfunc_currency_code,
                     dii.funding_currency_code,
                     di.inv_currency_code,
                     di.system_reference,
                     di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND di.transfer_status_code = 'A'
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND nvl(di.retention_invoice_flag, 'N') = 'Y'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num, dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code,
                       di.system_reference,di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
             UNION
              SELECT dii_mc.set_of_books_id,
                     di.draft_invoice_num drft_inv_num,
                     dii_mc.currency_code projfunc_currency_code,
                     dii.funding_currency_code,
                     di.inv_currency_code,
                     di.system_reference,
                     di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii_mc.amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount
              FROM pa_draft_invoice_items dii, pa_mc_draft_inv_items dii_mc, pa_draft_invoices di,
                   gl_alc_ledger_rships_v rep, pa_implementations imp
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND di.transfer_status_code = 'A'
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND rep.source_ledger_id  = imp.set_of_books_id
              AND rep.relationship_enabled_flag = 'Y'
              AND (rep.org_id = -99 OR rep.org_id = imp.org_id)
              AND rep.application_id = 275
              AND dii_mc.set_of_books_id =rep.ledger_id
              AND dii_mc.project_id = dii.project_id
              AND dii_mc.draft_invoice_num = dii.draft_invoice_num
              AND dii_mc.line_num = dii.line_num
              AND nvl(di.retention_invoice_flag, 'N') = 'Y'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num, dii_mc.set_of_books_id, dii_mc.currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference,di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
               )
              ORDER BY drft_inv_num, set_of_books_id; */
Line: 2724

                       l_RetnInvTab.DELETE;
Line: 2742

                l_SetOfBookIdTab.DELETE;
Line: 2743

                l_DraftInvNumTab.DELETE;
Line: 2744

                l_PFCCurrTab.DELETE;
Line: 2745

                l_FCCurrTab.DELETE;
Line: 2746

                l_ITCCurrTab.DELETE;
Line: 2747

                l_SysRefTab.DELETE;
Line: 2748

                l_CancelFlgTab.DELETE;
Line: 2749

                l_CrMemoFlgTab.DELETE;
Line: 2750

                l_WrOffFlgTab.DELETE;
Line: 2751

                l_ClCrMemoFlgTab.DELETE;
Line: 2752

                l_BillAmtPFCTab.DELETE;
Line: 2753

                l_BillAmtFCTab.DELETE;
Line: 2754

                l_BillAmtITCTab.DELETE;
Line: 2809

                          l_RetnInvTab.DELETE;
Line: 2864

                     l_RetnInvTab.DELETE;
Line: 2883

                l_SetOfBookIdTab.DELETE;
Line: 2884

                l_DraftInvNumTab.DELETE;
Line: 2885

                l_PFCCurrTab.DELETE;
Line: 2886

                l_FCCurrTab.DELETE;
Line: 2887

                l_ITCCurrTab.DELETE;
Line: 2888

                l_SysRefTab.DELETE;
Line: 2889

                l_CancelFlgTab.DELETE;
Line: 2890

                l_ClCrMemoFlgTab.DELETE;
Line: 2891

                l_WrOffFlgTab.DELETE;
Line: 2892

                l_CrMemoFlgTab.DELETE;
Line: 2893

                l_BillAmtPFCTab.DELETE;
Line: 2894

                l_BillAmtFCTab.DELETE;
Line: 2895

                l_BillAmtITCTab.DELETE;
Line: 3008

         l_ArAmtsTab.DELETE;
Line: 3273

       /* The following CURSOR will select all invoices for given project/agreement for
          primary set of book id and will get executed for
          a) project level funding/project level retention - p_task_id will be zero
          b) project level funding/task level retention    -p_task_id will be zero
                  All task level retention amounts will be summarized to project level funding amounts
       */

       CURSOR get_proj_invoices IS
             (SELECT 'REGULAR-PROJ' invoice_type,
                     PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     0 task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code, dii.projfunc_currency_code, dii.funding_currency_code,
                     di.inv_currency_code, di.system_reference, di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount,
                     0 retn_amount,
                     0 projfunc_retn_amount,
                     0 funding_retn_amount,
                     0 inv_retn_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND di.released_date is not NULL      /* Added for Bug 9453661 */
              AND dii.invoice_line_type <> 'RETENTION'
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num,
                       dii.invproc_currency_code,dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference, di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
              UNION
              SELECT 'RETENTION-PROJ' invoice_type,
                     PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     0 task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code, dii.projfunc_currency_code, dii.funding_currency_code,
                     di.inv_currency_code, di.system_reference, di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount,
                     0 retn_amount,
                     0 projfunc_retn_amount,
                     0 funding_retn_amount,
                     0 inv_retn_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND di.released_date is not NULL      /* Added for Bug 9453661 */
              AND nvl(di.retention_invoice_flag, 'N') = 'Y'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num,
                       dii.invproc_currency_code,dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference, di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y'))
              ORDER BY drft_inv_num;
Line: 3349

       /* The following CURSOR will select all invoices for given project/agreement for
          primary and reporting set of book ids  */


  /* R12 :  Ledger Architecture Changes : The table gl_mc_reporting_options will be  obsolete, replace with
     new table gl_alc_ledger_rships_v and corresponding columns */

/* mrc migration to SLA bug 4571438
       CURSOR get_all_proj_invoices IS
             (SELECT 'REGULAR-PROJ' invoice_type,
                     PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     0 task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code, dii.projfunc_currency_code, dii.funding_currency_code,
                     di.inv_currency_code, di.system_reference, di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount,
                     0 retn_amount,
                     0 projfunc_retn_amount,
                     0 funding_retn_amount,
                     0 inv_retn_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND dii.invoice_line_type <> 'RETENTION'
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num,
                       dii.invproc_currency_code,dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference , di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
              UNION
              SELECT 'RETENTION-PROJ' invoice_type,
                     PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     0 task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code,
                     dii.projfunc_currency_code,
                     dii.funding_currency_code,
                     di.inv_currency_code,
                     di.system_reference,
                     di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount,
                     0 retn_amount,
                     0 projfunc_retn_amount,
                     0 funding_retn_amount,
                     0 inv_retn_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND nvl(di.retention_invoice_flag, 'N') = 'Y'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num,
                       dii.invproc_currency_code,dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference , di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
              UNION
              SELECT 'REGULAR-PROJ' invoice_type,
                     dii_mc.set_of_books_id,
                     0 task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code,
                     dii_mc.currency_code projfunc_currency_code,
                     dii.funding_currency_code,
                     di.inv_currency_code,
                     di.system_reference,
                     di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.amount) amount,
                     sum(dii_mc.amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount,
                     0 retn_amount,
                     0 projfunc_retn_amount,
                     0 funding_retn_amount,
                     0 inv_retn_amount
              FROM pa_mc_draft_inv_items dii_mc, pa_draft_invoice_items dii, pa_draft_invoices di,
                   gl_alc_ledger_rships_v rep, pa_implementations imp
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND dii.invoice_line_type <> 'RETENTION'
              AND rep.source_ledger_id = imp.set_of_books_id
              AND rep.relationship_enabled_flag  = 'Y'
              AND  (rep.org_id = -99 OR rep.org_id = imp.org_id)
              AND rep.application_id = 275
              AND dii_mc.set_of_books_id =rep.ledger_id
              AND dii_mc.project_id = dii.project_id
              AND dii_mc.draft_invoice_num = dii.draft_invoice_num
              AND dii_mc.line_num = dii.line_num
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num,dii_mc.set_of_books_id,
                       dii.invproc_currency_code, dii_mc.currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference , di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
              UNION
              SELECT 'RETENTION-PROJ' invoice_type,
                     dii_mc.set_of_books_id,
                     0 task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code,
                     dii_mc.currency_code projfunc_currency_code,
                     dii.funding_currency_code,
                     di.inv_currency_code,
                     di.system_reference,
                     di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.amount) amount,
                     sum(dii_mc.amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount,
                     0 retn_amount,
                     0 projfunc_retn_amount,
                     0 funding_retn_amount,
                     0 inv_retn_amount
              FROM pa_mc_draft_inv_items dii_mc, pa_draft_invoice_items dii, pa_draft_invoices di,
                   gl_alc_ledger_rships_v rep, pa_implementations imp
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND rep.source_ledger_id = imp.set_of_books_id
              AND rep.relationship_enabled_flag  = 'Y'
              AND (rep.org_id = -99 OR rep.org_id = imp.org_id)
              AND rep.application_id = 275
              AND dii_mc.set_of_books_id =rep.ledger_id
              AND dii_mc.project_id = dii.project_id
              AND dii_mc.draft_invoice_num = di.draft_invoice_num
              AND dii_mc.line_num = dii.line_num
              AND nvl(di.retention_invoice_flag, 'N') = 'Y'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num,dii_mc.set_of_books_id,
                       dii.invproc_currency_code, dii_mc.currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference, di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       DECOde(di.draft_invoice_num_credited, NULL, 'N', 'Y')
                )
              ORDER BY drft_inv_num, set_of_books_id; */
Line: 3518

       /* The following CURSOR will select all invoices for given project/agreement for
          primary set of book id and will get executed for
          a) task level funding/task level retention
          In the case of task level funding /project level retention, only the regular invoices will get selected
          Also the retained amount for the task is obtained separately from RDL.DII.ERDL. To eliminate project
          level retention lines from regular invoice, nvl(dii.task_id) <> 0 is added
          Project level Retention invoices are not required as the retained amount will be calculated for each invoice
          from RDL ERDL DII. These are eliminated by the check nvl(dii.task_id,0) <> 0
       */
       CURSOR get_task_invoices IS
             (SELECT 'REGULAR-TASK' invoice_type,
                     PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     dii.task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code, dii.projfunc_currency_code, dii.funding_currency_code,
                     di.inv_currency_code, di.system_reference, di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,

/*
                     The following is commented and changed as below.

                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount

                     Standard line amount is required to get the billed amount in PA

                     Retention line amount is required to get the Net line amount (standard - retention)

                     Net line amount is required as AR amounts (invoice level)  are for net invoice amount

                     In order to get the task level (line level) AR amounts, invoice level  AR amounts will be
                     prorated.
                            (invoice level AR amount / invoice level net amount) * task level net amount
*/
/*                  Commented for bug 2794334
                     sum(decode(dii.invoice_line_type,'STANDARD',
                              dii.amount,0)) amount,
                     sum(decode(dii.invoice_line_type,'STANDARD',
                              dii.projfunc_bill_amount,0)) projfunc_bill_amount,
                     sum(decode(dii.invoice_line_type,'STANDARD',
                              dii.funding_bill_amount,0)) funding_bill_amount,
                     sum(decode(dii.invoice_line_type,'STANDARD',
                              dii.inv_amount,0)) inv_amount,
*/
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.amount)) amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.projfunc_bill_amount)) projfunc_bill_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.funding_bill_amount)) funding_bill_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.inv_amount)) inv_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.amount,0)) retn_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.projfunc_bill_amount,0)) projfunc_retn_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.funding_bill_amount,0))  funding_retn_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.inv_amount,0)) inv_retn_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND di.released_date is not NULL      /* Added for Bug 9453661 */
              AND nvl(dii.task_id,0) <> 0
              -- AND dii.invoice_line_type <> 'RETENTION'
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num, dii.task_id,
                       dii.invproc_currency_code,dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference , di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
              UNION
              SELECT 'RETENTION-TASK' invoice_type,
                     PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     dii.task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code, dii.projfunc_currency_code, dii.funding_currency_code,
                     di.inv_currency_code, di.system_reference, di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount,
                     0 retn_amount,
                     0 projfunc_retn_amount,
                     0 funding_retn_amount,
                     0 inv_retn_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND NVL(dii.task_id,0) <> 0
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND di.released_date is not NULL      /* Added for Bug 9453661 */
              AND nvl(di.retention_invoice_flag, 'N') = 'Y'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num, dii.task_id,
                       dii.invproc_currency_code,dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference, di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y'))
              ORDER BY drft_inv_num, task_id;
Line: 3636

       /* This CURSOR is same as previous CURSOR except that ti will select for both primary and reporting set of
           books isd */

  /* R12 :  Ledger Architecture Changes : The table gl_mc_reporting_options will be  obsolete, replace with
     new table gl_alc_ledger_rships_v and corresponding columns */

 /* mrc migration to SLA bug 4571438      CURSOR get_all_task_invoices IS
             (SELECT 'REGULAR-TASK' invoice_type,
                     PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     dii.task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code, dii.projfunc_currency_code, dii.funding_currency_code,
                     di.inv_currency_code, di.system_reference, di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.amount)) amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.projfunc_bill_amount)) projfunc_bill_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.funding_bill_amount)) funding_bill_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.inv_amount)) inv_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.amount,0)) retn_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.projfunc_bill_amount,0)) projfunc_retn_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.funding_bill_amount,0)) funding_retn_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.inv_amount,0)) inv_retn_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND nvl(dii.task_id,0) <> 0
              -- AND dii.invoice_line_type <> 'RETENTION'
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num, dii.task_id,
                       dii.invproc_currency_code,dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference , di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
              UNION
              SELECT 'RETENTION-TASK' invoice_type,
                     PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     dii.task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code, dii.projfunc_currency_code, dii.funding_currency_code,
                     di.inv_currency_code, di.system_reference, di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount,
                     0 retn_amount,
                     0 projfunc_retn_amount,
                     0 funding_retn_amount,
                     0 inv_retn_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND NVL(dii.task_id,0) <> 0
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND nvl(di.retention_invoice_flag, 'N') = 'Y'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num, dii.task_id,
                       dii.invproc_currency_code,dii.projfunc_currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference , di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
              UNION
              SELECT 'REGULAR-TASK' invoice_type,
                     dii_mc.set_of_books_id,
                     dii.task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code,
                     dii_mc.currency_code projfunc_currency_code,
                     dii.funding_currency_code,
                     di.inv_currency_code,
                     di.system_reference, di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.amount)) amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii_mc.amount)) projfunc_bill_amount,    -- changed dii.projfunc_bill_amount to dii_mc.amount bug2827328
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.funding_bill_amount)) funding_bill_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              0, dii.inv_amount)) inv_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.amount,0)) retn_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii_mc.amount,0)) projfunc_retn_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.funding_bill_amount,0)) funding_retn_amount,
                     sum(decode(dii.invoice_line_type,'RETENTION',
                              dii.inv_amount,0)) inv_retn_amount
              FROM pa_mc_draft_inv_items dii_mc, pa_draft_invoice_items dii, pa_draft_invoices di,
                   gl_alc_ledger_rships_v  rep, pa_implementations imp
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND nvl(dii.task_id,0) <> 0
             --  AND dii.invoice_line_type <> 'RETENTION'
              AND rep.source_ledger_id = imp.set_of_books_id
              AND rep.relationship_enabled_flag  = 'Y'
              AND (rep.org_id = -99 OR rep.org_id = imp.org_id)
              AND rep.application_id = 275
              AND dii_mc.set_of_books_id =rep.ledger_id
              AND dii_mc.project_id = dii.project_id
              AND dii_mc.draft_invoice_num = dii.draft_invoice_num
              AND dii_mc.line_num = dii.line_num
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num,dii.task_id, dii_mc.set_of_books_id,
                       dii.invproc_currency_code, dii_mc.currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference , di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
              UNION
              SELECT 'RETENTION-TASK' invoice_type,
                     dii_mc.set_of_books_id,
                     dii.task_id,
                     di.draft_invoice_num drft_inv_num,
                     dii.invproc_currency_code,
                     dii_mc.currency_code projfunc_currency_code,
                     dii.funding_currency_code,
                     di.inv_currency_code,
                     di.system_reference, di.transfer_status_code,
                     nvl(di.canceled_flag, 'N') canceled_flag,
                     nvl(di.cancel_credit_memo_flag, 'N') cancel_credit_memo_flag,
                     nvl(di.write_off_flag, 'N') write_off_flag,
                     decode(di.draft_invoice_num_credited, NULL, 'N', 'Y') credit_memo_flag,
                     sum(dii.amount) amount,
                     sum(dii_mc.amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount,
                     0 retn_amount,
                     0 projfunc_retn_amount,
                     0 funding_retn_amount,
                     0 inv_retn_amount
              FROM pa_mc_draft_inv_items dii_mc, pa_draft_invoice_items dii, pa_draft_invoices di,
                   gl_alc_ledger_rships_v  rep, pa_implementations imp
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND NVL(dii.task_id,0) <> 0
              AND rep.source_ledger_id = imp.set_of_books_id
              AND rep.relationship_enabled_flag  = 'Y'
              AND (rep.org_id = -99 OR rep.org_id = imp.org_id)
              AND rep.application_id = 275
              AND dii_mc.set_of_books_id =rep.ledger_id
              AND dii_mc.project_id = dii.project_id
              AND dii_mc.draft_invoice_num = dii.draft_invoice_num
              AND dii_mc.line_num = dii.line_num
              AND nvl(di.retention_invoice_flag, 'N') = 'Y'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY di.draft_invoice_num,dii.task_id, dii_mc.set_of_books_id,
                       dii.invproc_currency_code, dii_mc.currency_code,
                       dii.funding_currency_code, di.inv_currency_code, di.system_reference, di.transfer_status_code,
                       canceled_flag, cancel_credit_memo_flag, write_off_flag,
                       decode(di.draft_invoice_num_credited, NULL, 'N', 'Y')
            )
              ORDER BY drft_inv_num, task_id,set_of_books_id; */
Line: 3985

                          l_InvTab.DELETE;
Line: 4002

                  l_SetOfBookIdTab.DELETE;
Line: 4003

                  l_InvTypeTab.DELETE;
Line: 4004

                  l_DraftInvNumTab.DELETE;
Line: 4005

                  l_TaskIdTab.DELETE;
Line: 4006

                  l_IPCCurrTab.DELETE;
Line: 4007

                  l_PFCCurrTab.DELETE;
Line: 4008

                  l_FCCurrTab.DELETE;
Line: 4009

                  l_ITCCurrTab.DELETE;
Line: 4010

                  l_SysRefTab.DELETE;
Line: 4011

                  l_StatusCodeTab.DELETE;
Line: 4012

                  l_CancelFlgTab.DELETE;
Line: 4013

                  l_ClCrMemoFlgTab.DELETE;
Line: 4014

                  l_WrOffFlgTab.DELETE;
Line: 4015

                  l_CrMemoFlgTab.DELETE;
Line: 4016

                  l_BillAmtPFCTab.DELETE;
Line: 4017

                  l_BillAmtFCTab.DELETE;
Line: 4018

                  l_BillAmtITCTab.DELETE;
Line: 4019

                  l_BillAmtIPCTab.DELETE;
Line: 4020

                  l_RetnAmtIPCTab.DELETE;
Line: 4021

                  l_RetnAmtPFCTab.DELETE;
Line: 4022

                  l_RetnAmtFCTab.DELETE;
Line: 4023

                  l_RetnAmtITCTab.DELETE;
Line: 4095

                              l_InvTab.DELETE;
Line: 4166

                          l_InvTab.DELETE;
Line: 4175

                   l_SetOfBookIdTab.DELETE;
Line: 4176

                   l_InvTypeTab.DELETE;
Line: 4177

                   l_DraftInvNumTab.DELETE;
Line: 4178

                   l_TaskIdTab.DELETE;
Line: 4179

                   l_IPCCurrTab.DELETE;
Line: 4180

                   l_PFCCurrTab.DELETE;
Line: 4181

                   l_FCCurrTab.DELETE;
Line: 4182

                   l_ITCCurrTab.DELETE;
Line: 4183

                   l_SysRefTab.DELETE;
Line: 4184

                   l_StatusCodeTab.DELETE;
Line: 4185

                   l_CancelFlgTab.DELETE;
Line: 4186

                   l_ClCrMemoFlgTab.DELETE;
Line: 4187

                   l_WrOffFlgTab.DELETE;
Line: 4188

                   l_CrMemoFlgTab.DELETE;
Line: 4189

                   l_BillAmtPFCTab.DELETE;
Line: 4190

                   l_BillAmtFCTab.DELETE;
Line: 4191

                   l_BillAmtITCTab.DELETE;
Line: 4192

                   l_BillAmtIPCTab.DELETE;
Line: 4193

                   l_RetnAmtIPCTab.DELETE;
Line: 4194

                   l_RetnAmtPFCTab.DELETE;
Line: 4195

                   l_RetnAmtFCTab.DELETE;
Line: 4196

                   l_RetnAmtITCTab.DELETE;
Line: 4267

                              l_InvTab.DELETE;
Line: 4335

                         l_InvTab.DELETE;
Line: 4344

                   l_SetOfBookIdTab.DELETE;
Line: 4345

                   l_InvTypeTab.DELETE;
Line: 4346

                   l_DraftInvNumTab.DELETE;
Line: 4347

                   l_TaskIdTab.DELETE;
Line: 4348

                   l_IPCCurrTab.DELETE;
Line: 4349

                   l_PFCCurrTab.DELETE;
Line: 4350

                   l_FCCurrTab.DELETE;
Line: 4351

                   l_ITCCurrTab.DELETE;
Line: 4352

                   l_SysRefTab.DELETE;
Line: 4353

                   l_StatusCodeTab.DELETE;
Line: 4354

                   l_CancelFlgTab.DELETE;
Line: 4355

                   l_ClCrMemoFlgTab.DELETE;
Line: 4356

                   l_WrOffFlgTab.DELETE;
Line: 4357

                   l_CrMemoFlgTab.DELETE;
Line: 4358

                   l_BillAmtPFCTab.DELETE;
Line: 4359

                   l_BillAmtFCTab.DELETE;
Line: 4360

                   l_BillAmtITCTab.DELETE;
Line: 4361

                   l_BillAmtIPCTab.DELETE;
Line: 4362

                   l_RetnAmtIPCTab.DELETE;
Line: 4363

                   l_RetnAmtPFCTab.DELETE;
Line: 4364

                   l_RetnAmtFCTab.DELETE;
Line: 4365

                   l_RetnAmtITCTab.DELETE;
Line: 4435

                              l_InvTab.DELETE;
Line: 4504

                         l_InvTab.DELETE;
Line: 4513

                   l_SetOfBookIdTab.DELETE;
Line: 4514

                   l_InvTypeTab.DELETE;
Line: 4515

                   l_DraftInvNumTab.DELETE;
Line: 4516

                   l_TaskIdTab.DELETE;
Line: 4517

                   l_IPCCurrTab.DELETE;
Line: 4518

                   l_PFCCurrTab.DELETE;
Line: 4519

                   l_FCCurrTab.DELETE;
Line: 4520

                   l_ITCCurrTab.DELETE;
Line: 4521

                   l_SysRefTab.DELETE;
Line: 4522

                   l_StatusCodeTab.DELETE;
Line: 4523

                   l_CancelFlgTab.DELETE;
Line: 4524

                   l_ClCrMemoFlgTab.DELETE;
Line: 4525

                   l_WrOffFlgTab.DELETE;
Line: 4526

                   l_CrMemoFlgTab.DELETE;
Line: 4527

                   l_BillAmtPFCTab.DELETE;
Line: 4528

                   l_BillAmtFCTab.DELETE;
Line: 4529

                   l_BillAmtITCTab.DELETE;
Line: 4530

                   l_BillAmtIPCTab.DELETE;
Line: 4531

                   l_RetnAmtIPCTab.DELETE;
Line: 4532

                   l_RetnAmtPFCTab.DELETE;
Line: 4533

                   l_RetnAmtFCTab.DELETE;
Line: 4534

                   l_RetnAmtITCTab.DELETE;
Line: 4745

         l_ArAmtsTab.DELETE;
Line: 4793

               l_AdjTotTab.DELETE;
Line: 4852

            l_InvTotTab.DELETE;
Line: 5013

                          l_RetainedAmtTab.DELETE;
Line: 5212

                i_conversion_type_tab.DELETE;
Line: 5213

                i_to_currency_tab.DELETE;
Line: 5214

                i_from_currency_tab.DELETE;
Line: 5215

                i_amount_tab.DELETE;
Line: 5216

                i_user_validate_flag_tab.DELETE;
Line: 5217

                i_converted_amount_tab.DELETE;
Line: 5218

                i_denominator_tab.DELETE;
Line: 5219

                i_numerator_tab.DELETE;
Line: 5220

                i_rate_tab.DELETE;
Line: 5221

                i_status_tab.DELETE;
Line: 5264

                       insert_rejection_reason_spf (
                             p_project_id     => G_ProjLvlGlobRec.project_id,
                             p_agreement_id   => p_agreement_id,
                             p_task_id        => p_task_id,
                             p_reason_code    => i_status_tab(1),
                             x_return_status  => l_return_status,
                             x_msg_count      => l_msg_count,
                             x_msg_data       => l_msg_data) ;
Line: 5632

                i_conversion_type_tab.DELETE;
Line: 5633

                i_to_currency_tab.DELETE;
Line: 5634

                i_from_currency_tab.DELETE;
Line: 5635

                i_amount_tab.DELETE;
Line: 5636

                i_user_validate_flag_tab.DELETE;
Line: 5637

                i_converted_amount_tab.DELETE;
Line: 5638

                i_denominator_tab.DELETE;
Line: 5639

                i_numerator_tab.DELETE;
Line: 5640

                i_rate_tab.DELETE;
Line: 5641

                i_status_tab.DELETE;
Line: 5683

                       insert_rejection_reason_spf (
                             p_project_id     => G_ProjLvlGlobRec.project_id,
                             p_agreement_id   => p_agreement_id,
                             p_task_id        => p_task_id,
                             p_reason_code    => i_status_tab(1),
                             x_return_status  => l_return_status,
                             x_msg_count      => l_msg_count,
                             x_msg_data       => l_msg_data) ;
Line: 5882

              SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount
              FROM pa_draft_invoice_items dii,pa_draft_invoices di
              WHERE dii.project_id = p_project_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = p_draft_inv_num
              AND di.draft_invoice_num = dii.draft_invoice_num
              AND di.released_date is not NULL ;    /* Added for Bug 9453661 */
Line: 5903

              (SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount
              FROM pa_draft_invoice_items dii
              WHERE dii.project_id = p_project_id
              AND dii.draft_invoice_num = p_draft_inv_num
              --AND dii.invoice_line_type <> 'RETENTION'
              UNION
              SELECT dii_mc.set_of_books_id set_of_books_id,
                     sum(dii.amount) amount,
                     sum(dii_mc.amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount,
                     sum(dii.inv_amount) inv_amount
              FROM pa_mc_draft_inv_items dii_mc, pa_draft_invoice_items dii,
                   gl_alc_ledger_rships_v  rep, pa_implementations imp
              WHERE dii.project_id = p_project_id
              AND dii.draft_invoice_num = p_draft_inv_num
             -- AND dii.invoice_line_type <> 'RETENTION'
              AND rep.source_ledger_id = imp.set_of_books_id
              AND rep.relationship_enabled_flag  = 'Y'
              AND (rep.org_id = -99 OR rep.org_id = imp.org_id)
              AND rep.application_id = 275
              AND dii_mc.set_of_books_id =rep.ledger_id
              AND dii_mc.project_id = dii.project_id
              AND dii_mc.draft_invoice_num = dii.draft_invoice_num
              AND dii_mc.line_num = dii.line_num
              GROUP BY dii_mc.set_of_books_id
              )
              ORDER by set_of_books_id;  */
Line: 5999

               l_SetOfBookIdTab.DELETE;
Line: 6000

               l_BillAmtIPCTab.DELETE;
Line: 6001

               l_BillAmtPFCTab.DELETE;
Line: 6002

               l_BillAmtFCTab.DELETE;
Line: 6003

               l_BillAmtITCTab.DELETE;
Line: 6056

               l_SetOfBookIdTab.DELETE;
Line: 6057

               l_BillAmtIPCTab.DELETE;
Line: 6058

               l_BillAmtPFCTab.DELETE;
Line: 6059

               l_BillAmtFCTab.DELETE;
Line: 6060

               l_BillAmtITCTab.DELETE;
Line: 6144

            SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                   SUM((rdl.retained_amount/rdl.bill_amount) * rdl.projfunc_bill_amount) retained_amt_pfc,
                   SUM((rdl.retained_amount/rdl.bill_amount) * rdl.funding_bill_amount) retained_amt_fc
            FROM   pa_cust_rev_dist_lines RDL, pa_draft_invoice_items DII,
                   pa_draft_invoices DI
            WHERE  DII.project_id = p_project_id
            AND    DI.project_id = DII.project_id
            AND    DII.draft_invoice_num = p_draft_inv_num
            AND    DI.draft_invoice_num = DII.draft_invoice_num
            AND    DI.released_date is not NULL    /* Added for Bug 9453661 */
            AND    NVL(DII.task_id,0) = p_task_id
            AND    RDL.project_id = DII.project_id
            AND    RDL.draft_invoice_num = DII.draft_invoice_num
            AND    RDL.draft_invoice_item_line_num = DII.line_num;
Line: 6163

            (SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                   SUM((rdl.retained_amount/rdl.bill_amount) * rdl.projfunc_bill_amount) retained_amt_pfc,
                   SUM((rdl.retained_amount/rdl.bill_amount) * rdl.funding_bill_amount) retained_amt_fc
            FROM   pa_cust_rev_dist_lines RDL, pa_draft_invoice_items DII
            WHERE  DII.project_id = p_project_id
            AND    DII.draft_invoice_num = p_draft_inv_num
            AND    NVL(DII.task_id,0) = p_task_id
            AND    RDL.project_id = DII.project_id
            AND    RDL.draft_invoice_num = DII.draft_invoice_num
            AND    RDL.draft_invoice_item_line_num = DII.line_num
            UNION
            SELECT RDL_MC.set_of_books_id,
                   SUM((rdl.retained_amount/rdl.bill_amount) * rdl_mc.amount) retained_amt_pfc,
                   SUM((rdl.retained_amount/rdl.bill_amount) * rdl.funding_bill_amount) retained_amt_fc
            FROM   pa_cust_rev_dist_lines RDL, pa_draft_invoice_items DII, pa_mc_cust_rdl_all RDL_MC,
                   gl_alc_ledger_rships_v rep, pa_implementations imp
            WHERE  DII.project_id = p_project_id
            AND    DII.draft_invoice_num = p_draft_inv_num
            AND    NVL(DII.task_id,0) = p_task_id
            AND    RDL.project_id = DII.project_id
            AND    RDL.draft_invoice_num = DII.draft_invoice_num
            AND    RDL.draft_invoice_item_line_num = DII.line_num
            AND    rep.source_ledger_id = imp.set_of_books_id
            AND    rep.relationship_enabled_flag  = 'Y'
            AND    (rep.org_id = -99 OR rep.org_id = imp.org_id)
            AND    rep.application_id = 275
            AND    RDL_MC.set_of_books_id =rep.ledger_id
            AND    RDL_MC.expenditure_item_id = RDL.expenditure_item_id
            AND    RDL_MC.line_num            = RDL.line_num
            GROUP by RDL_MC.set_of_books_id
            )
       ORDER by set_of_books_id; */
Line: 6197

            SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                   SUM((erdl.retained_amount/erdl.amount) * erdl.projfunc_bill_amount) retained_amt_pfc,
                   SUM((erdl.retained_amount/erdl.amount) * erdl.funding_bill_amount) retained_amt_fc
            FROM   pa_cust_event_rdl_all ERDL, pa_draft_invoice_items DII,
                   pa_draft_invoices DI
            WHERE  DII.project_id = p_project_id
            AND    DI.project_id = DII.project_id
            AND    DII.draft_invoice_num = p_draft_inv_num
            AND    DI.draft_invoice_num = DII.draft_invoice_num
            AND    DI.released_date is not NULL     /* Added for Bug 9453661 */
            AND    NVL(DII.task_id,0) = p_task_id
            AND    ERDL.project_id = DII.project_id
            AND    ERDL.draft_invoice_num = DII.draft_invoice_num
            AND    ERDL.draft_invoice_item_line_num = DII.line_num;
Line: 6217

            (SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                   SUM((erdl.retained_amount/erdl.amount) * erdl.projfunc_bill_amount) retained_amt_pfc,
                   SUM((erdl.retained_amount/erdl.amount) * erdl.funding_bill_amount) retained_amt_fc
            FROM   pa_cust_event_rdl_all ERDL, pa_draft_invoice_items DII
            WHERE  DII.project_id = p_project_id
            AND    DII.draft_invoice_num = p_draft_inv_num
            AND    NVL(DII.task_id,0) = p_task_id
            AND    ERDL.project_id = DII.project_id
            AND    ERDL.draft_invoice_num = DII.draft_invoice_num
            AND    ERDL.draft_invoice_item_line_num = DII.line_num
            UNION
            SELECT ERDL_MC.set_of_books_id,
                   SUM((erdl.retained_amount/erdl.amount) * ERDL_MC.amount) retained_amt_pfc,
                   SUM((erdl.retained_amount/erdl.amount) * erdl.funding_bill_amount) retained_amt_fc
            FROM   pa_cust_event_rdl_all ERDL, pa_draft_invoice_items DII,
                   pa_mc_cust_event_rdl_all ERDL_MC,
                   gl_alc_ledger_rships_v  rep, pa_implementations imp
            WHERE  DII.project_id = p_project_id
            AND    DII.draft_invoice_num = p_draft_inv_num
            AND    NVL(DII.task_id,0) = p_task_id
            AND    ERDL.project_id = DII.project_id
            AND    ERDL.draft_invoice_num = DII.draft_invoice_num
            AND    ERDL.draft_invoice_item_line_num = DII.line_num
            AND    rep.source_ledger_id = imp.set_of_books_id
            AND    rep.relationship_enabled_flag  = 'Y'
            AND    (rep.org_id = -99 OR rep.org_id = imp.org_id)
            AND    rep.application_id = 275
            AND    ERDL_MC.set_of_books_id =rep.ledger_id
            AND    ERDL_MC.project_id = ERDL.project_id
            AND    ERDL_MC.event_num = ERDL.event_num
            AND    NVL(ERDL_MC.task_id,0) = NVL(ERDL.task_id,0)
            AND    ERDL_MC.line_num      = ERDL.line_num
            GROUP by ERDL_MC.set_of_books_id
            )
       ORDER by set_of_books_id; */
Line: 6254

            SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                   SUM((DII.retained_amount/DII.amount) * DII.projfunc_bill_amount) retained_amt_pfc,
                   SUM((DII.retained_amount/DII.amount) * DII.funding_bill_amount) retained_amt_fc
            FROM   pa_draft_invoice_items DII,pa_draft_invoices DI
            WHERE  DII.project_id = p_project_id
            AND    DI.project_id = DII.project_id
            AND    DII.draft_invoice_num = p_draft_inv_num
            AND    DI.draft_invoice_num = DII.draft_invoice_num
            AND    DI.released_date is not NULL    /* Added for Bug 9453661 */
            AND    DII.task_id = p_task_id
            AND    DII.event_num is not null;
Line: 6270

           (SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                   SUM((DII.retained_amount/DII.amount) * DII.projfunc_bill_amount) retained_amt_pfc,
                   SUM((DII.retained_amount/DII.amount) * DII.funding_bill_amount) retained_amt_fc
            FROM   pa_draft_invoice_items DII
            WHERE  DII.project_id = p_project_id
            AND    DII.draft_invoice_num = p_draft_inv_num
            AND    DII.event_num is not null
            AND    DII.task_id = p_task_id
            UNION
            SELECT DII_MC.set_of_books_id,
                   SUM((DII.retained_amount/DII.amount) * DII_MC.amount) retained_amt_pfc,
                   SUM((DII.retained_amount/DII.amount) * DII.funding_bill_amount) retained_amt_fc
            FROM   pa_draft_invoice_items DII, pa_mc_draft_inv_items DII_MC,
                   gl_alc_ledger_rships_v  rep, pa_implementations imp
            WHERE  DII.project_id = p_project_id
            AND    DII.draft_invoice_num = p_draft_inv_num
            AND    DII.task_id = p_task_id
            AND    rep.source_ledger_id = imp.set_of_books_id
            AND    rep.relationship_enabled_flag  = 'Y'
            AND    (rep.org_id = -99 OR rep.org_id = imp.org_id)
            AND    rep.application_id = 275
            AND    DII_MC.set_of_books_id =rep.ledger_id
            AND    DII_MC.project_id = DII.project_id
            AND    DII_MC.draft_invoice_num = DII.draft_invoice_num
            AND    DII_MC.line_num = DII.line_num
            AND    DII.event_num is not null
            GROUP by DII_MC.set_of_books_id
           )
       ORDER by set_of_books_id; */
Line: 6345

         SELECT 'T' INTO l_RetnExistFlag
         FROM DUAL
         WHERE EXISTS (SELECT NULL
                       FROM pa_draft_invoice_items dii
                       WHERE  dii.project_id = p_project_id
                       AND    dii.draft_invoice_num = p_draft_inv_num
                       AND    dii.invoice_line_type = 'RETENTION');
Line: 6403

                l_SetOfBookIdTab.DELETE;
Line: 6404

                l_RetainedAmtPFCTab.DELETE;
Line: 6405

                l_RetainedAmtFCTab.DELETE;
Line: 6456

                l_SetOfBookIdTab.DELETE;
Line: 6457

                l_RetainedAmtPFCTab.DELETE;
Line: 6458

                l_RetainedAmtFCTab.DELETE;
Line: 6509

                l_SetOfBookIdTab.DELETE;
Line: 6510

                l_RetainedAmtPFCTab.DELETE;
Line: 6511

                l_RetainedAmtFCTab.DELETE;
Line: 6564

                l_SetOfBookIdTab.DELETE;
Line: 6565

                l_RetainedAmtPFCTab.DELETE;
Line: 6566

                l_RetainedAmtFCTab.DELETE;
Line: 6617

                l_SetOfBookIdTab.DELETE;
Line: 6618

                l_RetainedAmtPFCTab.DELETE;
Line: 6619

                l_RetainedAmtFCTab.DELETE;
Line: 6670

                l_SetOfBookIdTab.DELETE;
Line: 6671

                l_RetainedAmtPFCTab.DELETE;
Line: 6672

                l_RetainedAmtFCTab.DELETE;
Line: 7043

       /* The following CURSOR will select all invoices for given project/agreement for
          primary set of book id and will get executed for
          a) project level funding
       */

       CURSOR get_proj_invoices IS
             SELECT  PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     0 task_id,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND di.released_date is not NULL      /* Added for Bug 9453661 */
              AND dii.invoice_line_type <> 'RETENTION'
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE;
Line: 7065

       /* The following CURSOR will select all invoices for given project/agreement for
          primary and reporting set of book ids  */

  /* R12 :  Ledger Architecture Changes : The table gl_mc_reporting_options will be  obsolete, replace with
     new table gl_alc_ledger_rships_v and corresponding columns */

   /* mrc migration to SLA bug 4571438    CURSOR get_all_proj_invoices IS
             (SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     0 task_id,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND dii.invoice_line_type <> 'RETENTION'
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              UNION
              SELECT dii_mc.set_of_books_id,
                     0 task_id,
                     sum(dii.amount) amount,
                     sum(dii_mc.amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount
              FROM pa_mc_draft_inv_items dii_mc, pa_draft_invoice_items dii,
                   pa_draft_invoices di,
                   gl_alc_ledger_rships_v rep, pa_implementations imp
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND dii.invoice_line_type <> 'RETENTION'
              AND rep.source_ledger_id = imp.set_of_books_id
              AND rep.relationship_enabled_flag  = 'Y'
              AND (rep.org_id = -99 OR rep.org_id = imp.org_id)
              AND rep.application_id = 275
              AND dii_mc.set_of_books_id =rep.ledger_id
              AND dii_mc.project_id = dii.project_id
              AND dii_mc.draft_invoice_num = dii.draft_invoice_num
              AND dii_mc.line_num = dii.line_num
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY dii_mc.set_of_books_id
               )
              ORDER BY set_of_books_id; */
Line: 7114

       /* The following CURSOR will select all invoices for given project/agreement for
          primary set of book id and will get executed for
          a) task level funding
       */

       CURSOR get_task_invoices IS
             SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     dii.task_id,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND di.released_date is not NULL      /* Added for Bug 9453661 */
              AND dii.invoice_line_type <> 'RETENTION'
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY dii.task_id
              ORDER BY task_id;
Line: 7141

       /* This CURSOR is same as previous CURSOR except that ti will select for both primary and reporting set of
           books isd */
       /* mrc migration to SLA bug 4571438 CURSOR get_all_task_invoices IS
             (SELECT PA_FUND_REVAL_PVT.G_SET_OF_BOOKS_ID set_of_books_id,
                     dii.task_id,
                     sum(dii.amount) amount,
                     sum(dii.projfunc_bill_amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount
              FROM pa_draft_invoice_items dii,
                   pa_draft_invoices di
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND dii.invoice_line_type <> 'RETENTION'
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY dii.task_id
              UNION
              SELECT dii_mc.set_of_books_id,
                     dii.task_id,
                     sum(dii.amount) amount,
                     sum(dii_mc.amount) projfunc_bill_amount,
                     sum(dii.funding_bill_amount) funding_bill_amount
              FROM pa_mc_draft_inv_items dii_mc, pa_draft_invoice_items dii, pa_draft_invoices di,
                   gl_alc_ledger_rships_v rep, pa_implementations imp
              WHERE di.project_id = p_project_id
              AND di.agreement_id = p_agreement_id
              AND dii.project_id = di.project_id
              AND dii.draft_invoice_num = di.draft_invoice_num
              AND dii.invoice_line_type <> 'RETENTION'
              AND rep.source_ledger_id = imp.set_of_books_id
              AND rep.relationship_enabled_flag  = 'Y'
              AND (rep.org_id = -99 OR rep.org_id = imp.org_id)
              AND rep.application_id = 275
              AND dii_mc.set_of_books_id =rep.ledger_id
              AND dii_mc.project_id = dii.project_id
              AND dii_mc.draft_invoice_num = dii.draft_invoice_num
              AND dii_mc.line_num = dii.line_num
              AND nvl(di.retention_invoice_flag, 'N') = 'N'
              AND di.invoice_date <= G_THRU_DATE
              GROUP BY dii.task_id, dii_mc.set_of_books_id
              )
              ORDER BY task_id,set_of_books_id; */
Line: 7273

                   l_SetOfBookIdTab.DELETE;
Line: 7274

                   l_TaskIdTab.DELETE;
Line: 7275

                   l_BillAmtPFCTab.DELETE;
Line: 7276

                   l_BillAmtFCTab.DELETE;
Line: 7277

                   l_BillAmtIPCTab.DELETE;
Line: 7336

                   l_SetOfBookIdTab.DELETE;
Line: 7337

                   l_TaskIdTab.DELETE;
Line: 7338

                   l_BillAmtPFCTab.DELETE;
Line: 7339

                   l_BillAmtFCTab.DELETE;
Line: 7340

                   l_BillAmtIPCTab.DELETE;
Line: 7402

                   l_SetOfBookIdTab.DELETE;
Line: 7403

                   l_TaskIdTab.DELETE;
Line: 7404

                   l_BillAmtPFCTab.DELETE;
Line: 7405

                   l_BillAmtFCTab.DELETE;
Line: 7406

                   l_BillAmtIPCTab.DELETE;
Line: 7464

                   l_SetOfBookIdTab.DELETE;
Line: 7465

                   l_TaskIdTab.DELETE;
Line: 7466

                   l_BillAmtPFCTab.DELETE;
Line: 7467

                   l_BillAmtFCTab.DELETE;
Line: 7468

                   l_BillAmtIPCTab.DELETE;
Line: 7897

         SELECT NVL(org_id,-99) INTO l_OrgId FROM PA_IMPLEMENTATIONS;
Line: 7937

         l_from_currency_tab.DELETE;
Line: 7938

         l_to_currency_tab.DELETE;
Line: 7939

         l_conversion_date_tab.DELETE;
Line: 7940

         l_conversion_type_tab.DELETE;
Line: 7941

         l_amount_tab.DELETE;
Line: 7942

         l_user_validate_flag_tab.DELETE;
Line: 7943

         l_converted_amount_tab.DELETE;
Line: 7944

         l_denominator_tab.DELETE;
Line: 7945

         l_numerator_tab.DELETE;
Line: 7946

         l_rate_tab.DELETE;
Line: 7947

         l_status_tab.DELETE;
Line: 7987

            insert_rejection_reason_spf (
                  p_project_id     => G_ProjLvlGlobRec.project_id,
                  p_agreement_id   => p_agreement_id,
                  p_task_id        => p_task_id,
                  p_reason_code    => l_status_tab(1),
                  x_return_status  => l_return_status,
                  x_msg_count      => l_msg_count,
                  x_msg_data       => l_msg_data) ;
Line: 8016

            l_from_currency_tab.DELETE;
Line: 8017

            l_to_currency_tab.DELETE;
Line: 8018

            l_conversion_date_tab.DELETE;
Line: 8019

            l_conversion_type_tab.DELETE;
Line: 8020

            l_amount_tab.DELETE;
Line: 8021

            l_user_validate_flag_tab.DELETE;
Line: 8022

            l_converted_amount_tab.DELETE;
Line: 8023

            l_denominator_tab.DELETE;
Line: 8024

            l_numerator_tab.DELETE;
Line: 8025

            l_rate_tab.DELETE;
Line: 8026

            l_status_tab.DELETE;
Line: 8065

               insert_rejection_reason_spf (
                  p_project_id     => G_ProjLvlGlobRec.project_id,
                  p_agreement_id   => p_agreement_id,
                  p_task_id        => p_task_id,
                  p_reason_code    => l_status_tab(1),
                  x_return_status  => l_return_status,
                  x_msg_count      => l_msg_count,
                  x_msg_data       => l_msg_data) ;
Line: 8547

               l_from_currency_tab.DELETE;
Line: 8548

               l_to_currency_tab.DELETE;
Line: 8549

               l_conversion_date_tab.DELETE;
Line: 8550

               l_conversion_type_tab.DELETE;
Line: 8551

               l_amount_tab.DELETE;
Line: 8552

               l_user_validate_flag_tab.DELETE;
Line: 8553

               l_converted_amount_tab.DELETE;
Line: 8554

               l_denominator_tab.DELETE;
Line: 8555

               l_numerator_tab.DELETE;
Line: 8556

               l_rate_tab.DELETE;
Line: 8557

               l_status_tab.DELETE;
Line: 8621

                  insert_rejection_reason_spf (
                     p_project_id     => G_ProjLvlGlobRec.project_id,
                     p_agreement_id   => p_agreement_id,
                     p_task_id        => p_task_id,
                     p_reason_code    => l_status_tab(1),
                     x_return_status  => l_return_status,
                     x_msg_count      => l_msg_count,
                     x_msg_data       => l_msg_data) ;
Line: 8670

               l_from_currency_tab.DELETE;
Line: 8671

               l_to_currency_tab.DELETE;
Line: 8672

               l_conversion_date_tab.DELETE;
Line: 8673

               l_conversion_type_tab.DELETE;
Line: 8674

               l_amount_tab.DELETE;
Line: 8675

               l_user_validate_flag_tab.DELETE;
Line: 8676

               l_converted_amount_tab.DELETE;
Line: 8677

               l_denominator_tab.DELETE;
Line: 8678

               l_numerator_tab.DELETE;
Line: 8679

               l_rate_tab.DELETE;
Line: 8680

               l_status_tab.DELETE;
Line: 8727

                  insert_rejection_reason_spf (
                        p_project_id     => G_ProjLvlGlobRec.project_id,
                        p_agreement_id   => p_agreement_id,
                        p_task_id        => p_task_id,
                        p_reason_code    => l_status_tab(1),
                        x_return_status  => l_return_status,
                        x_msg_count      => l_msg_count,
                        x_msg_data       => l_msg_data) ;
Line: 8985

			     insert the warning into distributions and
			     update the summary project funding with rejectionr reason as INVOICED_EXCEEDS_FUNDED
	  */

         /*   Changes Start ------------------------------------ Commented for bug 3532963

	   IF (NVL(l_InvOvrFndFlag,'N') ='Y') AND (nvl(l_RevaluationIndex,1)=1)  THEN  /* Added AND condition for bug 3532963

			ROLLBACK;
Line: 8999

                  	insert_rejection_reason_spf (
                     		p_project_id     => G_ProjLvlGlobRec.project_id,
                     		p_agreement_id   => p_agreement_id,
                     		p_task_id        => p_task_id,
                     		p_reason_code    => 'PA_FR_INVOICED_EXCEEDS_FUNDED',
                     		x_return_status  => l_return_status,
                     		x_msg_count      => l_msg_count,
                     		x_msg_data       => l_msg_data) ;
Line: 9062

   |   Procedure  :   insert_rejection_reason_spf                                            |
   |   Purpose    :   To insert rejection reason in SPF                                      |
   |   Parameters :                                                                          |
   |     ==================================================================================  |
   |     Name                             Mode    Description                                |
   |     ==================================================================================  |
   |     p_project_id          IN      Project ID                                            |
   |     p_agreement_id        IN      Agreement_id                                          |
   |     p_task_id             IN      Task Id of summary project funding                    |
   |     p_reason_code         IN      Rejection reason code                                 |
   |     x_return_status       OUT     Return status of this procedure                       |
   |     x_msg_count           OUT     Error message count                                   |
   |     x_msg_data            OUT     Error message                                         |
   |     ==================================================================================  |
   +----------------------------------------------------------------------------------------*/
   PROCEDURE insert_rejection_reason_spf(
             p_project_id        IN    NUMBER,
             p_agreement_id      IN    VARCHAR2,
             p_task_id           IN    VARCHAR2,
             p_reason_code       IN    VARCHAR2,
             x_return_status     OUT   NOCOPY VARCHAR2,
             x_msg_count         OUT   NOCOPY NUMBER,
             x_msg_data          OUT   NOCOPY VARCHAR2)   IS


       l_return_status               VARCHAR2(30) := NULL;
Line: 9099

            PA_DEBUG.g_err_stage := '-----------Entering PA_FUND_REVAL_PVT.insert_rejection_reason_spf-----------' ;
Line: 9104

         UPDATE pa_summary_project_fundings
         SET  reval_rejection_code = p_reason_code,
              last_update_date = sysdate,
              last_updated_by =  G_LAST_UPDATED_BY,
              last_update_login =  G_LAST_UPDATE_LOGIN,
              program_application_id = G_PROGRAM_APPLICATION_ID ,
              program_id = G_PROGRAM_ID,
              program_update_date= SYSDATE,
              request_id= G_REQUEST_ID
         WHERE project_id = p_project_id
         AND   agreement_id = p_agreement_id
         AND   nvl(task_id,0) = nvl(p_task_id,0);
Line: 9117

         Insert_distribution_warnings(
                p_project_id     => p_project_id,
                p_task_id        => p_task_id,
                p_agreement_id   => p_agreement_id,
                p_reason_code    => p_Reason_Code,
                x_return_status  => l_return_status,
                x_msg_count      => l_msg_count,
                x_msg_data       => l_msg_data) ;
Line: 9139

            PA_DEBUG.g_err_stage := '-----------Exiting PA_FUND_REVAL_PVT.insert_rejection_reason_spf-----------' ;
Line: 9158

                PA_DEBUG.g_err_stage := 'insert_rejection_reason_spf:' || x_msg_data ;
Line: 9163

   END insert_rejection_reason_spf;
Line: 9193

                SELECT 'Y' non_zero_amt
                FROM DUAL
                WHERE EXISTS ( SELECT  NULL
                               FROM pa_project_fundings
                               WHERE project_funding_id = l_project_funding_id
                               AND  (  projfunc_allocated_amount <> 0
                                       OR   projfunc_realized_gains_amt <> 0
                                       OR   projfunc_realized_losses_amt <> 0
                                       OR   invproc_allocated_amount <> 0)
                              /* mrc migration to SLA bug 4571438 UNION
                               SELECT  NULL
                               FROM pa_mc_project_fundings
                               WHERE project_funding_id = l_project_funding_id
                               AND  (  allocated_amount <> 0
                                       OR   realized_gains_amt <> 0
                                       OR   realized_losses_amt <> 0) */ );
Line: 9226

         /* Insert into table pa_project_fundings */
         l_SobId := G_SET_OF_BOOKS_ID;
Line: 9248

            PA_PROJECT_FUNDINGS_PKG. Insert_Row (
                 X_Rowid                         => l_RowId ,
                 X_Project_Funding_Id            => l_ProjectFundingId ,
                 X_Last_Update_Date              => SYSDATE,
                 X_Last_Updated_By               => G_LAST_UPDATED_BY ,
                 X_Creation_Date                 => SYSDATE ,
                 X_Created_By                    => G_LAST_UPDATED_BY ,
                 X_Last_Update_Login             => G_LAST_UPDATE_LOGIN ,
                 X_Agreement_Id                  => G_RevalCompTab(l_SobId).agreement_id ,
                 X_Project_Id                    => G_RevalCompTab(l_SobId).project_id ,
                 X_Task_Id                       => G_RevalCompTab(l_SobId).task_id ,
                 X_Budget_Type_Code              => 'DRAFT' ,
                 X_Allocated_Amount              => 0 ,
                 X_Date_Allocated                => G_RATE_DATE,
                 X_Attribute_Category            => NULL ,
                 X_Attribute1                    => NULL ,
                 X_Attribute2                    => NULL ,
                 X_Attribute3                    => NULL ,
                 X_Attribute4                    => NULL ,
                 X_Attribute5                    => NULL ,
                 X_Attribute6                    => NULL ,
                 X_Attribute7                    => NULL ,
                 X_Attribute8                    => NULL ,
                 X_Attribute9                    => NULL ,
                 X_Attribute10                   => NULL ,
                 X_pm_funding_reference          => NULL ,
                 X_pm_product_code               => NULL ,
                 x_funding_currency_code         => G_RevalCompTab(l_SobId).funding_currency_code ,
                 x_project_currency_code         => G_RevalCompTab(l_SobId).project_currency_code ,
                 x_project_rate_type             => NULL,
                 x_project_rate_date             => NULL,
                 x_project_exchange_rate         => NULL,
                 x_project_allocated_amount      => NULL,
                 x_projfunc_currency_code        => G_RevalCompTab(l_SobId).projfunc_currency_code ,
                 x_projfunc_rate_type            => NULL,
                 x_projfunc_rate_date            => NULL,
                 x_projfunc_exchange_rate        => NULL,
                 x_projfunc_allocated_amount     => G_RevalCompTab(l_SobId).projfunc_allocated_amount ,
                 x_invproc_currency_code         => G_RevalCompTab(l_SobId).invproc_currency_code ,
                 x_invproc_rate_type             => NULL,
                 x_invproc_rate_date             => NULL,
                 x_invproc_exchange_rate         => NULL,
                 x_invproc_allocated_amount      => G_RevalCompTab(l_SobId).invproc_allocated_amount ,
                 x_revproc_currency_code         => G_RevalCompTab(l_SobId).projfunc_currency_code ,
                 x_revproc_rate_type             => G_RevalCompTab(l_SobId).reval_projfunc_rate_type ,
                 x_revproc_rate_date             => NULL,
                 x_revproc_exchange_rate         => NULL,
                 x_revproc_allocated_amount      => G_RevalCompTab(l_SobId).projfunc_allocated_amount ,
                 x_funding_category              => 'REVALUATION' ,
                 x_revaluation_through_date      => G_THRU_DATE ,
                 x_revaluation_rate_date         => G_RATE_DATE ,
                 x_reval_projfunc_rate_type      => G_RevalCompTab(l_SobId).reval_projfunc_rate_type ,
                 x_revaluation_projfunc_rate     => G_RevalCompTab(l_SobId).reval_projfunc_rate ,
                 x_reval_invproc_rate_type       => G_RevalCompTab(l_SobId).reval_invproc_rate_type ,
                 x_revaluation_invproc_rate      => G_RevalCompTab(l_SobId).reval_invproc_rate  ,
                 x_funding_inv_applied_amount    => G_RevalCompTab(l_SobId).funding_inv_applied_amount,
                 x_funding_inv_due_amount        => G_RevalCompTab(l_SobId).funding_inv_due_amount,
                 x_funding_backlog_amount        => G_RevalCompTab(l_SobId).funding_backlog_amount,
                 x_projfunc_realized_gains_amt   => G_RevalCompTab(l_SobId).projfunc_realized_gains_amt,
                 x_projfunc_realized_losses_amt  => G_RevalCompTab(l_SobId).projfunc_realized_losses_amt,
                 x_projfunc_inv_applied_amount   => G_RevalCompTab(l_SobId).projfunc_inv_applied_amount,
                 x_projfunc_inv_due_amount       => G_RevalCompTab(l_SobId).projfunc_inv_due_amount,
                 x_projfunc_backlog_amount       => G_RevalCompTab(l_SobId).projfunc_backlog_amount,
                 x_non_updateable_flag           => 'Y',
                 x_invproc_backlog_amount        => G_RevalCompTab(l_SobId).invproc_backlog_amount,
                 x_funding_reval_amount          => G_RevalCompTab(l_SobId).funding_reval_amount,
                 x_projfunc_reval_amount         => G_RevalCompTab(l_SobId).projfunc_reval_amount,
                 x_projfunc_revalued_amount      => G_RevalCompTab(l_SobId).projfunc_revalued_amount,
                 x_invproc_reval_amount          => G_RevalCompTab(l_SobId).invproc_reval_amount,
                 x_invproc_revalued_amount       => G_RevalCompTab(l_SobId).invproc_revalued_amount,
                 x_funding_revaluation_factor    => G_RevalCompTab(l_SobId).funding_revaluation_factor,
                 x_request_id                    => G_REQUEST_ID,
                 x_program_application_id        => G_PROGRAM_APPLICATION_ID,
                 x_program_id                    => G_PROGRAM_ID,
                 x_program_update_date           => SYSDATE);
Line: 9326

               l_LogMsg := 'After Insert Project Funding Id:' || l_ProjectFundingId;
Line: 9354

               UPDATE pa_summary_project_fundings
               SET    projfunc_unbaselined_amount =
                            nvl(projfunc_unbaselined_amount,0) + G_RevalCompTab(l_SobId).projfunc_allocated_amount,
                      revproc_unbaselined_amount =
                            nvl(revproc_unbaselined_amount,0) + G_RevalCompTab(l_SobId).projfunc_allocated_amount,
                      invproc_unbaselined_amount =
                            nvl(invproc_unbaselined_amount,0) + G_RevalCompTab(l_SobId).invproc_allocated_amount,
                      projfunc_realized_gains_amt =
                            nvl(projfunc_realized_gains_amt,0) + G_RevalCompTab(l_SobId).projfunc_realized_gains_amt,
                      projfunc_realized_losses_amt =
                            nvl(projfunc_realized_losses_amt,0) + G_RevalCompTab(l_SobId).projfunc_realized_losses_amt,
                      reval_rejection_code = NULL
               WHERE project_id = G_RevalCompTab(l_SobId).project_id
               AND   agreement_id = G_RevalCompTab(l_SobId).agreement_id
               AND   nvl(task_id,0) = nvl(G_RevalCompTab(l_SobId).task_id,0);
Line: 9408

                  insert_event_record (
                         p_project_id            => G_RevalCompTab(l_SobId).project_id,
                         p_task_id               => G_RevalCompTab(l_SobId).task_id,
                         p_event_type            => G_ProjLvlGlobRec.gain_event_type,
                         p_event_desc            => G_ProjLvlGlobRec.gain_event_type,
                         p_Bill_trans_rev_amount => G_RevalCompTab(l_SobId).projfunc_realized_gains_amt ,
                         p_project_funding_id    => l_ProjectFundingId,
			 p_agreement_id          => G_RevalCompTab(l_SobId).agreement_id,
                         x_return_status         => l_return_status,
                         x_msg_count             => l_msg_count,
                         x_msg_data              => l_msg_data) ;
Line: 9446

                  insert_event_record (
                         p_project_id            => G_RevalCompTab(l_SobId).project_id,
                         p_task_id               => G_RevalCompTab(l_SobId).task_id,
                         p_event_type            => G_ProjLvlGlobRec.loss_event_type,
                         p_event_desc            => G_ProjLvlGlobRec.loss_event_type,
                         p_Bill_trans_rev_amount => G_RevalCompTab(l_SobId).projfunc_realized_losses_amt ,
                         p_project_funding_id    => l_ProjectFundingId,
			 p_agreement_id          => G_RevalCompTab(l_SobId).agreement_id,
                         x_return_status         => l_return_status,
                         x_msg_count             => l_msg_count,
                         x_msg_data              => l_msg_data) ;
Line: 9480

               DELETE FROM pa_project_fundings
               WHERE  project_funding_id = l_ProjectFundingId;
Line: 9522

   |   Procedure  :   insert_event_record                                                    |
   |   Purpose    :   To insert event record for gains/losses amount                         |
   |   Parameters :                                                                          |
   |     ==================================================================================  |
   |     Name                             Mode    Description                                |
   |     ==================================================================================  |
   |     p_project_id              IN      Project ID                                        |
   |     p_task_id                 IN      Task Id of summary project funding                |
   |     p_event_type              IN      Event type (gain/loss event type )                |
   |     p_event_desc              IN      Event description (gain/loss event description )  |
   |     p_bill_trans_rev_amount   IN      Amount (Realized gain/loss amount)                |
   |     p_project_funding_id      IN      Funding line Id for which this event is created   |
   |     x_return_status           OUT     Return status of this procedure                   |
   |     x_msg_count               OUT     Error message count                               |
   |     x_msg_data                OUT     Error message                                     |
   |     ==================================================================================  |
   +----------------------------------------------------------------------------------------*/
   PROCEDURE insert_event_record(
                  p_project_id             IN   NUMBER,
                  p_task_id                IN   NUMBER,
                  p_event_type             IN   VARCHAR2,
                  p_event_desc             IN   VARCHAR2,
                  p_Bill_trans_rev_amount  IN   NUMBER,
                  p_project_funding_id     IN   NUMBER,
		  p_agreement_id           IN   NUMBER,
                  x_return_status          OUT  NOCOPY VARCHAR2,
                  x_msg_count              OUT  NOCOPY NUMBER,
                  x_msg_data               OUT  NOCOPY VARCHAR2) IS

       l_RowId                       VARCHAR2(30);
Line: 9565

                SELECT 'Y' non_zero_amt
                FROM DUAL
                WHERE EXISTS ( SELECT  NULL
                               FROM pa_events
                               WHERE event_id = l_EventId
                               AND  bill_trans_rev_amount <> 0
                             /* mrc migration to SLA bug 4571438  UNION
                               SELECT  NULL
                               FROM pa_mc_events
                               WHERE event_id = l_EventId
                               AND  revenue_amount <> 0 */ );
Line: 9584

            PA_DEBUG.g_err_stage := '-----------Entering PA_FUND_REVAL_PVT.insert_event_record-----------' ;
Line: 9603

            zero dollar events in all reporting set of books. If zero, the record(s) will be deleted */

         IF ((p_bill_trans_rev_amount <> 0)  OR (G_PRIMARY_ONLY = 'N')) THEN

           SELECT nvl(max(event_num),0) into l_EventNum
           FROM   pa_events
           WHERE  project_id = G_RevalCompTab(l_SobId).project_id
           AND    nvl(task_id,0) =  nvl(G_RevalCompTab(l_SobId).task_id,0);
Line: 9621

            pa_events_pkg.insert_row (
                       X_Rowid                      => l_RowId ,
                       X_Event_Id                   => l_EventId ,
                       X_Task_Id                    => p_task_id ,
                       X_Event_Num                  => l_EventNum ,
                       X_Last_Update_Date           => SYSDATE ,
                       X_Last_Updated_By            => G_LAST_UPDATED_BY ,
                       X_Creation_Date              => SYSDATE ,
                       X_Created_By                 => G_LAST_UPDATED_BY ,
                       X_Last_Update_Login          => G_LAST_UPDATE_LOGIN ,
                       X_Event_Type                 => p_event_type ,
                       X_Description                => p_event_desc ,
                       X_Bill_Amount                => 0 ,
                       X_Revenue_Amount             => 0 ,
                       X_Revenue_Distributed_Flag   => 'N' ,
                       X_Zero_Revenue_Amount_Flag   => l_ZeroRevAmtFlag,
                       X_Bill_Hold_Flag             => 'N' ,
                       X_Completion_Date            => G_RATE_DATE ,
                       X_Rev_Dist_Rejection_Code    => NULL ,
                       X_Attribute_Category         => NULL ,
                       X_Attribute1                 => NULL ,
                       X_Attribute2                 => NULL ,
                       X_Attribute3                 => NULL ,
                       X_Attribute4                 => NULL ,
                       X_Attribute5                 => NULL ,
                       X_Attribute6                 => NULL ,
                       X_Attribute7                 => NULL ,
                       X_Attribute8                 => NULL ,
                       X_Attribute9                 => NULL ,
                       X_Attribute10                => NULL ,
                       X_Project_Id                 => p_project_id ,
                       X_Organization_Id            => G_ProjLvlGlobRec.carrying_out_organization_id ,
                       X_Billing_Assignment_Id      => NULL ,
                       X_Event_Num_Reversed         => NULL ,
                       X_Calling_Place              => NULL ,
                       X_Calling_Process            => NULL ,
                       X_Bill_Trans_Currency_Code   => G_RevalCompTab(l_SobId).projfunc_currency_code ,
                       X_Bill_Trans_Bill_Amount     => 0 ,  -- Changed from NULL for bug2829565
                       X_Bill_Trans_rev_Amount      => p_bill_trans_rev_amount ,
                       X_Project_Currency_Code      => G_RevalCompTab(l_SobId).project_currency_code ,
                       X_Project_Rate_Type          => NULL ,
                       X_Project_Rate_Date          => NULL ,
                       X_Project_Exchange_Rate      => NULL ,
                       X_Project_Inv_Rate_Date      => NULL ,
                       X_Project_Inv_Exchange_Rate  => NULL ,
                       X_Project_Bill_Amount        => NULL ,
                       X_Project_Rev_Rate_Date      => NULL ,
                       X_Project_Rev_Exchange_Rate  => NULL ,
                       X_Project_Revenue_Amount     => NULL ,
                       X_ProjFunc_Currency_Code     => G_RevalCompTab(l_SobId).projfunc_currency_code  ,
                       X_ProjFunc_Rate_Type         => NULL ,
                       X_ProjFunc_Rate_Date         => NULL ,
                       X_ProjFunc_Exchange_Rate     => NULL ,
                       X_ProjFunc_Inv_Rate_Date     => NULL ,
                       X_ProjFunc_Inv_Exchange_Rate => NULL ,
                       X_ProjFunc_Bill_Amount       => NULL ,
                       X_ProjFunc_Rev_Rate_Date     => NULL ,
                       X_Projfunc_Rev_Exchange_Rate => NULL ,
                       X_ProjFunc_Revenue_Amount    => NULL ,
                       X_Funding_Rate_Type          => NULL ,
                       X_Funding_Rate_Date          => NULL ,
                       X_Funding_Exchange_Rate      => NULL ,
                       X_Invproc_Currency_Code      => G_RevalCompTab(l_SobId).invproc_currency_code  ,
                       X_Invproc_Rate_Type          => NULL ,
                       X_Invproc_Rate_Date          => NULL ,
                       X_Invproc_Exchange_Rate      => NULL ,
                       X_Revproc_Currency_Code      => G_RevalCompTab(l_SobId).projfunc_currency_code ,
                       X_Revproc_Rate_Type          => NULL ,
                       X_Revproc_Rate_Date          => NULL ,
                       X_Revproc_Exchange_Rate      => NULL ,
                       X_Inv_Gen_Rejection_Code     => NULL ,
                       X_Adjusting_Revenue_Flag     => NULL ,
                       X_non_updateable_flag        => 'Y' ,
                       X_revenue_hold_flag          => 'Y' ,
                       X_project_funding_id         => p_project_funding_id,
		       X_agreement_id               => p_agreement_id);
Line: 9714

                DELETE FROM pa_events
                WHERE  event_id = l_EventId;
Line: 9723

            PA_DEBUG.g_err_stage := '-----------Exiting PA_FUND_REVAL_PVT.insert_event_record-----------' ;
Line: 9746

                PA_DEBUG.g_err_stage := 'insert_event_record:' || x_msg_data ;
Line: 9751

   END insert_event_record;
Line: 9935

   |   Purpose    :   To delete any rejection reason that is logged by revaluation process   |
   |                  for the request id                                                     |
   |   Parameters :                                                                          |
   |     ==================================================================================  |
   |     Name                             Mode    Description                                |
   |     ==================================================================================  |
   |     p_request_id          IN      Request ID                                            |
   |     x_return_status       OUT     Return status of this procedure                       |
   |     x_msg_count           OUT     Error message count                                   |
   |     x_msg_data            OUT     Error message                                         |
   |     ==================================================================================  |
   +----------------------------------------------------------------------------------------*/
   PROCEDURE clear_distribution_warnings(
             p_request_id        IN    NUMBER,
             x_return_status     OUT   NOCOPY VARCHAR2,
             x_msg_count         OUT   NOCOPY NUMBER,
             x_msg_data          OUT   NOCOPY VARCHAR2)   IS


       l_return_status               VARCHAR2(30) := NULL;
Line: 9971

         DELETE from pa_distribution_warnings
         WHERE request_id = p_request_id;
Line: 10067

            Insert_distribution_warnings(
                        p_project_id     => G_RevalCompTab(l_SobId).project_id,
                        p_agreement_id   => G_RevalCompTab(l_SobId).agreement_id,
                        p_task_id        => G_RevalCompTab(l_SobId).task_id,
                        p_reason_code    => l_ReasonCode,
                        x_return_status  => l_return_status,
                        x_msg_count      => l_msg_count,
                        x_msg_data       => l_msg_data) ;
Line: 10101

            Insert_distribution_warnings(
                        p_project_id     => G_RevalCompTab(l_SobId).project_id,
                        p_agreement_id   => G_RevalCompTab(l_SobId).agreement_id,
                        p_task_id        => G_RevalCompTab(l_SobId).task_id,
                        p_reason_code    => l_ReasonCode,
                        x_return_status  => l_return_status,
                        x_msg_count      => l_msg_count,
                        x_msg_data       => l_msg_data) ;
Line: 10157

   |   Procedure  :   Get_Delete_Projects                                                    |
   |   Purpose    :   To open all projects eligible for funding revaluation and has          |
   |                  unbaselined adjustment lines                                           |
   |                  given project numbers                                                  |
   |   Parameters :                                                                          |
   |     ==================================================================================  |
   |     Name                             Mode    Description                                |
   |     ==================================================================================  |
   |     p_project_id          IN      Project ID                                            |
   |     p_project_type_id     IN      Project Type ID                                       |
   |     p_from_proj_number    IN      Start project number                                  |
   |     p_to_proj_number      IN      End project number                                    |
   |     p_run_mode            IN      Run mode                                              |
   |                                   Values are 'SINGLE', 'RANGE'                          |
   |     x_return_status       OUT     Return status of this procedure                       |
   |     x_msg_count           OUT     Error message count                                   |
   |     x_msg_data            OUT     Error message                                         |
   |     ==================================================================================  |
   +----------------------------------------------------------------------------------------*/
   PROCEDURE get_delete_projects(
             p_project_type_id   IN    NUMBER,
             p_from_proj_number  IN    VARCHAR2,
             p_to_proj_number    IN    VARCHAR2,
             p_run_mode          IN    VARCHAR2,
             x_return_status     OUT   NOCOPY VARCHAR2,
             x_msg_count         OUT   NOCOPY NUMBER,
             x_msg_data          OUT   NOCOPY VARCHAR2)   IS


       /* This CURSOR selects all projects with the following criteria
              a) should be contract  projects
              b) revaluate_funding_flag is enabled
              c) has unbaselined adjustments */

         CURSOR open_projects IS
                SELECT P.segment1, P.project_id, P.baseline_funding_flag,
                       P.include_gains_losses_flag include_gains_losses_flag
                FROM pa_projects P, pa_project_types T
                WHERE P.segment1 BETWEEN p_from_proj_number
                               AND p_to_proj_number
                AND   P.PROJECT_TYPE = T.PROJECT_TYPE
                AND   T.DIRECT_FLAG = 'Y'
                AND   T.PROJECT_TYPE_ID  = NVL(P_PROJECT_TYPE_ID ,T.project_type_id)
                AND   NVL(P.revaluate_funding_flag, 'N') = 'Y'
                AND   NVL(P.template_flag, 'N') = 'N'
                AND   exists ( SELECT NULL
                               FROM pa_project_fundings
                               WHERE project_id = P.project_id
                               AND funding_category = 'REVALUATION'
                               AND budget_type_code = 'DRAFT')
                ORDER BY segment1 ;
Line: 10221

            PA_DEBUG.g_err_stage := '-----------Entering PA_FUND_REVAL_PVT.get_delete_projects-----------' ;
Line: 10242

             Delete_unbaselined_adjmts(
                    p_project_id     => proj_rec.project_id,
                    p_run_mode       => p_run_mode,
                    x_return_status  => l_return_status,
                    x_msg_count      => l_msg_count,
                    x_msg_data       => l_msg_data) ;
Line: 10259

             COMMIT; /* Commit delete for the current project */
Line: 10265

            PA_DEBUG.g_err_stage := '-----------Exiting PA_FUND_REVAL_PVT.get_delete_projects-----------' ;
Line: 10294

   END get_delete_projects;