DBA Data[Home] [Help]

APPS.PQH_GL_POSTING SQL Statements

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

Line: 67

PROCEDURE insert_pqh_gms_interface
(
 p_budget_detail_id  IN pqh_gl_interface.budget_detail_id%TYPE,
 p_period_name       IN varchar2,
 p_project_id        IN pqh_gl_interface.project_id%TYPE,
 p_task_id	     IN pqh_gl_interface.task_id%TYPE,
 p_award_id	     IN pqh_gl_interface.award_id%TYPE,
 p_expenditure_type  IN pqh_gl_interface.expenditure_type%TYPE,
 p_organization_id   IN pqh_gl_interface.organization_id%TYPE,
 p_amount            IN pqh_gl_interface.amount_dr%TYPE
);
Line: 79

PROCEDURE update_pqh_gms_interface
(
 p_budget_detail_id  IN pqh_gl_interface.budget_detail_id%TYPE,
 p_period_name       IN varchar2,
 p_project_id        IN pqh_gl_interface.project_id%TYPE,
 p_task_id	     IN pqh_gl_interface.task_id%TYPE,
 p_award_id	     IN pqh_gl_interface.award_id%TYPE,
 p_expenditure_type  IN pqh_gl_interface.expenditure_type%TYPE,
 p_organization_id   IN pqh_gl_interface.organization_id%TYPE,
 p_amount            IN pqh_gl_interface.amount_dr%TYPE
) ;
Line: 182

 SELECT *
 FROM pqh_budget_details
 WHERE budget_version_id  = p_budget_version_id
   AND NVL(gl_status,'X') <> 'POST';
Line: 251

            update_period_amt_tab
            (
             p_budget_detail_id => l_budget_details_rec.budget_detail_id
            );
Line: 313

   update gl_status of pqh_budget_versions and pqh_budget_details
   update posting_date and status of pqh_gl_interface
   update the global g_status with the program status
*/

     IF NOT p_validate THEN
       update_gl_status;
Line: 388

 SELECT *
 FROM pqh_budget_versions
 WHERE budget_version_id = p_budget_version_id;
Line: 393

 SELECT *
 FROM pqh_budgets
 WHERE budget_id = c_budget_id;
Line: 397

 ( SELECT budget_id
                     FROM pqh_budget_versions
                     WHERE budget_version_id = p_budget_version_id ) ;
Line: 403

 SELECT bg.ORG_INFORMATION10
 FROM  HR_ORGANIZATION_INFORMATION bg
 WHERE  bg.organization_id = p_business_group_id
  AND  bg.ORG_INFORMATION_CONTEXT = 'Business Group Information';
Line: 409

 SELECT *
 FROM gl_sets_of_books
 WHERE set_of_books_id = p_set_of_books_id;
Line: 414

 SELECT *
 FROM per_shared_types
 WHERE shared_type_id = p_shared_type_id;
Line: 421

 SELECT *
 FROM gl_budget_versions
 WHERE budget_name = p_gl_budget_name AND
       status in ('O','C');
Line: 427

 SELECT *
 FROM gl_je_sources
 WHERE je_source_name = 'Public Sector Budget';
Line: 432

 SELECT *
 FROM gl_je_categories
 WHERE je_category_name = 'Public Sector Budget';
Line: 437

 SELECT COUNT(*)
 FROM pqh_budget_gl_flex_maps
 WHERE budget_id = p_budget_id;
Line: 443

 SELECT table_alias,table_route_id
 FROM pqh_table_route
 WHERE table_alias IN ('BVR','BDT','BPR','BFS','GLF');
Line: 449

 SELECT COUNT(*)
 FROM pqh_budget_gl_flex_maps
 WHERE budget_id = p_budget_id
   AND payroll_cost_segment IS NULL;
Line: 870

          UPDATE pqh_process_log
           SET message_type_cd =  'ERROR',
               message_text   = l_message_text,
               txn_table_route_id    =  g_table_route_id_bvr
              -- batch_status    = 'ERROR',
              -- batch_end_date  = sysdate
           WHERE process_log_id = pqh_process_batch_log.g_master_process_log_id;
Line: 885

      END IF; -- insert error message if l_error_flag is Y
Line: 931

SELECT bpr.budget_period_id ,
       bfs.cost_allocation_keyflex_id,
       bfs.project_id,
       bfs.award_id,
       bfs.task_id,
       bfs.expenditure_type,
       bfs.organization_id,
       SUM(pqh_gl_posting.get_amt1(bfs.budget_fund_src_id)) Amount1,
       SUM(pqh_gl_posting.get_amt2(bfs.budget_fund_src_id)) Amount2,
       SUM(pqh_gl_posting.get_amt3(bfs.budget_fund_src_id)) Amount3
FROM pqh_budget_fund_srcs bfs, pqh_budget_elements bel,
     pqh_budget_sets bst, pqh_budget_periods bpr
WHERE bpr.budget_period_id = bst.budget_period_id
  AND bst.budget_set_id = bel.budget_set_id
  AND bel.budget_element_id = bfs.budget_element_id
  AND bpr.budget_detail_id = p_budget_detail_id
GROUP BY bpr.budget_period_id ,bfs.cost_allocation_keyflex_id,
         bfs.project_id, bfs.award_id,bfs.task_id,
	 bfs.expenditure_type,bfs.organization_id
ORDER BY bpr.budget_period_id , bfs.cost_allocation_keyflex_id,
         bfs.project_id, bfs.award_id,bfs.task_id,
	 bfs.expenditure_type,bfs.organization_id;
Line: 955

SELECT bpr.budget_period_id ,
       bfs.cost_allocation_keyflex_id,
       bfs.project_id,
       bfs.award_id,
       bfs.task_id,
       bfs.expenditure_type,
       bfs.organization_id,
       SUM((NVL(bfs.dflt_dist_percentage,0)*0.01)*(NVL(bel.dflt_dist_percentage,0)*0.01)*NVL(bst.budget_unit1_value,0)) Amount1,
       SUM((NVL(bfs.dflt_dist_percentage,0)*0.01)*(NVL(bel.dflt_dist_percentage,0)*0.01)*NVL(bst.budget_unit2_value,0)) Amount2,
       SUM((NVL(bfs.dflt_dist_percentage,0)*0.01)*(NVL(bel.dflt_dist_percentage,0)*0.01)*NVL(bst.budget_unit3_value,0)) Amount3
FROM   pqh_dflt_fund_srcs bfs,
       pqh_dflt_budget_elements bel,
       pqh_budget_sets bst,
       pqh_budget_periods bpr
WHERE  bpr.budget_period_id = bst.budget_period_id
  AND  bst.dflt_budget_set_id = bel.dflt_budget_set_id
  AND  bel.dflt_budget_element_id = bfs.dflt_budget_element_id
  AND  bpr.budget_detail_id = p_budget_detail_id
GROUP BY bpr.budget_period_id ,bfs.cost_allocation_keyflex_id,
         bfs.project_id, bfs.award_id,bfs.task_id,
	 bfs.expenditure_type,bfs.organization_id
ORDER BY bpr.budget_period_id , bfs.cost_allocation_keyflex_id,
         bfs.project_id, bfs.award_id,bfs.task_id,
	 bfs.expenditure_type,bfs.organization_id;
Line: 985

     g_period_amt_tab.DELETE;
Line: 1049

PROCEDURE update_period_amt_tab
(
 p_budget_detail_id IN pqh_budget_details.budget_detail_id%TYPE
)
IS
/*
  This procedure will read the above populated global table g_period_amt_tab and

   1.Get the period_name and code_combination_id corresponding to the period_id and
     cost_allocation_keyflex_id. If it does not find a period_name or a code_combination_id then
     it will populate the global variable   g_detail_error to Y.

   2.Get LD Encumbrance/Liquidation amount for each Budget Period and make adjustments to
     all PTAEO's invlved in that Budget period.

  If g_detail_error is Y then we will not populate the pqh_gl_interface table for the current
  budget_detail_id
*/

--
-- local variables
--
 l_proc                           varchar2(72) := g_package||'.update_period_amt_tab';
Line: 1142

              pqh_process_batch_log.insert_log
              (
               p_message_type_cd    =>  'ERROR',
               p_message_text       =>  l_message_text
              );
Line: 1190

              pqh_process_batch_log.insert_log
              (
               p_message_type_cd    =>  'ERROR',
               p_message_text       =>  l_message_text
              );
Line: 1220

END update_period_amt_tab;
Line: 1231

  This procedure will update or insert into pqh_gl_interface if there was no error for
  the current budget detail record i.e g_detail_error = N
  if g_detail_error = Y then update the pqh_budget_details record with gl_status = ERROR
