Wednesday, 1 September 2021

Script to Update Oracle Apps R12 User Password

 DECLARE

    v_user_name    VARCHAR2 (100) := '<USER_NAME>';
    v_new_password VARCHAR2 (100) := '<NEW_PASSWORD>';
    v_status       BOOLEAN := NULL;
BEGIN
    v_status := fnd_user_pkg.Changepassword (v_user_name, v_new_password);
    COMMIT;
    dbms_output.Put_line ('Password is changed successfully for the user '|| v_user_name);
EXCEPTION
    WHEN OTHERS THEN
      dbms_output.Put_line (
'Error encountered while setting new password to the user and the error is '|| SQLERRM);
END; 

Monday, 16 August 2021

Query for operating unit and inventory organization in Oracle Apps R12

 SELECT ou.organization_id                                   OU_ID,

       ou.name                                              ou_name,
       ood.organization_id                                  io_id,
       ood.organization_code                                io_code,
       ood.organization_name                                io_name,
       org_information1                                     SOB_id,
       sob.name                                             sob_name,
       --hr1.ATTRIBUTE30 BUSINESS_LINE,
       (SELECT gcc.segment1
        FROM   mtl_parameters mp,
               gl_code_combinations_kfv gcc
        WHERE  mp.material_account = gcc.code_combination_id
               AND mp.organization_id = ood.organization_id)IO_SEG1,
       (SELECT gcc.segment1
        FROM   ap_system_parameters_all ap,
               gl_code_combinations_kfv gcc
        WHERE  ap.accts_pay_code_combination_id = gcc.code_combination_id
               AND ap.org_id = ou.organization_id)          OU_SEG1,
       (SELECT Listagg(b.registration_number, ', ')
                 within GROUP (ORDER BY b.registration_number) GSTIN
        FROM   jai_party_regs a,
               jai_party_reg_lines b
        WHERE  party_type_code = 'IO'
               AND a.party_reg_id = b.party_reg_id
               AND b.registration_type_code = 'GST'
               AND b.effective_to IS NULL
               AND b.regime_id = 10001
               AND a.party_id = ood.organization_id
        GROUP  BY party_id)                                 GSTIN
FROM   org_organization_definitions ood,
       hr_operating_units ou,
       hr_organization_information_v hr,
       gl_sets_of_books sob,
       hr_all_organization_units hr1
WHERE  hr.org_information_context = 'Accounting Information'
       AND hr.organization_id = ood.organization_id
       AND ood.operating_unit = ou.organization_id
       AND ood.organization_id = hr1.organization_id
       AND To_char(sob.set_of_books_id) = hr.org_information1
       AND ood.disable_date IS NULL; 

Applied Receipts Register Query (Query to find Receipt applied against which transaction) in Oracle Apps R12

SELECT a.cash_receipt_id,
       (SELECT gcc.segment1
        FROM   ap_system_parameters_all ap,
               gl_code_combinations_kfv gcc,
               hr_operating_units ou
        WHERE  ap.accts_pay_code_combination_id = gcc.code_combination_id
               AND ap.org_id = ou.organization_id
               AND ou.organization_id = a.org_id)        unit_code,
       e.name                                            org_name,
       d.customer_name,
       a3.bank_account_name,
       a3.bank_account_num,
       a.trx_number                                      receipt_number,
       a.trx_date                                        receipt_date,
       a.amount_due_original * Nvl (c.exchange_rate, 1)  receipt_amt,
       a.amount_applied * Nvl (c.exchange_rate, 1)       amount_applied,
       a.amount_due_remaining * Nvl (c.exchange_rate, 1) remaining_amount,
       b.amount_applied * Nvl (c.exchange_rate, 1)       inv_amt_applied,
       -- A.AMOUNT_ADJUSTED, A.AMOUNT_CREDITED,
       c.trx_number                                      invoice_number,
       e1.name                                           inv_type,
       c.trx_date                                        invoice_date,
       b.apply_date,
       b.gl_date
FROM   ar_payment_schedules_all a,
       ar_receivable_applications_all b,
       ra_customer_trx_all c,
       ar_customers d,
       hr_operating_units e,
       ra_cust_trx_types_all e1,
       ar_cash_receipts_all a1,
       ce_bank_acct_uses_all a2,
       ce_bank_accounts a3
