DBA Data[Home] [Help]

PACKAGE BODY: APPS.QA_MOAC_PKG

Source


1 PACKAGE BODY QA_MOAC_PKG AS
2 /* $Header: qamoacb.pls 120.4 2006/05/22 22:02:08 shkalyan noship $ */
3 
4 -- Global Package Variable for storing Session Context
5 g_SESSION_ORG_ID org_organization_definitions.organization_id%TYPE;
6 g_SESSION_ACCESS_MODE VARCHAR2(1);
7 
8 -- Global Package variable for Application short name
9 c_APPL_SHORT_NAME CONSTANT VARCHAR2(2) := 'QA';
10 
11 
12 -- initialize the MOAC context
13 -- R12 Project MOAC 4637896 redesign.   p_ou_id is currently unused.
14 PROCEDURE init(p_ou_id NUMBER DEFAULT NULL) IS
15 BEGIN
16     mo_global.init(c_APPL_SHORT_NAME);
17 END init;
18 
19 
20 -- initialize the MOAC context to single MOAC  for given Inv Org
21 PROCEDURE init_single_ou(p_ou_id NUMBER) IS
22 BEGIN
23     -- call MO API to initialize the MOAC context
24     mo_global.init(c_APPL_SHORT_NAME);
25     mo_global.set_policy_context('S', p_ou_id);
26 
27 END init_single_ou;
28 
29 
30 -- Save existing MOAC context into a global package variable.
31 -- Useful in transaction scenario to save parent context;
32 -- init context to single;
33 -- then restoring parent context before returning.
34 PROCEDURE save_context IS
35 BEGIN
36     -- coming from a transaction, so required to
37     -- save the parent MOAC context
38     -- get the current org_id and access mode
39     -- and save it into session
40     g_SESSION_ORG_ID := mo_global.get_current_org_id;
41     g_SESSION_ACCESS_MODE := mo_global.get_access_mode;
42 
43 END save_context;
44 
45 
46 -- Restore the existing context used prior to returning
47 -- to parent transaction
48 PROCEDURE restore_context IS
49 BEGIN
50 
51     -- back to the transaction
52     -- set the context back to the original
53     mo_global.set_policy_context(g_SESSION_ACCESS_MODE, g_SESSION_ORG_ID);
54 
55 END restore_context;
56 
57 
58 -- Derive parent OU given an Inventory Organization ID.
59 FUNCTION derive_ou_id(p_organization_id NUMBER)
60     RETURN NUMBER IS
61 
62     -- Define cursor to get Operating Unit for Inventory Org
63     -- Bug 5196069. SQL Repository Fix SQL ID 17898437.
64     -- Removed usage of inv_organization_info_v and replaced with
65     -- call to base table hr_organization_information
66     -- to improve performance.
67     CURSOR c_org_id IS
68       SELECT to_number(org_information3)
69       FROM   hr_organization_information
70       WHERE  organization_id = p_organization_id
71       AND    org_information_context = 'Accounting Information';
72 
73 
74 /*
75     Bug 4958733. SQL Repository Fix SQL ID: 15007810
76     CURSOR c_org_id IS
77         SELECT operating_unit
78         FROM  inv_organization_info_v
79         WHERE organization_id = p_organization_id;
80 */
81 /*
82         SELECT operating_unit
83         FROM org_organization_definitions
84         WHERE organization_id = p_organization_id;
85 */
86 
87     l_org_id NUMBER;
88 
89 BEGIN
90 
91     OPEN c_org_id;
92     FETCH c_org_id INTO l_org_id;
93     CLOSE c_org_id;
94 
95     RETURN l_org_id;
96 
97 END derive_ou_id;
98 
99 
100 END QA_MOAC_PKG;