*/
--
-- local variables
--
 l_proc                           varchar2(72) := g_package||'.populate_pqh_gl_interface';
Line: 1247

 SELECT COUNT(*)
 FROM pqh_gl_interface
 WHERE budget_version_id    = g_budget_version_id
   AND budget_detail_id     = p_budget_detail_id
   AND posting_type_cd      = 'BUDGET'
   AND period_name          = p_period_name
   AND code_combination_id  = p_code_combination_id
   AND currency_code        = p_currency_code
   AND NVL(adjustment_flag,'N') = 'N'
   AND status IS NOT NULL
   AND posting_date IS NOT NULL;
Line: 1283

              update_pqh_gl_interface
              (
               p_budget_detail_id            => p_budget_detail_id,
               p_period_name                 => g_period_amt_tab(i).period_name,
               p_accounting_date             => g_period_amt_tab(i).accounting_date,
               p_code_combination_id         => g_period_amt_tab(i).code_combination_id,
               p_cost_allocation_keyflex_id  => g_period_amt_tab(i).cost_allocation_keyflex_id,
               p_amount                      => g_period_amt_tab(i).amount1,
               p_currency_code               => g_currency_code1
               );
Line: 1295

              insert_pqh_gl_interface
              (
               p_budget_detail_id            => p_budget_detail_id,
               p_period_name                 => g_period_amt_tab(i).period_name,
               p_accounting_date             => g_period_amt_tab(i).accounting_date,
               p_code_combination_id         => g_period_amt_tab(i).code_combination_id,
               p_cost_allocation_keyflex_id  => g_period_amt_tab(i).cost_allocation_keyflex_id,
               p_amount                      => g_period_amt_tab(i).amount1,
               p_currency_code               => g_currency_code1
               );
Line: 1319

                  update_pqh_gl_interface
                  (
                   p_budget_detail_id            => p_budget_detail_id,
                   p_period_name                 => g_period_amt_tab(i).period_name,
                   p_accounting_date             => g_period_amt_tab(i).accounting_date,
                   p_code_combination_id         => g_period_amt_tab(i).code_combination_id,
                   p_cost_allocation_keyflex_id  => g_period_amt_tab(i).cost_allocation_keyflex_id,
                   p_amount                      => g_period_amt_tab(i).amount2,
                   p_currency_code               => g_currency_code2
                  );
Line: 1331

                  insert_pqh_gl_interface
                  (
                   p_budget_detail_id            => p_budget_detail_id,
                   p_period_name                 => g_period_amt_tab(i).period_name,
                   p_accounting_date             => g_period_amt_tab(i).accounting_date,
                   p_code_combination_id         => g_period_amt_tab(i).code_combination_id,
                   p_cost_allocation_keyflex_id  => g_period_amt_tab(i).cost_allocation_keyflex_id,
                   p_amount                      => g_period_amt_tab(i).amount2,
                   p_currency_code               => g_currency_code2
                  );
Line: 1357

                  update_pqh_gl_interface
                  (
                   p_budget_detail_id            => p_budget_detail_id,
                   p_period_name                 => g_period_amt_tab(i).period_name,
                   p_accounting_date             => g_period_amt_tab(i).accounting_date,
                   p_code_combination_id         => g_period_amt_tab(i).code_combination_id,
                   p_cost_allocation_keyflex_id  => g_period_amt_tab(i).cost_allocation_keyflex_id,
                   p_amount                      => g_period_amt_tab(i).amount3,
                   p_currency_code               => g_currency_code3
                  );
Line: 1369

                  insert_pqh_gl_interface
                  (
                   p_budget_detail_id            => p_budget_detail_id,
                   p_period_name                 => g_period_amt_tab(i).period_name,
                   p_accounting_date             => g_period_amt_tab(i).accounting_date,
                   p_code_combination_id         => g_period_amt_tab(i).code_combination_id,
                   p_cost_allocation_keyflex_id  => g_period_amt_tab(i).cost_allocation_keyflex_id,
                   p_amount                      => g_period_amt_tab(i).amount3,
                   p_currency_code               => g_currency_code3
                  );
Line: 1387

      END IF; -- Insert only GL records
Line: 1391

      UPDATE pqh_budget_details
         SET gl_status = ''
       WHERE budget_detail_id = p_budget_detail_id;
Line: 1400

      UPDATE pqh_budget_details
         SET gl_status = 'ERROR'
       WHERE budget_detail_id = p_budget_detail_id;
Line: 1419

PROCEDURE insert_pqh_gl_interface
(
 p_budget_detail_id            IN  pqh_gl_interface.budget_detail_id%TYPE,
 p_period_name                 IN  pqh_gl_interface.period_name%TYPE,
 p_accounting_date             IN  pqh_gl_interface.accounting_date%TYPE,
 p_code_combination_id         IN  pqh_gl_interface.code_combination_id%TYPE,
 p_cost_allocation_keyflex_id  IN  pqh_gl_interface.cost_allocation_keyflex_id%TYPE,
 p_amount                      IN  pqh_gl_interface.amount_dr%TYPE,
 p_currency_code               IN  pqh_gl_interface.currency_code%TYPE
 ) IS
 /*
  This procedure will insert record into pqh_gl_interface
  If the same UOM is repeated more then once then we would update the unposted txn.
 */
 --
-- local variables
--
 l_proc                         varchar2(72) := g_package||'.insert_pqh_gl_interface';
Line: 1440

 SELECT COUNT(*)
  FROM pqh_gl_interface
 WHERE budget_version_id    = g_budget_version_id
   AND budget_detail_id     = p_budget_detail_id
   AND posting_type_cd      = 'BUDGET'
   AND period_name          = p_period_name
   AND code_combination_id  = p_code_combination_id
   AND currency_code        = p_currency_code
   AND NVL(adjustment_flag,'N') = 'N'
   AND status IS NULL
   AND posting_date IS NULL;
Line: 1460

  hr_utility.set_location('l_count in Insert pqh_gl_interface : '||l_count,10);
Line: 1465

    UPDATE pqh_gl_interface
 -- ns since the record is new, the current amount is actual amount
 -- no need to add to previous amount
 --      SET AMOUNT_DR = NVL(AMOUNT_DR,0) + NVL(p_amount,0)
       SET AMOUNT_DR = NVL(p_amount,0)
     WHERE budget_version_id    = g_budget_version_id
       AND budget_detail_id     = p_budget_detail_id
       AND posting_type_cd      = 'BUDGET'
       AND period_name          = p_period_name
       AND code_combination_id  = p_code_combination_id
       AND currency_code        = p_currency_code
       AND NVL(adjustment_flag,'N') = 'N'
       AND status IS NULL
       AND posting_date IS NULL;
Line: 1483

     INSERT INTO pqh_gl_interface
     (
       gl_interface_id,
       budget_version_id,
       budget_detail_id,
       period_name,
       accounting_date,
       code_combination_id,
       cost_allocation_keyflex_id,
       amount_dr,
       amount_cr,
       currency_code,
       status,
       adjustment_flag,
       posting_date,
       posting_type_cd
     )
     VALUES
     (
       pqh_gl_interface_s.nextval,
       g_budget_version_id,
       p_budget_detail_id,
       p_period_name,
       p_accounting_date,
       p_code_combination_id,
       p_cost_allocation_keyflex_id,
       NVL(p_amount,0),
       0,
       p_currency_code,
       null,
       null,
       null,
       'BUDGET'
     );
Line: 1529

END insert_pqh_gl_interface;
Line: 1532

PROCEDURE update_pqh_gl_interface
(
 p_budget_detail_id            IN  pqh_gl_interface.budget_detail_id%TYPE,
 p_period_name                 IN  pqh_gl_interface.period_name%TYPE,
 p_accounting_date             IN  pqh_gl_interface.accounting_date%TYPE,
 p_code_combination_id         IN  pqh_gl_interface.code_combination_id%TYPE,
 p_cost_allocation_keyflex_id  IN  pqh_gl_interface.cost_allocation_keyflex_id%TYPE,
 p_amount                      IN  pqh_gl_interface.amount_dr%TYPE,
 p_currency_code               IN  pqh_gl_interface.currency_code%TYPE
 ) IS
 /*
  This procedure will update pqh_gl_interface and create a adjustment record
 */
 --
-- local variables
--
 l_proc                         varchar2(72) := g_package||'.update_pqh_gl_interface';
Line: 1556

 SELECT *
  FROM pqh_gl_interface
 WHERE budget_version_id    = g_budget_version_id
   AND budget_detail_id     = p_budget_detail_id
   AND posting_type_cd      = 'BUDGET'
   AND period_name          = p_period_name
   AND code_combination_id  = p_code_combination_id
   AND currency_code        = p_currency_code
   AND NVL(adjustment_flag,'N') = 'N'
   AND status IS NOT NULL
   AND posting_date IS NOT NULL
  FOR UPDATE of amount_dr;
