DBA Data[Home] [Help]

PACKAGE BODY: APPS.PSA_BC_XLA_PUB

Source


1 PACKAGE BODY PSA_BC_XLA_PUB AS
2 --$Header: psapbcxb.pls 120.6 2006/06/26 13:05:12 bnarang noship $
3 
4 G_PKG_NAME  CONSTANT  VARCHAR2(30)  :=  'PSA_BC_XLA_PUB';
5 
6 
7 ---------------------------------------------------------------------------
8 
9 --==========================================================================
10 --Logging Declarations
11 --==========================================================================
12 g_state_level NUMBER          :=    FND_LOG.LEVEL_STATEMENT;
13 g_proc_level  NUMBER          :=    FND_LOG.LEVEL_PROCEDURE;
14 g_event_level NUMBER          :=    FND_LOG.LEVEL_EVENT;
15 g_excep_level NUMBER          :=    FND_LOG.LEVEL_EXCEPTION;
16 g_error_level NUMBER          :=    FND_LOG.LEVEL_ERROR;
17 g_unexp_level NUMBER          :=    FND_LOG.LEVEL_UNEXPECTED;
18 g_log_level   CONSTANT NUMBER         := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
19 g_path_name   CONSTANT VARCHAR2(200)  := 'psa.plsql.psapbcxb.psa_bc_xla_pub';
20 g_log_enabled BOOLEAN := FALSE;
21 
22 --==========================================================================
23 -- declaring private constants
24 --==========================================================================
25 
26 C_YES                       CONSTANT VARCHAR2(1)  := 'Y'; -- yes flag
27 C_NO                        CONSTANT VARCHAR2(1)  := 'N'; -- no flag
28 C_FUNDS_CHECK               CONSTANT VARCHAR2(1)   := 'C';
29 C_FUNDS_RESERVE             CONSTANT VARCHAR2(1)   := 'R';
30 
31 
32 
33  -- /*============================================================================
34  -- API name     : Budgetary_Control
35  -- Type         : public
36  -- Pre-reqs     : Create events in psa_bc_xla_events_gt
37  -- Description  :
38  --                  This procedure calls private function which invokes the SLA online accounting engine.
39  --                    All the events in the PSA_BC_XLA_EVENTS_GT would be
40  --                    processed by accounitng engine.
41  --  Parameters  :
42  --  IN          :   p_api_version    IN NUMBER  Required
43  --                  p_init_msg_list  IN VARCHAR2 optional Default FND_API.G_FALSE
44  --                  p_commit         IN VARCHAR2 optional Default FND_API.G_FALSE
45  --                  p_application_id IN NUMBER  Required
46  --                  p_bc_mode        IN NUMBER optional Possible values:Check(C )
47  --                                               /Reserve(R)/partial(P)/Force pass(F)
48  --                  p_bc_override_flag VARCHAR2 optional Possible values: Y/N
49  --                  p_user_id        IN NUMBER optional
50  --                  p_user_resp_id   IN NUMBER optional
51  --
52  -- OUT          :   x_return_status  OUT VARCHAR2(1)
53  --                  x_msg_count      OUT NUMBER
54  --                  x_msg_data       OUT VARCHAR2(2000)
55  --                  x_status_code    OUT
56  --                  x_packet_id      OUT  NUMBER
57  -- Version      : Current Version 1.0
58  --                  Initial Version 1.0
59  --
60  --
61  --
62  --  Logic
63  --        - Validate the wf parameters
64  --        - Get the events to be processed
65  --        -  Call the SLA online accounting engine with required parameters
66  --         -  Return the Fund status/error
67  --
68  --  Notes:
69  --         Currently calling accounting eginge in document mode
70  --          After SLA API for bcpsa is available need to make neccessary changes
71  --
72  --  Modification History
73  --  Date         Author             Description of Change
74  --
75  -- *===========================================================================*/
76 
77 PROCEDURE Budgetary_Control
78    ( p_api_version               IN  NUMBER
79     ,p_init_msg_list             IN  VARCHAR2
80     ,x_return_status             OUT NOCOPY VARCHAR2
81     ,x_msg_count                 OUT NOCOPY NUMBER
82     ,x_msg_data                  OUT NOCOPY VARCHAR2
83     ,p_application_id	         IN  INTEGER
84     ,p_bc_mode                   IN  VARCHAR2
85     ,p_override_flag             IN  VARCHAR2
86     ,P_user_id                   IN  NUMBER
87     ,P_user_resp_id              IN  NUMBER
88     ,x_status_code                OUT NOCOPY VARCHAR2
89     ,x_Packet_ID                 OUT NOCOPY NUMBER
90    )
91 
92 
93 IS
94 l_api_name        VARCHAR2(240);
95 l_api_version     CONSTANT  NUMBER        :=  1.0;
96 
97 
98 BEGIN
99 
100  l_api_name :=  g_path_name || '.Budgetary_Control';
101  psa_utils.debug_other_string(g_state_level,l_api_name,'Begin of Procedure Budgetary_Control');
102  psa_utils.debug_other_string(g_state_level,l_api_name,'In parameters.. ');
103  psa_utils.debug_other_string(g_state_level,l_api_name,'API Version =  ' || p_api_version);
104  psa_utils.debug_other_string(g_state_level,l_api_name,'Application Id = '|| p_application_id);
105  psa_utils.debug_other_string(g_state_level,l_api_name,'Budgetary Control Mode = '|| p_bc_mode);
106  psa_utils.debug_other_string(g_state_level,l_api_name,'Override flag = '|| p_override_flag);
107  psa_utils.debug_other_string(g_state_level,l_api_name,'User Id = '|| P_user_id);
108  psa_utils.debug_other_string(g_state_level,l_api_name,'User Responsibility Id = '|| P_user_resp_id);
109 
110   IF (FND_API.to_boolean(NVl(p_init_msg_list,FND_API.G_FALSE))) THEN
111     FND_MSG_PUB.initialize;
112   END IF;
113 
114   psa_utils.debug_other_string(g_state_level,l_api_name,'Checking for API compatibility..');
115   --
116   --Standard call to check for call compatibility.
117   --
118   IF (NOT FND_API.compatible_api_call
119                  (p_current_version_number => l_api_version
120                  ,p_caller_version_number  => p_api_version
121                  ,p_api_name               => l_api_name
122                  ,p_pkg_name               => G_PKG_NAME))
123   THEN
124     RAISE FND_API.G_EXC_UNEXPECTED_ERROR ;
125   END IF;
126 
127 
128   --
129   --  Initialize global variables
130   --
131   x_return_status        := FND_API.G_RET_STS_SUCCESS;
132 
133   --
134   -- call the private function
135   --
136   psa_utils.debug_other_string(g_state_level,l_api_name,'Calling the Private API psa_bc_xla_pvt.Budgetary_control..');
137 
138   PSA_BC_XLA_PVT.Budgetary_control(p_init_msg_list  => NVl(p_init_msg_list,FND_API.G_FALSE)
139                                   ,x_return_status  => x_return_status
140                                   ,x_msg_count      => x_msg_count
141                                   ,x_msg_data       => x_msg_data
142                                   ,p_application_id	=> p_application_id
143                                   ,p_bc_mode        => NVL(p_bc_mode,'C')
144                                   ,p_override_flag  => NVL(p_override_flag,'N')
145                                   ,P_user_id        => p_user_id
146                                   ,P_user_resp_id   => P_user_resp_id
147                                   ,x_status_code    => x_status_code
148                                   ,x_Packet_ID      => x_Packet_ID );
149 
150 
151    psa_utils.debug_other_string(g_state_level,l_api_name,'Call to Private API PSA_BC_XLA_PVT.Budgetary_control successful')   ;
152 
153 EXCEPTION
154 
155 WHEN FND_API.G_EXC_ERROR THEN
156   psa_utils.debug_other_string(g_error_level,l_api_name,'EXCEPTION: '|| SQLERRM(sqlcode));
157   psa_utils.debug_other_string(g_error_level,l_api_name,'Error in Budgetary_control Procedure' );
158   x_return_status := FND_API.G_RET_STS_ERROR ;
159   FND_MSG_PUB.count_and_get(p_encoded => FND_API.G_FALSE
160                              ,p_count => x_msg_count
161                              ,p_data  => x_msg_data);
162 
163 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
164   psa_utils.debug_other_string(g_unexp_level,l_api_name,'ERROR: Unexpected Error in budgetary_control Procedure' );
165   x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
166   FND_MSG_PUB.count_and_get(p_encoded => FND_API.G_FALSE
167                              ,p_count => x_msg_count
168                            ,p_data  => x_msg_data);
169 
170 WHEN OTHERS THEN
171 
172   x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
173   IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_unexp_error) THEN
174     FND_MSG_PUB.add_exc_msg(G_PKG_NAME, l_api_name);
175   END IF;
176    psa_utils.debug_other_string(g_unexp_level,l_api_name,'EXCEPTION: '|| SQLERRM(sqlcode));
177    psa_utils.debug_other_string(g_unexp_level,l_api_name,'Error in budgetary_control Procedure' );
178    FND_MSG_PUB.count_and_get(p_encoded => FND_API.G_FALSE
179                              ,p_count => x_msg_count
180                              ,p_data  => x_msg_data);
181 
182 
183 END Budgetary_control;
184 
185 
186  /*============================================================================
187  -- API name     : get_sla_notupgraded_flag
188  -- Type         : public
189  -- Pre-reqs     : None
190  -- Description  : Returns Y/N depending on whether the distribution passed is notupgraded
191  --
192  --  Parameters  :
193  --  IN          :
194  --                  p_application_id 	IN NUMBER        Applied to Application ID
195  --                  p_entity_code	IN VARCHAR2      Applied to Entity code
196  --                  p_source_id_int_1	IN NUMBER        Applied to Header ID
197  --                  p_dist_link_type 	IN VARCHAR2      Applied to Dist Link Type
198  --                  p_distribution_id  IN NUMBER        Applied to Distribution ID
199  --
200  --  Returns     :   VARCHAR2 i.e., Y/N
201  --
202  --  Logic
203  --        - If the transaction was created in transaction tables after R12 upgrade,
204  --             return N
205  --        - Else
206  --             If the distribution was accounted in xla
207  --                 return N;
208  --             Else
209  --                 return Y;
210  --
211  --  Notes:
212  --         This is called from transaction objects and the return value is
213  --         populated into a column that will be mapped to Upgrade option acct attrib
214  --         in SLA.
215  --
216  --  Modification History
217  --  Date               Author             Description of Change
218  --  27-Oct-2005    Venkatesh N             Created
219  -- ===========================================================================*/
220 
221  -- /*============================================================================
222 FUNCTION get_sla_notupgraded_flag (p_application_id 	IN NUMBER,
223     				   p_entity_code	IN VARCHAR2,
224 				   p_source_id_int_1	IN NUMBER,
225                                    p_dist_link_type 	IN VARCHAR2,
226                                    p_distribution_id    IN NUMBER) RETURN VARCHAR2
227 IS
228    l_return_val           VARCHAR2(1);
229    l_path_name            VARCHAR2(500);
230 
231 BEGIN
232 
233    l_path_name := g_path_name || '.get_sla_notupgraded_flag';
234    psa_utils.debug_other_string(g_state_level,l_path_name,'BEGIN of ' || l_path_name);
235 
236    l_return_val := PSA_BC_XLA_PVT.get_sla_notupgraded_flag (p_application_id ,
237     						                                p_entity_code,
238    						                                    p_source_id_int_1,
239                         	        	                    p_dist_link_type,
240                                 		                    p_distribution_id);
241 
242    psa_utils.debug_other_string(g_state_level,l_path_name,'END of ' || l_path_name);
243 
244   RETURN l_return_val;
245 EXCEPTION
246 	WHEN others THEN
247         psa_utils.debug_other_string(g_error_level,l_path_name,'EXCEPTION: '|| SQLERRM(sqlcode));
248         psa_utils.debug_other_string(g_error_level,l_path_name,'Error in get_sla_notupgraded_flag function' );
249         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
250 END get_sla_notupgraded_flag;
251 
252 BEGIN
253          g_log_enabled    := fnd_log.test
254                             (log_level  => FND_LOG.G_CURRENT_RUNTIME_LEVEL
255                             ,MODULE     => g_path_name);
256 END psa_bc_xla_pub;