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; 

No comments:

Post a Comment