Line: 1588

           UPDATE pqh_gl_interface
              SET amount_dr = NVL(p_amount,0)
            WHERE CURRENT OF csr_pqh_gl_interface;
Line: 1598

       INSERT INTO pqh_gl_interface
       (
         gl_interface_id,
         budget_version_id,
         budget_detail_id,
         period_name,
         accounting_date,
         code_combination_id,
         cost_allocation_keyflex_id,
         amount_dr,
         amount_cr,
         currency_code,
         status,
         adjustment_flag,
         posting_date,
         posting_type_cd
       )
       VALUES
       (
         pqh_gl_interface_s.nextval,
         g_budget_version_id,
         p_budget_detail_id,
         p_period_name,
         p_accounting_date,
         p_code_combination_id,
         p_cost_allocation_keyflex_id,
         NVL(l_amount_dr,0),
         NVL(l_amount_cr,0),
         p_currency_code,
         null,
         'Y',
         null,
         'BUDGET'
       );
Line: 1633

     END IF; -- create i.e insert a adjustment record ONLY if l_amount_diff <> 0
Line: 1644

END update_pqh_gl_interface;
Line: 1650

  This procedure will pick records from pqh_gl_interface table and insert them into
  gl tables depending on the g_budgetary_control_flag
  If we insert into gl_bc_packets do funds checking for each packet
*/
--
-- local variables
--
 l_proc                         varchar2(72) := g_package||'.populate_gl_tables';
Line: 1677

 SELECT period_name, accounting_date,
        code_combination_id, cost_allocation_keyflex_id, currency_code,
        SUM(NVL(amount_dr,0))  amount_dr,
        SUM(NVL(amount_cr,0))  amount_cr
 FROM pqh_gl_interface
 WHERE budget_version_id IN (g_budget_version_id, NVL(g_last_posted_ver,0) )
   AND status IS NULL
   AND posting_date IS NULL
   AND posting_type_cd = 'BUDGET'
   AND cost_allocation_keyflex_id is NOT NULL
 GROUP BY period_name, accounting_date,code_combination_id,
          cost_allocation_keyflex_id,currency_code;
Line: 1691

 SELECT gl_bc_packets_s.nextval
 FROM dual;
Line: 1695

 SELECT *
 FROM  gl_period_statuses
 WHERE application_id = g_application_id
   AND set_of_books_id = g_set_of_books_id
   AND period_name  = p_period_name;
Line: 1702

 SELECT description
 FROM gl_lookups
 WHERE lookup_type = 'FUNDS_CHECK_RESULT_CODE'
   AND lookup_code = p_lookup_code
   AND NVL(enabled_flag,'N') = 'Y';
Line: 1709

 SELECT result_code
 FROM gl_bc_packets
 WHERE packet_id = p_packet_id;
Line: 1714

 SELECT description
 FROM gl_lookups
 WHERE lookup_type = 'FUNDS_CHECK_STATUS_CODE'
   AND lookup_code = p_lookup_code
   AND NVL(enabled_flag,'N') = 'Y';
Line: 1727

      hr_utility.set_location('Inserting into GL_BC_PACKETS',10);
Line: 1759

              Insert in gl_bc_packets and Call the GL funds checker
              The  GL funds checker program has COMMIT inside the program so we cannot rollback
              The  GL funds checker is only called when the validate flag is false i.e no validation
             -- do funds checking for each packet
             -- Mode = R (reserved) if amount is dr
             -- Mode = U (unreserved) if amount is cr
             -- Mode = C (Checking) if program is run in validate mode i.e g_validate = TRUE
             -- Mode C is never called as there as explicit commits in GL funds checker program , so
             -- we call the GL funds checker program only when p_validate is FALSE in R or U mode
     ------------------------------------------------------------------------------------------------
*/
              -- Insert in gl_bc_packets and run funds checker
              hr_utility.set_location('Calling ins_gl_bc_run_fund_check with fund checker Mode : '||l_fc_mode,100);
Line: 1808

2. update all the budget_detail records which have this Period Name + CCID + currency code to ERROR ( gl_status)

3. Reverse unposted adjustment txns in pqh_gl_interface

4. Delete all unposted non-adjustment txns from pqh_gl_interface
-----------------------------------------------------------------------------------------------------

*/

           IF NOT ( l_fc_success )  OR
              ( NVL(l_fc_return,'T') in ('T', 'F','R') ) THEN
              -- fund checker failed

               hr_utility.set_location('Fund Checker Failed ',120);
Line: 1857

                 pqh_process_batch_log.insert_log
                 (
                  p_message_type_cd    =>  'ERROR',
                  p_message_text       =>  l_packet_status_code||' : '||l_fc_message
                 );
Line: 1864

               hr_utility.set_location('Inserted Error and calling reverse txn ',140);
Line: 1894

      hr_utility.set_location('Inserting into GL_INTERFACE',200);
Line: 1903

          INSERT INTO gl_interface
               (status,
                set_of_books_id,
                user_je_source_name,
                user_je_category_name,
                currency_code,
                date_created,
                created_by,
                actual_flag,
                budget_version_id,
                accounting_date,
                period_name,
                code_combination_id,
                chart_of_accounts_id,
                entered_dr,
                entered_cr,
                reference1,
                reference2)
           VALUES
               ('NEW',
                g_set_of_books_id,
                g_user_je_source_name,
                g_user_je_category_name,
                l_currency_code,
                sysdate,
                8302,
                'B',
                g_gl_budget_version_id,
                l_accounting_date,
                l_period_name,
                l_code_combination_id,
                g_chart_of_accounts_id,
                NVL(l_amount_dr,0),
                NVL(l_amount_cr,0),
                g_budget_version_id,
                l_cost_allocation_keyflex_id);
Line: 1959

PROCEDURE update_gl_status
IS
/*
  This procedure will update the gl_status of pqh_budget_versions, pqh_budget_details
  and update the pqh_gl_interface table

  We always update the TRANSFERED_TO_GL_FLAG = Y to indicate this is the latest budget_version that is posted to GL
  gl_status = POST or ERROR
*/

--
-- local variables
--
 l_proc                         varchar2(72) := g_package||'.update_gl_status';
Line: 1977

 SELECT *
 FROM pqh_budget_details
 WHERE budget_version_id = g_budget_version_id
   AND NVL(gl_status,'X') <> 'ERROR'
  FOR UPDATE OF gl_status;
Line: 1984

 SELECT COUNT(*)
 FROM pqh_budget_details
  WHERE budget_version_id = g_budget_version_id
   AND NVL(gl_status,'ERROR') = 'ERROR';
Line: 1998

        UPDATE pqh_budget_details
        SET gl_status = 'POST'
        WHERE CURRENT OF csr_budget_details;
Line: 2013

      UPDATE pqh_budget_versions
      SET gl_status = 'POST',
          transfered_to_gl_flag = 'Y'
      WHERE budget_version_id = g_budget_version_id;
Line: 2023

      UPDATE pqh_budget_versions
      SET gl_status = 'ERROR',
          transfered_to_gl_flag = 'Y'
      WHERE budget_version_id = g_budget_version_id;
Line: 2037

   UPDATE pqh_gl_interface
   SET posting_date = sysdate,
       status       = 'POST'
   WHERE budget_version_id = g_budget_version_id
     AND posting_type_cd = 'BUDGET'
     AND posting_date IS NULL
     AND status       IS NULL;
Line: 2046

   UPDATE pqh_gl_interface
   SET posting_date = sysdate,
       status       = 'POST'
   WHERE budget_version_id = NVL(g_last_posted_ver,0)
     AND posting_type_cd = 'BUDGET'
     AND posting_date IS NULL
     AND status       IS NULL;
Line: 2063

END update_gl_status;
Line: 2108

 SELECT *
 FROM pay_cost_allocation_keyflex
 WHERE cost_allocation_keyflex_id = p_cost_allocation_keyflex_id;
Line: 2114

 SELECT *
 FROM pqh_budget_gl_flex_maps
 WHERE budget_id = g_budget_id ;
Line: 2255

    hr_utility.set_location('Built dynamic select ',26);
Line: 2257

      sql_stmt := 'SELECT * FROM  gl_code_combinations WHERE  chart_of_accounts_id = :g_chart_of_accounts_id and '||l_where_str ;
Line: 2374

 SELECT start_date
 FROM per_time_periods
 WHERE time_period_id = ( SELECT start_time_period_id
                          FROM pqh_budget_periods
                          WHERE budget_period_id = p_budget_period_id );
