[Home] [Help]
PACKAGE BODY: APPS.INV_GLOBALS
Source
1 PACKAGE BODY INV_Globals AS
2 /* $Header: INVSGLBB.pls 120.1 2005/05/31 04:59:27 appldev $ */
3
4 -- Global constant holding the package name
5
6 G_PKG_NAME CONSTANT VARCHAR2(30) := 'INV_Globals';
7
8
9 -- Procedure Get_Entities_Tbl.
10 --
11 -- Used by generator to avoid overriding or duplicating existing
12 -- entity constants.
13 --
14 -- DO NOT REMOVE
15
16 PROCEDURE Get_Entities_Tbl
17 IS
18 I NUMBER:=0;
19 BEGIN
20
21 FND_API.g_entity_tbl.DELETE;
22
23 -- START GEN entities
24 I := I + 1;
25 FND_API.g_entity_tbl(I).name := 'ALL';
26 I := I + 1;
27 FND_API.g_entity_tbl(I).name := 'TROHDR';
28 I := I + 1;
29 FND_API.g_entity_tbl(I).name := 'TROLIN';
30 -- END GEN entities
31
32 END Get_Entities_Tbl;
33
34 Function Is_Issue_Xfr_Transaction
35 (p_transaction_action_id In Number) Return Boolean
36 Is
37 Begin
38 If p_transaction_action_id in (INV_GLOBALS.G_Action_Issue,
39 INV_GLOBALS.G_Action_Subxfr,
40 INV_GLOBALS.G_Action_Planxfr,
41 INV_GLOBALS.G_Action_Stgxfr,
42 INV_GLOBALS.G_Action_Orgxfr,
43 INV_GLOBALS.G_Action_IntransitShipment,
44 INV_GLOBALS.G_Action_AssyReturn,
45 INV_GLOBALS.g_action_negcompreturn,
46 INV_GLOBALS.G_Action_ownxfr)
47 then
48 Return TRUE;
49 Else
50 Return False;
51 End If;
52 End;
53
54 -- Initialize control record.
55 FUNCTION Init_Control_Rec
56 ( p_operation IN VARCHAR2
57 , p_control_rec IN Control_Rec_Type
58 )RETURN Control_Rec_Type
59 IS
60 l_control_rec Control_Rec_Type;
61 BEGIN
62
63 IF p_control_rec.controlled_operation THEN
64
65 RETURN p_control_rec;
66
67 ELSIF p_operation = G_OPR_NONE OR p_operation IS NULL THEN
68
69 l_control_rec.default_attributes:= FALSE;
70 l_control_rec.change_attributes := FALSE;
71 l_control_rec.validate_entity := FALSE;
72 l_control_rec.write_to_DB := FALSE;
73 l_control_rec.process := p_control_rec.process;
74 l_control_rec.process_entity := p_control_rec.process_entity;
75 l_control_rec.request_category := p_control_rec.request_category;
76 l_control_rec.request_name := p_control_rec.request_name;
77 l_control_rec.clear_api_cache := p_control_rec.clear_api_cache;
78 l_control_rec.clear_api_requests:= p_control_rec.clear_api_requests;
79
80 ELSIF p_operation = G_OPR_CREATE THEN
81
82 l_control_rec.default_attributes:= TRUE;
83 l_control_rec.change_attributes := FALSE;
84 l_control_rec.validate_entity := TRUE;
85 l_control_rec.write_to_DB := TRUE;
86 l_control_rec.process := TRUE;
87 l_control_rec.process_entity := p_control_rec.process_entity;
88 l_control_rec.clear_api_cache := TRUE;
89 l_control_rec.clear_api_requests:= TRUE;
90
91 ELSIF p_operation = G_OPR_UPDATE THEN
92
93 l_control_rec.default_attributes:= FALSE;
94 l_control_rec.change_attributes := TRUE;
95 l_control_rec.validate_entity := TRUE;
96 l_control_rec.write_to_DB := TRUE;
97 l_control_rec.process := TRUE;
98 l_control_rec.process_entity := p_control_rec.process_entity;
99 l_control_rec.clear_api_cache := TRUE;
100 l_control_rec.clear_api_requests:= TRUE;
101
102 ELSIF p_operation = G_OPR_DELETE THEN
103
104 l_control_rec.default_attributes:= FALSE;
105 l_control_rec.change_attributes := FALSE;
106 l_control_rec.validate_entity := TRUE;
107 l_control_rec.write_to_DB := TRUE;
108 l_control_rec.process := TRUE;
109 l_control_rec.process_entity := p_control_rec.process_entity;
110 l_control_rec.clear_api_cache := TRUE;
111 l_control_rec.clear_api_requests:= TRUE;
112
113 ELSE
114
115 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
116 THEN
117 FND_MSG_PUB.Add_Exc_Msg
118 ( G_PKG_NAME
119 , 'Init_Control_Rec'
120 , 'Invalid operation'
121 );
122 END IF;
123
124 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
125
126 END IF;
127
128 RETURN l_control_rec;
129
130 END Init_Control_Rec;
131
132 -- Function Equal
133 -- Number comparison.
134
135 FUNCTION Equal
136 ( p_attribute1 IN NUMBER
137 , p_attribute2 IN NUMBER
138 )RETURN BOOLEAN
139 IS
140 BEGIN
141
142 RETURN ( p_attribute1 IS NULL AND p_attribute2 IS NULL ) OR
143 ( p_attribute1 IS NOT NULL AND
144 p_attribute2 IS NOT NULL AND
145 p_attribute1 = p_attribute2 );
146
147 END Equal;
148
149 -- Varchar2 comparison.
150
151 FUNCTION Equal
152 ( p_attribute1 IN VARCHAR2
153 , p_attribute2 IN VARCHAR2
154 )RETURN BOOLEAN
155 IS
156 BEGIN
157
158 RETURN ( p_attribute1 IS NULL AND p_attribute2 IS NULL ) OR
159 ( p_attribute1 IS NOT NULL AND
160 p_attribute2 IS NOT NULL AND
161 p_attribute1 = p_attribute2 );
162
163 END Equal;
164
165 -- Date comparison.
166
167 FUNCTION Equal
168 ( p_attribute1 IN DATE
169 , p_attribute2 IN DATE
170 )RETURN BOOLEAN
171 IS
172 BEGIN
173
174 RETURN ( p_attribute1 IS NULL AND p_attribute2 IS NULL ) OR
175 ( p_attribute1 IS NOT NULL AND
176 p_attribute2 IS NOT NULL AND
177 p_attribute1 = p_attribute2 );
178
179 END Equal;
180
181 PROCEDURE Set_Org_Id
182 ( p_org_id In NUMBER
183 )
184 IS
185 BEGIN
186 INV_GLOBALS.G_ORG_ID := p_org_id;
187
188 END Set_Org_Id;
189
190
191 PROCEDURE set_pjm_org_id(organization_id IN NUMBER)
192 IS
193 BEGIN
194 -- Setting the profile to the Passed organization
195 fnd_profile.put('MFG_ORGANIZATION_ID',organization_id);
196 END set_pjm_org_id;
197
198
199 FUNCTION NO_NEG_Allowed(p_restrict_flag IN Number,
200 p_neg_flag IN Number,
201 p_action IN Number)
202 return boolean IS
203 begin
204 if (p_restrict_flag = 2 or p_restrict_flag IS NULL) then
205 if (p_neg_flag = 2) THEN
206 if (p_action = 1 OR p_action = 2 or p_action = 3 or
207 p_action = 21 or p_action = 30 or p_action = 32) then
208 Return TRUE;
209 else
210 Return FALSE;
211 end if;
212 else
213 Return FALSE;
214 end if;
215 else
216 Return TRUE;
217 end if;
218 end No_Neg_Allowed;
219
220 Function Locator_Control
221 ( x_return_status OUT NOCOPY VARCHAR2,
222 x_msg_count OUT NOCOPY NUMBER,
223 x_msg_data OUT NOCOPY VARCHAR2,
224 p_org_control In NUMBER,
225 p_sub_control In NUMBER,
226 p_item_control In NUMBER,
227 p_Item_Loc_restrict In NUMBER,
228 p_Org_Neg_allowed In NUMBER,
229 p_Action In NUMBER
230 ) Return Number
231 IS
232
233 l_locator_control number;
234 l_invalid_loc_control_exc exception;
235
236 BEGIN
237
238 if (p_org_control = 1) then
239 l_locator_control := 1;
240 elsif (p_org_control = 2) then
241 l_locator_control := 2;
242 elsif (p_org_control = 3) then
243 l_locator_control := 3 ;
244 if no_neg_allowed(p_Item_Loc_restrict,p_Org_neg_Allowed,p_action)
245 then
246 l_locator_control := 2;
247 end if;
248 elsif (p_org_control = 4) then
249 if (p_sub_control = 1) then
250 l_locator_control := 1;
251 elsif (p_sub_control = 2) then
252 l_locator_control := 2;
253 elsif (p_sub_control = 3) then
254 l_locator_control := 3;
255 if no_neg_allowed(p_Item_Loc_restrict,p_Org_neg_Allowed,p_action)
256 then
257 l_locator_control := 2;
258 end if;
259 elsif (p_sub_control = 5) then
260 if (p_item_control = 1) then
261 l_locator_control := 1;
262 elsif (p_item_control = 2) then
263 l_locator_control := 2;
264 elsif (p_item_control = 3) then
265 l_locator_control := 3;
266 if no_neg_allowed(p_Item_Loc_restrict,p_Org_neg_Allowed,p_action)
267 then
268 l_locator_control := 2;
269 end if;
270 elsif (p_item_control IS NULL) then
271 l_locator_control := p_sub_control;
272 else
273 raise l_invalid_loc_control_exc;
274 end if;
275 else
276 raise l_invalid_loc_control_exc;
277 end if;
278 else
279 raise l_invalid_loc_control_exc;
280 end if;
281
282 return l_locator_control;
283
284 exception
285 when l_invalid_loc_control_exc then
286 fnd_message.set_name('INV','INV_INVALID_LOC_CONTROL');
287 fnd_msg_pub.add;
288
289 x_return_status := fnd_api.g_ret_sts_error ;
290 l_locator_control := -1 ;
291 return l_locator_control ;
292
293 when fnd_api.g_exc_error then
294 x_return_status := fnd_api.g_ret_sts_error ;
295 l_locator_control := -1 ;
296 return l_locator_control ;
297
298 when fnd_api.g_exc_unexpected_error then
299 x_return_status := fnd_api.g_ret_sts_unexp_error ;
300 l_locator_control := -1 ;
301 return l_locator_control ;
302
303 when others then
304 x_return_status := fnd_api.g_ret_sts_unexp_error ;
305
306 if (fnd_msg_pub.check_msg_level(
307 fnd_msg_pub.g_msg_lvl_unexp_error)) then
308 fnd_msg_pub.add_exc_msg(g_pkg_name, 'Locator_Control');
309 end if;
310
311 l_locator_control := -1 ;
312 return l_locator_control ;
313
314 END Locator_Control;
315
316 PROCEDURE GET_COA_LEDGER_ID
317 (X_return_status OUT NOCOPY VARCHAR2,
318 X_msg_data OUT NOCOPY VARCHAR2,
319 P_Account_Info_Context IN VARCHAR2,
320 P_ENTITY_CONTEXT IN VARCHAR2,
321 P_Org_Id IN NUMBER,
322 X_ACCOUNT_INFO1 OUT NOCOPY NUMBER,
323 X_ACCOUNT_INFO3 OUT NOCOPY NUMBER,
324 X_COA_ID OUT NOCOPY NUMBER
325 ) IS
326 l_msg_data VARCHAR2(2000);
327 l_legal_entity_id NUMBER;
328 BEGIN
329 IF P_ACCOUNT_INFO_CONTEXT NOT IN ('SOB','COA','BOTH') THEN
330 --
331 -- Exiting with Error Message if the Info Context is not Passed properly
332 --
333 X_return_status := 'E';
334 ELSIF P_ACCOUNT_INFO_CONTEXT = 'SOB' THEN
335 --
336 -- Get the Org_Information1 and Org_Information3 that stores LedgerID
337 -- for Inventory Organization and Operating Unit(depends on value
338 -- of P_ENTITY_CONTEXT) respectively.
339 --
340 BEGIN
341 SELECT to_number(org_information1), to_number(org_information3)
342 INTO X_ACCOUNT_INFO1, X_ACCOUNT_INFO3
343 FROM hr_organization_information
344 WHERE organization_id = P_Org_Id
345 AND org_information_context = P_ENTITY_CONTEXT;
346 EXCEPTION
347 WHEN NO_DATA_FOUND THEN
348 X_return_status := 'E';
349 END;
350 ELSIF P_ACCOUNT_INFO_CONTEXT IN ('COA','BOTH') THEN
351 BEGIN
352 --
353 -- Get the Org_Information1 and Org_Information3 that stores LedgerID
354 -- for Inventory Organization and Operating Unit(depends on value
355 -- of P_ENTITY_CONTEXT) respectively. Additionally also get chart_of_accounts.
356 --
357 SELECT to_number(HOI.org_information1), to_number(HOI.org_information3), gsob.chart_of_accounts_id
358 INTO X_ACCOUNT_INFO1, X_ACCOUNT_INFO3, X_COA_ID
359 FROM gl_sets_of_books gsob,
360 hr_organization_information HOI
361 WHERE HOI.organization_id = P_Org_Id
362 AND HOI.org_information_context = P_ENTITY_CONTEXT
363 AND gsob.set_of_books_id = DECODE(P_ENTITY_CONTEXT,
364 'Operating Unit Information',to_number(HOI.org_information3),
365 to_number(HOI.org_information1));
366 EXCEPTION
367 WHEN NO_DATA_FOUND THEN
368 X_return_status := 'E';
369 END;
370 END IF;
371 END GET_COA_LEDGER_ID;
372
373 PROCEDURE GET_LEDGER_INFO
374 (X_return_status OUT NOCOPY VARCHAR2,
375 X_msg_data OUT NOCOPY VARCHAR2,
376 P_Context_Type IN VARCHAR2,
377 P_Org_Id IN NUMBER,
378 X_SOB_ID OUT NOCOPY NUMBER,
379 X_COA_ID OUT NOCOPY NUMBER,
380 P_Account_Info_Context IN VARCHAR2 DEFAULT 'SOB'
381 ) IS
382 l_legal_entity_id NUMBER;
383 l_Account_Info1 NUMBER;
384 l_Account_Info3 NUMBER;
385 l_COA_Id NUMBER;
386
387 BEGIN
388 IF (p_context_type NOT IN ('Legal Entity Accounting',
389 'Operating Unit Information',
390 'Accounting Information')) THEN
391
392 --
393 -- Exiting with Error Message if the Info Context is not Passed properly
394 --
395 X_return_status := 'E';
396 ELSE
397 --
398 -- Call to the Private Procedure to the Accounting Information
399 -- and Chart of Accounts
400 --
401 GET_COA_LEDGER_ID(
402 X_return_status => X_return_status,
403 X_msg_data => X_msg_data,
404 P_Account_Info_Context => P_Account_Info_Context,
405 P_ENTITY_CONTEXT => P_Context_Type,
406 P_Org_Id => P_Org_Id,
407 X_ACCOUNT_INFO1 => l_Account_Info1,
408 X_ACCOUNT_INFO3 => l_Account_Info3,
409 X_COA_ID => l_COA_Id);
410 IF NVL(X_return_status,'S') = 'S' THEN
411 IF p_context_type IN ('Legal Entity Accounting',
412 'Accounting Information') THEN
413 --
414 -- Return l_Account_Info1 as SOB_ID if context is Legal Entity or Inventory Organization
415 --
416 X_SOB_ID := l_Account_Info1;
417 X_COA_ID := l_COA_Id;
418 ELSE
419 --
420 -- Return l_Account_Info3 as SOB_ID if context is Operating Unit
421 --
422 X_SOB_ID := l_Account_Info3;
423 X_COA_ID := l_COA_Id;
424 END IF;
425 END IF;
426 END IF;
427 END GET_LEDGER_INFO;
428
429 END INV_Globals;