Thursday, June 27, 2013

Finding ORG_ID and Operating UNIT detail based MO:Operating UNIT profile



=> Query to Find Operating Unit and Org_id details

SELECT * FROM fnd_profile_options_vl fpo,
fnd_profile_option_values fpov,
applsys.fnd_responsibility_tl fr,
hr_operating_units hou
WHERE profile_option_name = 'ORG_ID'
AND fpo.profile_option_id = fpov.profile_option_id
AND fpov.level_value = fr.responsibility_id
AND hou.organization_id = fpov.profile_option_value
AND fr.responsibility_name ='IBE_CUSTOMER'
AND fr.language='US';


=> How to get ORG ID and Organization Details:  


SELECT fr.responsibility_name, fpov.profile_option_value orgid, NAME org_name
FROM fnd_profile_options_vl fpo,
fnd_profile_option_values fpov,
applsys.fnd_responsibility_tl fr,
hr_operating_units hou
WHERE UPPER (fpo.user_profile_option_name) LIKE UPPER ('MO%OPERATIN%')
AND profile_option_name = 'ORG_ID'
AND fpo.profile_option_id = fpov.profile_option_id
AND fpov.level_value = fr.responsibility_id
AND hou.organization_id = fpov.profile_option_value




=>Finding org id based on Organization name:

select * from hr_operating_units where name ='Vision Operation'

=>Finding List of SHIP_TO and BILL_TO address based on customer  

CURSOR get_party_bill_to_cur
      IS
         SELECT   hps.party_site_id                                
   FROM   hz_party_sites hps,
                  hz_cust_accounts hca,
                  hz_parties hp,
                  hz_cust_acct_sites_all hcas,
                  hz_cust_site_uses_all hcsu
          WHERE       hps.party_id = hp.party_id
                  AND hca.cust_account_id = hcas.cust_account_id
                  AND hps.party_site_id = hcas.party_site_id
                  AND hcsu.cust_acct_site_id = hcas.cust_acct_site_id
                  AND hcsu.site_use_code = 'BILL_TO'
                  AND hcsu.primary_flag = 'Y'
                  AND hcsu.status = 'A'
                  AND hca.cust_account_id =P_cust_acct_id
                  AND hcas.org_id = p_org_id;
-------------------------------------------------------------------------------
      CURSOR get_party_ship_to_cur
      IS
         SELECT   hps.party_site_id                               
           FROM   hz_party_sites hps,
                  hz_cust_accounts hca,
                  hz_parties hp,
                  hz_cust_acct_sites_all hcas,
                  hz_cust_site_uses_all hcsu
          WHERE       hps.party_id = hp.party_id
                  AND hca.cust_account_id = hcas.cust_account_id
                  AND hps.party_site_id = hcas.party_site_id
                  AND hcsu.cust_acct_site_id = hcas.cust_acct_site_id
                  AND hcsu.site_use_code = 'SHIP_TO'
                  --AND hcsu.primary_flag = 'Y'
                  AND hcsu.status = 'A'
                  AND hca.cust_account_id =P_cust_acct_id
                  AND hcas.org_id = p_org_id;


No comments:

Post a Comment