Line: 2381

 SELECT *
 FROM  gl_period_statuses
 WHERE application_id = g_application_id
   AND set_of_books_id = g_set_of_books_id
   AND closing_status  = 'O'
   AND p_start_date BETWEEN start_date AND end_date;
Line: 2434

SELECT (NVL(srcs.distribution_percentage,0) * .01) *
       (NVL(elem.distribution_percentage,0) * .01) *
        NVL(sets.budget_unit1_value,0)
FROM  pqh_budget_fund_srcs srcs,
      pqh_budget_elements  elem,
      pqh_budget_sets      sets
WHERE srcs.budget_fund_src_id = p_budget_fund_src_id
AND   elem.budget_element_id  = srcs.budget_element_id
AND   sets.budget_set_id      = elem.budget_set_id;
Line: 2483

SELECT (NVL(srcs.distribution_percentage,0) * .01) *
       (NVL(elem.distribution_percentage,0) * .01) *
        NVL(sets.budget_unit2_value,0)
FROM  pqh_budget_fund_srcs srcs,
      pqh_budget_elements  elem,
      pqh_budget_sets      sets
WHERE srcs.budget_fund_src_id = p_budget_fund_src_id
AND   elem.budget_element_id  = srcs.budget_element_id
AND   sets.budget_set_id      = elem.budget_set_id;
Line: 2534

SELECT (NVL(srcs.distribution_percentage,0) * .01) *
       (NVL(elem.distribution_percentage,0) * .01) *
        NVL(sets.budget_unit3_value,0)
FROM  pqh_budget_fund_srcs srcs,
      pqh_budget_elements  elem,
      pqh_budget_sets      sets
WHERE srcs.budget_fund_src_id = p_budget_fund_src_id
AND   elem.budget_element_id  = srcs.budget_element_id
AND   sets.budget_set_id      = elem.budget_set_id;
Line: 2593

 SELECT *
 FROM pqh_budget_details
 WHERE budget_detail_id = p_budget_detail_id ;
Line: 2687

 SELECT *
 FROM pqh_budget_periods
 WHERE budget_period_id = p_budget_period_id ;
Line: 2692

 SELECT *
 FROM per_time_periods
 WHERE time_period_id = p_time_period_id ;
Line: 2757

 SELECT *
 FROM pay_cost_allocation_keyflex
 WHERE cost_allocation_keyflex_id = p_cost_allocation_keyflex_id;
Line: 2789

  This will update the g_status global with ERROR or SUCCESS
*/
--
-- local variables
--
l_proc                  varchar2(72) := g_package||'end_log';
Line: 2803

SELECT COUNT(*)
FROM pqh_process_log
WHERE message_type_cd = p_message_type_cd
START WITH process_log_id = pqh_process_batch_log.g_master_process_log_id
CONNECT BY PRIOR process_log_id = master_process_log_id;
Line: 2810

SELECT *
FROM pqh_process_log
WHERE process_log_id = pqh_process_batch_log.g_master_process_log_id;
Line: 2858

    update the 'start' record for this batch with message_type_cd = 'COMPLETE' and
    update the batch_end_date with current date time
  */

   OPEN csr_batch_rec;
Line: 2868

      UPDATE pqh_process_log
      SET message_type_cd = 'COMPLETE',
         message_text   = fnd_message.get_string('PQH','PQH_PROCESS_COMPLETED'),
          txn_table_route_id    =  g_table_route_id_bvr,
          batch_status = l_status,
          batch_end_date  = sysdate
      WHERE process_log_id = pqh_process_batch_log.g_master_process_log_id;
Line: 2878

      UPDATE pqh_process_log
      SET batch_status = l_status,
          batch_end_date  = sysdate,
          txn_table_route_id    =  g_table_route_id_bvr
      WHERE process_log_id = pqh_process_batch_log.g_master_process_log_id;
Line: 2922

   UPDATE pqh_process_log
   SET message_type_cd =  'ERROR',
       message_text   = p_message_text,
       txn_table_route_id    =  g_table_route_id_bvr
       -- batch_status    = 'ERROR',
       -- batch_end_date  = sysdate
   WHERE process_log_id = pqh_process_batch_log.g_master_process_log_id;
Line: 2969

SELECT *
FROM pqh_budgets
WHERE budget_id = p_budget_id;
Line: 2974

SELECT *
FROM gl_sets_of_books
WHERE set_of_books_id = p_set_of_books_id;
Line: 2979

SELECT *
FROM fnd_id_flex_segments
WHERE application_id = 101
  AND id_flex_code = 'GL#'
  AND id_flex_num = p_id_flex_num
  AND enabled_flag = 'Y'
  AND display_flag = 'Y'
ORDER BY application_column_name;
Line: 3049

1. update all the budget_detail records which have this Period Name + CCID + currency code to ERROR ( gl_status)

2. Reverse unposted adjustment txns in pqh_gl_interface

3. Delete all unposted non-adjustment txns from pqh_gl_interface

Note : If a budget detail record has 4 periods and there was a error in 4th period , we have no control on the 1st three
as they have already been Approved by funs checker program and would have already been posted to GL.

*/

--
-- local variables
--
l_proc                    varchar2(72) := g_package||'reverse_budget_details';
Line: 3068

SELECT *
FROM pqh_gl_interface
WHERE budget_version_id = g_budget_version_id
     AND posting_type_cd = 'BUDGET'
  AND period_name = p_period_name
  AND currency_code = p_currency_code
  AND code_combination_id = p_code_combination_id
  AND NVL(adjustment_flag,'N') = 'Y'
  AND status IS NULL
  AND posting_date IS NULL;
Line: 3091

         UPDATE pqh_gl_interface
         SET amount_dr = NVL(amount_dr,0) -
                         NVL(l_pqh_gl_interface_rec.amount_dr,0) +
                         NVL(l_pqh_gl_interface_rec.amount_cr,0)
         WHERE budget_version_id = l_pqh_gl_interface_rec.budget_version_id
           AND budget_detail_id = l_pqh_gl_interface_rec.budget_detail_id
     AND posting_type_cd = 'BUDGET'
           AND period_name = l_pqh_gl_interface_rec.period_name
           AND currency_code = l_pqh_gl_interface_rec.currency_code
           AND code_combination_id = l_pqh_gl_interface_rec.code_combination_id
           AND NVL(adjustment_flag,'N') = 'N'
           AND status IS NOT NULL;
Line: 3109

      UPDATE pqh_budget_details
      SET gl_status = 'ERROR'
      WHERE budget_detail_id IN
        (
          SELECT distinct budget_detail_id
          FROM pqh_gl_interface
          WHERE budget_version_id = g_budget_version_id
     AND posting_type_cd = 'BUDGET'
            AND period_name = p_period_name
            AND currency_code = p_currency_code
            AND code_combination_id = p_code_combination_id
            AND status IS NULL
            AND posting_date IS NULL
        );
Line: 3126

       DELETE FROM pqh_gl_interface
       WHERE budget_version_id = g_budget_version_id
         AND period_name = p_period_name
         AND currency_code = p_currency_code
         AND code_combination_id = p_code_combination_id
     AND posting_type_cd = 'BUDGET'
         AND status IS NULL
         AND posting_date IS NULL;
Line: 3163

                   3         3      US   100  (update)    3         3        US   200  ( update )
                   4         4      US   100  (unchanged) 4         4        US   100  ( unchanged )
                                                          4         7        UK   100  ( new )
                                                          7         9        US   100  ( new )


*/
--
-- local variables
--
l_proc                    varchar2(72) := g_package||'build_old_bdgt_dtls_tab';
Line: 3180

SELECT *
FROM pqh_gl_interface
WHERE budget_version_id        =  g_budget_version_id
  AND budget_detail_id         =  p_budget_detail_id
     AND posting_type_cd = 'BUDGET'
  AND NVL(adjustment_flag,'N') = 'N'
  AND status IS NOT NULL
  AND posting_date IS NOT NULL
  AND (NVL(amount_dr,0) > 0 OR NVL(amount_cr,0) > 0 ) ;
Line: 3239

  g_old_bdgt_dtls_tab which are not in g_period_amt_tab and update the reverse flag for those records to 'Y' so that
  we can reverse those records
*/

--
-- local variables
--
l_proc                    varchar2(72) := g_package||'compare_old_bdgt_dtls_tab';
Line: 3314

  where reverse_flag is Y and update the posted record amount to 0