WHERE  a.cash_receipt_id = b.cash_receipt_id
       AND a.cash_receipt_id = a1.cash_receipt_id
       AND a1.remit_bank_acct_use_id = a2.bank_acct_use_id
       AND a2.bank_account_id = a3.bank_account_id
       AND b.applied_customer_trx_id = c.customer_trx_id(+)
       AND a.customer_id = d.customer_id(+)
       AND a.org_id = e.organization_id
       AND c.cust_trx_type_id = e1.cust_trx_type_id
       AND c.org_id = e1.org_id
       AND A.trx_date >= To_date(:p_from_date)
       AND A.trx_date < To_date(:p_to_date) + 1
       AND a.class = 'PMT'
       --INV->Invoice; DM->Memo; CM->Credit Memo; CB->Chargeback; PMT->receipt; BR->Bills Receivable
       AND display = 'Y'
--     AND c.trx_number = '21*******941'
ORDER  BY a.org_id,
          a.trx_date,
          a.trx_number;


(OR)


SELECT F.customer_trx_id,
       D.source_id_int_1,
       d.entity_code,
       f.bill_to_customer_id,
       d.transaction_number,
       (SELECT x.name FROM   apps.ra_terms WHERE  x.term_id = f.term_id)
       term_name,
       CASE
         WHEN d.entity_code = 'RECEIPTS' THEN (SELECT X.receipt_date
                                               FROM
         apps.ar_cash_receipts_all X
                                               WHERE
         X.cash_receipt_id = D.source_id_int_1)
       END
       RECEIPT_DATE,
       (SELECT X.amount * Nvl(X.exchange_rate, 1)
        FROM   apps.ar_cash_receipts_all X
        WHERE  X.cash_receipt_id = D.source_id_int_1)
       RECEIPT_AMOUNT,
       a.accounting_class_code,
       b.segment1
       unit_code,
       (SELECT customer_name
        FROM   apps.ar_customers
        WHERE  customer_id = f.bill_to_customer_id)
       customer_name,
       g.name
       org_name,--e.APPLIED_TO_SOURCE_ID_NUM_1,
       e.applied_to_entity_code,
       f.trx_number,
       (SELECT SUM(X.amount_due_original)
        FROM   apps.ar_payment_schedules_all X
        WHERE  X.customer_trx_id = F.customer_trx_id)
       INVOICE_AMOUNT,
       (SELECT Max(X.trx_date)
        FROM   apps.ar_payment_schedules_all X
        WHERE  X.customer_trx_id = F.customer_trx_id)
       INVOICE_DATE,
       Nvl((SELECT SUM(X.amount_applied * Nvl(Y.exchange_rate, 1))
            FROM   apps.ar_receivable_applications_all X,
                   apps.ar_cash_receipts_all Y
            WHERE  X.cash_receipt_id = Y.cash_receipt_id
                   AND X.applied_customer_trx_id = F.customer_trx_id
                   AND X.gl_date BETWEEN '01-Oct-2022' AND '31-Mar-2023'
                   AND X.cash_receipt_id = D.source_id_int_1
                   AND X.display = 'Y'), 0)
       APPLIED_AMOUNT,
       SUM(Nvl(e.unrounded_accounted_dr, 0) - Nvl(e.unrounded_accounted_cr, 0))
       amt
FROM   apps.xla_ae_lines a,
       apps.gl_code_combinations b,
       apps.xla_ae_headers c,
       xla.xla_transaction_entities d,
       apps.xla_distribution_links e,
       apps.ra_customer_trx_all f,
       apps.hr_operating_units g
WHERE  a.code_combination_id = b.code_combination_id
       AND a.ae_header_id = e.ae_header_id
       AND a.ae_line_num = e.ae_line_num
       AND a.application_id = e.application_id
       AND a.ae_header_id = c.ae_header_id
       AND a.application_id = c.application_id
       AND c.entity_id = d.entity_id
       AND d.security_id_int_1 = g.organization_id
       AND c.application_id = d.application_id
       AND e.applied_to_source_id_num_1 = f.customer_trx_id(+)
       AND a.ledger_id = :P_LEDGER_ID
       AND b.segment2 = '<COA_ACCOUNT_CODE>'
       --AND D.TRANSACTION_NUMBER='<------>'
       --and d.entity_code!='RECEIPTS'
       --and c.event_id=163694391
       AND a.accounting_date BETWEEN '01-Oct-2022' AND '31-Mar-2023'
GROUP  BY d.entity_code,
          b.segment1,
          f.bill_to_customer_id,
          e.applied_to_source_id_num_1,
          e.applied_to_entity_code,
          d.transaction_number,
          f.trx_number,
          a.accounting_class_code,
          g.name,
          F.customer_trx_id,
          D.source_id_int_1,
          f.term_id
ORDER  BY 4,2,7;