DBA Data[Home] [Help]

PACKAGE BODY: APPS.ISC_MAINT_CURRENCY_PKG

Source


1 package body isc_maint_currency_pkg
2 /* $Header: iscmaintccyb.pls 120.0 2005/05/25 17:18:16 appldev noship $ */
3 as
4 
5   g_primary_global_ccy_code   varchar2(15);
6   g_secondary_global_ccy_code varchar2(15);
7   g_org_ccy_code              varchar2(15);
8 
9   g_resp_id number;
10   g_resp_appl_id number;
11   g_org varchar2(100);
12 
13 function get_org_currency
14 ( p_selected_org   in varchar2
15 ) return varchar2
16 is
17 
18   cursor c_one_org_currency(b_org_id number) is
19     select distinct
20       gsob.currency_code
21     from
22       hr_organization_information hoi
23     , gl_sets_of_books gsob
24     , mtl_parameters mp
25     where hoi.org_information_context  = 'Accounting Information'
26     and hoi.org_information1  = to_char(gsob.set_of_books_id)
27     and hoi.organization_id = mp.organization_id
28     and mp.organization_id = b_org_id
29     and mp.eam_enabled_flag = 'Y';
30 
31   cursor c_all_orgs_currency is
32     select distinct
33       gsob.currency_code
34     , count(distinct gsob.currency_code) over() currency_count
35     from
36       hr_organization_information hoi
37     , gl_sets_of_books gsob
38     , mtl_parameters mp
39     where hoi.org_information_context  = 'Accounting Information'
40     and hoi.org_information1  = to_char(gsob.set_of_books_id)
41     and hoi.organization_id = mp.organization_id
42     and
43         ( exists
44             ( select 1
45               from org_access o
46               where o.responsibility_id = fnd_global.resp_id
47               and o.resp_application_id = fnd_global.resp_appl_id
48               and o.organization_id = mp.organization_id ) or
49             ( not exists ( select 1
50                            from org_access ora
51                            where mp.organization_id = ora.organization_id
52                           )
53             )
54         )
55     and mp.eam_enabled_flag = 'Y';
56 
57   l_currency varchar(15);
58   l_currency_count number;
59   l_org_id number;
60 
61 begin
62 
63   if g_primary_global_ccy_code is null then
64 
65     g_primary_global_ccy_code := bis_common_parameters.get_currency_code;
66     g_secondary_global_ccy_code := bis_common_parameters.get_secondary_currency_code;
67 
68   end if;
69 
70   if nvl(g_resp_id,-5) <> fnd_global.resp_id or
71      nvl(g_resp_appl_id,-5) <> fnd_global.resp_appl_id or
72      nvl(g_org,'NULL') <> p_selected_org then
73 
74     g_resp_id := fnd_global.resp_id;
75     g_resp_appl_id := fnd_global.resp_appl_id;
76     g_org := p_selected_org;
77     g_org_ccy_code := 'FII_GLOBAL1';
78 
79     if p_selected_org = 'ALL' then
80 
81       open c_all_orgs_currency;
82       fetch c_all_orgs_currency into l_currency, l_currency_count;
83       close c_all_orgs_currency;
84 
85     else
86 
87       l_org_id := to_number(p_selected_org);
88 
89       open c_one_org_currency(l_org_id);
90       fetch c_one_org_currency into l_currency;
91       if c_one_org_currency%found then
92         l_currency_count := 1;
93       end if;
94       close c_one_org_currency;
95 
96     end if;
97 
98       if l_currency_count = 1 and
99          l_currency <> g_primary_global_ccy_code and
100          l_currency <> nvl(g_secondary_global_ccy_code,g_primary_global_ccy_code) then
101 
102         g_org_ccy_code := l_currency;
103 
104       end if;
105 
106   end if;
107 
108   return g_org_ccy_code;
109 
110 exception
111   when others then
112     return nvl(g_org_ccy_code,'FII_GLOBAL1');
113 
114 end get_org_currency;
115 
116 end isc_maint_currency_pkg;