*/
--
-- local variables
--
l_proc                    varchar2(72) := g_package||'reverse_old_bdgt_dtls_tab';
Line: 3325

 SELECT *
  FROM pqh_gl_interface
 WHERE budget_version_id    = g_budget_version_id
   AND budget_detail_id     = p_budget_detail_id
   AND period_name          = p_period_name
   AND code_combination_id  = p_code_combination_id
   AND currency_code        = p_currency_code
     AND posting_type_cd = 'BUDGET'
   AND NVL(adjustment_flag,'N') = 'N'
   AND status IS NOT NULL
   AND posting_date IS NOT NULL
  FOR UPDATE of amount_dr;
Line: 3345

   SELECT *
    FROM pqh_gl_interface
   WHERE budget_version_id        = g_budget_version_id
     AND budget_detail_id         = p_budget_detail_id
     AND period_name              = p_period_name
     AND project_id               = p_project_id
     AND task_id	   	  = p_task_id
     AND award_id	   	  = p_award_id
     AND expenditure_type	  = p_expenditure_type
     AND organization_id 	  = p_organization_id
     AND posting_type_cd          = 'BUDGET'
     AND NVL(adjustment_flag,'N') = 'N'
     AND status IS NOT NULL
     AND posting_date IS NOT NULL
  FOR UPDATE of amount_dr;
Line: 3392

                 UPDATE pqh_gl_interface
                     SET amount_dr = 0
                 WHERE CURRENT OF csr_pqh_gl_interface;
Line: 3396

                 hr_utility.set_location('Updated pqh_gl_interface ',15);
Line: 3401

                 INSERT INTO pqh_gl_interface
                 (
                   gl_interface_id,
                   budget_version_id,
                   budget_detail_id,
                   period_name,
                   accounting_date,
                   code_combination_id,
                   cost_allocation_keyflex_id,
                   amount_dr,
                   amount_cr,
                   currency_code,
                   status,
                   adjustment_flag,
                   posting_date,
                   posting_type_cd
                 )
                 VALUES
                 (
                   pqh_gl_interface_s.nextval,
                   g_budget_version_id,
                   p_budget_detail_id,
                   g_old_bdgt_dtls_tab(i).period_name,
                   g_old_bdgt_dtls_tab(i).accounting_date,
                   g_old_bdgt_dtls_tab(i).code_combination_id,
                   g_old_bdgt_dtls_tab(i).cost_allocation_keyflex_id,
                   0,
                   NVL(l_pqh_gl_interface_rec.amount_dr,0),
                   g_old_bdgt_dtls_tab(i).currency_code,
                   null,
                   'Y',
                   null,
                   'BUDGET'
                 );
Line: 3451

	          -- update the pqh_gl_interface table
	          UPDATE pqh_gl_interface
	              SET amount_dr = 0
	          WHERE CURRENT OF csr_pqh_gms_interface;
Line: 3456

	          hr_utility.set_location('Updated pqh_gl_interface ',15);
Line: 3461

	          INSERT INTO pqh_gl_interface
	          (
	            gl_interface_id,
	            budget_version_id,
	            budget_detail_id,
                    period_name,
	            project_id,
		    task_id,
		    award_id,
		    expenditure_type,
                    organization_id,
	            amount_dr,
	            amount_cr,
	            status,
	            adjustment_flag,
	            posting_date,
                    currency_code,
	            posting_type_cd
	          )
	          VALUES
	          (
	            pqh_gl_interface_s.nextval,
	            g_budget_version_id,
	            p_budget_detail_id,
                    g_old_bdgt_dtls_tab(i).period_name,
	            g_old_bdgt_dtls_tab(i).project_id,
	            g_old_bdgt_dtls_tab(i).task_id,
	            g_old_bdgt_dtls_tab(i).award_id,
	            g_old_bdgt_dtls_tab(i).expenditure_type,
	            g_old_bdgt_dtls_tab(i).organization_id,
	            0,
	            NVL(l_pqh_gl_interface_rec.amount_dr,0),
	            null,
	            'Y',
	            null,
                    g_old_bdgt_dtls_tab(i).currency_code,
	            'BUDGET'
	            );
Line: 3539

SELECT bg.ORG_INFORMATION10
FROM  HR_ORGANIZATION_INFORMATION bg,
      pqh_budgets bgt,
      pqh_budget_versions bvr
WHERE bgt.budget_id = bvr.budget_id
  AND bvr.budget_version_id = g_budget_version_id
  AND bgt.business_group_id = bg.organization_id
  AND bg.ORG_INFORMATION_CONTEXT = 'Business Group Information';
Line: 3549

SELECT bgt.currency_code
FROM  pqh_budgets  bgt,
      pqh_budget_versions bvr
WHERE bgt.budget_id = bvr.budget_id
  AND bvr.budget_version_id = g_budget_version_id;
Line: 3617

SELECT  cost_allocation_keyflex_id
  FROM  PAY_ALL_PAYROLLS_F pay,
        FND_SESSIONS SS
WHERE   SS.SESSION_ID = USERENV( 'sessionid')
  AND   PAY.EFFECTIVE_START_DATE <= ss.effective_date
  AND   PAY.EFFECTIVE_END_DATE >= ss.effective_date
  AND   pay.payroll_id =
(SELECT  pos.pay_freq_payroll_id
  FROM  pqh_budget_details bdt,
        hr_all_positions_f pos,
        FND_SESSIONS SS
WHERE   bdt.budget_detail_id = p_budget_detail_id
  AND   bdt.position_id = pos.position_id
  AND   SS.SESSION_ID = USERENV( 'sessionid')
  AND   POS.EFFECTIVE_START_DATE <= ss.effective_date
  AND   POS.EFFECTIVE_END_DATE >= ss.effective_date
);
Line: 3636

 SELECT *
 FROM pay_cost_allocation_keyflex
 WHERE cost_allocation_keyflex_id = p_cost_allocation_keyflex_id;
Line: 3648

     g_seg_val_tab.DELETE;
Line: 3827

SELECT  cost_allocation_keyflex_id
  FROM  pqh_budget_details bdt, pqh_budget_periods bpr,
        pqh_budget_sets bst, pqh_budget_elements bel,
        pay_element_links pel
WHERE  bdt.budget_detail_id  =  bpr.budget_detail_id
  AND  bpr.budget_period_id  =  bst.budget_period_id
  AND  bst.budget_set_id     =  bel.budget_set_id
  AND  bdt.position_id       =  pel.position_id
  AND  bel.element_type_id   =  pel.element_type_id
  AND  bdt.budget_detail_id  =  p_budget_detail_id
  AND  bpr.budget_period_id  =  p_budget_period_id ;
Line: 3841

 SELECT *
 FROM pay_cost_allocation_keyflex
 WHERE cost_allocation_keyflex_id = p_cost_allocation_keyflex_id;
Line: 3938

SELECT  cost_allocation_keyflex_id
  FROM  pqh_budget_details bdt,
        hr_all_organization_units org
WHERE   bdt.budget_detail_id = p_budget_detail_id
  AND   bdt.organization_id = org.organization_id;
Line: 3946

 SELECT *
 FROM pay_cost_allocation_keyflex
 WHERE cost_allocation_keyflex_id = p_cost_allocation_keyflex_id;
Line: 4031

  We will also update the following :
  Budget Version table :
     For last Posted Version :
       TRANSFERED_TO_GL_FLAG for the last posted version to 'N '
       gl_status = 'UNPOST'
     For the current budget_version :
        After posting the current version we will update the TRANSFERED_TO_GL_FLAG to Y for the current version.
        gl_status = POST or ERROR

  Budget Detail table :
     For last Posted Version :
        gl_status = NULL ( for all records )
     For the current budget_version :
        handled by the current posting logic, will be set to POST or ERROR



*/
--
-- local variables
--
l_proc                    varchar2(72) := g_package||' .reverse_prev_posted_version';
Line: 4057

SELECT budget_version_id
  FROM pqh_budget_versions
 WHERE budget_id = g_budget_id
   AND NVL(transfered_to_gl_flag,'N') = 'Y';
Line: 4063

SELECT *
FROM pqh_gl_interface
WHERE budget_version_id    = p_budget_version_id
   AND NVL(adjustment_flag,'N') = 'N'
   AND posting_type_cd = 'BUDGET'
   AND status IS NOT NULL
   AND posting_date IS NOT NULL
   AND (NVL(amount_dr,0) > 0 OR NVL(amount_cr,0) > 0 )
  FOR UPDATE of amount_dr;
Line: 4093

                     UPDATE pqh_gl_interface
                        SET amount_dr = 0
                      WHERE CURRENT OF csr_unpost_version;
Line: 4098

                        INSERT INTO pqh_gl_interface
                        (
                          gl_interface_id,
                          budget_version_id,
                          budget_detail_id,
                          period_name,
                          accounting_date,
                          code_combination_id,
                          cost_allocation_keyflex_id,
                          project_id,
			  task_id,
			  award_id,
			  expenditure_type,
                          organization_id,
                          amount_dr,
                          amount_cr,
                          currency_code,
                          status,
                          adjustment_flag,
                          posting_date,
                          posting_type_cd
                        )
                        VALUES
                        (
                          pqh_gl_interface_s.nextval,
                          g_last_posted_ver,
                          l_pqh_gl_interface_rec.budget_detail_id,
                          l_pqh_gl_interface_rec.period_name,
                          l_pqh_gl_interface_rec.accounting_date,
                          l_pqh_gl_interface_rec.code_combination_id,
                          l_pqh_gl_interface_rec.cost_allocation_keyflex_id,
                          l_pqh_gl_interface_rec.project_id,
			  l_pqh_gl_interface_rec.task_id,
			  l_pqh_gl_interface_rec.award_id,
			  l_pqh_gl_interface_rec.expenditure_type,
                          l_pqh_gl_interface_rec.organization_id,
                          0,
                          NVL(l_pqh_gl_interface_rec.amount_dr,0),
                          l_pqh_gl_interface_rec.currency_code,
                          null,
                          'Y',
                          null,
                          'BUDGET'
                        );
Line: 4149

           UPDATE pqh_budget_versions
              SET transfered_to_gl_flag = 'N' ,
                              gl_status = 'UNPOST'
           WHERE budget_version_id = g_last_posted_ver;
Line: 4155

           UPDATE pqh_budget_details
              SET gl_status = ''
            WHERE  budget_version_id = g_last_posted_ver;
Line: 4264

SELECT *
FROM pqh_gl_interface
WHERE budget_version_id    = p_budget_version_id
   AND NVL(adjustment_flag,'N') = 'N'
   AND posting_type_cd = 'COMMITMENT'
   AND status IS NOT NULL
   AND posting_date IS NOT NULL
   AND (NVL(amount_dr,0) > 0 OR NVL(amount_cr,0) > 0 )
  FOR UPDATE of amount_dr;
Line: 4289

          UPDATE pqh_gl_interface
             SET amount_dr = 0
           WHERE CURRENT OF csr_unpost_version;
Line: 4294

          INSERT INTO pqh_gl_interface
          (
                          gl_interface_id,
                          budget_version_id,
                          budget_detail_id,
                          period_name,
                          accounting_date,
                          code_combination_id,
                          cost_allocation_keyflex_id,
                          project_id,
			  task_id,
			  award_id,
			  expenditure_type,
                          organization_id,
                          amount_dr,
                          amount_cr,
                          currency_code,
                          status,
                          adjustment_flag,
                          posting_date,
                          posting_type_cd
           )
           VALUES
           (
                          pqh_gl_interface_s.nextval,
                          g_last_posted_ver,
                          l_pqh_gl_interface_rec.budget_detail_id,
                          l_pqh_gl_interface_rec.period_name,
                          l_pqh_gl_interface_rec.accounting_date,
                          l_pqh_gl_interface_rec.code_combination_id,
                          l_pqh_gl_interface_rec.cost_allocation_keyflex_id,
                          l_pqh_gl_interface_rec.project_id,
			  l_pqh_gl_interface_rec.task_id,
			  l_pqh_gl_interface_rec.award_id,
			  l_pqh_gl_interface_rec.expenditure_type,
                          l_pqh_gl_interface_rec.organization_id,
                          0,
                          NVL(l_pqh_gl_interface_rec.amount_dr,0),
                          l_pqh_gl_interface_rec.currency_code,
                          null,
                          'Y',
                          null,
                          'BUDGET'
           );
Line: 4345

      UPDATE pqh_budget_versions
         SET commitment_gl_status = 'UNPOST'
      WHERE budget_version_id = g_last_posted_ver;
Line: 4351

      UPDATE pqh_budget_details
         SET commitment_gl_status = 'UNPOST'
       WHERE budget_version_id = g_last_posted_ver;
Line: 4378

 SELECT bfs.budget_fund_src_id
 FROM pqh_budget_details bdt, pqh_budget_periods bpr, pqh_budget_sets bst, pqh_budget_elements bel, pqh_budget_fund_srcs bfs
 WHERE bdt.budget_version_id  =  p_budget_version_id
   and bdt.budget_detail_id  = bpr.budget_detail_id
   and bpr.budget_period_id = bst.budget_period_id
   and bst.budget_set_id = bel.budget_set_id
   and bel.budget_element_id = bfs.budget_element_id;
Line: 4472

Select position_id
From
pqh_budget_details
where budget_detail_id = p_budget_detail_id;
Line: 4478

Select organization_id
From
pqh_budget_details
where budget_detail_id = p_budget_detail_id;
Line: 4484

Select grade_id
From
pqh_budget_details
where budget_detail_id = p_budget_detail_id;
Line: 4490

Select job_id
From
pqh_budget_details
where budget_detail_id = p_budget_detail_id;
Line: 4498

Select
assignment_id,
effective_start_date,
effective_end_date
From per_all_assignments_f
Where position_id=l_entity_id and
(
(effective_start_date <=start_date AND effective_end_date >start_date)
 OR
(effective_start_date <=end_date AND effective_end_date >end_date)
);
Line: 4512

Select
assignment_id,
effective_start_date,
effective_end_date
From per_all_assignments_f
Where organization_id=l_entity_id and
(
(effective_start_date <=start_date AND effective_end_date >start_date)
 OR
(effective_start_date <=end_date AND effective_end_date >end_date)
);
Line: 4526

Select
assignment_id,
effective_start_date,
effective_end_date
From per_all_assignments_f
Where grade_id=l_entity_id and
(
(effective_start_date <=start_date AND effective_end_date >start_date)
 OR
(effective_start_date <=end_date AND effective_end_date >end_date)
);
Line: 4540

Select
assignment_id,
effective_start_date,
effective_end_date
From per_all_assignments_f
Where job_id=l_entity_id and
(
(effective_start_date <=start_date AND effective_end_date >start_date)
 OR
(effective_start_date <=end_date AND effective_end_date >end_date)
);
Line: 4554

Select
start_time_period_id,
end_time_period_id
From
pqh_budget_periods
Where
budget_period_id = p_budget_period_id;
Line: 4563

Select
start_date,
end_date
From
per_time_periods
Where
time_period_id = p_time_period_id;
Line: 4572

Select
hr_general.decode_shared_type(budget_unit1_id) UOM1,
hr_general.decode_shared_type(budget_unit2_id) UOM2,
hr_general.decode_shared_type(budget_unit3_id) UOM3
From
pqh_budgets
Where budget_id=g_budget_id;
Line: 4581

Select budget_version_id
From pqh_budget_versions
Where     budget_id = g_budget_id
      AND NVL(transfered_to_gl_flag,'N') = 'Y';
Line: 4782

  DELETE from pqh_gms_excess
  WHERE  budget_period_id in (Select budget_period_id
                              From
                              pqh_budget_periods bpr
                             ,pqh_budget_details bdt
                              Where bpr.budget_detail_id = bdt.budget_detail_id AND
                              bdt.budget_version_id=g_budget_version_id);
Line: 4877

Select amount
From pqh_gms_excess
Where
     budget_period_id =g_period_amt_tab(inx).period_id
AND  project_id       =g_period_amt_tab(inx).project_id
AND  task_id          =g_period_amt_tab(inx).task_id
AND  award_id         =g_period_amt_tab(inx).award_id
AND  expenditure_type =g_period_amt_tab(inx).expenditure_type
AND  organization_id  =g_period_amt_tab(inx).organization_id;
Line: 4959

    DELETE FROM PQH_GMS_EXCESS
    WHERE     budget_period_id =g_period_amt_tab(p_inx).period_id
          AND project_id       =g_period_amt_tab(p_inx).project_id
          AND task_id          =g_period_amt_tab(p_inx).task_id
          AND award_id         =g_period_amt_tab(p_inx).award_id
          AND expenditure_type =g_period_amt_tab(p_inx).expenditure_type
          AND organization_id  =g_period_amt_tab(p_inx).organization_id;
Line: 4969

    UPDATE PQH_GMS_EXCESS
    SET amount = l_ptaeo_excess
    WHERE     budget_period_id =g_period_amt_tab(p_inx).period_id
          AND project_id       =g_period_amt_tab(p_inx).project_id
          AND task_id          =g_period_amt_tab(p_inx).task_id
          AND award_id         =g_period_amt_tab(p_inx).award_id
          AND expenditure_type =g_period_amt_tab(p_inx).expenditure_type
          AND organization_id  =g_period_amt_tab(p_inx).organization_id;
Line: 4988

  INSERT into pqh_gms_excess
   ( GMS_EXCESS_ID
    ,BUDGET_PERIOD_ID
    ,PROJECT_ID
    ,TASK_ID
    ,AWARD_ID
    ,EXPENDITURE_TYPE
    ,ORGANIZATION_ID
    ,AMOUNT
   )
  VALUES
   (
    pqh_gms_excess_s.nextval
    ,g_period_amt_tab(p_inx).period_id
    ,g_period_amt_tab(p_inx).project_id
    ,g_period_amt_tab(p_inx).task_id
    ,g_period_amt_tab(p_inx).award_id
    ,g_period_amt_tab(p_inx).expenditure_type
    ,g_period_amt_tab(p_inx).organization_id
    ,-l_ptaeo_amt
   );
Line: 5038

  This procedure will update or insert GMS records into pqh_gl_interface if there was no error for
  the current budget detail record i.e g_detail_error = N
  if g_detail_error = Y then update the pqh_budget_details record with gl_status = ERROR
*/
--
-- local variables
--
 l_proc                           varchar2(72) := g_package||'.populate_pqh_gms_interface';
Line: 5060

 Select COUNT(*)
 From pqh_gl_interface
 Where budget_version_id  = g_budget_version_id
   AND budget_detail_id   = p_budget_detail_id
   AND period_name        = p_period_name
   AND posting_type_cd    = 'BUDGET'
   AND project_id	  = p_project_id
   AND task_id		  = p_task_id
   AND award_id		  = p_award_id
   AND expenditure_type	  = p_expenditure_type
   AND organization_id	  = p_organization_id
   AND NVL(adjustment_flag,'N') = 'N'
   AND status IS NOT NULL
   AND posting_date IS NOT NULL;
Line: 5077

Select
hr_general.decode_shared_type(budget_unit1_id) UOM1,
hr_general.decode_shared_type(budget_unit2_id) UOM2,
hr_general.decode_shared_type(budget_unit3_id) UOM3
From
pqh_budgets
Where budget_id=g_budget_id;
Line: 5122

       update_pqh_gms_interface
              (
               p_budget_detail_id  => p_budget_detail_id,
               p_period_name       => g_period_amt_tab(i).period_name,
               p_project_id        => g_period_amt_tab(i).project_id,
	       p_task_id	   => g_period_amt_tab(i).task_id,
	       p_award_id	   => g_period_amt_tab(i).award_id,
	       p_expenditure_type  => g_period_amt_tab(i).expenditure_type,
               p_organization_id   => g_period_amt_tab(i).organization_id,
               p_amount            => l_amount
              );
Line: 5135

       insert_pqh_gms_interface
                     (
                      p_budget_detail_id  => p_budget_detail_id,
                      p_period_name       => g_period_amt_tab(i).period_name,
                      p_project_id        => g_period_amt_tab(i).project_id,
       	              p_task_id	          => g_period_amt_tab(i).task_id,
       	              p_award_id	  => g_period_amt_tab(i).award_id,
       	              p_expenditure_type  => g_period_amt_tab(i).expenditure_type,
                      p_organization_id   => g_period_amt_tab(i).organization_id,
                      p_amount            => l_amount
              );
Line: 5148

      END IF; -- Insert only GMS records
Line: 5152

      UPDATE pqh_budget_details
         SET gl_status = ''
       WHERE budget_detail_id = p_budget_detail_id;
Line: 5161

      UPDATE pqh_budget_details
         SET gl_status = 'ERROR'
       WHERE budget_detail_id = p_budget_detail_id;
Line: 5179

PROCEDURE insert_pqh_gms_interface
(
 p_budget_detail_id  IN pqh_gl_interface.budget_detail_id%TYPE,
 p_period_name       IN varchar2,
 p_project_id        IN pqh_gl_interface.project_id%TYPE,
 p_task_id	     IN pqh_gl_interface.task_id%TYPE,
 p_award_id	     IN pqh_gl_interface.award_id%TYPE,
 p_expenditure_type  IN pqh_gl_interface.expenditure_type%TYPE,
 p_organization_id   IN pqh_gl_interface.organization_id%TYPE,
 p_amount            IN pqh_gl_interface.amount_dr%TYPE
) IS
 /*
  This procedure will insert record into pqh_gl_interface
  If the same UOM is repeated more then once then we would update the unposted txn.
 */
 --
-- local variables
--
 l_proc                         varchar2(72) := g_package||'.insert_pqh_gms_interface';
Line: 5201

 Select COUNT(*)
 From   pqh_gl_interface
 Where budget_version_id        = g_budget_version_id
   AND budget_detail_id         = p_budget_detail_id
   AND p_period_name            = p_period_name
   AND posting_type_cd          = 'BUDGET'
   AND project_id               = p_project_id
   AND task_id	   	        = p_task_id
   AND award_id	   	        = p_award_id
   AND expenditure_type	        = p_expenditure_type
   AND organization_id 	        = p_organization_id
   AND NVL(adjustment_flag,'N') = 'N'
   AND status IS NULL
   AND posting_date IS NULL;
Line: 5225

  hr_utility.set_location('l_count in Insert pqh_gl_interface : '||l_count,10);
Line: 5230

    UPDATE pqh_gl_interface
       SET AMOUNT_DR                = NVL(AMOUNT_DR,0) + NVL(p_amount,0)
     WHERE budget_version_id        = g_budget_version_id
       AND budget_detail_id         = p_budget_detail_id
       AND p_period_name            = p_period_name
       AND posting_type_cd          = 'BUDGET'
       AND project_id               = p_project_id
       AND task_id	   	    = p_task_id
       AND award_id	   	    = p_award_id
       AND expenditure_type	    = p_expenditure_type
       AND organization_id 	    = p_organization_id
       AND NVL(adjustment_flag,'N') = 'N'
       AND status IS NULL
       AND posting_date IS NULL;
Line: 5248

     INSERT INTO pqh_gl_interface
     (
       gl_interface_id,
       budget_version_id,
       budget_detail_id,
       period_name,
       project_id,
       task_id,
       award_id,
       expenditure_type,
       organization_id,
       amount_dr,
       amount_cr,
       currency_code,
       status,
       adjustment_flag,
       posting_date,
       posting_type_cd
     )
     VALUES
     (
       pqh_gl_interface_s.nextval,
       g_budget_version_id,
       p_budget_detail_id,
       p_period_name,
       p_project_id,
       p_task_id,
       p_award_id,
       p_expenditure_type,
       p_organization_id,
       NVL(p_amount,0),
       0,
       g_bgt_currency_code,
       null,
       null,
       null,
       'BUDGET'
     );
Line: 5298

END insert_pqh_gms_interface;
Line: 5301

PROCEDURE update_pqh_gms_interface
(
 p_budget_detail_id  IN pqh_gl_interface.budget_detail_id%TYPE,
 p_period_name       IN varchar2,
 p_project_id        IN pqh_gl_interface.project_id%TYPE,
 p_task_id	     IN pqh_gl_interface.task_id%TYPE,
 p_award_id	     IN pqh_gl_interface.award_id%TYPE,
 p_expenditure_type  IN pqh_gl_interface.expenditure_type%TYPE,
 p_organization_id   IN pqh_gl_interface.organization_id%TYPE,
 p_amount            IN pqh_gl_interface.amount_dr%TYPE
) IS
 /*
  This procedure will update pqh_gl_interface and create a adjustment record
 */
 --
-- local variables
--
 l_proc                         varchar2(72) := g_package||'.update_pqh_gms_interface';
Line: 5326

 SELECT *
  FROM pqh_gl_interface
 WHERE budget_version_id        = g_budget_version_id
   AND budget_detail_id         = p_budget_detail_id
   AND period_name              = p_period_name
   AND posting_type_cd          = 'BUDGET'
   AND project_id               = p_project_id
   AND task_id	   	        = p_task_id
   AND award_id	   	        = p_award_id
   AND expenditure_type	        = p_expenditure_type
   AND organization_id 	        = p_organization_id
   AND NVL(adjustment_flag,'N') = 'N'
   AND status IS NOT NULL
   AND posting_date IS NOT NULL
  FOR UPDATE of amount_dr;
Line: 5360

     UPDATE pqh_gl_interface
       SET amount_dr = NVL(p_amount,0)
      WHERE CURRENT OF csr_pqh_gms_interface;
Line: 5369

       INSERT INTO pqh_gl_interface
       (
         gl_interface_id,
         budget_version_id,
         budget_detail_id,
         period_name,
         project_id,
	 task_id,
	 award_id,
	 expenditure_type,
         organization_id,
         amount_dr,
         amount_cr,
         currency_code,
         status,
         adjustment_flag,
         posting_date,
         posting_type_cd
       )
       VALUES
       (
         pqh_gl_interface_s.nextval,
         g_budget_version_id,
         p_budget_detail_id,
         p_period_name,
         p_project_id,
	 p_task_id,
	 p_award_id,
	 p_expenditure_type,
         p_organization_id,
         NVL(l_amount_dr,0),
         NVL(l_amount_cr,0),
         g_bgt_currency_code,
         null,
         'Y',
         null,
         'BUDGET'
       );
Line: 5408

     END IF; -- create i.e insert a adjustment record ONLY if l_amount_diff <> 0
Line: 5419

END update_pqh_gms_interface;
Line: 5423

SELECT substr(l.description, 1, 240 ) meaning
  FROM pa_lookups l
 WHERE l.lookup_type in ('TRANSACTION REJECTION REASON','FC_RESULT_CODE',
                         'COST DIST REJECTION CODE','INVOICE_CURRENCY',
                         'TRANSACTION USER REJ REASON')
   AND l.lookup_code = p_rejection_code
UNION all
SELECT message_text
  FROM fnd_new_messages fnd
 WHERE language_code    = userenv('lang')
   AND fnd.message_name = p_rejection_code
   AND application_id   = 275; -- PA
Line: 5453

In case of failure the status in pqh_gl_interface is updated to error
*/
--
-- Cursor to get records rejected by import process
--
CURSOR gms_tie_back_reject_cur IS
SELECT
 nvl(transaction_rejection_code,'P') rejection_code,
 orig_transaction_reference,
 transaction_status_code
FROM   pa_transaction_interface_all
WHERE  transaction_source = 'GMSEPQHBC'
  AND  batch_name = p_gms_batch_name
  AND  transaction_status_code in ('R', 'PI', 'PR', 'PO');
Line: 5483

 SELECT
  count(*)  into l_cnt
 FROM  pa_transaction_interface_all
 WHERE transaction_source = 'GMSEPQHBC'
   And batch_name = p_gms_batch_name
   And transaction_status_code in ('P', 'I');
Line: 5520

   UPDATE pqh_gl_interface
     SET status='ERROR',posting_date=sysdate
   WHERE period_name      =g_gms_import_tab(l_int_id).period_name And
         project_id       =g_gms_import_tab(l_int_id).project_id And
         task_id          =g_gms_import_tab(l_int_id).task_id And
         award_id         =g_gms_import_tab(l_int_id).award_id And
         expenditure_type =g_gms_import_tab(l_int_id).expenditure_type And
         organization_id  =g_gms_import_tab(l_int_id).organization_id;
Line: 5549

 UPDATE pqh_budget_details
  SET gl_status = 'ERROR'
 Where budget_detail_id in (select budget_detail_id from pqh_gl_interface where
                            budget_version_id=g_budget_version_id
                            And cost_allocation_keyflex_id is null
                            And status='ERROR'
                           );
Line: 5595

 DELETE pa_transaction_interface_all
 WHERE  batch_name = p_gms_batch_name
    And transaction_source = 'GMSEPQHBC';
Line: 5599

 hr_utility.set_location('Deleted pa_transaction_interface_all:',20);
Line: 5601

 DELETE gms_transaction_interface_all
 WHERE  batch_name = p_gms_batch_name
    And transaction_source = 'GMSEPQHBC';
Line: 5605

 hr_utility.set_location('Deleted gms_transaction_interface_all:',30);
Line: 5646

 Select
  'PQH'||to_char(pqh_gms_batch_name_s.nextval) INTO p_gms_batch_name
 From  dual;
Line: 5658

  Select pa_txn_interface_s.nextval
         INTO l_txn_interface_id
  From dual;
Line: 5664

  INSERT INTO PA_TRANSACTION_INTERFACE_ALL
  (
    TXN_INTERFACE_ID
   ,TRANSACTION_SOURCE
   ,BATCH_NAME
   ,EXPENDITURE_ENDING_DATE
   ,ORGANIZATION_NAME
   ,EXPENDITURE_ITEM_DATE
   ,PROJECT_NUMBER
   ,TASK_NUMBER
   ,EXPENDITURE_TYPE
   ,QUANTITY
   ,TRANSACTION_STATUS_CODE
   ,ORIG_TRANSACTION_REFERENCE
   ,ORG_ID
   ,DENOM_CURRENCY_CODE
   ,DENOM_RAW_COST
  )
  VALUES
  (
    l_txn_interface_id
   ,g_gms_import_tab(cnt).TRANSACTION_SOURCE
   ,p_gms_batch_name
   ,g_gms_import_tab(cnt).EXPENDITURE_ENDING_DATE
   ,g_gms_import_tab(cnt).ORGANIZATION_NAME
   ,g_gms_import_tab(cnt).EXPENDITURE_ITEM_DATE
   ,g_gms_import_tab(cnt).PROJECT_NUMBER
   ,g_gms_import_tab(cnt).TASK_NUMBER
   ,g_gms_import_tab(cnt).EXPENDITURE_TYPE
   ,g_gms_import_tab(cnt).QUANTITY
   ,'P'
   ,g_gms_import_tab(cnt).ORIG_TRANSACTION_REFERENCE
   ,g_gms_import_tab(cnt).ORG_ID
   ,g_gms_import_tab(cnt).DENOM_CURRENCY_CODE
   ,g_gms_import_tab(cnt).amount
  );
Line: 5806

Select business_group_id
From pqh_budgets
Where budget_id=g_budget_id;
Line: 5811

Select transaction_source
From   pa_transaction_sources
Where  transaction_source = 'GMSEPQHBC';
Line: 5816

Select period_name,project_id,award_id,task_id,
       expenditure_type,organization_id,
       currency_code,
       SUM(NVL(amount_dr,0))  amount_dr,
       SUM(NVL(amount_cr,0))  amount_cr
From   pqh_gl_interface
Where  budget_version_id        = g_budget_version_id
   AND posting_type_cd          = 'BUDGET'
   AND status IS NULL
   AND posting_date IS NULL
   AND cost_allocation_keyflex_id IS NULL
   group by
   period_name,project_id,award_id,task_id,
   expenditure_type,organization_id,currency_code;
Line: 5833

Select name
From   hr_organization_units
Where  organization_id   = p_organization_id
  AND  business_group_id = l_bg_id;
Line: 5839

Select segment1,org_id
From   pa_projects_all
Where  project_id = p_project_id;
Line: 5845

Select task_number
From   pa_tasks
Where  task_id = p_task_id;
Line: 5935

   select pqh_gms_orig_txn_reference_s.nextval
   into   ref_cnt
   from   dual;
Line: 6019

          pqh_process_batch_log.insert_log
            (
            p_message_type_cd    =>  'ERROR',
            p_message_text       =>  fnd_message.get
            );
Line: 6055

  This procedure Inserts in gl_bc_packets , commits so that the data is available
  for the autonomous funds checker and runs funds checker returns as argument funds
  checker return code and success flag
*/
--
-- local variables
--
 l_proc                       varchar2(72) := g_package||'.ins_gl_bc_run_fund_check';
Line: 6075

   select s.audsid,  s.serial#
   into l_session_id, l_serial_id
   from v$session s, v$process p
   where s.paddr = p.addr
   and   s.audsid = USERENV('SESSIONID');
Line: 6084

   INSERT INTO  gl_bc_packets
      (packet_id,
       ledger_id,
       je_source_name,
       je_category_name,
       code_combination_id,
       actual_flag,
       period_name,
       period_year,
       period_num,
       quarter_num,
       currency_code,
       status_code,
       last_update_date,
       last_updated_by,
       budget_version_id,
       entered_dr,
       entered_cr,
       accounted_dr,
       accounted_cr,
       reference1,
       reference2,
       -- Added these three columns for Bug 6769905 fix,  only for R12
       SESSION_ID,
       SERIAL_ID,
       APPLICATION_ID
       )
    VALUES
      (p_packet_id,
       g_set_of_books_id,
       g_user_je_source_name,
       g_user_je_category_name,
       p_code_combination_id,
       'B',
       p_period_name,
       p_period_year,
       p_period_num,
       p_quarter_num,
       p_currency_code,
       'P',
       sysdate,
       8302,
       g_gl_budget_version_id,
       p_entered_dr,
       p_entered_cr,
       p_accounted_dr,
       p_accounted_cr,
       g_budget_version_id,
       p_cost_allocation_keyflex_id,
        -- Added these three columns for Bug 6769905 fix,  only for R12
       l_session_id,
       l_serial_id,
       l_application_id);