[Home] [Help]
PACKAGE BODY: APPS.OE_HOLDS_PVT
Source
1 PACKAGE BODY OE_Holds_Pvt AS
2 /* $Header: OEXVHLDB.pls 120.47.12020000.5 2013/04/10 09:04:18 spothula ship $ */
3
4 -- Global constant holding the package name
5
6 G_PKG_NAME CONSTANT VARCHAR2(30) := 'OE_Holds_Pvt';
7
8
9 Procedure Release_Hold_Source (
10 p_hold_source_rec IN OE_HOLDS_PVT.Hold_source_Rec_Type,
11 p_hold_release_rec IN OE_HOLDS_PVT.hold_release_rec_type,
12 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
13 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
14 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
15 );
16
17
18 /****************************/
19 /* entity_code_value */
20 /****************************/
21 /*
22 *
23 */
24 function entity_code_value (
25 p_hold_entity_code IN OE_HOLD_SOURCES_ALL.HOLD_ENTITY_CODE%TYPE
26 )
27 return VARCHAR2
28 IS
29 l_hold_entity_code_value VARCHAR2 (100) := NULL;
30
31
32 CURSOR hold_entity_code_value IS
33 select meaning
34 from oe_lookups
35 where LOOKUP_TYPE = 'HOLD_ENTITY_DESC'
36 and LOOKUP_CODE = p_hold_entity_code
37 and rownum = 1;
38
39 BEGIN
40
41 OPEN hold_entity_code_value;
42 FETCH hold_entity_code_value
43 INTO l_hold_entity_code_value;
44 CLOSE hold_entity_code_value;
45
46 return l_hold_entity_code_value;
47
48 END entity_code_value;
49 /*********************/
50 /*8477694*/
51 function check_system_holds(
52 p_hold_id IN NUMBER,
53 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
54 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
55 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
56 )
57 RETURN varchar2
58 IS
59 l_authorized_or_not varchar2(1) := 'Y';
60 l_return_status Varchar2(1) := FND_API.G_RET_STS_SUCCESS;
61 BEGIN
62
63 x_return_status := l_return_status;
64 x_msg_count := 0;
65 x_msg_data := NULL;
66
67
68 /* 7576948: IR ISO Change Management project Start */
69
70 -- In the below IF check for system holds, Hold_id 17 is added
71 -- for IR ISO change management project. This is a seeded system
72 -- hold, responsible for applying and release IR ISO hold, which
73 -- can be applied/released only by the Purchasing product, while
74 -- internal requisition / requisition line gets changed by the
75 -- requesting organization user. The judiciously application
76 -- and releasing of this hold will be done by Purchasing APIs.
77 -- OM has no APIs for calling the direct Application or Releasing
78 -- of this seeded system hold for any business flow other than
79 -- Internal Sales Order flow.
80 --
81 -- The application of this seeded hold can be done via OM API
82 -- OE_Internal_Requisition_Pvt.Apply_Hold_for_IReq, while it can
83 -- be released via OE_Internal_Requisition_Pvt.Release_Hold_for_IReq
84 -- The call to both these APIs will be done from Purchasing APIs only.
85 --
86 -- For details on IR ISO CMS project, please refer to FOL >
87 -- OM Development > OM GM > 12.1.1 > TDD > IR_ISO_CMS_TDD.doc
88
89 IF p_hold_id in (13,14,15,17) THEN
90
91 /* ============================= */
92 /* IR ISO Change Management Ends */
93
94 oe_debug_pub.add('renga: hold not authorized - ');
95 l_authorized_or_not := 'N';
96
97 END IF;
98
99 return l_authorized_or_not;
100
101 END check_system_holds;
102 /*8477694*/
103
104
105
106
107 /*=======================*/
108 /* Private procedures */
109 /*=======================*/
110 function get_user_id
111 return number
112 IS
113 BEGIN
114 return NVL(FND_GLOBAL.USER_ID, -1);
115 END get_user_id;
116
117
118 function entity_id_value (
119 p_hold_entity_code IN OE_HOLD_SOURCES_ALL.HOLD_ENTITY_CODE%TYPE,
120 p_hold_entity_id IN OE_HOLD_SOURCES_ALL.HOLD_ENTITY_ID%TYPE )
121 return VARCHAR2
122 IS
123 l_hold_entity_id_value VARCHAR2 (100) := NULL;
124
125 CURSOR order_value_cur IS
126 select order_number
127 from oe_order_headers
128 where header_id = p_hold_entity_id
129 and rownum = 1;
130
131 CURSOR item_value_cur IS
132 select concatenated_segments
133 from mtl_system_items_kfv
134 where inventory_item_id = p_hold_entity_id;
135
136 /* Following cursor has been changed to use direct TCA tables -Bug 1874065*/
137 /* CURSOR customer_value_cur IS
138 select customer_name
139 from ra_customers
140 where customer_id = p_hold_entity_id;
141 */
142 CURSOR customer_value_cur IS
143 select substrb(party.party_name,1,50) customer_name
144 from hz_parties party, hz_cust_accounts cust_acct
145 where party.party_id = cust_acct.party_id
146 AND cust_acct.cust_account_id = p_hold_entity_id;
147
148 CURSOR ship_to_value_cur IS
149 select name
150 from oe_ship_to_orgs_v
151 where ORGANIZATION_ID = p_hold_entity_id;
152
153 CURSOR bill_to_value_cur IS
154 select name
155 from oe_invoice_to_orgs_v
156 where ORGANIZATION_ID = p_hold_entity_id;
157
158 CURSOR ship_from_value_cur IS
159 select name
160 from oe_ship_from_orgs_v
161 where ORGANIZATION_ID = p_hold_entity_id;
162
163 --ER#7479609 start
164 CURSOR deliver_to_value_cur IS
165 select name
166 from oe_deliver_to_orgs_v
167 where ORGANIZATION_ID = p_hold_entity_id;
168
169 CURSOR payment_type_value_cur IS
170 SELECT name
171 FROM oe_payment_types_vl
172 WHERE payment_type_code = p_hold_entity_id;
173
174 CURSOR payment_term_value_cur IS
175 select name
176 from ra_terms
177 WHERE term_id = p_hold_entity_id;
178
179 CURSOR price_list_value_cur IS
180 select name
181 from qp_list_headers_vl
182 WHERE list_header_id = p_hold_entity_id;
183
184 CURSOR transaction_type_value_cur IS
185 select name
186 from oe_transaction_types
187 WHERE transaction_type_id = p_hold_entity_id;
188
189 CURSOR source_type_value_cur IS
190 select meaning
191 from oe_lookups
192 WHERE lookup_code= p_hold_entity_id
193 AND lookup_type = 'SOURCE_TYPE';
194
195 CURSOR shipping_method_value_cur IS
196 select meaning
197 from oe_ship_methods_v
198 WHERE lookup_code= p_hold_entity_id
199 AND lookup_type = 'SHIP_METHOD';
200
201 CURSOR currency_value_cur IS
202 select name
203 from fnd_currencies_vl
204 WHERE currency_code = p_hold_entity_id;
205
206 CURSOR salesrep_value_cur IS
207 select name
208 from ra_salesreps
209 WHERE salesrep_id = p_hold_entity_id;
210
211 CURSOR sales_channel_value_cur IS
212 select meaning
213 from oe_lookups
214 WHERE lookup_code= p_hold_entity_id
215 AND lookup_type = 'SALES_CHANNEL';
216
217 CURSOR project_value_cur IS
218 select PROJECT_NAME
219 from PJM_PROJECTS_ORG_OU_SECURE_V
220 WHERE PROJECT_ID = p_hold_entity_id;
221
222 CURSOR task_value_cur IS
223 select TASK_NAME
224 from PJM_TASKS_OU_V
225 WHERE TASK_ID = p_hold_entity_id;
226
227 CURSOR user_value_cur IS
228 select user_name
229 from fnd_user
230 WHERE user_id = p_hold_entity_id;
231
232 --ER#7479609 end
233
234 --ER# 13331078 start
235 CURSOR item_category_cur IS
236 SELECT CONCATENATED_SEGMENTS
237 FROM MTL_CATEGORIES_KFV
238 WHERE category_id = p_hold_entity_id;
239 --ER# 13331078 end
240
241 --ER#12571983 start
242 CURSOR endcust_loc_cur IS
243 select substrb(location,1,50) location
244 FROM HZ_CUST_SITE_USES_ALL
245 WHERE status='A'
246 AND SITE_USE_CODE in ('SHIP_TO','SOLD_TO','DELIVER_TO','BILL_TO')
247 AND SITE_USE_ID = p_hold_entity_id;
248 --ER#12571983 end
249
250 BEGIN
251
252 if p_hold_entity_code = 'O' THEN
253 OPEN order_value_cur;
254 FETCH order_value_cur
255 INTO l_hold_entity_id_value;
256 CLOSE order_value_cur;
257 --ER#7479609 elsif p_hold_entity_code = 'I' THEN
258 elsif p_hold_entity_code in ('I','OI','TM') THEN --ER#7479609
259 OPEN item_value_cur;
260 FETCH item_value_cur
261 into l_hold_entity_id_value;
262 CLOSE item_value_cur;
263 --ER# 13331078 start
264 elsif p_hold_entity_code ='IC' THEN
265 OPEN item_category_cur;
266 FETCH item_category_cur
267 into l_hold_entity_id_value;
268 CLOSE item_category_cur;
269 --ER# 13331078 end
270 elsif p_hold_entity_code = 'C' THEN
271 OPEN customer_value_cur;
272 FETCH customer_value_cur
273 into l_hold_entity_id_value;
274 CLOSE customer_value_cur;
275 --ER# 11824468 start
276 elsif p_hold_entity_code = 'CN' THEN
277 OPEN customer_value_cur;
278 FETCH customer_value_cur
279 into l_hold_entity_id_value;
280 CLOSE customer_value_cur;
281 --ER# 11824468 end
282 --ER#12571983 start
283 elsif p_hold_entity_code IN('EC','EN') THEN
284 OPEN customer_value_cur;
285 FETCH customer_value_cur
286 into l_hold_entity_id_value;
287 CLOSE customer_value_cur;
288 elsif p_hold_entity_code ='EL' THEN
289 OPEN endcust_loc_cur;
290 FETCH endcust_loc_cur
291 into l_hold_entity_id_value;
292 CLOSE endcust_loc_cur;
293 --ER#12571983 end
294 elsif p_hold_entity_code = 'S' THEN
295 OPEN ship_to_value_cur;
296 FETCH ship_to_value_cur
297 into l_hold_entity_id_value;
298 CLOSE ship_to_value_cur;
299 elsif p_hold_entity_code = 'B' THEN
300 OPEN bill_to_value_cur;
301 FETCH bill_to_value_cur
302 into l_hold_entity_id_value;
303 CLOSE bill_to_value_cur;
304 elsif p_hold_entity_code = 'W' THEN
305 OPEN ship_from_value_cur;
306 FETCH ship_from_value_cur
307 into l_hold_entity_id_value;
308 CLOSE ship_from_value_cur;
309 elsif p_hold_entity_code = 'H' THEN
310 l_hold_entity_id_value := p_hold_entity_id;
311 elsif p_hold_entity_code = 'L' THEN
312 l_hold_entity_id_value := p_hold_entity_id;
313 --ER#7479609 start
314 elsif p_hold_entity_code = 'D' THEN
315 OPEN deliver_to_value_cur;
316 FETCH deliver_to_value_cur
317 into l_hold_entity_id_value;
318 CLOSE deliver_to_value_cur;
319 elsif p_hold_entity_code = 'P' THEN
320 OPEN payment_type_value_cur;
321 FETCH payment_type_value_cur
322 into l_hold_entity_id_value;
323 CLOSE payment_type_value_cur;
324 elsif p_hold_entity_code = 'PT' THEN
325 OPEN payment_term_value_cur;
326 FETCH payment_term_value_cur
327 into l_hold_entity_id_value;
328 CLOSE payment_term_value_cur;
329
330 elsif p_hold_entity_code = 'PL' THEN
331 OPEN price_list_value_cur;
332 FETCH price_list_value_cur
333 into l_hold_entity_id_value;
334 CLOSE price_list_value_cur;
335
336 elsif p_hold_entity_code in ('OT','LT') THEN
337 OPEN transaction_type_value_cur;
338 FETCH transaction_type_value_cur
339 into l_hold_entity_id_value;
340 CLOSE transaction_type_value_cur;
341
342 elsif p_hold_entity_code = 'ST' THEN
343 OPEN source_type_value_cur;
344 FETCH source_type_value_cur
345 into l_hold_entity_id_value;
346 CLOSE source_type_value_cur;
347
348 elsif p_hold_entity_code = 'SM' THEN
349 OPEN shipping_method_value_cur;
350 FETCH shipping_method_value_cur
351 into l_hold_entity_id_value;
352 CLOSE shipping_method_value_cur;
353
354 elsif p_hold_entity_code = 'TC' THEN
355 OPEN currency_value_cur;
356 FETCH currency_value_cur
357 into l_hold_entity_id_value;
358 CLOSE currency_value_cur;
359
360 elsif p_hold_entity_code = 'SC' THEN
361 OPEN sales_channel_value_cur;
362 FETCH sales_channel_value_cur
363 into l_hold_entity_id_value;
364 CLOSE sales_channel_value_cur;
365
366 elsif p_hold_entity_code = 'PR' THEN
367 OPEN project_value_cur;
368 FETCH project_value_cur
369 into l_hold_entity_id_value;
370 CLOSE project_value_cur;
371
372 elsif p_hold_entity_code = 'T' THEN
373 OPEN task_value_cur;
374 FETCH task_value_cur
375 into l_hold_entity_id_value;
376 CLOSE task_value_cur;
377
378 elsif p_hold_entity_code = 'CB' THEN
379 OPEN user_value_cur;
380 FETCH user_value_cur
381 into l_hold_entity_id_value;
382 CLOSE user_value_cur;
383
384 elsif p_hold_entity_code = 'CD' THEN
385 l_hold_entity_id_value := p_hold_entity_id;
386 --ER#7479609 end
387 end if;
388
389 return l_hold_entity_id_value;
390
391 END entity_id_value;
392 --------------------------
393 function hold_name(
394 p_hold_source_id IN OE_HOLD_SOURCES_ALL.HOLD_SOURCE_ID%TYPE)
395 return varchar2
396 IS
397 l_hold_name oe_hold_definitions.name%type := '';
398 BEGIN
399 select hd.name
400 into l_hold_name
401 from oe_hold_sources hs,
402 oe_hold_definitions hd
403 where hs.HOLD_SOURCE_ID = p_hold_source_id
404 and hs.hold_id = hd.hold_id;
405
406 return l_hold_name;
407 END hold_name;
408
409 ------------------
410 function user_name (
411 p_user_id IN FND_USER.USER_ID%TYPE )
412 return VARCHAR2
413 IS
414 l_user_name VARCHAR2(100) := '';
415 BEGIN
416 select USER_NAME
417 into l_user_name
418 from fnd_user
419 where USER_ID = p_user_id;
420 return l_user_name;
421 END user_name;
422 -----------------
423
424 /*
425 NAME :
426 progress_order
427 BRIEF DESCRIPTION :
428 This API is called when a workflow based hold is released to progress
429 the workflow of affected lines/orders if eligible.Introduced as a part
430 of ER 1373910.
431 CALLER :
432 1. Process_release_holds_lines
433 2. Process_release_holds_orders
434 RELEASE LEVEL :
435 12.1.1 and higher.
436 PARAMETERS :
437 p_num_of_records Number of records affected by the hold release.
438 Determines whether workflow should be progressed
439 or deferred.
440 p_order_tbl Details of affected order/line.
441 x_return_status Return status
442 */
443 PROCEDURE progress_order( p_hold_id IN NUMBER,
444 p_num_of_records IN NUMBER,
445 p_order_tbl OE_HOLDS_PVT.order_tbl_type,
446 x_return_status OUT NOCOPY VARCHAR2,
447 x_msg_count OUT NOCOPY NUMBER,
448 x_msg_data OUT NOCOPY VARCHAR2
449 )
450 IS
451
452 l_rel_threshold NUMBER;
453 l_release_children VARCHAR2(10) := 'N';
454 l_result VARCHAR2(10);
455 l_item_type VARCHAR2(10);
456 l_activity VARCHAR2(250);
457 l_hold_activity VARCHAR2(250);
458 l_found VARCHAR2(2) := 'T';
459
460 CURSOR c_child_lines(p_header_id IN NUMBER, p_activity_name IN VARCHAR2)
461 IS
462 SELECT wpa_to.process_name || ':' || wpa_to.activity_name full_activity_name,
463 wias_to.item_type,
464 wias_to.item_key
465 FROM wf_item_activity_statuses wias_to,
466 wf_process_activities wpa_to,
467 wf_activities wa,
468 wf_item_activity_statuses wias_from,
469 wf_process_activities wpa_from,
470 wf_activity_transitions wat,
471 wf_items wi
472 WHERE wpa_to.instance_id= wias_to.process_activity
473 AND wat.to_process_activity = wpa_to.instance_id
474 AND wat.result_code = 'ON_HOLD'
475 AND wias_from.process_activity = wat.from_process_activity
476 AND wpa_from.instance_id = wias_from.process_activity
477 AND wpa_from.activity_name = p_activity_name -- 8284926
478 AND wias_from.activity_result_code = 'ON_HOLD'
479 AND wias_from.end_date IS NOT NULL
480 AND wias_from.item_type = 'OEOL'
481 AND wi.parent_item_key = To_Char(p_header_id)
482 AND wa.item_type = wias_to.item_type
483 AND wa.NAME = wpa_to.activity_name
484 AND wa.FUNCTION = 'OE_STANDARD_WF.STANDARD_BLOCK'
485 AND wa.end_date IS NULL
486 AND wias_to.end_date IS NULL
487 AND wias_to.activity_status = 'NOTIFIED'
488 AND wias_to.item_type = wias_from.item_type
489 AND wias_to.item_key = wias_from.item_key
490 AND wi.item_type = wias_to.item_type
491 AND wias_to.item_key = wi.item_key;
492
493 BEGIN
494
495 l_rel_threshold := wf_engine.threshold;
496 SAVEPOINT progress_order;
497
498 -- Begin : 8284926
499 -- Get the activity name on which the hold is defined
500 BEGIN
501 SELECT activity_name
502 INTO l_hold_activity
503 FROM oe_hold_definitions
504 WHERE hold_id = p_hold_id;
505 EXCEPTION
506 WHEN NO_DATA_FOUND THEN
507 Oe_debug_pub.ADD('Activity name not found!!');
508 WHEN OTHERS THEN
509 Oe_debug_pub.ADD(SQLERRM);
510 END;
511
512 IF l_hold_activity IS NULL THEN
513 RETURN; -- No further processing is needed.
514 ELSE
515 Oe_debug_pub.ADD('Hold Activity name : ' || l_hold_activity);
516 END IF;
517 -- End : 8284926
518
519 /*
520 This section will be executed in the following situation :
521 1. Hold is defined on a line and is workflow based.
522 2. Hold definition has its apply_to_order_and_line_flag
523 = 'Y'
524 If such an hold is applied on an order, the following code
525 takes care that the child lines are also progressed when it
526 is released.
527 */
528
529 IF p_order_tbl(1).line_id IS NULL THEN
530 BEGIN
531 SELECT 'Y'
532 INTO l_release_children
533 FROM oe_order_holds oh,
534 oe_hold_sources hs,
535 oe_hold_definitions hd
536 WHERE hs.hold_source_id = oh.hold_source_id
537 AND hs.hold_id = hd.hold_id
538 AND hd.hold_id = p_hold_id
539 AND oh.header_id = p_order_tbl(1).header_id
540 AND oh.line_id IS NULL
541 AND hs.hold_entity_code = 'O'
542 AND hs.hold_entity_id = p_order_tbl(1).header_id
543 AND NVL(hd.item_type, 'INVALID') = 'OEOL'
544 AND hd.activity_name IS NOT NULL
545 AND NVL(hd.apply_to_order_and_line_flag,'N') = 'Y';
546
547 EXCEPTION
548 WHEN NO_DATA_FOUND THEN
549 Oe_debug_pub.ADD('Normal hold release.');
550 WHEN OTHERS THEN
551 Oe_debug_pub.ADD(SQLERRM);
552 -- RAISE;
553 END;
554
555 IF l_release_children = 'Y' THEN
556
557 Oe_debug_pub.ADD('Handling apply_to_order_and_line_flag..');
558
559 wf_engine.threshold := -1;
560
561 FOR c_rec IN c_child_lines(p_order_tbl(1).header_id, l_hold_activity)
562 LOOP
563 Oe_debug_pub.ADD('Processing OEOL : ' || c_rec.item_key);
564 wf_engine.CompleteActivity('OEOL', c_rec.item_key, c_rec.full_activity_name, l_result);
565 END LOOP;
566
567 wf_engine.threshold := l_rel_threshold;
568 x_return_status := FND_API.G_RET_STS_SUCCESS;
569 Oe_msg_pub.Count_And_Get
570 ( p_count => x_msg_count
571 ,p_data => x_msg_data
572 );
573 RETURN;
574 END IF;
575 END IF;
576
577 /* This section will take care of the normal situation */
578
579 IF p_num_of_records > 1 THEN
580 wf_engine.threshold := -1 ;
581 END IF;
582
583 Oe_debug_pub.ADD('p_num_of_records : ' || p_num_of_records);
584
585 FOR i in p_order_tbl.FIRST..p_order_tbl.LAST
586 LOOP
587 BEGIN
588
589 /* This select statement will pick up the activity which fulfills
590 the following criteria :
591 1. Activity is based on a OE_STANDARD_WF.STANDARD_BLOCK function
592 2. Activity is in a 'NOTIFIED' status
593 3. Activity has been reached via a transition of 'ON_HOLD'
594 4. For a given item_type and item_key
595 */
596 l_found := 'T';
597
598 if l_hold_activity = 'REPRICE_LINE' THEN --16626753
599
600 SELECT wpa_to.process_name || ':' || wpa_to.activity_name,
601 wias_to.item_type
602 INTO l_activity, l_item_type
603 FROM wf_item_activity_statuses wias_to,
604 wf_process_activities wpa_to,
605 wf_activities wa,
606 wf_item_activity_statuses wias_from,
607 wf_process_activities wpa_from,
608 wf_activity_transitions wat
609 WHERE wpa_to.instance_id= wias_to.process_activity
610 AND wat.to_process_activity = wpa_to.instance_id
611 AND wat.result_code = 'ON_HOLD'
612 AND wias_from.process_activity = wat.from_process_activity
613 AND wpa_from.instance_id = wias_from.process_activity
614 AND wpa_from.activity_name in ('REPRICE', 'REPRICE_LINE') -- 16626753
615 AND wias_from.activity_result_code = 'ON_HOLD'
616 AND wias_from.end_date IS NOT NULL
617 AND wias_from.item_type = DECODE(p_order_tbl(i).line_id, NULL, 'OEOH', 'OEOL')
618 AND wias_from.item_key = To_Char(NVL(p_order_tbl(i).line_id,p_order_tbl(i).header_id))
619 AND wa.item_type = wias_to.item_type
620 AND wa.NAME = wpa_to.activity_name
621 AND wa.FUNCTION = 'OE_STANDARD_WF.STANDARD_BLOCK'
622 AND wa.end_date IS NULL
623 AND wias_to.end_date IS NULL
624 AND wias_to.activity_status = 'NOTIFIED'
625 AND wias_to.item_type = wias_from.item_type
626 AND wias_to.item_key = wias_from.item_key;
627
628 ELSE --16626753
629 SELECT wpa_to.process_name || ':' || wpa_to.activity_name,
630 wias_to.item_type
631 INTO l_activity, l_item_type
632 FROM wf_item_activity_statuses wias_to,
633 wf_process_activities wpa_to,
634 wf_activities wa,
635 wf_item_activity_statuses wias_from,
636 wf_process_activities wpa_from,
637 wf_activity_transitions wat
638 WHERE wpa_to.instance_id= wias_to.process_activity
639 AND wat.to_process_activity = wpa_to.instance_id
640 AND wat.result_code = 'ON_HOLD'
641 AND wias_from.process_activity = wat.from_process_activity
642 AND wpa_from.instance_id = wias_from.process_activity
643 AND wpa_from.activity_name = l_hold_activity -- 8284926
644 AND wias_from.activity_result_code = 'ON_HOLD'
645 AND wias_from.end_date IS NOT NULL
646 AND wias_from.item_type = DECODE(p_order_tbl(i).line_id, NULL, 'OEOH', 'OEOL')
647 AND wias_from.item_key = To_Char(NVL(p_order_tbl(i).line_id,p_order_tbl(i).header_id))
648 AND wa.item_type = wias_to.item_type
649 AND wa.NAME = wpa_to.activity_name
650 AND wa.FUNCTION = 'OE_STANDARD_WF.STANDARD_BLOCK'
651 AND wa.end_date IS NULL
652 AND wias_to.end_date IS NULL
653 AND wias_to.activity_status = 'NOTIFIED'
654 AND wias_to.item_type = wias_from.item_type
655 AND wias_to.item_key = wias_from.item_key;
656
657 END IF ; --16626753
658
659 Oe_debug_pub.ADD('Processing ' || l_item_type || ':' || NVL(p_order_tbl(i).line_id,p_order_tbl(i).header_id));
660
661 EXCEPTION
662 WHEN OTHERS THEN
663 Oe_debug_pub.ADD('Could not get activity ID for header/line : ' || To_Char(NVL(p_order_tbl(i).line_id,p_order_tbl(i).header_id)));
664 l_found := 'F';
665 -- Do not raise an exception here as the query might fail because
666 -- entity being processed is not at this workflow stage (not reached
667 -- yet/ crossed already). This is a valid scenario. say, line hasn't
668 -- been booked but scheduling hold is being released. So the
669 -- processing must resume for the other lines.
670
671 -- RAISE;
672 END;
673
674 -- Begin : 8284926
675 -- For BOOK_ORDER activity, search the history tables also as the ON_HOLD
676 -- transition is moved into the history table
677
678 IF l_found = 'F' AND l_hold_activity = 'BOOK_ORDER' THEN
679 BEGIN
680
681 l_found := 'T';
682
683 SELECT wpa_to.process_name || ':' || wpa_to.activity_name,
684 wias_to.item_type
685 INTO l_activity, l_item_type
686 FROM wf_item_activity_statuses wias_to,
687 wf_process_activities wpa_to,
688 wf_activities wa,
689 wf_item_activity_statuses_h wias_from,
690 wf_process_activities wpa_from,
691 wf_activity_transitions wat
692 WHERE wpa_to.instance_id= wias_to.process_activity
693 AND wat.to_process_activity = wpa_to.instance_id
694 AND wat.result_code = 'ON_HOLD'
695 AND wias_from.process_activity = wat.from_process_activity
696 AND wpa_from.instance_id = wias_from.process_activity
697 AND wpa_from.activity_name = l_hold_activity -- 8284926
698 AND wias_from.activity_result_code = 'ON_HOLD'
699 AND wias_from.end_date = wias_to.begin_date
700 AND wias_from.item_type = DECODE(p_order_tbl(i).line_id, NULL, 'OEOH', 'OEOL')
701 AND wias_from.item_key = To_Char(NVL(p_order_tbl(i).line_id,p_order_tbl(i).header_id))
702 AND wa.item_type = wias_to.item_type
703 AND wa.NAME = wpa_to.activity_name
704 AND wa.FUNCTION = 'OE_STANDARD_WF.STANDARD_BLOCK'
705 AND wa.end_date IS NULL
706 AND wias_to.end_date IS NULL
707 AND wias_to.activity_status = 'NOTIFIED'
708 AND wias_to.item_type = wias_from.item_type
709 AND wias_to.item_key = wias_from.item_key;
710
711 EXCEPTION
712 WHEN OTHERS THEN
713 Oe_debug_pub.ADD('Could not get activity ID for header (history) : ' || To_Char(NVL(p_order_tbl(i).line_id,p_order_tbl(i).header_id)));
714 l_found := 'F';
715 END;
716 END IF;
717
718 -- End : 8284926
719
720 IF l_found = 'T' THEN
721 wf_engine.CompleteActivity(l_item_type, To_Char(NVL(p_order_tbl(1).line_id,p_order_tbl(1).header_id)),l_activity, l_result);
722
723 END IF;
724
725 END LOOP;
726
727 wf_engine.threshold := l_rel_threshold;
728 x_return_status := FND_API.G_RET_STS_SUCCESS;
729 Oe_msg_pub.Count_And_Get
730 ( p_count => x_msg_count
731 ,p_data => x_msg_data
732 );
733
734 EXCEPTION
735 WHEN OTHERS THEN
736 Oe_debug_pub.ADD('Failed from progress order.');
737 wf_engine.threshold := l_rel_threshold;
738 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
739 Oe_msg_pub.Count_And_Get
740 ( p_count => x_msg_count
741 ,p_data => x_msg_data
742 );
743 ROLLBACK TO progress_order;
744
745 END progress_order;
746
747
748 /*
749 NAME :
750 progress_order
751 BRIEF DESCRIPTION :
752 This overloaded version of API is called when a workflow based hold
753 SOURCE is released to progress the workflow of affected lines/orders
754 if eligible.Introduced as a part of ER 1373910.
755 CALLER :
756 1. Process_release_source
757 RELEASE LEVEL :
758 12.1.1 and higher.
759 PARAMETERS :
760 p_hold_source_id Released hold source
761 x_return_status Return status
762 */
763
764 PROCEDURE progress_order( p_hold_source_id IN NUMBER,
765 x_return_status OUT NOCOPY VARCHAR2,
766 x_msg_count OUT NOCOPY NUMBER,
767 x_msg_data OUT NOCOPY VARCHAR2
768 )
769 IS
770
771 l_rel_threshold NUMBER;
772 l_result VARCHAR2(10);
773 l_activity VARCHAR2(250);
774 l_hold_activity VARCHAR2(250);
775 l_found VARCHAR2(2) := 'T';
776 l_item_type VARCHAR2(10);
777 l_hold_entity_code VARCHAR2(10);
778
779 CURSOR released_orders_lines
780 IS
781 SELECT NVL(line_id, header_id) entity_id,
782 DECODE(line_id , NULL, 'OEOH', 'OEOL') entity_type
783 FROM oe_order_holds oh, oe_hold_sources hs
784 WHERE hs.hold_source_id = p_hold_source_id
785 AND oh.hold_release_id = hs.hold_release_id
786 AND oh.released_flag = 'Y';
787
788 BEGIN
789
790 Oe_debug_pub.ADD('In overloaded progress_order!!');
791
792 l_rel_threshold := wf_engine.threshold;
793
794 -- Begin : 8284926
795 -- Get the activity name on which the hold is defined
796 BEGIN
797 SELECT hd.activity_name
798 INTO l_hold_activity
799 FROM oe_hold_definitions hd, oe_hold_sources hs
800 WHERE hd.hold_id = hs.hold_id
801 AND hs.hold_source_id = p_hold_source_id;
802 EXCEPTION
803 WHEN NO_DATA_FOUND THEN
804 Oe_debug_pub.ADD('Activity name not found!!');
805 WHEN OTHERS THEN
806 Oe_debug_pub.ADD(SQLERRM);
807 END;
808
809 IF l_hold_activity IS NULL THEN
810 RETURN; -- No further processing is needed.
811 END IF;
812 -- End : 8284926
813
814 BEGIN
815 SELECT hold_entity_code
816 INTO l_hold_entity_code
817 FROM oe_hold_sources
818 WHERE hold_source_id = p_hold_source_id;
819 EXCEPTION
820 WHEN OTHERS THEN
821 Oe_debug_pub.ADD('Source not found.!!');
822 -- RAISE;
823 END;
824
825 IF NVL(l_hold_entity_code,'INVALID') <> 'O' THEN
826 wf_engine.threshold := -1 ;
827 END IF;
828
829 FOR x IN released_orders_lines LOOP
830
831 BEGIN
832
833 /* This select statement will pick up the activity which fulfills
834 the following criteria :
835 1. Activity is based on a OE_STANDARD_WF.STANDARD_BLOCK function
836 2. Activity is in a 'NOTIFIED' status
837 3. Activity has been reached via a transition of 'ON_HOLD'
838 4. For a given item_type and item_key
839 */
840 l_found := 'T';
841
842 SELECT wpa_to.process_name || ':' || wpa_to.activity_name,
843 wias_to.item_type
844 INTO l_activity, l_item_type
845 FROM wf_item_activity_statuses wias_to,
846 wf_process_activities wpa_to,
847 wf_activities wa,
848 wf_item_activity_statuses wias_from,
849 wf_process_activities wpa_from,
850 wf_activity_transitions wat
851 WHERE wpa_to.instance_id= wias_to.process_activity
852 AND wat.to_process_activity = wpa_to.instance_id
853 AND wat.result_code = 'ON_HOLD'
854 AND wias_from.process_activity = wat.from_process_activity
855 AND wpa_from.instance_id = wias_from.process_activity
856 AND wpa_from.activity_name = l_hold_activity -- 8284926
857 AND wias_from.activity_result_code = 'ON_HOLD'
858 AND wias_from.end_date IS NOT NULL
859 AND wias_from.item_type = x.entity_type
860 AND wias_from.item_key = To_Char(x.entity_id)
861 AND wa.item_type = wias_to.item_type
862 AND wa.NAME = wpa_to.activity_name
863 AND wa.FUNCTION = 'OE_STANDARD_WF.STANDARD_BLOCK'
864 AND wa.end_date IS NULL
865 AND wias_to.end_date IS NULL
866 AND wias_to.activity_status = 'NOTIFIED'
867 AND wias_to.item_type = wias_from.item_type
868 AND wias_to.item_key = wias_from.item_key;
869
870 Oe_debug_pub.ADD('Processing ' || l_item_type || ':' || x.entity_id);
871 EXCEPTION
872 WHEN OTHERS THEN
873 Oe_debug_pub.ADD('Could not get activity ID for header/line : ' || x.entity_id);
874 l_found := 'F';
875 -- Do not raise an exception here as the query might fail because
876 -- entity being processed is not at this workflow stage (not reached
877 -- yet/ crossed already). This is a valid scenario. say, line hasn't
878 -- been booked but scheduling hold is being released. So the
879 -- processing must resume for the other lines.
880
881 -- RAISE;
882 END;
883
884 -- Begin : 8284926
885 -- For BOOK_ORDER activity, search the workflow history table also as the ON_HOLD
886 -- transition is moved into the history table
887
888 IF l_found = 'F' AND l_hold_activity = 'BOOK_ORDER' THEN
889 BEGIN
890
891 l_found := 'T';
892
893 SELECT wpa_to.process_name || ':' || wpa_to.activity_name,
894 wias_to.item_type
895 INTO l_activity, l_item_type
896 FROM wf_item_activity_statuses wias_to,
897 wf_process_activities wpa_to,
898 wf_activities wa,
899 wf_item_activity_statuses_h wias_from,
900 wf_process_activities wpa_from,
901 wf_activity_transitions wat
902 WHERE wpa_to.instance_id= wias_to.process_activity
903 AND wat.to_process_activity = wpa_to.instance_id
904 AND wat.result_code = 'ON_HOLD'
905 AND wias_from.process_activity = wat.from_process_activity
906 AND wpa_from.instance_id = wias_from.process_activity
907 AND wpa_from.activity_name = l_hold_activity -- 8284926
908 AND wias_from.activity_result_code = 'ON_HOLD'
909 AND wias_from.end_date = wias_to.begin_date
910 AND wias_from.item_type = x.entity_type
911 AND wias_from.item_key = To_Char(x.entity_id)
912 AND wa.item_type = wias_to.item_type
913 AND wa.NAME = wpa_to.activity_name
914 AND wa.FUNCTION = 'OE_STANDARD_WF.STANDARD_BLOCK'
915 AND wa.end_date IS NULL
916 AND wias_to.end_date IS NULL
917 AND wias_to.activity_status = 'NOTIFIED'
918 AND wias_to.item_type = wias_from.item_type
919 AND wias_to.item_key = wias_from.item_key;
920
921 EXCEPTION
922 WHEN OTHERS THEN
923 Oe_debug_pub.ADD('Could not get activity ID for header (history) : ' || x.entity_id);
924 l_found := 'F';
925 END;
926 END IF;
927
928 -- End : 8284926
929
930 SAVEPOINT progress_order;
931
932 IF l_found = 'T' THEN
933 wf_engine.CompleteActivity(l_item_type, To_Char(x.entity_id),l_activity, l_result);
934 END IF;
935
936 END LOOP;
937
938 wf_engine.threshold := l_rel_threshold;
939 x_return_status := FND_API.G_RET_STS_SUCCESS;
940 Oe_msg_pub.Count_And_Get
941 ( p_count => x_msg_count
942 ,p_data => x_msg_data
943 );
944
945 EXCEPTION
946 WHEN OTHERS THEN
947 OE_debug_pub.ADD('Failed from progress order');
948 wf_engine.threshold := l_rel_threshold;
949 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
950 Oe_msg_pub.Count_And_Get
951 ( p_count => x_msg_count
952 ,p_data => x_msg_data
953 );
954 ROLLBACK TO progress_order;
955 END progress_order;
956
957 -------------------------------------
958 -- CHECK_AUTHORIZATION
959 -------------------------------------
960 function check_authorization (
961 p_hold_id IN OE_HOLD_DEFINITIONS.HOLD_ID%TYPE,
962 p_authorized_action_code IN OE_HOLD_AUTHORIZATIONS.AUTHORIZED_ACTION_CODE%TYPE,
963 p_responsibility_id IN OE_HOLD_AUTHORIZATIONS.RESPONSIBILITY_ID%TYPE,
964 p_application_id IN OE_HOLD_AUTHORIZATIONS.APPLICATION_ID%TYPE,
965 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
966 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
967 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
968 )
969 RETURN varchar2
970 IS
971 l_auth_exists Varchar2(1) := 'N';
972 l_authorized_or_not varchar2(1) := 'Y';
973 l_dummy VARCHAR2(1);
974 BEGIN
975 OE_Debug_PUB.Add('Hold Check_Authorization Action' ||
976 p_authorized_action_code,1);
977 OE_Debug_PUB.Add('Hold_id' || to_char(p_hold_id),1);
978 OE_Debug_PUB.Add('Responsibility_Id' || to_char(p_responsibility_id),1);
979 OE_Debug_PUB.Add('Application_Id' || to_char(p_application_id),1);
980 begin
981 select 'Y'
982 Into l_auth_exists
983 from oe_hold_authorizations
984 where hold_id = p_hold_id
985 and authorized_action_code = p_authorized_action_code
986 and rownum = 1;
987 Exception
988 When NO_DATA_FOUND Then
989 OE_Debug_PUB.Add('No Authorization exists, Authorized=Yes',1);
990 l_authorized_or_not := 'Y';
991 l_auth_exists := 'N';
992 when others then
993 null;
994 End;
995
996 if l_auth_exists = 'Y' then
997 begin
998 select 'x'
999 into l_dummy
1000 from oe_hold_authorizations
1001 where sysdate between nvl(start_date_active,sysdate)
1002 and nvl(end_date_active,sysdate)
1003 and authorized_action_code = p_authorized_action_code
1004 and responsibility_id = p_responsibility_id
1005 and application_id = p_application_id
1006 and hold_id = p_hold_id
1007 and rownum = 1;
1008 exception
1009 when no_data_found then
1010 OE_Debug_PUB.Add('Not Authorized', 1);
1011 l_authorized_or_not := 'N';
1012 when others then
1013 null;
1014 end;
1015 end if;
1016 return l_authorized_or_not;
1017 END check_authorization;
1018
1019
1020
1021 --ER#7479609 start
1022 ---------------------------------------------------------------------------------------------------
1023 -- PROCEDURE : InsertTable_OOH_Header
1024 -- DESCRIPTION : This is a Local Procedure used to insert record into the OE_ORDER_HOLDS_ALL table
1025 -- for header level holds
1026
1027 -- Caller : Create_Order_Holds Procedure
1028 -- PARAMETERS:
1029 -- p_hold_source_id : Hold Source Id of the hold
1030 -- p_header_id : Line Id if the hold is applied using action -> apply hold for a specific Hold
1031 -- and BLANK if a hold source is created for a header level attribute
1032 -- p_org_id : Operating Unit ID
1033 -- p_hold_entity_where_clause : Condition for the hold criteria selected
1034 -- p_item_type : Workflow item type like 'OEOH' or 'OEOL'
1035 -- p_activity_name : Workflow activity name
1036 -- p_activity_status : Workflow activity status
1037 -- p_additional_where_clause : Its derived from the p_item_type and p_activity_name
1038 ---------------------------------------------------------------------------------------------------
1039 Procedure InsertTable_OOH_Header (p_hold_source_id OE_HOLD_SOURCES_ALL.hold_source_id%type
1040 ,p_header_id OE_ORDER_HEADERS_ALL.header_id%type
1041 ,p_org_id OE_ORDER_HEADERS_ALL.org_id%type
1042 ,p_hold_entity_where_clause VARCHAR2
1043 ,p_item_type VARCHAR2
1044 ,p_activity_name VARCHAR2
1045 ,p_activity_status VARCHAR2
1046 ,p_additional_where_clause VARCHAR2
1047 ,x_is_hold_applied OUT NOCOPY BOOLEAN)
1048 IS
1049 l_user_id NUMBER := OE_HOLDS_PVT.get_user_id;
1050 l_parent_count NUMBER;
1051 l_user_activity_name VARCHAR2(80);
1052 l_sql_rowcount NUMBER;
1053 l_sqlmt VARCHAR2(3000);
1054 l_wf_sqlmt VARCHAR2(3000);
1055
1056 BEGIN
1057
1058 OE_DEBUG_PUB.ADD('Entering InsertTable_OOH_Header');
1059
1060 IF p_header_id IS NOT NULL THEN
1061 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
1062 ( ORDER_HOLD_ID
1063 , LAST_UPDATE_DATE
1064 , LAST_UPDATED_BY
1065 , CREATION_DATE
1066 , CREATED_BY
1067 , LAST_UPDATE_LOGIN
1068 , HOLD_SOURCE_ID
1069 , HEADER_ID
1070 , LINE_ID
1071 , RELEASED_FLAG
1072 , ORG_ID
1073 )
1074 SELECT
1075 OE_ORDER_HOLDS_S.NEXTVAL
1076 , SYSDATE
1077 , :l_user_id
1078 , SYSDATE
1079 , :l_user_id
1080 , NULL
1081 , :hold_source_id
1082 , h.HEADER_ID
1083 , NULL
1084 , ''N''
1085 , h.org_id
1086 FROM OE_ORDER_HEADERS_ALL h
1087 WHERE h.OPEN_FLAG = ''Y''
1088 and h.org_id = :l_org_id
1089 and h.header_id = :header_id
1090 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
1091 and not exists ( select ''x''
1092 from oe_order_holds_ALL oh
1093 where oh.header_id = h.header_id
1094 and oh.line_id IS NULL
1095 and oh.hold_source_id =:hold_source_id )';
1096 IF p_item_type is not null and p_activity_name is not null then
1097 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
1098 , wf_process_activities wpa
1099 where was.process_activity = wpa.instance_id
1100 and item_type = :p_item_type
1101 and item_key = to_char(h.header_id)
1102 and activity_name = :l_activity_name
1103 and activity_status = :l_activity_status
1104 and nvl(activity_result_code, :l_activity_result)
1105 NOT IN (:l_result_1, :l_result_2))'; --9538334
1106 END IF;
1107
1108 IF p_hold_entity_where_clause IS NOT NULL THEN
1109 l_sqlmt :=l_sqlmt||' '||p_hold_entity_where_clause;
1110 END IF;
1111
1112
1113 IF p_item_type is null and p_activity_name is null then
1114
1115 EXECUTE IMMEDIATE
1116 l_sqlmt USING l_user_id,
1117 l_user_id,
1118 p_hold_source_id,
1119 p_org_id ,
1120 p_header_id,
1121 p_hold_source_id;
1122 IF sql%rowcount = 0 THEN
1123 x_is_hold_applied := FALSE;
1124 ELSIF sql%rowcount = 1 THEN
1125 x_is_hold_applied := TRUE;
1126 END IF;
1127 ELSE
1128
1129 EXECUTE IMMEDIATE
1130 l_sqlmt USING l_user_id,
1131 l_user_id,
1132 p_hold_source_id,
1133 p_org_id ,
1134 p_header_id,
1135 p_hold_source_id,
1136 'OEOH',
1137 p_activity_name,
1138 p_activity_status,
1139 'XXX', 'INCOMPLETE','ON_HOLD'; --9538334;
1140
1141 IF sql%rowcount = 0 THEN
1142 x_is_hold_applied := FALSE;
1143 ELSIF sql%rowcount = 1 THEN
1144 x_is_hold_applied := TRUE;
1145 END IF;
1146 END IF;
1147
1148 ELSE
1149
1150
1151 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
1152 ( ORDER_HOLD_ID
1153 , LAST_UPDATE_DATE
1154 , LAST_UPDATED_BY
1155 , CREATION_DATE
1156 , CREATED_BY
1157 , LAST_UPDATE_LOGIN
1158 , HOLD_SOURCE_ID
1159 , HEADER_ID
1160 , LINE_ID
1161 , RELEASED_FLAG
1162 , ORG_ID
1163 )
1164 SELECT
1165 OE_ORDER_HOLDS_S.NEXTVAL
1166 , SYSDATE
1167 , :l_user_id
1168 , SYSDATE
1169 , :l_user_id
1170 , NULL
1171 , :hold_source_id
1172 , h.HEADER_ID
1173 , NULL
1174 , ''N''
1175 , h.org_id
1176 FROM OE_ORDER_HEADERS_ALL h
1177 WHERE h.OPEN_FLAG = ''Y''
1178 and h.org_id = :l_org_id
1179 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
1180 and not exists ( select ''x''
1181 from oe_order_holds_ALL oh
1182 where oh.header_id = h.header_id
1183 and oh.line_id IS NULL
1184 and oh.hold_source_id =:hold_source_id )';
1185 IF p_item_type is not null and p_activity_name is not null then
1186 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
1187 , wf_process_activities wpa
1188 where was.process_activity = wpa.instance_id
1189 and item_type = :p_item_type
1190 and item_key = to_char(h.header_id)
1191 and activity_name = :l_activity_name
1192 and activity_status = :l_activity_status
1193 and nvl(activity_result_code, :l_activity_result)
1194 NOT IN (:l_result_1, :l_result_2))'; --9538334
1195 END IF;
1196
1197 IF p_hold_entity_where_clause IS NOT NULL THEN
1198 l_sqlmt :=l_sqlmt||' '||p_hold_entity_where_clause;
1199 END IF;
1200
1201
1202 IF p_item_type is null and p_activity_name is null then
1203
1204 EXECUTE IMMEDIATE
1205 l_sqlmt USING l_user_id,
1206 l_user_id,
1207 p_hold_source_id,
1208 p_org_id,
1209 p_hold_source_id;
1210 ELSE
1211
1212 EXECUTE IMMEDIATE
1213 l_sqlmt USING l_user_id,
1214 l_user_id,
1215 p_hold_source_id,
1216 p_org_id,
1217 p_hold_source_id,
1218 'OEOH',
1219 p_activity_name,
1220 p_activity_status,
1221 'XXX', 'INCOMPLETE','ON_HOLD'; --9538334;
1222
1223
1224 l_sql_rowcount := sql%rowcount;
1225
1226 OE_DEBUG_PUB.ADD('l_sql_rowcount - '||l_sql_rowcount);
1227
1228 IF l_sql_rowcount = 0 THEN
1229
1230 SELECT meaning
1231 INTO l_user_activity_name
1232 FROM oe_lookups
1233 WHERE lookup_type = DECODE(p_item_type,
1234 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
1235 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
1236 AND lookup_code = p_activity_name;
1237
1238 FND_MESSAGE.SET_NAME('ONT', 'OE_NO_HOLD_ALL_LINES');
1239 FND_MESSAGE.SET_TOKEN('WF_ACT', l_user_activity_name);
1240 OE_MSG_PUB.ADD;
1241 OE_DEBUG_PUB.ADD(' Hold Not applied for All requested records');
1242 RAISE FND_API.G_EXC_ERROR;
1243
1244 ELSIF l_sql_rowcount > 0 THEN
1245
1246 l_wf_sqlmt := 'SELECT count(*)
1247 FROM OE_ORDER_HEADERS_ALL h
1248 WHERE h.OPEN_FLAG = ''Y''
1249 AND nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
1250 AND NOT EXISTS ( select ''x''
1251 from oe_order_holds_ALL oh
1252 where oh.header_id = h.header_id
1253 and oh.hold_source_id = '||p_hold_source_id||' )';
1254
1255 IF p_hold_entity_where_clause IS NOT NULL THEN
1256 l_wf_sqlmt :=l_wf_sqlmt||' '||p_hold_entity_where_clause;
1257 END IF;
1258
1259
1260 EXECUTE IMMEDIATE l_wf_sqlmt INTO l_parent_count;
1261
1262 /* Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables. */
1263
1264 OE_DEBUG_PUB.ADD('l_parent_count - '||l_parent_count);
1265
1266 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
1267
1268 SELECT meaning
1269 INTO l_user_activity_name
1270 FROM oe_lookups
1271 WHERE lookup_type = DECODE(p_item_type,
1272 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
1273 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
1274 AND lookup_code = p_activity_name;
1275
1276 FND_MESSAGE.SET_NAME('ONT', 'OE_NO_HOLD_FEW_LINES');
1277 FND_MESSAGE.SET_TOKEN('WF_ACT', l_user_activity_name);
1278 OE_MSG_PUB.ADD;
1279 OE_DEBUG_PUB.ADD(' Hold Not applied for FEW of the requested records');
1280 END IF;
1281 END IF;
1282 END IF;
1283 END IF;
1284 OE_DEBUG_PUB.ADD('Exiting InsertTable_OOH_Header Successfully');
1285 EXCEPTION
1286 WHEN OTHERS THEN
1287 OE_DEBUG_PUB.ADD('Exiting InsertTable_OOH_Header with Error:'||SQLCODE);
1288 END InsertTable_OOH_Header;
1289 --ER#7479609 end
1290
1291
1292 --ER#7479609 start
1293 ---------------------------------------------------------------------------------------------------
1294 -- PROCEDURE : InsertTable_OOH_Line
1295 -- DESCRIPTION : This is a Local Procedure used to insert record into the OE_ORDER_HOLDS_ALL table
1296 -- for line level holds
1297
1298 -- Caller : Create_Order_Holds Procedure
1299 -- PARAMETERS:
1300 -- p_hold_source_id : Hold Source Id of the hold
1301 -- p_line_id : Line Id if the hold is applied using action -> apply hold for a specific Hold
1302 -- and BLANK if a hold source is created for a line level attribute
1303 -- p_org_id : Operating Unit ID
1304 -- p_hold_entity_where_clause : Condition for the hold criteria selected
1305 -- p_item_type : Workflow item type like 'OEOH' or 'OEOL'
1306 -- p_activity_name : Workflow activity name
1307 -- p_activity_status : Workflow activity status
1308 -- p_additional_where_clause : Its derived from the p_item_type and p_activity_name
1309 ---------------------------------------------------------------------------------------------------
1310 Procedure InsertTable_OOH_Line (p_hold_source_id OE_HOLD_SOURCES_ALL.hold_source_id%type,
1311 p_line_id OE_ORDER_LINES_ALL.line_id%type,
1312 p_org_id OE_ORDER_HEADERS_ALL.org_id%type,
1313 p_hold_entity_where_clause VARCHAR2,
1314 p_item_type VARCHAR2,
1315 p_activity_name VARCHAR2,
1316 p_activity_status VARCHAR2,
1317 p_additional_where_clause VARCHAR2,
1318 x_is_hold_applied OUT NOCOPY BOOLEAN)
1319 IS
1320 l_user_id NUMBER := OE_HOLDS_PVT.get_user_id;
1321 l_parent_count NUMBER;
1322 l_user_activity_name VARCHAR2(80);
1323 l_sql_rowcount NUMBER;
1324 l_sqlmt VARCHAR2(3000);
1325 l_wf_sqlmt VARCHAR2(3000);
1326 BEGIN
1327
1328 OE_DEBUG_PUB.ADD('Entering InsertTable_OOH_Line');
1329
1330 IF p_line_id IS NOT NULL THEN
1331
1332 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
1333 ( ORDER_HOLD_ID
1334 , LAST_UPDATE_DATE
1335 , LAST_UPDATED_BY
1336 , CREATION_DATE
1337 , CREATED_BY
1338 , LAST_UPDATE_LOGIN
1339 , HOLD_SOURCE_ID
1340 , HEADER_ID
1341 , LINE_ID
1342 , RELEASED_FLAG
1343 , ORG_ID
1344 )
1345 SELECT
1346 OE_ORDER_HOLDS_S.NEXTVAL
1347 , SYSDATE
1348 , :l_user_id
1349 , SYSDATE
1350 , :l_user_id
1351 , NULL
1352 , :hold_source_id
1353 , h.HEADER_ID
1354 , ol.line_id
1355 , ''N''
1356 , h.org_id
1357 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
1358 WHERE h.OPEN_FLAG = ''Y''
1359 and h.header_id = ol.header_id
1360 and h.org_id = :l_org_id
1361 and ol.line_id = :line_id
1362 and ol.OPEN_FLAG = ''Y''
1363 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
1364 and not exists ( select ''x''
1365 from oe_order_holds_ALL oh
1366 where oh.header_id = h.header_id
1367 and oh.line_id = ol.line_id
1368 and oh.hold_source_id = :hold_source_id )';
1369 IF p_item_type is not null and p_activity_name is not null then
1370 l_sqlmt :=l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
1371 , wf_process_activities wpa
1372 where was.process_activity = wpa.instance_id
1373 and item_type = :p_item_type
1374 and item_key = to_char(ol.line_id)
1375 and activity_name = :l_activity_name
1376 and activity_status = :l_activity_status
1377 and nvl(activity_result_code, :l_activity_result)
1378 NOT IN (:l_result_1, :l_result_2))'; --9538334
1379 END IF;
1380
1381 IF p_additional_where_clause = 'PICK_TRUE' THEN
1382 l_sqlmt :=l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
1383 where w.source_line_id = ol.line_id
1384 and w.source_code = ''OE''
1385 and w.released_status in (''Y'', ''C''))';
1386 ELSIF p_additional_where_clause = 'PACK_TRUE' THEN
1387 l_sqlmt :=l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
1388 where wdd.source_line_id = ol.LINE_ID
1389 and wdd.source_code = ''OE''
1390 and wda.delivery_detail_id = wdd.delivery_detail_id
1391 and wda.parent_delivery_detail_id is not null)';
1392 END IF;
1393
1394 IF p_hold_entity_where_clause IS NOT NULL THEN
1395 l_sqlmt :=l_sqlmt||' '||p_hold_entity_where_clause;
1396 END IF;
1397
1398 IF p_item_type is null and p_activity_name is null then
1399
1400 EXECUTE IMMEDIATE
1401 l_sqlmt USING l_user_id,
1402 l_user_id,
1403 p_hold_source_id,
1404 p_org_id,
1405 p_line_id,
1406 p_hold_source_id;
1407
1408 IF sql%rowcount = 0 THEN
1409 x_is_hold_applied := FALSE;
1410 ELSIF sql%rowcount = 1 THEN
1411 x_is_hold_applied := TRUE;
1412 END IF;
1413
1414 ELSE
1415
1416 EXECUTE IMMEDIATE
1417 l_sqlmt using l_user_id,
1418 l_user_id,
1419 p_hold_source_id,
1420 p_org_id ,
1421 p_line_id,
1422 p_hold_source_id,
1423 'OEOL',
1424 p_activity_name,
1425 p_activity_status,
1426 'XXX', 'INCOMPLETE','ON_HOLD'; --9538334;
1427
1428 IF sql%rowcount = 0 THEN
1429 x_is_hold_applied := FALSE;
1430 ELSIF sql%rowcount = 1 THEN
1431 x_is_hold_applied := TRUE;
1432 END IF;
1433
1434 END IF;
1435
1436 ELSE
1437
1438 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
1439 ( ORDER_HOLD_ID
1440 , LAST_UPDATE_DATE
1441 , LAST_UPDATED_BY
1442 , CREATION_DATE
1443 , CREATED_BY
1444 , LAST_UPDATE_LOGIN
1445 , HOLD_SOURCE_ID
1446 , HEADER_ID
1447 , LINE_ID
1448 , RELEASED_FLAG
1449 , ORG_ID
1450 )
1451 SELECT
1452 OE_ORDER_HOLDS_S.NEXTVAL
1453 , SYSDATE
1454 , :l_user_id
1455 , SYSDATE
1456 , :l_user_id
1457 , NULL
1458 , :hold_source_id
1459 , h.HEADER_ID
1460 , ol.line_id
1461 , ''N''
1462 , h.org_id
1463 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
1464 WHERE h.OPEN_FLAG = ''Y''
1465 and h.header_id = ol.header_id
1466 and h.org_id = :l_org_id
1467 and ol.OPEN_FLAG = ''Y''
1468 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
1469 and not exists ( select ''x''
1470 from oe_order_holds_ALL oh
1471 where oh.header_id = h.header_id
1472 and oh.line_id = ol.line_id
1473 and oh.hold_source_id =:hold_source_id )';
1474
1475 IF p_item_type is not null and p_activity_name is not null then
1476 l_sqlmt :=l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
1477 , wf_process_activities wpa
1478 where was.process_activity = wpa.instance_id
1479 and item_type = :p_item_type
1480 and item_key = to_char(ol.line_id)
1481 and activity_name = :l_activity_name
1482 and activity_status = :l_activity_status
1483 and nvl(activity_result_code, :l_activity_result)
1484 NOT IN (:l_result_1, :l_result_2))'; --9538334
1485 END IF;
1486
1487 IF p_additional_where_clause = 'PICK_TRUE' THEN
1488 l_sqlmt :=l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
1489 where w.source_line_id = ol.line_id and w.source_code = ''OE''
1490 and w.released_status in (''Y'', ''C''))';
1491 ELSIF p_additional_where_clause = 'PACK_TRUE' THEN
1492 l_sqlmt :=l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
1493 where wdd.source_line_id = ol.LINE_ID and wdd.source_code = ''OE''
1494 and wda.delivery_detail_id = wdd.delivery_detail_id
1495 and wda.parent_delivery_detail_id is not null)';
1496 END IF;
1497
1498 IF p_hold_entity_where_clause IS NOT NULL THEN
1499 l_sqlmt :=l_sqlmt||' '||p_hold_entity_where_clause;
1500 END IF;
1501
1502
1503 OE_DEBUG_PUB.ADD('Before Executing SQL:'||l_sqlmt);
1504 IF p_item_type is null AND p_activity_name is null THEN
1505
1506 EXECUTE IMMEDIATE
1507 l_sqlmt USING l_user_id,
1508 l_user_id,
1509 p_hold_source_id,
1510 p_org_id ,
1511 p_hold_source_id;
1512 OE_DEBUG_PUB.ADD('After Executing SQL for non-WF Hold');
1513 ELSE
1514
1515 EXECUTE IMMEDIATE
1516 l_sqlmt USING l_user_id,
1517 l_user_id,
1518 p_hold_source_id,
1519 p_org_id ,
1520 p_hold_source_id,
1521 'OEOL',
1522 p_activity_name,
1523 p_activity_status,
1524 'XXX', 'INCOMPLETE','ON_HOLD'; --9538334;;
1525
1526
1527 l_sql_rowcount := sql%rowcount;
1528 IF l_sql_rowcount = 0 THEN
1529
1530 SELECT meaning
1531 INTO l_user_activity_name
1532 FROM oe_lookups
1533 WHERE lookup_type = DECODE(p_item_type,
1534 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
1535 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
1536 AND lookup_code = p_activity_name;
1537
1538 FND_MESSAGE.SET_NAME('ONT', 'OE_NO_HOLD_ALL_LINES');
1539 FND_MESSAGE.SET_TOKEN('WF_ACT',l_user_activity_name);
1540 OE_MSG_PUB.ADD;
1541 OE_DEBUG_PUB.ADD(' Hold Not applied for All requested records');
1542 RAISE FND_API.G_EXC_ERROR;
1543
1544 ELSIF l_sql_rowcount > 0 THEN
1545 l_wf_sqlmt := 'SELECT count(*)
1546 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
1547 WHERE h.OPEN_FLAG = ''Y''
1548 AND h.header_id = ol.header_id
1549 AND ol.OPEN_FLAG = ''Y''
1550 AND NVL(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
1551 AND NOT EXISTS ( SELECT ''x''
1552 FROM oe_order_holds_ALL oh
1553 WHERE oh.header_id = h.header_id
1554 AND oh.line_id = ol.line_id
1555 AND oh.hold_source_id = '||p_hold_source_id||' )';
1556
1557 IF p_hold_entity_where_clause IS NOT NULL THEN
1558 l_wf_sqlmt :=l_wf_sqlmt||' '||p_hold_entity_where_clause;
1559 END IF;
1560
1561 EXECUTE IMMEDIATE l_wf_sqlmt INTO l_parent_count;
1562
1563 OE_DEBUG_PUB.ADD('l_parent_count/sql_count'||l_parent_count||sql%rowcount);
1564 /* Note: The above query is used based on WHERE clause of thel_sqlmt but without any query on Workflow or Shipping product tables. */
1565
1566 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
1567
1568 SELECT meaning
1569 INTO l_user_activity_name
1570 FROM oe_lookups
1571 WHERE lookup_type = DECODE(p_item_type,
1572 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
1573 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
1574 AND lookup_code = p_activity_name;
1575
1576 FND_MESSAGE.SET_NAME('ONT', 'OE_NO_HOLD_FEW_LINES');
1577 FND_MESSAGE.SET_TOKEN('WF_ACT',l_user_activity_name);
1578 OE_MSG_PUB.ADD;
1579 OE_DEBUG_PUB.ADD(' Hold Not applied for FEW of the requested records');
1580 END IF;
1581 END IF;
1582 END IF;
1583 END IF;
1584
1585 OE_DEBUG_PUB.ADD('Exiting InsertTable_OOH_Line Successfully');
1586 EXCEPTION
1587 WHEN OTHERS THEN
1588 OE_DEBUG_PUB.ADD('Exiting InsertTable_OOH_Line with Error:'||SQLCODE);
1589 END InsertTable_OOH_Line;
1590 --ER#7479609 end
1591
1592 --ER#7479609 start
1593 ---------------------------------------------------------------------------------------------------
1594 -- PROCEDURE : PaymentType_Hold
1595 -- DESCRIPTION : This is a Local Procedure used to insert record into the OE_ORDER_HOLDS_ALL table
1596 -- for header level holds
1597
1598 -- Caller : Create_Order_Holds Procedure
1599 -- PARAMETERS:
1600 -- p_hold_source_id : Hold Source Id of the hold
1601 -- p_header_id : Line Id if the hold is applied using action -> apply hold for a specific Hold
1602 ---------------------------------------------------------------------------------------------------
1603 Procedure PaymentType_Hold (p_hold_source_rec OE_HOLDS_PVT.Hold_source_Rec_Type
1604 ,p_org_id OE_ORDER_HEADERS_ALL.org_id%type
1605 ,p_item_type VARCHAR2
1606 ,p_activity_name VARCHAR2
1607 ,p_activity_status VARCHAR2
1608 ,p_additional_where_clause VARCHAR2
1609 ,x_is_hold_applied OUT NOCOPY BOOLEAN)
1610 IS
1611
1612 l_payment_count NUMBER := 0;
1613 l_sqlmt VARCHAR2(3000);
1614 l_sqlmt1 VARCHAR2(3000);
1615
1616 TYPE eligible_record_tab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
1617 l_eligible_record_tab eligible_record_tab;
1618
1619 BEGIN
1620
1621 OE_DEBUG_PUB.ADD('Entering PaymentType_Hold');
1622
1623 OE_DEBUG_PUB.ADD('Header_id :'||p_hold_source_rec.header_id);
1624 OE_DEBUG_PUB.ADD('Line_id :'||p_hold_source_rec.line_id);
1625 x_is_hold_applied := FALSE; --8221671
1626
1627 IF p_item_type = 'OEOL' or p_item_type IS NULL THEN
1628 oe_debug_pub.add('Line Level Processing Starts');
1629 l_eligible_record_tab.delete;
1630
1631 IF p_hold_source_rec.hold_entity_code = 'P' and p_hold_source_rec.hold_entity_code2 IS NULL THEN
1632
1633 l_sqlmt := 'Select line_id
1634 FROM OE_PAYMENTS OP
1635 WHERE line_id IS NOT NULL
1636 AND PAYMENT_TYPE_CODE =:hold_entity_id';
1637
1638
1639 IF (p_hold_source_rec.header_id IS NOT NULL AND p_hold_source_rec.line_id IS NOT NULL)
1640 OR (p_hold_source_rec.header_id IS NULL AND p_hold_source_rec.line_id IS NOT NULL) THEN
1641
1642 l_sqlmt := l_sqlmt||' AND OP.line_id = '||p_hold_source_rec.line_id;
1643
1644 EXECUTE IMMEDIATE l_sqlmt
1645 BULK COLLECT INTO l_eligible_record_tab
1646 USING p_hold_source_rec.hold_entity_id;
1647
1648 ELSIF (p_hold_source_rec.header_id IS NULL AND p_hold_source_rec.line_id IS NULL) THEN
1649
1650 EXECUTE IMMEDIATE l_sqlmt
1651 BULK COLLECT INTO l_eligible_record_tab
1652 USING p_hold_source_rec.hold_entity_id;
1653
1654 END IF;
1655
1656
1657
1658 -- ELSIF p_hold_source_rec.hold_entity_code = 'C' and p_hold_source_rec.hold_entity_code2 ='P' THEN --ER#11824468
1659 ELSIF p_hold_source_rec.hold_entity_code IN('C','CN') and p_hold_source_rec.hold_entity_code2 ='P' THEN --ER#11824468
1660
1661 l_sqlmt := 'Select OP.line_id
1662 FROM OE_PAYMENTS OP,OE_ORDER_LINES_ALL OL
1663 WHERE OP.line_id IS NOT NULL
1664 AND OP.line_id= OL.line_id
1665 AND OL.sold_to_org_id= :hold_entity_id
1666 AND OP.PAYMENT_TYPE_CODE = :hold_entity_id2';
1667
1668 IF (p_hold_source_rec.header_id IS NOT NULL AND p_hold_source_rec.line_id IS NOT NULL)
1669 OR (p_hold_source_rec.header_id IS NULL AND p_hold_source_rec.line_id IS NOT NULL) THEN
1670 l_sqlmt := l_sqlmt||' AND OP.line_id = '||p_hold_source_rec.line_id;
1671
1672 EXECUTE IMMEDIATE l_sqlmt
1673 BULK COLLECT INTO l_eligible_record_tab
1674 USING p_hold_source_rec.hold_entity_id,p_hold_source_rec.hold_entity_id2;
1675
1676 ELSIF (p_hold_source_rec.header_id IS NULL AND p_hold_source_rec.line_id IS NULL) THEN
1677
1678 EXECUTE IMMEDIATE l_sqlmt
1679 BULK COLLECT INTO l_eligible_record_tab
1680 USING p_hold_source_rec.hold_entity_id,p_hold_source_rec.hold_entity_id2;
1681
1682 END IF;
1683
1684 --ER#12571983 start added 'EC' 'EN'
1685 ELSIF p_hold_source_rec.hold_entity_code IN('EC','EN') and p_hold_source_rec.hold_entity_code2 ='P' THEN
1686
1687 l_sqlmt := 'Select OP.line_id
1688 FROM OE_PAYMENTS OP,OE_ORDER_LINES_ALL OL
1689 WHERE OP.line_id IS NOT NULL
1690 AND OP.line_id= OL.line_id
1691 AND OL.end_customer_id= :hold_entity_id
1692 AND OP.PAYMENT_TYPE_CODE = :hold_entity_id2';
1693
1694 IF (p_hold_source_rec.header_id IS NOT NULL AND p_hold_source_rec.line_id IS NOT NULL)
1695 OR (p_hold_source_rec.header_id IS NULL AND p_hold_source_rec.line_id IS NOT NULL) THEN
1696 l_sqlmt := l_sqlmt||' AND OP.line_id = '||p_hold_source_rec.line_id;
1697
1698 EXECUTE IMMEDIATE l_sqlmt
1699 BULK COLLECT INTO l_eligible_record_tab
1700 USING p_hold_source_rec.hold_entity_id,p_hold_source_rec.hold_entity_id2;
1701 ELSIF (p_hold_source_rec.header_id IS NULL AND p_hold_source_rec.line_id IS NULL) THEN
1702
1703 EXECUTE IMMEDIATE l_sqlmt
1704 BULK COLLECT INTO l_eligible_record_tab
1705 USING p_hold_source_rec.hold_entity_id,p_hold_source_rec.hold_entity_id2;
1706
1707 END IF;
1708 --ER#12571983 start end
1709
1710 END IF;
1711
1712
1713 FOR i in 1 .. l_eligible_record_tab.count LOOP
1714
1715 oe_debug_pub.add('Calling InsertTable_OOH_Line for P for line_id:'||l_eligible_record_tab(i));
1716 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
1717 ,p_line_id => l_eligible_record_tab(i)
1718 ,p_org_id => p_org_id
1719 ,p_hold_entity_where_clause => NULL
1720 ,p_item_type => p_item_type
1721 ,p_activity_name => p_activity_name
1722 ,p_activity_status => p_activity_status
1723 ,p_additional_where_clause => p_additional_where_clause
1724 ,x_is_hold_applied => x_is_hold_applied);
1725 oe_debug_pub.add('After Calling InsertTable_OOH_Line for P');
1726
1727 END LOOP;
1728 END IF;
1729 IF p_item_type = 'OEOH' or p_item_type IS NULL THEN
1730 oe_debug_pub.add('Header Level Processing Starts');
1731
1732 l_eligible_record_tab.delete;
1733
1734 IF p_hold_source_rec.hold_entity_code = 'P' and p_hold_source_rec.hold_entity_code2 IS NULL THEN
1735
1736 l_sqlmt := 'Select header_id
1737 FROM OE_PAYMENTS OP
1738 WHERE line_id IS NULL
1739 AND PAYMENT_TYPE_CODE = :hold_entity_id';
1740
1741 IF p_hold_source_rec.header_id IS NOT NULL and p_hold_source_rec.line_id IS NULL THEN
1742 l_sqlmt := l_sqlmt||' AND OP.header_id = '||p_hold_source_rec.header_id;
1743
1744 l_sqlmt1 := ' UNION Select header_id
1745 FROM OE_ORDER_HEADERS_ALL OH
1746 WHERE PAYMENT_TYPE_CODE = :hold_entity_id
1747 AND header_id = :header_id';
1748
1749 l_sqlmt := l_sqlmt||l_sqlmt1;
1750
1751 EXECUTE IMMEDIATE l_sqlmt
1752 BULK COLLECT INTO l_eligible_record_tab
1753 USING p_hold_source_rec.hold_entity_id,p_hold_source_rec.hold_entity_id,p_hold_source_rec.header_id;
1754
1755 ELSIF (p_hold_source_rec.header_id IS NULL AND p_hold_source_rec.line_id IS NULL) THEN
1756
1757 l_sqlmt1 := ' UNION Select header_id
1758 FROM OE_ORDER_HEADERS_ALL OH
1759 WHERE PAYMENT_TYPE_CODE = :hold_entity_id';
1760
1761 l_sqlmt := l_sqlmt||l_sqlmt1;
1762
1763 EXECUTE IMMEDIATE l_sqlmt
1764 BULK COLLECT INTO l_eligible_record_tab
1765 USING p_hold_source_rec.hold_entity_id,p_hold_source_rec.hold_entity_id;
1766
1767 END IF;
1768
1769 --ELSIF p_hold_source_rec.hold_entity_code = 'C' and p_hold_source_rec.hold_entity_code2 ='P' THEN --ER#11824468
1770 ELSIF p_hold_source_rec.hold_entity_code IN('C','CN') and p_hold_source_rec.hold_entity_code2 ='P' THEN --ER#11824468
1771
1772 l_sqlmt := 'Select OP.header_id
1773 FROM OE_PAYMENTS OP,OE_ORDER_HEADERS_ALL OH
1774 WHERE OP.line_id IS NULL
1775 AND OP.header_id= OH.header_id
1776 AND OH.sold_to_org_id= :hold_entity_id
1777 AND OP.PAYMENT_TYPE_CODE = :hold_entity_id2';
1778
1779 IF p_hold_source_rec.header_id IS NOT NULL and p_hold_source_rec.line_id IS NULL THEN
1780 l_sqlmt := l_sqlmt||' AND OP.header_id = '||p_hold_source_rec.header_id;
1781
1782 l_sqlmt1 := ' UNION Select header_id
1783 FROM OE_ORDER_HEADERS_ALL OH
1784 WHERE sold_to_org_id= :hold_entity_id
1785 AND PAYMENT_TYPE_CODE = :hold_entity_id2
1786 AND header_id = :header_id';
1787
1788 l_sqlmt := l_sqlmt||l_sqlmt1;
1789 EXECUTE IMMEDIATE l_sqlmt
1790 BULK COLLECT INTO l_eligible_record_tab
1791 USING p_hold_source_rec.hold_entity_id,p_hold_source_rec.hold_entity_id2,
1792 p_hold_source_rec.hold_entity_id,p_hold_source_rec.hold_entity_id2,
1793 p_hold_source_rec.header_id;
1794
1795 ELSIF (p_hold_source_rec.header_id IS NULL AND p_hold_source_rec.line_id IS NULL) THEN
1796
1797 l_sqlmt1 := ' UNION Select header_id
1798 FROM OE_ORDER_HEADERS_ALL OH
1799 WHERE sold_to_org_id= :hold_entity_id
1800 AND PAYMENT_TYPE_CODE = :hold_entity_id2';
1801
1802 l_sqlmt := l_sqlmt||l_sqlmt1;
1803
1804 EXECUTE IMMEDIATE l_sqlmt
1805 BULK COLLECT INTO l_eligible_record_tab
1806 USING p_hold_source_rec.hold_entity_id,p_hold_source_rec.hold_entity_id2,
1807 p_hold_source_rec.hold_entity_id,p_hold_source_rec.hold_entity_id2;
1808
1809 END IF;
1810
1811
1812 END IF;
1813
1814
1815 FOR i in 1 .. l_eligible_record_tab.count LOOP
1816
1817 oe_debug_pub.add('Calling InsertTable_OOH_Header for P for header_id:'||l_eligible_record_tab(i));
1818 InsertTable_OOH_Header (p_hold_source_id => p_hold_source_rec.hold_source_id
1819 ,p_header_id =>l_eligible_record_tab(i)
1820 ,p_org_id => p_org_id
1821 ,p_hold_entity_where_clause => NULL
1822 ,p_item_type => p_item_type
1823 ,p_activity_name => p_activity_name
1824 ,p_activity_status => p_activity_status
1825 ,p_additional_where_clause => p_additional_where_clause
1826 ,x_is_hold_applied => x_is_hold_applied);
1827
1828 oe_debug_pub.add('After Calling InsertTable_OOH_Header for P');
1829
1830 END LOOP;
1831 END IF;
1832
1833
1834
1835 oe_debug_pub.add('Exiting PaymentType_Hold Successfully');
1836
1837 EXCEPTION
1838 WHEN OTHERS THEN
1839 OE_DEBUG_PUB.ADD('Exiting PaymentType_Hold with Error:'||SQLCODE);
1840 END PaymentType_Hold;
1841 --ER#7479609 end
1842
1843
1844 /****************************
1845 | RELEASE_ORDERS
1846 ***************************/
1847 Procedure release_orders (
1848 p_hold_release_rec IN OE_HOLDS_PVT.hold_release_rec_type,
1849 p_order_rec IN OE_HOLDS_PVT.order_rec_type,
1850 p_hold_source_rec IN OE_HOLDS_PVT.Hold_source_Rec_Type,
1851 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
1852 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
1853 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
1854 )
1855 IS
1856
1857 CURSOR hold_source IS
1858 SELECT HS.HOLD_SOURCE_ID,
1859 HS.HOLD_ENTITY_CODE,
1860 hs.hold_id,
1861 oh.order_hold_id
1862 FROM OE_HOLD_SOURCES HS,
1863 OE_ORDER_HOLDS oh
1864 WHERE HS.HOLD_ID = nvl(p_hold_source_rec.hold_id, HS.HOLD_ID)
1865 and hs.hold_entity_code = nvl(p_hold_source_rec.hold_entity_code, hs.hold_entity_code)
1866 and hs.hold_entity_id = nvl(p_hold_source_rec.hold_entity_id, hs.hold_entity_id)
1867 and hs.HOLD_SOURCE_ID = oh.HOLD_SOURCE_ID
1868 and oh.HEADER_ID = p_order_rec.header_id
1869 and nvl(oh.LINE_ID, -99 ) = nvl(p_order_rec.line_id, -99)
1870 AND OH.RELEASED_FLAG = 'N';
1871
1872 -- GENESIS --
1873 CURSOR check_hold_type_cur(p_ord_hld_id IN NUMBER) IS
1874 SELECT 'Y'
1875 FROM DUAL
1876 WHERE EXISTS (SELECT NULL
1877 FROM oe_order_holds ooh,
1878 oe_hold_sources ohs,
1879 oe_hold_definitions ohd,
1880 oe_order_headers_all h,
1881 oe_order_sources oos
1882 WHERE ooh.header_id = h.header_id
1883 -- AND ohd.activity_name IS NULL Bug 6791587
1884 AND oos.aia_enabled_flag = 'Y'
1885 AND ohd.hold_id = ohs.hold_id
1886 AND ohs.hold_source_id = ooh.hold_source_id
1887 AND ooh.order_hold_id = p_ord_hld_id);
1888
1889 l_chk_hold VARCHAR2(1) := 'N';
1890
1891 -- Bug 8463870
1892 l_header_id number;
1893 l_header_rec oe_order_pub.header_rec_type;
1894
1895 l_line_id number;
1896 l_line_rec oe_order_pub.line_rec_type;
1897
1898 cursor header_line_id_cur(p_ord_hld_id in number) is
1899 select ohld.header_id,
1900 ohld.line_id
1901 from oe_order_holds ohld,
1902 oe_order_headers ooh,
1903 oe_order_sources src
1904 where ohld.order_hold_id = p_ord_hld_id
1905 and ohld.header_id = ooh.header_id
1906 and src.order_source_id = ooh.order_source_id
1907 and src.aia_enabled_flag = 'Y';
1908
1909 -- GENESIS --
1910 -- 16053361
1911 l_nameVal_tbl OE_ORDER_UTIL.nameVal_Tbl_Type;
1912 l_count number;
1913 -- 16053361
1914
1915 l_user_id NUMBER;
1916 x_hold_release_id oe_hold_releases.HOLD_RELEASE_ID%type;
1917 l_hold_source_id OE_HOLD_SOURCES.HOLD_SOURCE_ID%TYPE;
1918 x_hold_source_id OE_HOLD_SOURCES.HOLD_SOURCE_ID%TYPE;
1919 l_hold_entity_code OE_HOLD_SOURCES.HOLD_ENTITY_CODE%TYPE;
1920 l_order_hold_id OE_ORDER_HOLDS.ORDER_HOLD_ID%TYPE;
1921 l_hold_id OE_HOLD_DEFINITIONS.hold_id%type;
1922
1923 l_hold_source_rec OE_HOLDS_PVT.hold_source_rec_type;
1924 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
1925 BEGIN
1926 x_return_status := FND_API.G_RET_STS_SUCCESS;
1927 l_user_id := OE_HOLDS_PVT.get_user_id;
1928 -- XX Also check for release reason code
1929 OPEN hold_source;
1930 LOOP
1931
1932 FETCH hold_source INTO l_hold_source_id,
1933 l_hold_entity_code,
1934 l_hold_id,
1935 l_order_hold_id;
1936 exit when hold_source%NOTFOUND;
1937 -- If the Order was created as an Order Based Hold.
1938 OE_Debug_PUB.Add('Rleaseing Hold' || l_hold_id);
1939 if l_hold_entity_code = 'O' THEN
1940 --x_hold_source_id := l_hold_source_id;
1941 OE_Debug_PUB.Add('Rlsing Source for:'||to_char(p_order_rec.header_id),1);
1942 l_hold_source_rec.hold_source_id := l_hold_source_id;
1943 l_hold_source_rec.HOLD_ENTITY_CODE := 'O';
1944 l_hold_source_rec.HOLD_ENTITY_ID := p_order_rec.header_id;
1945 l_hold_source_rec.HOLD_ID := l_hold_id;
1946 oe_holds_pvt.Release_Hold_Source (
1947 p_hold_source_rec => l_hold_source_rec,
1948 p_hold_release_rec => p_hold_release_rec,
1949 x_return_status => x_return_status,
1950 x_msg_count => x_msg_count,
1951 x_msg_data => x_msg_data );
1952 ELSE
1953 -- Releasing only orders from hold. Insert a record in the
1954 -- OE_HOLD_RELEASES with hold_source_id as null.
1955 OE_Debug_PUB.Add('Releasing Orders from Hold',1);
1956 --x_hold_source_id := '';
1957
1958 SELECT OE_HOLD_RELEASES_S.NEXTVAL
1959 INTO x_hold_release_id
1960 FROM DUAL;
1961 /*Bug3042838 Added nvl condition for insertion into CREATED_BY column */
1962 INSERT INTO OE_HOLD_RELEASES
1963 ( HOLD_RELEASE_ID
1964 , CREATION_DATE
1965 , CREATED_BY
1966 , LAST_UPDATE_DATE
1967 , LAST_UPDATED_BY
1968 , LAST_UPDATE_LOGIN
1969 , PROGRAM_APPLICATION_ID
1970 , PROGRAM_ID
1971 , PROGRAM_UPDATE_DATE
1972 , REQUEST_ID
1973 , HOLD_SOURCE_ID
1974 , RELEASE_REASON_CODE
1975 , RELEASE_COMMENT
1976 , CONTEXT
1977 , ATTRIBUTE1
1978 , ATTRIBUTE2
1979 , ATTRIBUTE3
1980 , ATTRIBUTE4
1981 , ATTRIBUTE5
1982 , ATTRIBUTE6
1983 , ATTRIBUTE7
1984 , ATTRIBUTE8
1985 , ATTRIBUTE9
1986 , ATTRIBUTE10
1987 , ATTRIBUTE11
1988 , ATTRIBUTE12
1989 , ATTRIBUTE13
1990 , ATTRIBUTE14
1991 , ATTRIBUTE15
1992 , ORDER_HOLD_ID
1993 )
1994 VALUES
1995 ( x_hold_release_id
1996 , sysdate
1997 , nvl(p_hold_release_rec.CREATED_BY,l_user_id)
1998 , sysdate
1999 , l_user_id
2000 , p_hold_release_rec.LAST_UPDATE_LOGIN
2001 , p_hold_release_rec.PROGRAM_APPLICATION_ID
2002 , p_hold_release_rec.PROGRAM_ID
2003 , p_hold_release_rec.PROGRAM_UPDATE_DATE
2004 , p_hold_release_rec.REQUEST_ID
2005 , NULL -- HOLD_SOURCE_ID
2006 , p_hold_release_rec.RELEASE_REASON_CODE
2007 , p_hold_release_rec.RELEASE_COMMENT
2008 , p_hold_release_rec.CONTEXT
2009 , p_hold_release_rec.ATTRIBUTE1
2010 , p_hold_release_rec.ATTRIBUTE2
2011 , p_hold_release_rec.ATTRIBUTE3
2012 , p_hold_release_rec.ATTRIBUTE4
2013 , p_hold_release_rec.ATTRIBUTE5
2014 , p_hold_release_rec.ATTRIBUTE6
2015 , p_hold_release_rec.ATTRIBUTE7
2016 , p_hold_release_rec.ATTRIBUTE8
2017 , p_hold_release_rec.ATTRIBUTE9
2018 , p_hold_release_rec.ATTRIBUTE10
2019 , p_hold_release_rec.ATTRIBUTE11
2020 , p_hold_release_rec.ATTRIBUTE12
2021 , p_hold_release_rec.ATTRIBUTE13
2022 , p_hold_release_rec.ATTRIBUTE14
2023 , p_hold_release_rec.ATTRIBUTE15
2024 , l_order_hold_id
2025 );
2026
2027 --dbms_output.put_line('RlsID:'||to_char(p_hold_release_rec.hold_release_id));
2028 UPDATE oe_order_holds
2029 SET hold_release_id = x_hold_release_id,
2030 LAST_UPDATED_BY = l_user_id,
2031 LAST_UPDATE_DATE = sysdate,
2032 RELEASED_FLAG = 'Y'
2033 WHERE ORDER_HOLD_ID = l_order_hold_id;
2034
2035 END IF;
2036 -- XX Also check to see if its the last order from a non order based
2037 -- hold and release the hold source also. NO
2038 -- 16053361
2039 oe_debug_pub.add( 'OE_HOLDS_PVT - Raise Integration event for Applying hold');
2040 If NVL (Fnd_Profile.Value('ONT_RAISE_STATUS_CHANGE_BUSINESS_EVENT'), 'N')='Y'
2041 THEN
2042 IF l_debug_level > 0 THEN
2043 oe_debug_pub.add( 'OE_HOLDS_PVT - Preparing paramters to pass to Integration event for Releasing hold');
2044 END IF;
2045 l_count := 1;
2046 l_nameVal_tbl(l_count).name := 'CHANGE_TYPE';
2047 l_nameVal_tbl(l_count).value := 'RELEASE';
2048 l_nameVal_tbl(l_count+1).name := 'ORDER_HOLD_ID';
2049 l_nameVal_tbl(l_count+1).value := l_order_hold_id;
2050 l_nameVal_tbl(l_count+2).name := 'HOLD_SOURCE_ID';
2051 l_nameVal_tbl(l_count+2).value := null;
2052 l_nameVal_tbl(l_count+3).name := 'HOLD_RELEASE_ID';
2053 l_nameVal_tbl(l_count+3).value := x_hold_release_id;
2054 BEGIN
2055 SELECT ohld.header_id, ohld.line_id
2056 INTO l_header_id, l_line_id
2057 FROM oe_order_holds ohld,
2058 oe_order_headers ooh
2059 WHERE ohld.order_hold_id = l_order_hold_id
2060 AND ohld.header_id = ooh.header_id;
2061 EXCEPTION
2062 WHEN OTHERS THEN
2063 oe_debug_pub.add('No data found!');
2064 END;
2065 if l_debug_level > 0 then
2066 oe_debug_pub.add('....header_id = ' || l_header_id);
2067 oe_debug_pub.add('....line_id = ' || l_line_id);
2068 end if;
2069 oe_order_util.raise_business_event( p_header_id => l_header_id,
2070 p_line_id => l_line_id,
2071 p_event_name => 'oracle.apps.ont.hold.action',
2072 p_nameVal_tbl => l_nameVal_tbl);
2073 IF l_debug_level > 0 THEN
2074 oe_debug_pub.add( 'OE_HOLDS_PVT - Done with Raising Integration event for Releasing hold');
2075 END IF;
2076 END IF;
2077 oe_debug_pub.add( 'OE_HOLDS_PVT - Raise Integration event for Applying hold');
2078 -- 16053361
2079
2080 -- GENESIS --
2081 IF l_debug_level > 0 THEN
2082 oe_debug_pub.add( 'OE_HOLDS_PVT - RELEASE ORDERS- BEFORE GENESIS CALL');
2083 END IF;
2084
2085 OPEN check_hold_type_cur(l_order_hold_id);
2086 FETCH check_hold_type_cur INTO l_chk_hold;
2087 CLOSE check_hold_type_cur;
2088
2089 IF NVL(l_chk_hold, 'N') = 'Y' THEN
2090 IF l_debug_level > 0 THEN
2091 oe_debug_pub.add( 'OE_HOLDS_PVT - RELEASE ORDERS- BEFORE SYNC_HEADER_LINE');
2092 END IF;
2093
2094 -- Bug 8463870
2095 for hld_rls_rec in header_line_id_cur(l_order_hold_id)
2096 loop
2097 l_header_id := hld_rls_rec.header_id;
2098 l_line_id := hld_rls_rec.line_id;
2099 end loop;
2100
2101 if l_debug_level > 0 then
2102 oe_debug_pub.add('....header_id = ' || l_header_id);
2103 oe_debug_pub.add('....line_id = ' || l_line_id);
2104 end if;
2105
2106 if ( l_header_id is not null ) then
2107 l_header_rec := oe_header_util.query_row(p_header_id => l_header_id);
2108 if ( l_debug_level > 0 ) then
2109 oe_debug_pub.add('.... Queried up header record.');
2110 end if;
2111 end if;
2112
2113 if ( l_line_id is not null ) then
2114 l_line_rec := oe_line_util.query_row(p_line_id => l_line_id);
2115 if ( l_debug_level > 0 ) then
2116 oe_debug_pub.add('.... Queried up line record.');
2117 end if;
2118 end if;
2119
2120 if (l_debug_level > 0 ) then
2121 oe_debug_pub.add('.... Calling oe_sync_order_pvt.sync_header_line...');
2122 end if;
2123
2124 -- XXXX Do we need to generate req_id here
2125 OE_SYNC_ORDER_PVT.SYNC_HEADER_LINE( p_header_rec => l_header_rec -- NULL
2126 ,p_line_rec => l_line_rec -- NULL
2127 ,p_hold_source_id => NULL
2128 ,p_order_hold_id => l_order_hold_id
2129 ,p_change_type => 'RELEASE');
2130 END IF;
2131 -- GENESIS --
2132
2133 END LOOP;
2134 CLOSE hold_source;
2135
2136 END release_orders;
2137
2138
2139
2140 Procedure Validate_Hold_Source (
2141 p_hold_source_rec IN OE_HOLDS_PVT.Hold_Source_Rec_Type
2142 , x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2
2143 , x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER
2144 , x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
2145 )
2146 IS
2147 l_api_name CONSTANT VARCHAR2(30) := 'Validate_Hold_source';
2148 l_dummy VARCHAR2(30);
2149
2150 l_hold_id NUMBER := p_hold_source_rec.hold_id;
2151 l_item_type VARCHAR2(8);
2152 l_apply_to_flag VARCHAR2(1);
2153
2154 cursor hold_info
2155 is
2156 select
2157 item_type
2158 , nvl(apply_to_order_and_line_flag, 'N')
2159 from oe_hold_definitions
2160 where hold_id = l_hold_id;
2161
2162 BEGIN
2163 OE_Debug_PUB.Add('In OE_holds_PUB.Validate_Hold_source',1);
2164 -- Initialize API return status to success
2165 x_return_status := FND_API.G_RET_STS_SUCCESS;
2166
2167 --XXX Check the Entity Combination
2168 /*
2169 > Item - Customer
2170 > Item - Customer Ship to Site
2171 > Item - Customer Bill to Site
2172 > Item - Warehouse
2173 > Warehouse - Customer
2174 > Warehouse - Customer Ship to Site
2175 > Warehouse - Customer Bill to Site
2176 > Bill To Site - Order (Used by Line level Credit Checking only)
2177
2178 > Item - Blanket Number
2179 > Blanket Number
2180 > Blanket Number - Customer
2181 > Blanket Number - Customer Ship to Site
2182 > Blanket Number - Customer Bill to Site
2183 > Blanket Number - Warehouse
2184 > Blanket Number - Blanket Line Number
2185 */
2186 OE_Debug_PUB.Add('Entity Combination:' || p_hold_source_rec.hold_entity_code
2187 || '/' || p_hold_source_rec.hold_entity_code2,1);
2188
2189 /* ER # 2662206 Start */
2190 IF p_hold_source_rec.hold_entity_code IS NOT NULL THEN
2191 OPEN hold_info;
2192 FETCH hold_info into l_item_type, l_apply_to_flag;
2193 CLOSE hold_info;
2194
2195 /*ER#7479609
2196 IF l_item_type = 'OEOH' THEN
2197 IF p_hold_source_rec.hold_entity_code IN ('B','H','I','W','S','L') OR
2198 (p_hold_source_rec.hold_entity_code = 'O' AND
2199 p_hold_source_rec.line_id IS NOT NULL) OR
2200 p_hold_source_rec.hold_entity_code2 IS NOT NULL THEN
2201 oe_debug_pub.add('Error: Order WF Hold, being applied at Line Level');
2202 FND_MESSAGE.SET_NAME('ONT','OE_ORDER_HOLD_INVALID_CRITERIA');
2203 OE_MSG_PUB.ADD;
2204 RAISE FND_API.G_EXC_ERROR;
2205 END IF;
2206 ELSIF l_item_type = 'OEOL' THEN
2207 IF p_hold_source_rec.hold_entity_code IN ('C','O') AND
2208 p_hold_source_rec.line_id IS NULL AND
2209 l_apply_to_flag = 'N' THEN
2210 oe_debug_pub.add('Error: Line WF Hold, being applied at Order Level');
2211 FND_MESSAGE.SET_NAME('ONT','OE_LINE_HOLD_INVALID_CRITERIA');
2212 OE_MSG_PUB.ADD;
2213 RAISE FND_API.G_EXC_ERROR;
2214 END IF;
2215 END IF;
2216 ER#7479609*/
2217
2218 --ER#7479609 start
2219 IF (p_hold_source_rec.hold_entity_code = 'O' and p_hold_source_rec.line_id IS NULL) OR
2220 -- (p_hold_source_rec.hold_entity_code = 'C' and --ER# 11824468
2221 (p_hold_source_rec.hold_entity_code IN('C','CN') and --ER# 11824468
2222 (p_hold_source_rec.hold_entity_code2 IS NULL OR
2223 p_hold_source_rec.hold_entity_code2 = 'OT' OR
2224 p_hold_source_rec.hold_entity_code2 = 'P' OR
2225 p_hold_source_rec.hold_entity_code2 = 'TC' OR
2226 p_hold_source_rec.hold_entity_code2 = 'SC')) OR
2227 (p_hold_source_rec.hold_entity_code = 'PL' and
2228 (p_hold_source_rec.hold_entity_code2 IS NULL OR
2229 p_hold_source_rec.hold_entity_code2 = 'TC')) OR
2230 (p_hold_source_rec.hold_entity_code = 'OT' and
2231 (p_hold_source_rec.hold_entity_code2 IS NULL OR
2232 p_hold_source_rec.hold_entity_code2 = 'TC')) OR
2233 (p_hold_source_rec.hold_entity_code = 'SC' and p_hold_source_rec.hold_entity_code2 IS NULL) --ER#7479609 OR
2234 --ER#7479609 (p_hold_source_rec.hold_entity_code = 'P' and p_hold_source_rec.hold_entity_code2 IS NULL)
2235 THEN
2236 IF l_item_type = 'OEOH' THEN
2237 NULL;
2238 oe_debug_pub.add('Order WF HOLD');
2239 ELSIF l_item_type = 'OEOL' AND l_apply_to_flag = 'N' THEN
2240 oe_debug_pub.add('Error: Line WF Hold, being applied at Order Level');
2241 FND_MESSAGE.SET_NAME('ONT','OE_LINE_HOLD_INVALID_CRITERIA');
2242 OE_MSG_PUB.ADD;
2243 RAISE FND_API.G_EXC_ERROR;
2244 END IF;
2245 ELSE
2246 IF (p_hold_source_rec.hold_entity_code = 'P' and p_hold_source_rec.hold_entity_code2 IS NULL) THEN
2247 NULL;
2248 ELSE
2249 IF l_item_type = 'OEOL' AND l_apply_to_flag = 'N' THEN
2250 NULL;
2251 oe_debug_pub.add('Line WF HOLD');
2252 ELSIF l_item_type = 'OEOH' THEN
2253 oe_debug_pub.add('Error: Order WF Hold, being applied at Line Level');
2254 FND_MESSAGE.SET_NAME('ONT','OE_ORDER_HOLD_INVALID_CRITERIA');
2255 OE_MSG_PUB.ADD;
2256 RAISE FND_API.G_EXC_ERROR;
2257 END IF;
2258 END IF;
2259 END IF;
2260 --ER#7479609 end
2261
2262
2263 END IF;
2264 /* ER # 2662206 End */
2265
2266 if (p_hold_source_rec.hold_entity_code2 is not null) then
2267 if p_hold_source_rec.hold_entity_code = 'I' then
2268 --ER#7479609 if p_hold_source_rec.hold_entity_code2 not in ('C', 'S', 'B', 'W','H') then
2269 if p_hold_source_rec.hold_entity_code2 not in ('C', 'S', 'B', 'W','H','SM','D','PL','PR','ST','LT','CN','EC','EN') then --ER#7479609 --ER#11824468, added 'CN' --ER#12571983 added ,'EC','EN'
2270 OE_Debug_PUB.Add('Invalid Entity Combination',1);
2271 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ENTITY_CONBINATION');
2272 OE_MSG_PUB.ADD;
2273 RAISE FND_API.G_EXC_ERROR;
2274 end if;
2275 --ER# 13331078 start
2276 elsif p_hold_source_rec.hold_entity_code = 'IC' then
2277 if p_hold_source_rec.hold_entity_code2 not in ('C', 'S', 'B', 'W','H','SM','D','PL','PR','ST','LT','CN','EC','EN') then --ER#11824468, added 'CN' --ER#12571983 added ,'EC','EN'
2278 OE_Debug_PUB.Add('Invalid Entity Combination',1);
2279 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ENTITY_CONBINATION');
2280 OE_MSG_PUB.ADD;
2281 RAISE FND_API.G_EXC_ERROR;
2282 end if;
2283 --ER# 13331078 end
2284 elsif p_hold_source_rec.hold_entity_code = 'W' then
2285 --ER#7479609 if p_hold_source_rec.hold_entity_code2 not in ('C', 'S', 'B') then
2286 if p_hold_source_rec.hold_entity_code2 not in ('C', 'S', 'B','LT','SM','D','ST','CN','EC','EN') then --ER#7479609 --ER#11824468, added 'CN' --ER#12571983 added ,'EC','EN'
2287 OE_Debug_PUB.Add('Invalid Entity Combination',1);
2288 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ENTITY_CONBINATION');
2289 OE_MSG_PUB.ADD;
2290 RAISE FND_API.G_EXC_ERROR;
2291 end if;
2292 elsif p_hold_source_rec.hold_entity_code = 'B' then
2293 if p_hold_source_rec.hold_entity_code2 not in ('O') then
2294 OE_Debug_PUB.Add('Invalid Entity Combination',1);
2295 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ENTITY_CONBINATION');
2296 OE_MSG_PUB.ADD;
2297 RAISE FND_API.G_EXC_ERROR;
2298 end if;
2299 elsif p_hold_source_rec.hold_entity_code = 'H' then
2300 --ER#7479609 if p_hold_source_rec.hold_entity_code2 not in ('S', 'B', 'W', 'L') then
2301 if p_hold_source_rec.hold_entity_code2 not in ('S', 'B', 'W', 'L','PL','PT','SM','D','LT') then --ER#7479609
2302 OE_Debug_PUB.Add('Invalid Entity Combination',1);
2303 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ENTITY_CONBINATION');
2304 OE_MSG_PUB.ADD;
2305 RAISE FND_API.G_EXC_ERROR;
2306 end if;
2307 --ER#7479609 start
2308 elsif p_hold_source_rec.hold_entity_code = 'TM' then
2309 if p_hold_source_rec.hold_entity_code2 not in ('OI') then
2310 OE_Debug_PUB.Add('Invalid Entity Combination',1);
2311 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ENTITY_CONBINATION');
2312 OE_MSG_PUB.ADD;
2313 RAISE FND_API.G_EXC_ERROR;
2314 end if;
2315 elsif p_hold_source_rec.hold_entity_code = 'PR' then
2316 if p_hold_source_rec.hold_entity_code2 not in ('T') then
2317 OE_Debug_PUB.Add('Invalid Entity Combination',1);
2318 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ENTITY_CONBINATION');
2319 OE_MSG_PUB.ADD;
2320 RAISE FND_API.G_EXC_ERROR;
2321 end if;
2322 elsif p_hold_source_rec.hold_entity_code = 'C' then
2323 if p_hold_source_rec.hold_entity_code2 not in ('ST','B','S','D','PL','LT','PT','OT','P','TC','SC') then
2324 OE_Debug_PUB.Add('Invalid Entity Combination',1);
2325 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ENTITY_CONBINATION');
2326 OE_MSG_PUB.ADD;
2327 RAISE FND_API.G_EXC_ERROR;
2328 end if;
2329 --ER# 11824468 start
2330 elsif p_hold_source_rec.hold_entity_code = 'CN' then
2331 if p_hold_source_rec.hold_entity_code2 not in ('ST','B','S','D','PL','LT','PT','OT','P','TC','SC') then
2332 OE_Debug_PUB.Add('Invalid Entity Combination',1);
2333 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ENTITY_CONBINATION');
2334 OE_MSG_PUB.ADD;
2335 RAISE FND_API.G_EXC_ERROR;
2336 end if;
2337 --ER# 11824468 end
2338 --ER#12571983 start
2339 elsif p_hold_source_rec.hold_entity_code IN('EC','EN') then
2340 if p_hold_source_rec.hold_entity_code2 not in ('ST','B','S','D','PL','LT','PT','OT','P','TC','SC','EL') then
2341 OE_Debug_PUB.Add('Invalid Entity Combination',1);
2342 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ENTITY_CONBINATION');
2343 OE_MSG_PUB.ADD;
2344 RAISE FND_API.G_EXC_ERROR;
2345 end if;
2346 --ER#12571983 end
2347 elsif p_hold_source_rec.hold_entity_code = 'PL' then
2348 if p_hold_source_rec.hold_entity_code2 not in ('TC') then
2349 OE_Debug_PUB.Add('Invalid Entity Combination',1);
2350 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ENTITY_CONBINATION');
2351 OE_MSG_PUB.ADD;
2352 RAISE FND_API.G_EXC_ERROR;
2353 end if;
2354 elsif p_hold_source_rec.hold_entity_code = 'OT' then
2355 if p_hold_source_rec.hold_entity_code2 not in ('LT','TC') then
2356 OE_Debug_PUB.Add('Invalid Entity Combination',1);
2357 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ENTITY_CONBINATION');
2358 OE_MSG_PUB.ADD;
2359 RAISE FND_API.G_EXC_ERROR;
2360 end if;
2361 elsif p_hold_source_rec.hold_entity_code = 'CD' then
2362 if p_hold_source_rec.hold_entity_code2 not in ('CB') then
2363 OE_Debug_PUB.Add('Invalid Entity Combination',1);
2364 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_ENTITY_CONBINATION');
2365 OE_MSG_PUB.ADD;
2366 RAISE FND_API.G_EXC_ERROR;
2367 end if;
2368 --ER#7479609 end
2369 else
2370 null;
2371 end if;
2372 end if;
2373
2374 OE_Debug_PUB.Add('Entity ID Combination->' ||
2375 to_char(p_hold_source_rec.hold_entity_id) || '/' ||
2376 to_char(p_hold_source_rec.hold_entity_id2),1);
2377 IF p_hold_source_rec.hold_entity_code = 'O' THEN
2378
2379 SELECT 'Valid Entity'
2380 INTO l_dummy
2381 FROM OE_ORDER_HEADERS
2382 WHERE HEADER_ID = p_hold_source_rec.hold_entity_id
2383 -- QUOTING change
2384 AND nvl(TRANSACTION_PHASE_CODE,'F') = 'F';
2385
2386
2387 -- ELSIF p_hold_source_rec.hold_entity_code = 'C' THEN --ER# 11824468
2388 ELSIF p_hold_source_rec.hold_entity_code IN ('C','CN','EC','EN') THEN --ER# 11824468 --ER#12571983 added ,'EC','EN'
2389 SELECT 'Valid Entity'
2390 INTO l_dummy
2391 FROM oe_sold_to_orgs_v
2392 WHERE ORGANIZATION_ID = p_hold_source_rec.hold_entity_id;
2393
2394 /* Following cursor has been changed to use direct TCA tables -Bug 1874065*/
2395 /*
2396 ELSIF p_hold_source_rec.hold_entity_code = 'S' THEN
2397 SELECT 'Valid Entity'
2398 INTO l_dummy
2399 FROM RA_SITE_USES
2400 WHERE site_use_id = p_hold_source_rec.hold_entity_id
2401 AND site_use_code = 'SHIP_TO'
2402 AND STATUS='A';*/
2403
2404 ELSIF p_hold_source_rec.hold_entity_code = 'S' THEN
2405 SELECT 'Valid Entity'
2406 INTO l_dummy
2407 FROM hz_cust_site_uses -- Bug 2138398
2408 WHERE site_use_id = p_hold_source_rec.hold_entity_id
2409 AND site_use_code = 'SHIP_TO'
2410 AND STATUS='A';
2411
2412 /* Following cursor has been changed to use direct TCA tables -Bug 1874065*/
2413 /* ELSIF p_hold_source_rec.hold_entity_code = 'B' THEN
2414 SELECT 'Valid Entity'
2415 INTO l_dummy
2416 FROM RA_SITE_USES
2417 WHERE site_use_id = p_hold_source_rec.hold_entity_id
2418 AND site_use_code = 'BILL_TO'
2419 AND STATUS='A';*/
2420
2421 ELSIF p_hold_source_rec.hold_entity_code = 'B' THEN
2422 SELECT 'Valid Entity'
2423 INTO l_dummy
2424 FROM hz_cust_site_uses -- Bug 2138398
2425 WHERE site_use_id = p_hold_source_rec.hold_entity_id
2426 AND site_use_code = 'BILL_TO'
2427 AND STATUS='A';
2428 --ER#7479609 start
2429 ELSIF p_hold_source_rec.hold_entity_code = 'D' THEN
2430 SELECT 'Valid Entity'
2431 INTO l_dummy
2432 FROM hz_cust_site_uses
2433 WHERE site_use_id = p_hold_source_rec.hold_entity_id
2434 AND site_use_code = 'DELIVER_TO'
2435 AND STATUS='A';
2436 --ER#7479609 end
2437 ELSIF p_hold_source_rec.hold_entity_code = 'I' THEN
2438 SELECT 'Valid Entity'
2439 INTO l_dummy
2440 from mtl_system_items_kfv
2441 where inventory_item_id = p_hold_source_rec.hold_entity_id;
2442
2443 --ER# 13331078 start
2444 ELSIF p_hold_source_rec.hold_entity_code = 'IC' THEN
2445 select 'Valid Entity'
2446 into l_dummy
2447 from mtl_categories
2448 where category_id = p_hold_source_rec.hold_entity_id;
2449 --ER# 13331078 end
2450 ELSIF p_hold_source_rec.hold_entity_code = 'W' THEN
2451 SELECT 'Valid Entity'
2452 INTO l_dummy
2453 from oe_ship_from_orgs_v
2454 where ORGANIZATION_id = p_hold_source_rec.hold_entity_id;
2455 ELSIF p_hold_source_rec.hold_entity_code = 'H' THEN
2456 SELECT 'Valid Entity'
2457 INTO l_dummy
2458 FROM oe_blanket_headers
2459 WHERE ORDER_NUMBER = p_hold_source_rec.hold_entity_id
2460 AND SALES_DOCUMENT_TYPE_CODE = 'B';
2461 --ER#7479609 start
2462 ELSIF p_hold_source_rec.hold_entity_code = 'TM' THEN
2463 SELECT 'Valid Entity'
2464 INTO l_dummy
2465 from mtl_system_items_kfv
2466 where inventory_item_id = p_hold_source_rec.hold_entity_id;
2467 ELSIF p_hold_source_rec.hold_entity_code = 'PR' THEN
2468 SELECT 'Valid Entity'
2469 INTO l_dummy
2470 FROM PJM_PROJECTS_ORG_OU_SECURE_V
2471 WHERE PROJECT_ID = p_hold_source_rec.hold_entity_id;
2472 ELSIF p_hold_source_rec.hold_entity_code = 'PL' THEN
2473 SELECT 'Valid Entity'
2474 INTO l_dummy
2475 FROM qp_list_headers_vl
2476 WHERE list_header_id = p_hold_source_rec.hold_entity_id;
2477 ELSIF p_hold_source_rec.hold_entity_code = 'OT' THEN
2478 SELECT 'Valid Entity'
2479 INTO l_dummy
2480 FROM oe_transaction_types
2481 WHERE transaction_type_id = p_hold_source_rec.hold_entity_id;
2482 ELSIF p_hold_source_rec.hold_entity_code = 'P' THEN
2483 SELECT 'Valid Entity'
2484 INTO l_dummy
2485 FROM oe_payment_types_vl
2486 WHERE payment_type_code = p_hold_source_rec.hold_entity_id;
2487 ELSIF p_hold_source_rec.hold_entity_code = 'CD' THEN
2488 NULL;
2489 ELSIF p_hold_source_rec.hold_entity_code = 'SC' THEN
2490 SELECT 'Valid Entity'
2491 INTO l_dummy
2492 FROM oe_lookups
2493 WHERE lookup_code = p_hold_source_rec.hold_entity_id
2494 AND lookup_type = 'SALES_CHANNEL';
2495 ELSIF p_hold_source_rec.hold_entity_code = 'PT' THEN
2496 SELECT 'Valid Entity'
2497 INTO l_dummy
2498 FROM oe_payment_types_vl
2499 WHERE payment_type_code = p_hold_source_rec.hold_entity_id;
2500 ELSIF p_hold_source_rec.hold_entity_code = 'SM' THEN
2501 SELECT 'Valid Entity'
2502 INTO l_dummy
2503 FROM oe_ship_methods_v
2504 WHERE lookup_code= p_hold_source_rec.hold_entity_id
2505 AND lookup_type = 'SHIP_METHOD';
2506 --ER#7479609 end
2507 ELSE
2508 OE_Debug_PUB.Add('Invalid Entity Code');
2509 FND_MESSAGE.SET_NAME('ONT', 'OE_MISSING_ENTITY_CODE');
2510 OE_MSG_PUB.ADD;
2511 RAISE FND_API.G_EXC_ERROR;
2512 END IF;
2513
2514 /*********************************
2515 ** Check the Second Entity **
2516 *********************************/
2517 IF p_hold_source_rec.hold_entity_code2 is not null THEN
2518 OE_Debug_PUB.Add('Second Entity Code->' ||
2519 p_hold_source_rec.hold_entity_code2,1);
2520 OE_Debug_PUB.Add('Second Entity ID' ||
2521 to_char(p_hold_source_rec.hold_entity_id2),1);
2522
2523 IF p_hold_source_rec.hold_entity_code2 = 'O' THEN
2524
2525 SELECT 'Valid Entity'
2526 INTO l_dummy
2527 FROM OE_ORDER_HEADERS
2528 WHERE HEADER_ID = p_hold_source_rec.hold_entity_id2
2529 -- QUOTING change
2530 AND nvl(TRANSACTION_PHASE_CODE,'F') = 'F';
2531
2532 -- ELSIF p_hold_source_rec.hold_entity_code2 = 'C' THEN --ER# 11824468
2533 ELSIF p_hold_source_rec.hold_entity_code2 IN('C','CN','EC','EN') THEN --ER# 11824468 --ER#12571983 added ,'EC','EN'
2534
2535 SELECT 'Valid Entity'
2536 INTO l_dummy
2537 FROM oe_sold_to_orgs_v
2538 WHERE ORGANIZATION_ID = p_hold_source_rec.hold_entity_id2;
2539
2540 /* Following cursor has been changed to use direct TCA tables -Bug 1874065*/
2541 /* ELSIF p_hold_source_rec.hold_entity_code2 = 'S' THEN
2542 SELECT 'Valid Entity'
2543 INTO l_dummy
2544 FROM RA_SITE_USES
2545 WHERE SITE_USE_ID = p_hold_source_rec.hold_entity_id2
2546 AND site_use_code = 'SHIP_TO';*/
2547 --ER#12571983 added ,'EL'
2548 ELSIF p_hold_source_rec.hold_entity_code2 ='EL' THEN
2549
2550 SELECT 'Valid Entity'
2551 INTO l_dummy
2552 FROM HZ_CUST_SITE_USES_ALL
2553 WHERE status='A'
2554 AND SITE_USE_CODE in ('SHIP_TO','SOLD_TO','DELIVER_TO','BILL_TO')
2555 AND SITE_USE_ID = p_hold_source_rec.hold_entity_id2;
2556 --ER#12571983 end
2557
2558 ELSIF p_hold_source_rec.hold_entity_code2 = 'S' THEN
2559 SELECT 'Valid Entity'
2560 INTO l_dummy
2561 FROM hz_cust_site_uses -- Bug 2138398
2562 WHERE SITE_USE_ID = p_hold_source_rec.hold_entity_id2
2563 AND site_use_code = 'SHIP_TO';
2564
2565
2566 /* Following cursor has been changed to use direct TCA tables -Bug 1874065*/
2567 /* ELSIF p_hold_source_rec.hold_entity_code2 = 'B' THEN
2568 SELECT 'Valid Entity'
2569 INTO l_dummy
2570 FROM RA_SITE_USES
2571 WHERE SITE_USE_ID = p_hold_source_rec.hold_entity_id2
2572 AND site_use_code = 'BILL_TO';*/
2573
2574 ELSIF p_hold_source_rec.hold_entity_code2 = 'B' THEN
2575 SELECT 'Valid Entity'
2576 INTO l_dummy
2577 FROM hz_cust_site_uses -- Bug 2138398
2578 WHERE SITE_USE_ID = p_hold_source_rec.hold_entity_id2
2579 AND site_use_code = 'BILL_TO';
2580 ELSIF p_hold_source_rec.hold_entity_code2 = 'H' THEN
2581 SELECT 'Valid Entity'
2582 INTO l_dummy
2583 FROM oe_blanket_headers
2584 WHERE ORDER_NUMBER = p_hold_source_rec.hold_entity_id2
2585 AND SALES_DOCUMENT_TYPE_CODE = 'B';
2586 ELSIF p_hold_source_rec.hold_entity_code2 = 'L' THEN
2587 SELECT 'Valid Entity'
2588 INTO l_dummy
2589 FROM oe_blanket_lines_ext
2590 WHERE ORDER_NUMBER = p_hold_source_rec.hold_entity_id
2591 AND LINE_NUMBER = p_hold_source_rec.hold_entity_id2;
2592 ELSIF p_hold_source_rec.hold_entity_code2 = 'W' THEN
2593 SELECT 'Valid Entity'
2594 INTO l_dummy
2595 from oe_ship_from_orgs_v
2596 where ORGANIZATION_id = p_hold_source_rec.hold_entity_id2;
2597 --ER#7479609 start
2598 ELSIF p_hold_source_rec.hold_entity_code2 = 'CB' THEN
2599 SELECT 'Valid Entity'
2600 INTO l_dummy
2601 FROM fnd_user
2602 WHERE user_id = p_hold_source_rec.hold_entity_id2;
2603 ELSIF p_hold_source_rec.hold_entity_code2 = 'D' THEN
2604 SELECT 'Valid Entity'
2605 INTO l_dummy
2606 FROM hz_cust_site_uses
2607 WHERE SITE_USE_ID = p_hold_source_rec.hold_entity_id2
2608 AND site_use_code = 'DELIVER_TO';
2609 ELSIF p_hold_source_rec.hold_entity_code2 in ('LT','OT') THEN
2610 SELECT 'Valid Entity'
2611 INTO l_dummy
2612 FROM oe_transaction_types
2613 WHERE transaction_type_id = p_hold_source_rec.hold_entity_id2;
2614 ELSIF p_hold_source_rec.hold_entity_code2 = 'OI' THEN
2615 SELECT 'Valid Entity'
2616 INTO l_dummy
2617 from mtl_system_items_kfv
2618 where inventory_item_id = p_hold_source_rec.hold_entity_id2;
2619 ELSIF p_hold_source_rec.hold_entity_code2 = 'PT' THEN
2620 SELECT 'Valid Entity'
2621 INTO l_dummy
2622 FROM ra_terms
2623 WHERE term_id = p_hold_source_rec.hold_entity_id2;
2624 ELSIF p_hold_source_rec.hold_entity_code2 = 'P' THEN
2625 SELECT 'Valid Entity'
2626 INTO l_dummy
2627 FROM oe_payment_types_vl
2628 WHERE payment_type_code = p_hold_source_rec.hold_entity_id2;
2629 ELSIF p_hold_source_rec.hold_entity_code2 = 'PL' THEN
2630 SELECT 'Valid Entity'
2631 INTO l_dummy
2632 from qp_list_headers_vl
2633 where list_header_id = p_hold_source_rec.hold_entity_id2;
2634 ELSIF p_hold_source_rec.hold_entity_code2 = 'PR' THEN
2635 SELECT 'Valid Entity'
2636 INTO l_dummy
2637 FROM PJM_PROJECTS_ORG_OU_SECURE_V
2638 WHERE PROJECT_ID = p_hold_source_rec.hold_entity_id2;
2639 ELSIF p_hold_source_rec.hold_entity_code2 = 'SC' THEN
2640 SELECT 'Valid Entity'
2641 INTO l_dummy
2642 FROM oe_lookups
2643 WHERE lookup_code = p_hold_source_rec.hold_entity_id2
2644 AND lookup_type = 'SALES_CHANNEL';
2645 ELSIF p_hold_source_rec.hold_entity_code2 = 'SM' THEN
2646 SELECT 'Valid Entity'
2647 INTO l_dummy
2648 from oe_ship_methods_v
2649 where lookup_code = p_hold_source_rec.hold_entity_id2
2650 AND lookup_type = 'SHIP_METHOD';
2651 ELSIF p_hold_source_rec.hold_entity_code2 = 'ST' THEN
2652 SELECT 'Valid Entity'
2653 INTO l_dummy
2654 FROM oe_lookups
2655 WHERE lookup_code = p_hold_source_rec.hold_entity_id2
2656 AND lookup_type = 'SOURCE_TYPE';
2657 ELSIF p_hold_source_rec.hold_entity_code2 = 'T' THEN
2658 SELECT 'Valid Entity'
2659 INTO l_dummy
2660 FROM PJM_TASKS_OU_V
2661 WHERE TASK_ID = p_hold_source_rec.hold_entity_id2;
2662 ELSIF p_hold_source_rec.hold_entity_code2 = 'TC' THEN
2663 SELECT 'Valid Entity'
2664 INTO l_dummy
2665 from fnd_currencies_vl
2666 where currency_code = p_hold_source_rec.hold_entity_id2;
2667 --ER#7479609 end
2668 ELSE
2669 OE_Debug_PUB.Add('Invalid Second Entity Code');
2670 FND_MESSAGE.SET_NAME('ONT', 'OE_MISSING_ENTITY_CODE');
2671 OE_MSG_PUB.ADD;
2672 RAISE FND_API.G_EXC_ERROR;
2673 END IF;
2674 END IF;
2675 ------------------------------
2676
2677 EXCEPTION
2678 WHEN TOO_MANY_ROWS THEN
2679 null;
2680 WHEN NO_DATA_FOUND THEN
2681 /* XXX Error message here */
2682 OE_Debug_PUB.Add('Hold Entity ID not found for entity',1);
2683 FND_MESSAGE.SET_NAME('ONT', 'OE_MISSING_ENTITY_ID');
2684 OE_MSG_PUB.ADD;
2685 RAISE FND_API.G_EXC_ERROR;
2686 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2687 WHEN FND_API.G_EXC_ERROR THEN
2688 /*
2689 ** This message is not required.
2690 FND_MESSAGE.SET_NAME('ONT', 'OE_ENTITY_NOT_ON_ORDER_OR_LINE');
2691 OE_MSG_PUB.ADD;
2692 */
2693 OE_Debug_PUB.Add('Expected error in Validate_Hold_source',1);
2694 x_return_status := FND_API.G_RET_STS_ERROR;
2695 WHEN OTHERS THEN
2696 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2697 IF OE_MSG_PUB.Check_Msg_Level
2698 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2699 THEN
2700 OE_MSG_PUB.Add_Exc_Msg
2701 ( G_PKG_NAME
2702 , l_api_name
2703 );
2704 END IF;
2705
2706 END Validate_Hold_Source;
2707
2708
2709 -----------------------
2710 Procedure Validate_Hold (
2711 p_hold_id IN OE_HOLD_DEFINITIONS.HOLD_id%TYPE,
2712 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
2713 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
2714 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
2715 IS
2716 l_dummy VARCHAR2(30) DEFAULT NULL;
2717 BEGIN
2718 x_return_status := FND_API.G_RET_STS_SUCCESS;
2719
2720
2721 -- Check for Missing Values
2722 IF p_hold_id IS NULL THEN
2723 FND_MESSAGE.SET_NAME('ONT', 'OE_MISSING_HOLD_ID');
2724 OE_MSG_PUB.ADD;
2725 RAISE FND_API.G_EXC_ERROR;
2726 END IF;
2727
2728
2729 -- Validate Hold ID
2730
2731 BEGIN
2732 SELECT 'x'
2733 INTO l_dummy
2734 FROM OE_HOLD_DEFINITIONS
2735 WHERE HOLD_ID = p_hold_id
2736 AND SYSDATE
2737 BETWEEN NVL(START_DATE_ACTIVE, SYSDATE )
2738 AND NVL(END_DATE_ACTIVE, SYSDATE );
2739
2740 EXCEPTION
2741
2742 WHEN NO_DATA_FOUND THEN
2743 OE_Debug_PUB.Add('Invalid Hold ID'||to_char(p_hold_id),1);
2744 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_HOLD_ID');
2745 FND_MESSAGE.SET_TOKEN('HOLD_ID',p_hold_id);
2746 OE_MSG_PUB.ADD;
2747 x_return_status := FND_API.G_RET_STS_ERROR;
2748
2749 END; -- Validate Hold ID
2750
2751 END Validate_Hold;
2752
2753 ----------------------
2754 ---Overload procedure for bug5548778
2755 Procedure Create_Hold_Source (
2756 p_hold_source_rec IN OE_HOLDS_PVT.Hold_Source_Rec_Type,
2757 p_org_id IN NUMBER DEFAULT MO_GLOBAL.get_current_org_id, --ER#7479609
2758 x_hold_source_id OUT NOCOPY /* file.sql.39 change */ OE_HOLD_SOURCES_ALL.HOLD_SOURCE_ID%TYPE,
2759 x_hold_exists OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
2760 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
2761 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
2762 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
2763 IS
2764 l_api_name CONSTANT VARCHAR2(30) := 'CREATE_HOLD_SOURCE';
2765 l_user_id NUMBER;
2766 l_org_id NUMBER;
2767 l_count NUMBER;
2768 --l_hold_source_id OE_HOLD_SOURCES_ALL.HOLD_SOURCE_ID%TYPE;
2769 l_hold_source_rec OE_HOLDS_PVT.Hold_Source_Rec_Type;
2770 BEGIN
2771 x_return_status := FND_API.G_RET_STS_SUCCESS;
2772 x_hold_exists := 'N';
2773 l_user_id := OE_HOLDS_PVT.get_user_id;
2774 l_org_id := MO_GLOBAL.get_current_org_id;
2775 IF l_org_id IS NULL THEN
2776 -- org_id is null, raise an error.
2777 oe_debug_pub.add('Org_Id is NULL',1);
2778 x_return_status := FND_API.G_RET_STS_ERROR;
2779 FND_MESSAGE.SET_NAME('FND','MO_ORG_REQUIRED');
2780 FND_MSG_PUB.ADD;
2781 RAISE FND_API.G_EXC_ERROR;
2782 END IF;
2783
2784 if (p_hold_source_rec.hold_entity_code = 'O'
2785 AND p_hold_source_rec.hold_entity_code2 is NULL) then
2786 /* If Line-level hold */
2787 IF p_hold_source_rec.line_id is not null THEN
2788 select count(*)
2789 into l_count
2790 --ER#7479609 FROM OE_HOLD_SOURCES HS
2791 FROM OE_HOLD_SOURCES_ALL HS --ER#7479609
2792 WHERE HS.HOLD_ID = p_hold_source_rec.hold_id
2793 AND HS.HOLD_ENTITY_CODE = p_hold_source_rec.hold_entity_code
2794 AND HS.HOLD_ENTITY_ID = p_hold_source_rec.hold_entity_id
2795 AND HS.HOLD_ENTITY_CODE2 is null
2796 AND HS.HOLD_ENTITY_ID2 is null
2797 AND HS.RELEASED_FLAG = 'N'
2798 AND HS.org_id= p_org_id --ER#7479609
2799 AND NVL(HS.HOLD_UNTIL_DATE, SYSDATE + 1) > SYSDATE
2800 AND EXISTS ( select 'x'
2801 --ER#7479609 from oe_order_holds OH
2802 from oe_order_holds_all OH --ER#7479609
2803 where OH.line_id = p_hold_source_rec.line_id
2804 and OH.org_id= p_org_id --ER#7479609
2805 and OH.hold_source_id = HS.hold_source_id);
2806
2807 IF l_count > 0 THEN
2808 OE_Debug_PUB.Add('Duplicate Hold Source for EntityID'||
2809 to_char(p_hold_source_rec.hold_entity_id) ,1);
2810 --FND_MESSAGE.SET_NAME('ONT', 'OE_DUPLICATE_HOLD');
2811 FND_MESSAGE.SET_NAME('ONT', 'OE_DUPLICATE_HOLD_SOURCE');
2812 OE_MSG_PUB.ADD;
2813 x_hold_exists := 'Y';
2814 RETURN;
2815 --RAISE FND_API.G_EXC_ERROR;
2816 END IF;
2817 /* If Order Level Hold */
2818 ELSE
2819 select count(*)
2820 into l_count
2821 --ER#7479609 FROM OE_HOLD_SOURCES HS
2822 FROM OE_HOLD_SOURCES_ALL HS --ER#7479609
2823 WHERE HS.HOLD_ID = p_hold_source_rec.hold_id
2824 AND HS.HOLD_ENTITY_CODE = p_hold_source_rec.hold_entity_code
2825 AND HS.HOLD_ENTITY_ID = p_hold_source_rec.hold_entity_id
2826 AND HS.HOLD_ENTITY_CODE2 is null
2827 AND HS.HOLD_ENTITY_ID2 is null
2828 AND HS.RELEASED_FLAG = 'N'
2829 AND HS.org_id= p_org_id --ER#7479609
2830 AND NVL(HS.HOLD_UNTIL_DATE, SYSDATE + 1) > SYSDATE
2831 AND EXISTS ( select 'x'
2832 --ER#7479609 from oe_order_holds OH
2833 from oe_order_holds_all OH --ER#7479609
2834 where OH.line_id is null
2835 and OH.org_id= p_org_id --ER#7479609
2836 and OH.hold_source_id = HS.hold_source_id);
2837
2838 IF l_count > 0 THEN
2839 OE_Debug_PUB.Add('Duplicate Hold Source for EntityID'||
2840 to_char(p_hold_source_rec.hold_entity_id) ,1);
2841 --FND_MESSAGE.SET_NAME('ONT', 'OE_DUPLICATE_HOLD');
2842 FND_MESSAGE.SET_NAME('ONT', 'OE_DUPLICATE_HOLD_SOURCE');
2843 OE_MSG_PUB.ADD;
2844 x_hold_exists := 'Y';
2845 RETURN;
2846 --RAISE FND_API.G_EXC_ERROR;
2847 END IF;
2848
2849 END IF; /*If Order Level Hold */
2850 else
2851 select count(*)
2852 into l_count
2853 --ER#7479609 FROM OE_HOLD_SOURCES HS
2854 FROM OE_HOLD_SOURCES_ALL HS --ER#7479609
2855 WHERE HS.HOLD_ID = p_hold_source_rec.hold_id
2856 AND HS.HOLD_ENTITY_CODE = p_hold_source_rec.hold_entity_code
2857 AND HS.HOLD_ENTITY_ID = p_hold_source_rec.hold_entity_id
2858 AND HS.org_id= p_org_id --ER#7479609
2859 AND nvl(HS.HOLD_ENTITY_CODE2, 'NO_ENTITY_CODE2') =
2860 nvl(p_hold_source_rec.hold_entity_code2, 'NO_ENTITY_CODE2')
2861 AND nvl(HS.HOLD_ENTITY_ID2, -99) =
2862 nvl(p_hold_source_rec.hold_entity_id2,-99 )
2863 AND HS.RELEASED_FLAG = 'N'
2864 AND NVL(HS.HOLD_UNTIL_DATE, SYSDATE + 1) > SYSDATE;
2865
2866 IF l_count > 0 THEN
2867 OE_Debug_PUB.Add('Duplicate Hold Source for EntityID'||
2868 to_char(p_hold_source_rec.hold_entity_id) ,1);
2869 --FND_MESSAGE.SET_NAME('ONT', 'OE_DUPLICATE_HOLD');
2870 FND_MESSAGE.SET_NAME('ONT', 'OE_DUPLICATE_HOLD_SOURCE');
2871 OE_MSG_PUB.ADD;
2872 --RETURN;
2873 RAISE FND_API.G_EXC_ERROR;
2874 END IF;
2875 end if;
2876
2877
2878 -- Inserting a NEW HOLD SOURCE record
2879
2880 SELECT OE_HOLD_SOURCES_S.NEXTVAL
2881 INTO x_hold_source_id
2882 FROM DUAL;
2883
2884 INSERT INTO OE_HOLD_SOURCES_ALL
2885 ( HOLD_SOURCE_ID
2886 , LAST_UPDATE_DATE
2887 , LAST_UPDATED_BY
2888 , CREATION_DATE
2889 , CREATED_BY
2890 , LAST_UPDATE_LOGIN
2891 , PROGRAM_APPLICATION_ID
2892 , PROGRAM_ID
2893 , PROGRAM_UPDATE_DATE
2894 , REQUEST_ID
2895 , HOLD_ID
2896 , HOLD_ENTITY_CODE
2897 , HOLD_ENTITY_ID
2898 , HOLD_UNTIL_DATE
2899 , RELEASED_FLAG
2900 , HOLD_COMMENT
2901 , ORG_ID
2902 , CONTEXT
2903 , ATTRIBUTE1
2904 , ATTRIBUTE2
2905 , ATTRIBUTE3
2906 , ATTRIBUTE4
2907 , ATTRIBUTE5
2908 , ATTRIBUTE6
2909 , ATTRIBUTE7
2910 , ATTRIBUTE8
2911 , ATTRIBUTE9
2912 , ATTRIBUTE10
2913 , ATTRIBUTE11
2914 , ATTRIBUTE12
2915 , ATTRIBUTE13
2916 , ATTRIBUTE14
2917 , ATTRIBUTE15
2918 , HOLD_RELEASE_ID
2919 ,HOLD_ENTITY_CODE2
2920 ,HOLD_ENTITY_ID2
2921 )
2922 VALUES
2923 ( x_hold_source_id
2924 , sysdate
2925 , l_user_id
2926 , sysdate
2927 , l_user_id
2928 , p_hold_source_rec.LAST_UPDATE_LOGIN
2929 , p_hold_source_rec.PROGRAM_APPLICATION_ID
2930 , p_hold_source_rec.PROGRAM_ID
2931 , p_hold_source_rec.PROGRAM_UPDATE_DATE
2932 , p_hold_source_rec.REQUEST_ID
2933 , p_hold_source_rec.HOLD_ID
2934 , p_hold_source_rec.HOLD_ENTITY_CODE
2935 , p_hold_source_rec.HOLD_ENTITY_ID
2936 , p_hold_source_rec.HOLD_UNTIL_DATE
2937 , 'N'
2938 , p_hold_source_rec.HOLD_COMMENT
2939 , p_org_id --ER#7479609 l_org_id
2940 , p_hold_source_rec.CONTEXT
2941 , p_hold_source_rec.ATTRIBUTE1
2942 , p_hold_source_rec.ATTRIBUTE2
2943 , p_hold_source_rec.ATTRIBUTE3
2944 , p_hold_source_rec.ATTRIBUTE4
2945 , p_hold_source_rec.ATTRIBUTE5
2946 , p_hold_source_rec.ATTRIBUTE6
2947 , p_hold_source_rec.ATTRIBUTE7
2948 , p_hold_source_rec.ATTRIBUTE8
2949 , p_hold_source_rec.ATTRIBUTE9
2950 , p_hold_source_rec.ATTRIBUTE10
2951 , p_hold_source_rec.ATTRIBUTE11
2952 , p_hold_source_rec.ATTRIBUTE12
2953 , p_hold_source_rec.ATTRIBUTE13
2954 , p_hold_source_rec.ATTRIBUTE14
2955 , p_hold_source_rec.ATTRIBUTE15
2956 , p_hold_source_rec.HOLD_RELEASE_ID
2957 , p_hold_source_rec.HOLD_ENTITY_CODE2
2958 , p_hold_source_rec.HOLD_ENTITY_ID2
2959 );
2960
2961 --l_hold_source_rec := p_hold_source_rec;
2962 --l_hold_source_rec.hold_source_id := l_hold_source_id;
2963
2964 --dbms_output.put_line ('Caling Create_Order_Holds');
2965
2966 EXCEPTION
2967 WHEN FND_API.G_EXC_ERROR THEN
2968 --ROLLBACK TO Create_Hold_Source;
2969 x_return_status := FND_API.G_RET_STS_ERROR;
2970 OE_MSG_PUB.Count_And_Get
2971 ( p_count => x_msg_count
2972 , p_data => x_msg_data
2973 );
2974 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2975 --ROLLBACK TO Create_Hold_Source;
2976 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2977 OE_MSG_PUB.Count_And_Get
2978 ( p_count => x_msg_count
2979 , p_data => x_msg_data
2980 );
2981 WHEN OTHERS THEN
2982 --ROLLBACK TO Create_Hold_Source;
2983 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2984 IF OE_MSG_PUB.Check_Msg_Level
2985 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2986 THEN
2987 OE_MSG_PUB.Add_Exc_Msg
2988 ( G_PKG_NAME,
2989 l_api_name);
2990 END IF;
2991 OE_MSG_PUB.Count_And_Get
2992 ( p_count => x_msg_count
2993 , p_data => x_msg_data
2994 );
2995 END Create_Hold_Source;
2996
2997 ------
2998 Procedure Create_Hold_Source (
2999 p_hold_source_rec IN OE_HOLDS_PVT.Hold_Source_Rec_Type,
3000 p_org_id IN NUMBER DEFAULT MO_GLOBAL.get_current_org_id, --ER#7479609
3001 x_hold_source_id OUT NOCOPY /* file.sql.39 change */ OE_HOLD_SOURCES_ALL.HOLD_SOURCE_ID%TYPE,
3002 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
3003 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
3004 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
3005 IS
3006 l_api_name CONSTANT VARCHAR2(30) := 'CREATE_HOLD_SOURCE';
3007 l_user_id NUMBER;
3008 l_org_id NUMBER;
3009 l_count NUMBER;
3010 --l_hold_source_id OE_HOLD_SOURCES_ALL.HOLD_SOURCE_ID%TYPE;
3011 l_hold_source_rec OE_HOLDS_PVT.Hold_Source_Rec_Type;
3012 l_hold_comment OE_HOLD_SOURCES_ALL.HOLD_COMMENT%TYPE; --ER#7479609
3013 BEGIN
3014 x_return_status := FND_API.G_RET_STS_SUCCESS;
3015 l_user_id := OE_HOLDS_PVT.get_user_id;
3016 l_org_id := MO_GLOBAL.get_current_org_id;
3017 IF l_org_id IS NULL THEN
3018 -- org_id is null, raise an error.
3019 oe_debug_pub.add('Org_Id is NULL',1);
3020 x_return_status := FND_API.G_RET_STS_ERROR;
3021 FND_MESSAGE.SET_NAME('FND','MO_ORG_REQUIRED');
3022 FND_MSG_PUB.ADD;
3023 RAISE FND_API.G_EXC_ERROR;
3024 END IF;
3025
3026 if (p_hold_source_rec.hold_entity_code = 'O'
3027 AND p_hold_source_rec.hold_entity_code2 is NULL) then
3028 /* If Line-level hold */
3029 IF p_hold_source_rec.line_id is not null THEN
3030 select count(*)
3031 into l_count
3032 --ER#7479609 FROM OE_HOLD_SOURCES HS
3033 FROM OE_HOLD_SOURCES_ALL HS --ER#7479609
3034 WHERE HS.HOLD_ID = p_hold_source_rec.hold_id
3035 AND HS.HOLD_ENTITY_CODE = p_hold_source_rec.hold_entity_code
3036 AND HS.HOLD_ENTITY_ID = p_hold_source_rec.hold_entity_id
3037 AND HS.HOLD_ENTITY_CODE2 is null
3038 AND HS.HOLD_ENTITY_ID2 is null
3039 AND HS.RELEASED_FLAG = 'N'
3040 AND HS.ORG_ID = p_org_id --ER#7479609
3041 AND NVL(HS.HOLD_UNTIL_DATE, SYSDATE + 1) > SYSDATE
3042 AND EXISTS ( select 'x'
3043 --ER#7479609 from oe_order_holds OH
3044 from oe_order_holds_all OH --ER#7479609
3045 where OH.line_id = p_hold_source_rec.line_id
3046 and OH.hold_source_id = HS.hold_source_id);
3047
3048 IF l_count > 0 THEN
3049 OE_Debug_PUB.Add('Duplicate Hold Source for EntityID'||
3050 to_char(p_hold_source_rec.hold_entity_id) ,1);
3051 --FND_MESSAGE.SET_NAME('ONT', 'OE_DUPLICATE_HOLD');
3052 FND_MESSAGE.SET_NAME('ONT', 'OE_DUPLICATE_HOLD_SOURCE');
3053 OE_MSG_PUB.ADD;
3054 --RETURN;
3055 RAISE FND_API.G_EXC_ERROR;
3056 END IF;
3057 /* If Order Level Hold */
3058 ELSE
3059 select count(*)
3060 into l_count
3061 --ER#7479609 FROM OE_HOLD_SOURCES HS
3062 FROM OE_HOLD_SOURCES_ALL HS --ER#7479609
3063 WHERE HS.HOLD_ID = p_hold_source_rec.hold_id
3064 AND HS.HOLD_ENTITY_CODE = p_hold_source_rec.hold_entity_code
3065 AND HS.HOLD_ENTITY_ID = p_hold_source_rec.hold_entity_id
3066 AND HS.HOLD_ENTITY_CODE2 is null
3067 AND HS.HOLD_ENTITY_ID2 is null
3068 AND HS.RELEASED_FLAG = 'N'
3069 AND HS.ORG_ID = p_org_id --ER#7479609
3070 AND NVL(HS.HOLD_UNTIL_DATE, SYSDATE + 1) > SYSDATE
3071 AND EXISTS ( select 'x'
3072 --ER#7479609 from oe_order_holds OH
3073 from oe_order_holds_all OH --ER#7479609
3074 where OH.line_id is null
3075 and OH.hold_source_id = HS.hold_source_id);
3076
3077 IF l_count > 0 THEN
3078 OE_Debug_PUB.Add('Duplicate Hold Source for EntityID'||
3079 to_char(p_hold_source_rec.hold_entity_id) ,1);
3080 --FND_MESSAGE.SET_NAME('ONT', 'OE_DUPLICATE_HOLD');
3081 FND_MESSAGE.SET_NAME('ONT', 'OE_DUPLICATE_HOLD_SOURCE');
3082 OE_MSG_PUB.ADD;
3083 --RETURN;
3084 RAISE FND_API.G_EXC_ERROR;
3085 END IF;
3086
3087 END IF; /*If Order Level Hold */
3088 else
3089 select count(*)
3090 into l_count
3091 --ER#7479609 FROM OE_HOLD_SOURCES HS
3092 FROM OE_HOLD_SOURCES_ALL HS --ER#7479609
3093 WHERE HS.HOLD_ID = p_hold_source_rec.hold_id
3094 AND HS.HOLD_ENTITY_CODE = p_hold_source_rec.hold_entity_code
3095 AND HS.HOLD_ENTITY_ID = p_hold_source_rec.hold_entity_id
3096 AND nvl(HS.HOLD_ENTITY_CODE2, 'NO_ENTITY_CODE2') =
3097 nvl(p_hold_source_rec.hold_entity_code2, 'NO_ENTITY_CODE2')
3098 AND nvl(HS.HOLD_ENTITY_ID2, -99) =
3099 nvl(p_hold_source_rec.hold_entity_id2,-99 )
3100 AND HS.RELEASED_FLAG = 'N'
3101 AND HS.ORG_ID = p_org_id --ER#7479609
3102 AND NVL(HS.HOLD_UNTIL_DATE, SYSDATE + 1) > SYSDATE;
3103
3104 -- AND EXISTS ( select 'x'
3105 -- from oe_order_holds
3106 -- where header_id = p_hold_source_rec.hold_entity_id
3107 -- and line_id = nvl(p_hold_source_rec.line_id, -99));
3108
3109 IF l_count > 0 THEN
3110 OE_Debug_PUB.Add('Duplicate Hold Source for EntityID'||
3111 to_char(p_hold_source_rec.hold_entity_id) ,1);
3112 --FND_MESSAGE.SET_NAME('ONT', 'OE_DUPLICATE_HOLD');
3113 FND_MESSAGE.SET_NAME('ONT', 'OE_DUPLICATE_HOLD_SOURCE');
3114 OE_MSG_PUB.ADD;
3115 --RETURN;
3116 RAISE FND_API.G_EXC_ERROR;
3117 END IF;
3118
3119 end if;
3120
3121 -- Check to see if the hold source already exists
3122 -- and if exists, retrieve hold source ID.
3123
3124 -- BEGIN
3125 -- SELECT HOLD_SOURCE_ID
3126 -- INTO l_hold_source_id
3127 -- FROM OE_HOLD_SOURCES HS
3128 -- WHERE HS.HOLD_ID = p_hold_source_rec.hold_id
3129 -- AND HS.HOLD_ENTITY_CODE = p_hold_source_rec.hold_entity_code
3130 -- AND HS.HOLD_ENTITY_ID = p_hold_source_rec.hold_entity_id
3131 -- AND nvl(HS.HOLD_ENTITY_CODE2, 'NO_ENTITY_CODE2') =
3132 -- nvl(p_hold_source_rec.hold_entity_code2, 'NO_ENTITY_CODE2')
3133 -- AND nvl(HS.HOLD_ENTITY_ID2, -99) =
3134 -- nvl(p_hold_source_rec.hold_entity_id2,-99 )
3135 -- AND HS.RELEASED_FLAG = 'N'
3136 -- AND NVL(HS.HOLD_UNTIL_DATE, SYSDATE + 1) > SYSDATE;
3137
3138 -- oe_debug_pub.add('Using Existing Hold Source for:' ||
3139 -- to_char(p_hold_source_rec.hold_entity_id) || 'And:' ||
3140 -- nvl(to_char(p_hold_source_rec.hold_entity_id2), 'No Second Entity'),3);
3141 -- EXCEPTION
3142 -- WHEN NO_DATA_FOUND THEN
3143
3144 -- Inserting a NEW HOLD SOURCE record
3145
3146 --ER#7479609 start
3147 l_hold_comment := p_hold_source_rec.HOLD_COMMENT;
3148 IF p_hold_source_rec.hold_id = 1 and p_hold_source_rec.HOLD_COMMENT IS NULL THEN
3149 l_hold_comment := 'Credit Hold check box has been enabled that has put the hold';
3150 END IF;
3151
3152 --ER#7479609 end
3153
3154
3155 SELECT OE_HOLD_SOURCES_S.NEXTVAL
3156 INTO x_hold_source_id
3157 FROM DUAL;
3158
3159 INSERT INTO OE_HOLD_SOURCES_ALL
3160 ( HOLD_SOURCE_ID
3161 , LAST_UPDATE_DATE
3162 , LAST_UPDATED_BY
3163 , CREATION_DATE
3164 , CREATED_BY
3165 , LAST_UPDATE_LOGIN
3166 , PROGRAM_APPLICATION_ID
3167 , PROGRAM_ID
3168 , PROGRAM_UPDATE_DATE
3169 , REQUEST_ID
3170 , HOLD_ID
3171 , HOLD_ENTITY_CODE
3172 , HOLD_ENTITY_ID
3173 , HOLD_UNTIL_DATE
3174 , RELEASED_FLAG
3175 , HOLD_COMMENT
3176 , ORG_ID
3177 , CONTEXT
3178 , ATTRIBUTE1
3179 , ATTRIBUTE2
3180 , ATTRIBUTE3
3181 , ATTRIBUTE4
3182 , ATTRIBUTE5
3183 , ATTRIBUTE6
3184 , ATTRIBUTE7
3185 , ATTRIBUTE8
3186 , ATTRIBUTE9
3187 , ATTRIBUTE10
3188 , ATTRIBUTE11
3189 , ATTRIBUTE12
3190 , ATTRIBUTE13
3191 , ATTRIBUTE14
3192 , ATTRIBUTE15
3193 , HOLD_RELEASE_ID
3194 ,HOLD_ENTITY_CODE2
3195 ,HOLD_ENTITY_ID2
3196 )
3197 VALUES
3198 ( x_hold_source_id
3199 , sysdate
3200 , l_user_id
3201 , sysdate
3202 , l_user_id
3203 , p_hold_source_rec.LAST_UPDATE_LOGIN
3204 , p_hold_source_rec.PROGRAM_APPLICATION_ID
3205 , p_hold_source_rec.PROGRAM_ID
3206 , p_hold_source_rec.PROGRAM_UPDATE_DATE
3207 , p_hold_source_rec.REQUEST_ID
3208 , p_hold_source_rec.HOLD_ID
3209 , p_hold_source_rec.HOLD_ENTITY_CODE
3210 , p_hold_source_rec.HOLD_ENTITY_ID
3211 , p_hold_source_rec.HOLD_UNTIL_DATE
3212 , 'N'
3213 , l_hold_comment --ER#7479609 p_hold_source_rec.HOLD_COMMENT
3214 , p_org_id --ER#7479609 l_org_id
3215 , p_hold_source_rec.CONTEXT
3216 , p_hold_source_rec.ATTRIBUTE1
3217 , p_hold_source_rec.ATTRIBUTE2
3218 , p_hold_source_rec.ATTRIBUTE3
3219 , p_hold_source_rec.ATTRIBUTE4
3220 , p_hold_source_rec.ATTRIBUTE5
3221 , p_hold_source_rec.ATTRIBUTE6
3222 , p_hold_source_rec.ATTRIBUTE7
3223 , p_hold_source_rec.ATTRIBUTE8
3224 , p_hold_source_rec.ATTRIBUTE9
3225 , p_hold_source_rec.ATTRIBUTE10
3226 , p_hold_source_rec.ATTRIBUTE11
3227 , p_hold_source_rec.ATTRIBUTE12
3228 , p_hold_source_rec.ATTRIBUTE13
3229 , p_hold_source_rec.ATTRIBUTE14
3230 , p_hold_source_rec.ATTRIBUTE15
3231 , p_hold_source_rec.HOLD_RELEASE_ID
3232 , p_hold_source_rec.HOLD_ENTITY_CODE2
3233 , p_hold_source_rec.HOLD_ENTITY_ID2
3234 );
3235
3236 --l_hold_source_rec := p_hold_source_rec;
3237 --l_hold_source_rec.hold_source_id := l_hold_source_id;
3238
3239 --dbms_output.put_line ('Caling Create_Order_Holds');
3240
3241 EXCEPTION
3242 WHEN FND_API.G_EXC_ERROR THEN
3243 --ROLLBACK TO Create_Hold_Source;
3244 x_return_status := FND_API.G_RET_STS_ERROR;
3245 OE_MSG_PUB.Count_And_Get
3246 ( p_count => x_msg_count
3247 , p_data => x_msg_data
3248 );
3249 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3250 --ROLLBACK TO Create_Hold_Source;
3251 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3252 OE_MSG_PUB.Count_And_Get
3253 ( p_count => x_msg_count
3254 , p_data => x_msg_data
3255 );
3256 WHEN OTHERS THEN
3257 --ROLLBACK TO Create_Hold_Source;
3258 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3259 IF OE_MSG_PUB.Check_Msg_Level
3260 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3261 THEN
3262 OE_MSG_PUB.Add_Exc_Msg
3263 ( G_PKG_NAME,
3264 l_api_name);
3265 END IF;
3266 OE_MSG_PUB.Count_And_Get
3267 ( p_count => x_msg_count
3268 , p_data => x_msg_data
3269 );
3270 END Create_Hold_Source;
3271
3272
3273 ---------------------
3274 Procedure Create_Order_Holds(
3275 p_hold_source_rec IN OE_HOLDS_PVT.Hold_Source_Rec_Type,
3276 p_org_id IN NUMBER DEFAULT MO_GLOBAL.get_current_org_id, --ER#7479609
3277 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
3278 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
3279 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
3280 IS
3281 l_user_id NUMBER;
3282 l_org_id NUMBER;
3283 l_api_name CONSTANT VARCHAR2(30) := 'Create_Order_Holds';
3284 l_site_use_code VARCHAR2(30);
3285 /*Added the three variables for WF_HOLDS bug 6449458*/
3286 l_is_hold_applied BOOLEAN DEFAULT NULL;
3287 l_wf_item_type OE_HOLD_DEFINITIONS.ITEM_TYPE%TYPE := NULL;
3288 l_wf_activity_name OE_HOLD_DEFINITIONS.ACTIVITY_NAME%TYPE := NULL;
3289
3290
3291 /* Moved to Overloaded Procedure under Bug 6801108
3292 -- GENESIS --
3293 l_check_hold VARCHAR2(1) := 'N';
3294
3295 CURSOR check_line_hold_type_cur(p_line_id IN NUMBER) IS
3296 SELECT 'Y'
3297 FROM DUAL
3298 WHERE EXISTS (SELECT NULL
3299 FROM oe_order_holds ooh,
3300 oe_hold_sources ohs,
3301 oe_hold_definitions ohd,
3302 oe_order_headers_all h,
3303 oe_order_sources oos
3304 WHERE ohd.activity_name IS NULL
3305 AND ohd.hold_id = ohs.hold_id
3306 AND ooh.header_id = h.header_id
3307 AND h.order_source_id = oos.order_source_id
3308 AND oos.aia_enabled_flag = 'Y'
3309 AND ohs.hold_source_id = ooh.hold_source_id
3310 AND ooh.line_id = p_line_id);
3311
3312 CURSOR check_hdr_hold_type_cur(p_hdr_id IN NUMBER) IS
3313 SELECT 'Y'
3314 FROM DUAL
3315 WHERE EXISTS (SELECT NULL
3316 FROM oe_order_holds ooh,
3317 oe_hold_sources ohs,
3318 oe_hold_definitions ohd,
3319 oe_order_headers_all h,
3320 oe_order_sources oos
3321 WHERE ohd.activity_name IS NULL
3322 AND ohd.hold_id = ohs.hold_id
3323 AND h.order_source_id = oos.order_source_id
3324 AND oos.aia_enabled_flag = 'Y'
3325 AND ooh.header_id = h.header_id
3326 AND ohs.hold_source_id = ooh.hold_source_id
3327 AND ooh.header_id = p_hdr_id);
3328
3329 CURSOR check_src_hold_type_cur(p_hld_src_id IN NUMBER) IS
3330 SELECT 'Y'
3331 FROM DUAL
3332 WHERE EXISTS (SELECT NULL
3333 FROM oe_hold_sources ohs,
3334 oe_hold_definitions ohd
3335 WHERE ohd.activity_name IS NULL
3336 AND ohd.hold_id = ohs.hold_id
3337 AND ohs.hold_source_id = p_hld_src_id);
3338
3339 l_header_rec OE_Order_PUB.Header_Rec_Type;
3340 l_line_rec OE_Order_PUB.Line_Rec_Type;*/
3341 -- GENESIS --
3342 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
3343 BEGIN
3344 x_return_status := FND_API.G_RET_STS_SUCCESS;
3345 l_user_id := OE_HOLDS_PVT.get_user_id;
3346 l_org_id := MO_GLOBAL.get_current_org_id;
3347 IF l_org_id IS NULL THEN
3348 -- org_id is null, raise an error.
3349 oe_debug_pub.add('Org_Id is NULL',1);
3350 x_return_status := FND_API.G_RET_STS_ERROR;
3351 FND_MESSAGE.SET_NAME('FND','MO_ORG_REQUIRED');
3352 FND_MSG_PUB.ADD;
3353 RAISE FND_API.G_EXC_ERROR;
3354 END IF;
3355
3356 Begin
3357 select item_type, activity_name
3358 into l_wf_item_type, l_wf_activity_name
3359 from oe_hold_definitions
3360 where hold_id = p_hold_source_rec.hold_id;
3361 Exception
3362 When NO_DATA_FOUND Then
3363 NULL; -- OE_Holds_Pvt.Validate has not yet been called.
3364 End;
3365
3366 OE_DEBUG_PUB.Add ('Calling Overloaded Create_Order_Holds Based on Workflow from original Create_Order_Holds',1);
3367 Create_Order_Holds (
3368 p_hold_source_rec => p_hold_source_rec
3369 ,p_org_id => p_org_id --ER#7479609
3370 ,p_item_type => l_wf_item_type
3371 ,p_activity_name => l_wf_activity_name
3372 ,x_return_status => x_return_status
3373 ,x_msg_count => x_msg_count
3374 ,x_msg_data => x_msg_data
3375 ,x_is_hold_applied => l_is_hold_applied);
3376
3377 /*oe_debug_pub.add('p_hold_source_rec.hold_source_id:' ||
3378 p_hold_source_rec.hold_source_id);
3379 oe_debug_pub.add('Hold_entity_code/Hold_entity_id/' ||
3380 'Hold_entity_code2/Hold_entity_id2:' ||
3381 p_hold_source_rec.Hold_entity_code || '/' ||
3382 p_hold_source_rec.Hold_entity_id || '/' ||
3383 p_hold_source_rec.Hold_entity_code2 || '/' ||
3384 p_hold_source_rec.Hold_entity_id2);
3385 oe_debug_pub.add('p_hold_source_rec.header_id:' || p_hold_source_rec.header_id);
3386 oe_debug_pub.add('p_hold_source_rec.line_id:' || p_hold_source_rec.line_id);
3387 -- Insert a hold record for the order header or the order line.
3388
3389 IF p_hold_source_rec.hold_entity_code = 'I' and
3390 p_hold_source_rec.hold_entity_code2 = 'C' THEN
3391 IF p_hold_source_rec.line_id IS NOT NULL THEN
3392 INSERT INTO OE_ORDER_HOLDS_ALL
3393 ( ORDER_HOLD_ID
3394 , LAST_UPDATE_DATE
3395 , LAST_UPDATED_BY
3396 , CREATION_DATE
3397 , CREATED_BY
3398 , LAST_UPDATE_LOGIN
3399 , HOLD_SOURCE_ID
3400 , HEADER_ID
3401 , LINE_ID
3402 , RELEASED_FLAG
3403 , ORG_ID
3404 )
3405 SELECT
3406 OE_ORDER_HOLDS_S.NEXTVAL
3407 , SYSDATE
3408 , l_user_id
3409 , SYSDATE
3410 , l_user_id
3411 , NULL
3412 , p_hold_source_rec.hold_source_id
3413 , h.HEADER_ID
3414 , ol.line_id
3415 , 'N'
3416 , l_org_id
3417 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
3418 WHERE h.OPEN_FLAG = 'Y'
3419 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
3420 and h.SOLD_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
3421 and h.header_id = ol.header_id
3422 and ol.line_id = p_hold_source_rec.line_id
3423 and ol.INVENTORY_ITEM_ID = p_hold_source_rec.hold_entity_id
3424 and ol.OPEN_FLAG = 'Y'
3425 -- QUOTING change
3426 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
3427 and not exists ( select 'x'
3428 from oe_order_holds_ALL oh
3429 where oh.header_id = h.header_id
3430 and oh.line_id = ol.line_id
3431 and oh.hold_source_id =
3432 p_hold_source_rec.hold_source_id );
3433 ELSE
3434 INSERT INTO OE_ORDER_HOLDS_ALL
3435 ( ORDER_HOLD_ID
3436 , LAST_UPDATE_DATE
3437 , LAST_UPDATED_BY
3438 , CREATION_DATE
3439 , CREATED_BY
3440 , LAST_UPDATE_LOGIN
3441 , HOLD_SOURCE_ID
3442 , HEADER_ID
3443 , LINE_ID
3444 , RELEASED_FLAG
3445 , ORG_ID
3446 )
3447 SELECT
3448 OE_ORDER_HOLDS_S.NEXTVAL
3449 , SYSDATE
3450 , l_user_id
3451 , SYSDATE
3452 , l_user_id
3453 , NULL
3454 , p_hold_source_rec.hold_source_id
3455 , h.HEADER_ID
3456 , ol.line_id
3457 , 'N'
3458 , l_org_id
3459 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
3460 WHERE h.OPEN_FLAG = 'Y'
3461 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
3462 and h.SOLD_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
3463 and h.header_id = ol.header_id
3464 and ol.INVENTORY_ITEM_ID = p_hold_source_rec.hold_entity_id
3465 and ol.OPEN_FLAG = 'Y'
3466 -- QUOTING change
3467 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
3468 and not exists ( select 'x'
3469 from oe_order_holds_ALL oh
3470 where oh.header_id = h.header_id
3471 and oh.line_id = ol.line_id
3472 and oh.hold_source_id =
3473 p_hold_source_rec.hold_source_id );
3474 END IF;
3475 Only used by Credit checking
3476 ELSIF p_hold_source_rec.hold_entity_code = 'B' and
3477 p_hold_source_rec.hold_entity_code2 = 'O' THEN
3478 IF p_hold_source_rec.line_id IS NOT NULL THEN
3479 INSERT INTO OE_ORDER_HOLDS_ALL
3480 ( ORDER_HOLD_ID
3481 , LAST_UPDATE_DATE
3482 , LAST_UPDATED_BY
3483 , CREATION_DATE
3484 , CREATED_BY
3485 , LAST_UPDATE_LOGIN
3486 , HOLD_SOURCE_ID
3487 , HEADER_ID
3488 , LINE_ID
3489 , RELEASED_FLAG
3490 , ORG_ID
3491 )
3492 SELECT
3493 OE_ORDER_HOLDS_S.NEXTVAL
3494 , SYSDATE
3495 , l_user_id
3496 , SYSDATE
3497 , l_user_id
3498 , NULL
3499 , p_hold_source_rec.hold_source_id
3500 , h.HEADER_ID
3501 , ol.line_id
3502 , 'N'
3503 , l_org_id
3504 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol,
3505 ra_terms_b rt
3506 WHERE h.OPEN_FLAG = 'Y'
3507 and h.header_id = p_hold_source_rec.hold_entity_id2
3508 and h.header_id = ol.header_id
3509 and ol.INVOICE_TO_ORG_ID = p_hold_source_rec.hold_entity_id
3510 and ol.line_id = p_hold_source_rec.line_id
3511 and ol.OPEN_FLAG = 'Y'
3512 and ol.PAYMENT_TERM_ID = rt.TERM_ID
3513 and rt.CREDIT_CHECK_FLAG = 'Y'
3514 -- QUOTING change
3515 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
3516 and not exists ( select 'x'
3517 from oe_order_holds_ALL oh
3518 where oh.header_id = h.header_id
3519 and oh.line_id = ol.line_id
3520 and oh.hold_source_id =
3521 p_hold_source_rec.hold_source_id );
3522 ELSE
3523 INSERT INTO OE_ORDER_HOLDS_ALL
3524 ( ORDER_HOLD_ID
3525 , LAST_UPDATE_DATE
3526 , LAST_UPDATED_BY
3527 , CREATION_DATE
3528 , CREATED_BY
3529 , LAST_UPDATE_LOGIN
3530 , HOLD_SOURCE_ID
3531 , HEADER_ID
3532 , LINE_ID
3533 , RELEASED_FLAG
3534 , ORG_ID
3535 )
3536 SELECT
3537 OE_ORDER_HOLDS_S.NEXTVAL
3538 , SYSDATE
3539 , l_user_id
3540 , SYSDATE
3541 , l_user_id
3542 , NULL
3543 , p_hold_source_rec.hold_source_id
3544 , h.HEADER_ID
3545 , ol.line_id
3546 , 'N'
3547 , l_org_id
3548 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol,
3549 ra_terms_b rt
3550 WHERE h.OPEN_FLAG = 'Y'
3551 and h.header_id = p_hold_source_rec.hold_entity_id2
3552 and h.header_id = ol.header_id
3553 and ol.INVOICE_TO_ORG_ID = p_hold_source_rec.hold_entity_id
3554 and ol.OPEN_FLAG = 'Y'
3555 and ol.PAYMENT_TERM_ID = rt.TERM_ID
3556 and rt.CREDIT_CHECK_FLAG = 'Y'
3557 -- QUOTING change
3558 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
3559 and not exists ( select 'x'
3560 from oe_order_holds_ALL oh
3561 where oh.header_id = h.header_id
3562 and oh.line_id = ol.line_id
3563 and oh.hold_source_id =
3564 p_hold_source_rec.hold_source_id );
3565 END IF;
3566
3567 ELSIF p_hold_source_rec.hold_entity_code = 'I' and
3568 p_hold_source_rec.hold_entity_code2 = 'B' THEN
3569 IF p_hold_source_rec.line_id IS NOT NULL THEN
3570 INSERT INTO OE_ORDER_HOLDS_ALL
3571 ( ORDER_HOLD_ID
3572 , LAST_UPDATE_DATE
3573 , LAST_UPDATED_BY
3574 , CREATION_DATE
3575 , CREATED_BY
3576 , LAST_UPDATE_LOGIN
3577 , HOLD_SOURCE_ID
3578 , HEADER_ID
3579 , LINE_ID
3580 , RELEASED_FLAG
3581 , ORG_ID
3582 )
3583 SELECT
3584 OE_ORDER_HOLDS_S.NEXTVAL
3585 , SYSDATE
3586 , l_user_id
3587 , SYSDATE
3588 , l_user_id
3589 , NULL
3590 , p_hold_source_rec.hold_source_id
3591 , h.HEADER_ID
3592 , ol.line_id
3593 , 'N'
3594 , l_org_id
3595 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
3596 WHERE h.OPEN_FLAG = 'Y'
3597 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
3598 and h.header_id = ol.header_id
3599 and ol.INVOICE_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
3600 and ol.line_id = p_hold_source_rec.line_id
3601 and ol.INVENTORY_ITEM_ID = p_hold_source_rec.hold_entity_id
3602 and ol.OPEN_FLAG = 'Y'
3603 -- QUOTING change
3604 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
3605 and not exists ( select 'x'
3606 from oe_order_holds_ALL oh
3607 where oh.header_id = h.header_id
3608 and oh.line_id = ol.line_id
3609 and oh.hold_source_id =
3610 p_hold_source_rec.hold_source_id );
3611 ELSE
3612 INSERT INTO OE_ORDER_HOLDS_ALL
3613 ( ORDER_HOLD_ID
3614 , LAST_UPDATE_DATE
3615 , LAST_UPDATED_BY
3616 , CREATION_DATE
3617 , CREATED_BY
3618 , LAST_UPDATE_LOGIN
3619 , HOLD_SOURCE_ID
3620 , HEADER_ID
3621 , LINE_ID
3622 , RELEASED_FLAG
3623 , ORG_ID
3624 )
3625 SELECT
3626 OE_ORDER_HOLDS_S.NEXTVAL
3627 , SYSDATE
3628 , l_user_id
3629 , SYSDATE
3630 , l_user_id
3631 , NULL
3632 , p_hold_source_rec.hold_source_id
3633 , h.HEADER_ID
3634 , ol.line_id
3635 , 'N'
3636 , l_org_id
3637 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
3638 WHERE h.OPEN_FLAG = 'Y'
3639 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
3640 and h.header_id = ol.header_id
3641 and ol.INVOICE_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
3642 and ol.INVENTORY_ITEM_ID = p_hold_source_rec.hold_entity_id
3643 and ol.OPEN_FLAG = 'Y'
3644 -- QUOTING change
3645 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
3646 and not exists ( select 'x'
3647 from oe_order_holds_ALL oh
3648 where oh.header_id = h.header_id
3649 and oh.line_id = ol.line_id
3650 and oh.hold_source_id =
3651 p_hold_source_rec.hold_source_id );
3652 END IF;
3653 ELSIF p_hold_source_rec.hold_entity_code = 'I' and
3654 p_hold_source_rec.hold_entity_code2 = 'S' THEN
3655 IF p_hold_source_rec.line_id IS NOT NULL THEN
3656 INSERT INTO OE_ORDER_HOLDS_ALL
3657 ( ORDER_HOLD_ID
3658 , LAST_UPDATE_DATE
3659 , LAST_UPDATED_BY
3660 , CREATION_DATE
3661 , CREATED_BY
3662 , LAST_UPDATE_LOGIN
3663 , HOLD_SOURCE_ID
3664 , HEADER_ID
3665 , LINE_ID
3666 , RELEASED_FLAG
3667 , ORG_ID
3668 )
3669 SELECT
3670 OE_ORDER_HOLDS_S.NEXTVAL
3671 , SYSDATE
3672 , l_user_id
3673 , SYSDATE
3674 , l_user_id
3675 , NULL
3676 , p_hold_source_rec.hold_source_id
3677 , h.HEADER_ID
3678 , ol.line_id
3679 , 'N'
3680 , l_org_id
3681 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
3682 WHERE h.OPEN_FLAG = 'Y'
3683 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
3684 and h.header_id = ol.header_id
3685 and ol.SHIP_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
3686 and ol.line_id = p_hold_source_rec.line_id
3687 and ol.INVENTORY_ITEM_ID = p_hold_source_rec.hold_entity_id
3688 and ol.OPEN_FLAG = 'Y'
3689 -- QUOTING change
3690 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
3691 and not exists ( select 'x'
3692 from oe_order_holds_ALL oh
3693 where oh.header_id = h.header_id
3694 and oh.line_id = ol.line_id
3695 and oh.hold_source_id =
3696 p_hold_source_rec.hold_source_id );
3697 ELSE
3698 INSERT INTO OE_ORDER_HOLDS_ALL
3699 ( ORDER_HOLD_ID
3700 , LAST_UPDATE_DATE
3701 , LAST_UPDATED_BY
3702 , CREATION_DATE
3703 , CREATED_BY
3704 , LAST_UPDATE_LOGIN
3705 , HOLD_SOURCE_ID
3706 , HEADER_ID
3707 , LINE_ID
3708 , RELEASED_FLAG
3709 , ORG_ID
3710 )
3711 SELECT
3712 OE_ORDER_HOLDS_S.NEXTVAL
3713 , SYSDATE
3714 , l_user_id
3715 , SYSDATE
3716 , l_user_id
3717 , NULL
3718 , p_hold_source_rec.hold_source_id
3719 , h.HEADER_ID
3720 , ol.line_id
3721 , 'N'
3722 , l_org_id
3723 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
3724 WHERE h.OPEN_FLAG = 'Y'
3725 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
3726 and h.header_id = ol.header_id
3727 and ol.SHIP_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
3728 and ol.INVENTORY_ITEM_ID = p_hold_source_rec.hold_entity_id
3729 and ol.OPEN_FLAG = 'Y'
3730 -- QUOTING change
3731 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
3732 and not exists ( select 'x'
3733 from oe_order_holds_ALL oh
3734 where oh.header_id = h.header_id
3735 and oh.line_id = ol.line_id
3736 and oh.hold_source_id =
3737 p_hold_source_rec.hold_source_id );
3738 END IF;
3739 ELSIF p_hold_source_rec.hold_entity_code = 'I' and
3740 p_hold_source_rec.hold_entity_code2 = 'W' THEN
3741 IF p_hold_source_rec.line_id IS NOT NULL THEN
3742 INSERT INTO OE_ORDER_HOLDS_ALL
3743 ( ORDER_HOLD_ID
3744 , LAST_UPDATE_DATE
3745 , LAST_UPDATED_BY
3746 , CREATION_DATE
3747 , CREATED_BY
3748 , LAST_UPDATE_LOGIN
3749 , HOLD_SOURCE_ID
3750 , HEADER_ID
3751 , LINE_ID
3752 , RELEASED_FLAG
3753 , ORG_ID
3754 )
3755 SELECT
3756 OE_ORDER_HOLDS_S.NEXTVAL
3757 , SYSDATE
3758 , l_user_id
3759 , SYSDATE
3760 , l_user_id
3761 , NULL
3762 , p_hold_source_rec.hold_source_id
3763 , h.HEADER_ID
3764 , ol.line_id
3765 , 'N'
3766 , l_org_id
3767 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
3768 WHERE h.OPEN_FLAG = 'Y'
3769 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
3770 and h.header_id = ol.header_id
3771 and ol.SHIP_FROM_ORG_ID = p_hold_source_rec.hold_entity_id2
3772 and ol.line_id = p_hold_source_rec.line_id
3773 and ol.INVENTORY_ITEM_ID = p_hold_source_rec.hold_entity_id
3774 and ol.OPEN_FLAG = 'Y'
3775 -- QUOTING change
3776 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
3777 and not exists ( select 'x'
3778 from oe_order_holds_ALL oh
3779 where oh.header_id = h.header_id
3780 and oh.line_id = ol.line_id
3781 and oh.hold_source_id =
3782 p_hold_source_rec.hold_source_id );
3783 ELSE
3784 INSERT INTO OE_ORDER_HOLDS_ALL
3785 ( ORDER_HOLD_ID
3786 , LAST_UPDATE_DATE
3787 , LAST_UPDATED_BY
3788 , CREATION_DATE
3789 , CREATED_BY
3790 , LAST_UPDATE_LOGIN
3791 , HOLD_SOURCE_ID
3792 , HEADER_ID
3793 , LINE_ID
3794 , RELEASED_FLAG
3795 , ORG_ID
3796 )
3797 SELECT
3798 OE_ORDER_HOLDS_S.NEXTVAL
3799 , SYSDATE
3800 , l_user_id
3801 , SYSDATE
3802 , l_user_id
3803 , NULL
3804 , p_hold_source_rec.hold_source_id
3805 , h.HEADER_ID
3806 , ol.line_id
3807 , 'N'
3808 , l_org_id
3809 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
3810 WHERE h.OPEN_FLAG = 'Y'
3811 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
3812 and h.header_id = ol.header_id
3813 and ol.SHIP_FROM_ORG_ID = p_hold_source_rec.hold_entity_id2
3814 and ol.INVENTORY_ITEM_ID = p_hold_source_rec.hold_entity_id
3815 and ol.OPEN_FLAG = 'Y'
3816 -- QUOTING change
3817 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
3818 and not exists ( select 'x'
3819 from oe_order_holds_ALL oh
3820 where oh.header_id = h.header_id
3821 and oh.line_id = ol.line_id
3822 and oh.hold_source_id =
3823 p_hold_source_rec.hold_source_id );
3824 END IF;
3825 ELSIF p_hold_source_rec.hold_entity_code = 'I' and
3826 p_hold_source_rec.hold_entity_code2 = 'H' THEN
3827 IF p_hold_source_rec.line_id IS NOT NULL THEN
3828 INSERT INTO OE_ORDER_HOLDS_ALL
3829 ( ORDER_HOLD_ID
3830 , LAST_UPDATE_DATE
3831 , LAST_UPDATED_BY
3832 , CREATION_DATE
3833 , CREATED_BY
3834 , LAST_UPDATE_LOGIN
3835 , HOLD_SOURCE_ID
3836 , HEADER_ID
3837 , LINE_ID
3838 , RELEASED_FLAG
3839 , ORG_ID
3840 )
3841 SELECT
3842 OE_ORDER_HOLDS_S.NEXTVAL
3843 , SYSDATE
3844 , l_user_id
3845 , SYSDATE
3846 , l_user_id
3847 , NULL
3848 , p_hold_source_rec.hold_source_id
3849 , h.HEADER_ID
3850 , ol.line_id
3851 , 'N'
3852 , l_org_id
3853 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
3854 WHERE h.OPEN_FLAG = 'Y'
3855 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
3856 and h.header_id = ol.header_id
3857 and ol.BLANKET_NUMBER = p_hold_source_rec.hold_entity_id2
3858 and ol.line_id = p_hold_source_rec.line_id
3859 and ol.INVENTORY_ITEM_ID = p_hold_source_rec.hold_entity_id
3860 and ol.OPEN_FLAG = 'Y'
3861 -- QUOTING change
3862 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
3863 and not exists ( select 'x'
3864 from oe_order_holds_ALL oh
3865 where oh.header_id = h.header_id
3866 and oh.line_id = ol.line_id
3867 and oh.hold_source_id =
3868 p_hold_source_rec.hold_source_id );
3869 ELSE
3870 INSERT INTO OE_ORDER_HOLDS_ALL
3871 ( ORDER_HOLD_ID
3872 , LAST_UPDATE_DATE
3873 , LAST_UPDATED_BY
3874 , CREATION_DATE
3875 , CREATED_BY
3876 , LAST_UPDATE_LOGIN
3877 , HOLD_SOURCE_ID
3878 , HEADER_ID
3879 , LINE_ID
3880 , RELEASED_FLAG
3881 , ORG_ID
3882 )
3883 SELECT
3884 OE_ORDER_HOLDS_S.NEXTVAL
3885 , SYSDATE
3886 , l_user_id
3887 , SYSDATE
3888 , l_user_id
3889 , NULL
3890 , p_hold_source_rec.hold_source_id
3891 , h.HEADER_ID
3892 , ol.line_id
3893 , 'N'
3894 , l_org_id
3895 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
3896 WHERE h.OPEN_FLAG = 'Y'
3897 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
3898 and h.header_id = ol.header_id
3899 and ol.BLANKET_NUMBER = p_hold_source_rec.hold_entity_id2
3900 and ol.INVENTORY_ITEM_ID = p_hold_source_rec.hold_entity_id
3901 and ol.OPEN_FLAG = 'Y'
3902 -- QUOTING change
3903 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
3904 and not exists ( select 'x'
3905 from oe_order_holds_ALL oh
3906 where oh.header_id = h.header_id
3907 and oh.line_id = ol.line_id
3908 and oh.hold_source_id =
3909 p_hold_source_rec.hold_source_id );
3910 END IF;
3911
3912 ELSIF p_hold_source_rec.hold_entity_code = 'W' and
3913 p_hold_source_rec.hold_entity_code2 = 'C' THEN
3914 IF p_hold_source_rec.line_id IS NOT NULL THEN
3915 INSERT INTO OE_ORDER_HOLDS_ALL
3916 ( ORDER_HOLD_ID
3917 , LAST_UPDATE_DATE
3918 , LAST_UPDATED_BY
3919 , CREATION_DATE
3920 , CREATED_BY
3921 , LAST_UPDATE_LOGIN
3922 , HOLD_SOURCE_ID
3923 , HEADER_ID
3924 , LINE_ID
3925 , RELEASED_FLAG
3926 , ORG_ID
3927 )
3928 SELECT
3929 OE_ORDER_HOLDS_S.NEXTVAL
3930 , SYSDATE
3931 , l_user_id
3932 , SYSDATE
3933 , l_user_id
3934 , NULL
3935 , p_hold_source_rec.hold_source_id
3936 , h.HEADER_ID
3937 , ol.line_id
3938 , 'N'
3939 , l_org_id
3940 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
3941 WHERE h.OPEN_FLAG = 'Y'
3942 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
3943 and h.header_id = ol.header_id
3944 and ol.SHIP_FROM_ORG_ID = p_hold_source_rec.hold_entity_id
3945 and ol.line_id = p_hold_source_rec.line_id
3946 and h.SOLD_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
3947 and ol.OPEN_FLAG = 'Y'
3948 -- QUOTING change
3949 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
3950 and not exists ( select 'x'
3951 from oe_order_holds_ALL oh
3952 where oh.header_id = h.header_id
3953 and oh.line_id = ol.line_id
3954 and oh.hold_source_id =
3955 p_hold_source_rec.hold_source_id );
3956 ELSE
3957 INSERT INTO OE_ORDER_HOLDS_ALL
3958 ( ORDER_HOLD_ID
3959 , LAST_UPDATE_DATE
3960 , LAST_UPDATED_BY
3961 , CREATION_DATE
3962 , CREATED_BY
3963 , LAST_UPDATE_LOGIN
3964 , HOLD_SOURCE_ID
3965 , HEADER_ID
3966 , LINE_ID
3967 , RELEASED_FLAG
3968 , ORG_ID
3969 )
3970 SELECT
3971 OE_ORDER_HOLDS_S.NEXTVAL
3972 , SYSDATE
3973 , l_user_id
3974 , SYSDATE
3975 , l_user_id
3976 , NULL
3977 , p_hold_source_rec.hold_source_id
3978 , h.HEADER_ID
3979 , ol.line_id
3980 , 'N'
3981 , l_org_id
3982 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
3983 WHERE h.OPEN_FLAG = 'Y'
3984 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
3985 and h.header_id = ol.header_id
3986 and ol.SHIP_FROM_ORG_ID = p_hold_source_rec.hold_entity_id
3987 and h.SOLD_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
3988 and ol.OPEN_FLAG = 'Y'
3989 -- QUOTING change
3990 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
3991 and not exists ( select 'x'
3992 from oe_order_holds_ALL oh
3993 where oh.header_id = h.header_id
3994 and oh.line_id = ol.line_id
3995 and oh.hold_source_id =
3996 p_hold_source_rec.hold_source_id );
3997 END IF;
3998 ELSIF p_hold_source_rec.hold_entity_code = 'W' and
3999 p_hold_source_rec.hold_entity_code2 = 'B' THEN
4000 IF p_hold_source_rec.line_id IS NOT NULL THEN
4001 INSERT INTO OE_ORDER_HOLDS_ALL
4002 ( ORDER_HOLD_ID
4003 , LAST_UPDATE_DATE
4004 , LAST_UPDATED_BY
4005 , CREATION_DATE
4006 , CREATED_BY
4007 , LAST_UPDATE_LOGIN
4008 , HOLD_SOURCE_ID
4009 , HEADER_ID
4010 , LINE_ID
4011 , RELEASED_FLAG
4012 , ORG_ID
4013 )
4014 SELECT
4015 OE_ORDER_HOLDS_S.NEXTVAL
4016 , SYSDATE
4017 , l_user_id
4018 , SYSDATE
4019 , l_user_id
4020 , NULL
4021 , p_hold_source_rec.hold_source_id
4022 , h.HEADER_ID
4023 , ol.line_id
4024 , 'N'
4025 , l_org_id
4026 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4027 WHERE h.OPEN_FLAG = 'Y'
4028 --AND nvl(h.CANCELLED_FLAG, 'N') = 'N'
4029 AND h.header_id = ol.header_id
4030 AND ol.SHIP_FROM_ORG_ID = p_hold_source_rec.hold_entity_id
4031 and ol.line_id = p_hold_source_rec.line_id
4032 AND ol.INVOICE_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
4033 and ol.OPEN_FLAG = 'Y'
4034 -- QUOTING change
4035 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4036 AND NOT EXISTS ( SELECT 'x'
4037 FROM oe_order_holds_ALL oh
4038 WHERE oh.header_id = h.header_id
4039 AND oh.line_id = ol.line_id
4040 AND oh.hold_source_id =
4041 p_hold_source_rec.hold_source_id );
4042 ELSE
4043 INSERT INTO OE_ORDER_HOLDS_ALL
4044 ( ORDER_HOLD_ID
4045 , LAST_UPDATE_DATE
4046 , LAST_UPDATED_BY
4047 , CREATION_DATE
4048 , CREATED_BY
4049 , LAST_UPDATE_LOGIN
4050 , HOLD_SOURCE_ID
4051 , HEADER_ID
4052 , LINE_ID
4053 , RELEASED_FLAG
4054 , ORG_ID
4055 )
4056 SELECT
4057 OE_ORDER_HOLDS_S.NEXTVAL
4058 , SYSDATE
4059 , l_user_id
4060 , SYSDATE
4061 , l_user_id
4062 , NULL
4063 , p_hold_source_rec.hold_source_id
4064 , h.HEADER_ID
4065 , ol.line_id
4066 , 'N'
4067 , l_org_id
4068 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4069 WHERE h.OPEN_FLAG = 'Y'
4070 --AND nvl(h.CANCELLED_FLAG, 'N') = 'N'
4071 AND h.header_id = ol.header_id
4072 AND ol.SHIP_FROM_ORG_ID = p_hold_source_rec.hold_entity_id
4073 AND ol.INVOICE_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
4074 and ol.OPEN_FLAG = 'Y'
4075 -- QUOTING change
4076 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4077 AND NOT EXISTS ( SELECT 'x'
4078 FROM oe_order_holds_ALL oh
4079 WHERE oh.header_id = h.header_id
4080 AND oh.line_id = ol.line_id
4081 AND oh.hold_source_id =
4082 p_hold_source_rec.hold_source_id );
4083 END IF;
4084 ELSIF p_hold_source_rec.hold_entity_code = 'W' and
4085 p_hold_source_rec.hold_entity_code2 = 'S' THEN
4086 IF p_hold_source_rec.line_id IS NOT NULL THEN
4087 INSERT INTO OE_ORDER_HOLDS_ALL
4088 ( ORDER_HOLD_ID
4089 , LAST_UPDATE_DATE
4090 , LAST_UPDATED_BY
4091 , CREATION_DATE
4092 , CREATED_BY
4093 , LAST_UPDATE_LOGIN
4094 , HOLD_SOURCE_ID
4095 , HEADER_ID
4096 , LINE_ID
4097 , RELEASED_FLAG
4098 , ORG_ID
4099 )
4100 SELECT
4101 OE_ORDER_HOLDS_S.NEXTVAL
4102 , SYSDATE
4103 , l_user_id
4104 , SYSDATE
4105 , l_user_id
4106 , NULL
4107 , p_hold_source_rec.hold_source_id
4108 , h.HEADER_ID
4109 , ol.line_id
4110 , 'N'
4111 , l_org_id
4112 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4113 WHERE h.OPEN_FLAG = 'Y'
4114 --AND nvl(h.CANCELLED_FLAG, 'N') = 'N'
4115 AND ol.SHIP_FROM_ORG_ID = p_hold_source_rec.hold_entity_id
4116 and ol.line_id = p_hold_source_rec.line_id
4117 AND h.header_id = ol.header_id
4118 AND ol.SHIP_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
4119 and ol.OPEN_FLAG = 'Y'
4120 -- QUOTING change
4121 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4122 AND NOT EXISTS ( SELECT 'x'
4123 FROM oe_order_holds_ALL oh
4124 WHERE oh.header_id = h.header_id
4125 AND oh.line_id = ol.line_id
4126 AND oh.hold_source_id =
4127 p_hold_source_rec.hold_source_id );
4128 ELSE
4129 INSERT INTO OE_ORDER_HOLDS_ALL
4130 ( ORDER_HOLD_ID
4131 , LAST_UPDATE_DATE
4132 , LAST_UPDATED_BY
4133 , CREATION_DATE
4134 , CREATED_BY
4135 , LAST_UPDATE_LOGIN
4136 , HOLD_SOURCE_ID
4137 , HEADER_ID
4138 , LINE_ID
4139 , RELEASED_FLAG
4140 , ORG_ID
4141 )
4142 SELECT
4143 OE_ORDER_HOLDS_S.NEXTVAL
4144 , SYSDATE
4145 , l_user_id
4146 , SYSDATE
4147 , l_user_id
4148 , NULL
4149 , p_hold_source_rec.hold_source_id
4150 , h.HEADER_ID
4151 , ol.line_id
4152 , 'N'
4153 , l_org_id
4154 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4155 WHERE h.OPEN_FLAG = 'Y'
4156 --AND nvl(h.CANCELLED_FLAG, 'N') = 'N'
4157 AND ol.SHIP_FROM_ORG_ID = p_hold_source_rec.hold_entity_id
4158 AND h.header_id = ol.header_id
4159 AND ol.SHIP_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
4160 and ol.OPEN_FLAG = 'Y'
4161 -- QUOTING change
4162 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4163 AND NOT EXISTS ( SELECT 'x'
4164 FROM oe_order_holds_ALL oh
4165 WHERE oh.header_id = h.header_id
4166 AND oh.line_id = ol.line_id
4167 AND oh.hold_source_id =
4168 p_hold_source_rec.hold_source_id );
4169 END IF;
4170 ELSIF p_hold_source_rec.hold_entity_code = 'H' and
4171 p_hold_source_rec.hold_entity_code2 = 'B' THEN
4172 IF p_hold_source_rec.line_id IS NOT NULL THEN
4173 INSERT INTO OE_ORDER_HOLDS_ALL
4174 ( ORDER_HOLD_ID
4175 , LAST_UPDATE_DATE
4176 , LAST_UPDATED_BY
4177 , CREATION_DATE
4178 , CREATED_BY
4179 , LAST_UPDATE_LOGIN
4180 , HOLD_SOURCE_ID
4181 , HEADER_ID
4182 , LINE_ID
4183 , RELEASED_FLAG
4184 , ORG_ID
4185 )
4186 SELECT
4187 OE_ORDER_HOLDS_S.NEXTVAL
4188 , SYSDATE
4189 , l_user_id
4190 , SYSDATE
4191 , l_user_id
4192 , NULL
4193 , p_hold_source_rec.hold_source_id
4194 , h.HEADER_ID
4195 , ol.line_id
4196 , 'N'
4197 , l_org_id
4198 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4199 WHERE h.OPEN_FLAG = 'Y'
4200 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
4201 and h.header_id = ol.header_id
4202 and ol.INVOICE_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
4203 and ol.line_id = p_hold_source_rec.line_id
4204 and ol.BLANKET_NUMBER = p_hold_source_rec.hold_entity_id
4205 and ol.OPEN_FLAG = 'Y'
4206 -- QUOTING change
4207 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4208 and not exists ( select 'x'
4209 from oe_order_holds_ALL oh
4210 where oh.header_id = h.header_id
4211 and oh.line_id = ol.line_id
4212 and oh.hold_source_id =
4213 p_hold_source_rec.hold_source_id );
4214 ELSE
4215 INSERT INTO OE_ORDER_HOLDS_ALL
4216 ( ORDER_HOLD_ID
4217 , LAST_UPDATE_DATE
4218 , LAST_UPDATED_BY
4219 , CREATION_DATE
4220 , CREATED_BY
4221 , LAST_UPDATE_LOGIN
4222 , HOLD_SOURCE_ID
4223 , HEADER_ID
4224 , LINE_ID
4225 , RELEASED_FLAG
4226 , ORG_ID
4227 )
4228 SELECT
4229 OE_ORDER_HOLDS_S.NEXTVAL
4230 , SYSDATE
4231 , l_user_id
4232 , SYSDATE
4233 , l_user_id
4234 , NULL
4235 , p_hold_source_rec.hold_source_id
4236 , h.HEADER_ID
4237 , ol.line_id
4238 , 'N'
4239 , l_org_id
4240 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4241 WHERE h.OPEN_FLAG = 'Y'
4242 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
4243 and h.header_id = ol.header_id
4244 and ol.INVOICE_TO_ORG_ID= p_hold_source_rec.hold_entity_id2
4245 and ol.BLANKET_NUMBER = p_hold_source_rec.hold_entity_id
4246 and ol.OPEN_FLAG = 'Y'
4247 -- QUOTING change
4248 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4249 and not exists ( select 'x'
4250 from oe_order_holds_ALL oh
4251 where oh.header_id = h.header_id
4252 and oh.line_id = ol.line_id
4253 and oh.hold_source_id =
4254 p_hold_source_rec.hold_source_id );
4255 END IF;
4256
4257 ELSIF p_hold_source_rec.hold_entity_code = 'H' and
4258 p_hold_source_rec.hold_entity_code2 = 'S' THEN
4259 IF p_hold_source_rec.line_id IS NOT NULL THEN
4260 INSERT INTO OE_ORDER_HOLDS_ALL
4261 ( ORDER_HOLD_ID
4262 , LAST_UPDATE_DATE
4263 , LAST_UPDATED_BY
4264 , CREATION_DATE
4265 , CREATED_BY
4266 , LAST_UPDATE_LOGIN
4267 , HOLD_SOURCE_ID
4268 , HEADER_ID
4269 , LINE_ID
4270 , RELEASED_FLAG
4271 , ORG_ID
4272 )
4273 SELECT
4274 OE_ORDER_HOLDS_S.NEXTVAL
4275 , SYSDATE
4276 , l_user_id
4277 , SYSDATE
4278 , l_user_id
4279 , NULL
4280 , p_hold_source_rec.hold_source_id
4281 , h.HEADER_ID
4282 , ol.line_id
4283 , 'N'
4284 , l_org_id
4285 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4286 WHERE h.OPEN_FLAG = 'Y'
4287 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
4288 and h.header_id = ol.header_id
4289 and ol.SHIP_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
4290 and ol.line_id = p_hold_source_rec.line_id
4291 and ol.BLANKET_NUMBER = p_hold_source_rec.hold_entity_id
4292 and ol.OPEN_FLAG = 'Y'
4293 -- QUOTING change
4294 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4295 and not exists ( select 'x'
4296 from oe_order_holds_ALL oh
4297 where oh.header_id = h.header_id
4298 and oh.line_id = ol.line_id
4299 and oh.hold_source_id =
4300 p_hold_source_rec.hold_source_id );
4301 ELSE
4302 INSERT INTO OE_ORDER_HOLDS_ALL
4303 ( ORDER_HOLD_ID
4304 , LAST_UPDATE_DATE
4305 , LAST_UPDATED_BY
4306 , CREATION_DATE
4307 , CREATED_BY
4308 , LAST_UPDATE_LOGIN
4309 , HOLD_SOURCE_ID
4310 , HEADER_ID
4311 , LINE_ID
4312 , RELEASED_FLAG
4313 , ORG_ID
4314 )
4315 SELECT
4316 OE_ORDER_HOLDS_S.NEXTVAL
4317 , SYSDATE
4318 , l_user_id
4319 , SYSDATE
4320 , l_user_id
4321 , NULL
4322 , p_hold_source_rec.hold_source_id
4323 , h.HEADER_ID
4324 , ol.line_id
4325 , 'N'
4326 , l_org_id
4327 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4328 WHERE h.OPEN_FLAG = 'Y'
4329 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
4330 and h.header_id = ol.header_id
4331 and ol.SHIP_TO_ORG_ID= p_hold_source_rec.hold_entity_id2
4332 and ol.BLANKET_NUMBER = p_hold_source_rec.hold_entity_id
4333 and ol.OPEN_FLAG = 'Y'
4334 -- QUOTING change
4335 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4336 and not exists ( select 'x'
4337 from oe_order_holds_ALL oh
4338 where oh.header_id = h.header_id
4339 and oh.line_id = ol.line_id
4340 and oh.hold_source_id =
4341 p_hold_source_rec.hold_source_id );
4342 END IF;
4343 ELSIF p_hold_source_rec.hold_entity_code = 'H' and
4344 p_hold_source_rec.hold_entity_code2 = 'W' THEN
4345 IF p_hold_source_rec.line_id IS NOT NULL THEN
4346 INSERT INTO OE_ORDER_HOLDS_ALL
4347 ( ORDER_HOLD_ID
4348 , LAST_UPDATE_DATE
4349 , LAST_UPDATED_BY
4350 , CREATION_DATE
4351 , CREATED_BY
4352 , LAST_UPDATE_LOGIN
4353 , HOLD_SOURCE_ID
4354 , HEADER_ID
4355 , LINE_ID
4356 , RELEASED_FLAG
4357 , ORG_ID
4358 )
4359 SELECT
4360 OE_ORDER_HOLDS_S.NEXTVAL
4361 , SYSDATE
4362 , l_user_id
4363 , SYSDATE
4364 , l_user_id
4365 , NULL
4366 , p_hold_source_rec.hold_source_id
4367 , h.HEADER_ID
4368 , ol.line_id
4369 , 'N'
4370 , l_org_id
4371 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4372 WHERE h.OPEN_FLAG = 'Y'
4373 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
4374 and h.header_id = ol.header_id
4375 and ol.SHIP_FROM_ORG_ID = p_hold_source_rec.hold_entity_id2
4376 and ol.line_id = p_hold_source_rec.line_id
4377 and ol.BLANKET_NUMBER = p_hold_source_rec.hold_entity_id
4378 and ol.OPEN_FLAG = 'Y'
4379 -- QUOTING change
4380 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4381 and not exists ( select 'x'
4382 from oe_order_holds_ALL oh
4383 where oh.header_id = h.header_id
4384 and oh.line_id = ol.line_id
4385 and oh.hold_source_id =
4386 p_hold_source_rec.hold_source_id );
4387 ELSE
4388 INSERT INTO OE_ORDER_HOLDS_ALL
4389 ( ORDER_HOLD_ID
4390 , LAST_UPDATE_DATE
4391 , LAST_UPDATED_BY
4392 , CREATION_DATE
4393 , CREATED_BY
4394 , LAST_UPDATE_LOGIN
4395 , HOLD_SOURCE_ID
4396 , HEADER_ID
4397 , LINE_ID
4398 , RELEASED_FLAG
4399 , ORG_ID
4400 )
4401 SELECT
4402 OE_ORDER_HOLDS_S.NEXTVAL
4403 , SYSDATE
4404 , l_user_id
4405 , SYSDATE
4406 , l_user_id
4407 , NULL
4408 , p_hold_source_rec.hold_source_id
4409 , h.HEADER_ID
4410 , ol.line_id
4411 , 'N'
4412 , l_org_id
4413 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4414 WHERE h.OPEN_FLAG = 'Y'
4415 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
4416 and h.header_id = ol.header_id
4417 and ol.SHIP_FROM_ORG_ID= p_hold_source_rec.hold_entity_id2
4418 and ol.BLANKET_NUMBER = p_hold_source_rec.hold_entity_id
4419 and ol.OPEN_FLAG = 'Y'
4420 -- QUOTING change
4421 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4422 and not exists ( select 'x'
4423 from oe_order_holds_ALL oh
4424 where oh.header_id = h.header_id
4425 and oh.line_id = ol.line_id
4426 and oh.hold_source_id =
4427 p_hold_source_rec.hold_source_id );
4428 END IF;
4429
4430 ELSIF p_hold_source_rec.hold_entity_code = 'H' and
4431 p_hold_source_rec.hold_entity_code2 = 'L' THEN
4432 IF p_hold_source_rec.line_id IS NOT NULL THEN
4433 INSERT INTO OE_ORDER_HOLDS_ALL
4434 ( ORDER_HOLD_ID
4435 , LAST_UPDATE_DATE
4436 , LAST_UPDATED_BY
4437 , CREATION_DATE
4438 , CREATED_BY
4439 , LAST_UPDATE_LOGIN
4440 , HOLD_SOURCE_ID
4441 , HEADER_ID
4442 , LINE_ID
4443 , RELEASED_FLAG
4444 , ORG_ID
4445 )
4446 SELECT
4447 OE_ORDER_HOLDS_S.NEXTVAL
4448 , SYSDATE
4449 , l_user_id
4450 , SYSDATE
4451 , l_user_id
4452 , NULL
4453 , p_hold_source_rec.hold_source_id
4454 , h.HEADER_ID
4455 , ol.line_id
4456 , 'N'
4457 , l_org_id
4458 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4459 WHERE h.OPEN_FLAG = 'Y'
4460 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
4461 and h.header_id = ol.header_id
4462 and ol.BLANKET_LINE_NUMBER = p_hold_source_rec.hold_entity_id2
4463 and ol.line_id = p_hold_source_rec.line_id
4464 and ol.BLANKET_NUMBER = p_hold_source_rec.hold_entity_id
4465 and ol.OPEN_FLAG = 'Y'
4466 -- QUOTING change
4467 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4468 and not exists ( select 'x'
4469 from oe_order_holds_ALL oh
4470 where oh.header_id = h.header_id
4471 and oh.line_id = ol.line_id
4472 and oh.hold_source_id =
4473 p_hold_source_rec.hold_source_id );
4474 ELSE
4475 INSERT INTO OE_ORDER_HOLDS_ALL
4476 ( ORDER_HOLD_ID
4477 , LAST_UPDATE_DATE
4478 , LAST_UPDATED_BY
4479 , CREATION_DATE
4480 , CREATED_BY
4481 , LAST_UPDATE_LOGIN
4482 , HOLD_SOURCE_ID
4483 , HEADER_ID
4484 , LINE_ID
4485 , RELEASED_FLAG
4486 , ORG_ID
4487 )
4488 SELECT
4489 OE_ORDER_HOLDS_S.NEXTVAL
4490 , SYSDATE
4491 , l_user_id
4492 , SYSDATE
4493 , l_user_id
4494 , NULL
4495 , p_hold_source_rec.hold_source_id
4496 , h.HEADER_ID
4497 , ol.line_id
4498 , 'N'
4499 , l_org_id
4500 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4501 WHERE h.OPEN_FLAG = 'Y'
4502 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
4503 and h.header_id = ol.header_id
4504 and ol.BLANKET_LINE_NUMBER = p_hold_source_rec.hold_entity_id2
4505 and ol.BLANKET_NUMBER = p_hold_source_rec.hold_entity_id
4506 and ol.OPEN_FLAG = 'Y'
4507 -- QUOTING change
4508 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4509 and not exists ( select 'x'
4510 from oe_order_holds_ALL oh
4511 where oh.header_id = h.header_id
4512 and oh.line_id = ol.line_id
4513 and oh.hold_source_id =
4514 p_hold_source_rec.hold_source_id );
4515 END IF;
4516
4517 ELSIF p_hold_source_rec.hold_entity_code = 'H' THEN
4518 IF p_hold_source_rec.line_id IS NOT NULL THEN
4519 INSERT INTO OE_ORDER_HOLDS_ALL
4520 ( ORDER_HOLD_ID
4521 , LAST_UPDATE_DATE
4522 , LAST_UPDATED_BY
4523 , CREATION_DATE
4524 , CREATED_BY
4525 , LAST_UPDATE_LOGIN
4526 , HOLD_SOURCE_ID
4527 , HEADER_ID
4528 , LINE_ID
4529 , RELEASED_FLAG
4530 , ORG_ID
4531 )
4532 SELECT
4533 OE_ORDER_HOLDS_S.NEXTVAL
4534 , SYSDATE
4535 , l_user_id
4536 , SYSDATE
4537 , l_user_id
4538 , NULL
4539 , p_hold_source_rec.hold_source_id
4540 , h.HEADER_ID
4541 , ol.line_id
4542 , 'N'
4543 , l_org_id
4544 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4545 WHERE h.OPEN_FLAG = 'Y'
4546 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
4547 and h.header_id = ol.header_id
4548 and ol.line_id = p_hold_source_rec.line_id
4549 and ol.BLANKET_NUMBER = p_hold_source_rec.hold_entity_id
4550 and ol.OPEN_FLAG = 'Y'
4551 -- QUOTING change
4552 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4553 and not exists ( select 'x'
4554 from oe_order_holds_ALL oh
4555 where oh.header_id = h.header_id
4556 and oh.line_id = ol.line_id
4557 and oh.hold_source_id =
4558 p_hold_source_rec.hold_source_id );
4559 ELSE
4560 INSERT INTO OE_ORDER_HOLDS_ALL
4561 ( ORDER_HOLD_ID
4562 , LAST_UPDATE_DATE
4563 , LAST_UPDATED_BY
4564 , CREATION_DATE
4565 , CREATED_BY
4566 , LAST_UPDATE_LOGIN
4567 , HOLD_SOURCE_ID
4568 , HEADER_ID
4569 , LINE_ID
4570 , RELEASED_FLAG
4571 , ORG_ID
4572 )
4573 SELECT
4574 OE_ORDER_HOLDS_S.NEXTVAL
4575 , SYSDATE
4576 , l_user_id
4577 , SYSDATE
4578 , l_user_id
4579 , NULL
4580 , p_hold_source_rec.hold_source_id
4581 , h.HEADER_ID
4582 , ol.line_id
4583 , 'N'
4584 , l_org_id
4585 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4586 WHERE h.OPEN_FLAG = 'Y'
4587 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
4588 and h.header_id = ol.header_id
4589 and ol.BLANKET_NUMBER = p_hold_source_rec.hold_entity_id
4590 and ol.OPEN_FLAG = 'Y'
4591 -- QUOTING change
4592 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4593 and not exists ( select 'x'
4594 from oe_order_holds_ALL oh
4595 where oh.header_id = h.header_id
4596 and oh.line_id = ol.line_id
4597 and oh.hold_source_id =
4598 p_hold_source_rec.hold_source_id );
4599 END IF;
4600
4601 ELSIF p_hold_source_rec.hold_entity_code = 'O' THEN
4602 IF p_hold_source_rec.line_id is NULL THEN
4603 INSERT INTO OE_ORDER_HOLDS_ALL
4604 ( ORDER_HOLD_ID
4605 , LAST_UPDATE_DATE
4606 , LAST_UPDATED_BY
4607 , CREATION_DATE
4608 , CREATED_BY
4609 , LAST_UPDATE_LOGIN
4610 , HOLD_SOURCE_ID
4611 , HEADER_ID
4612 , LINE_ID
4613 , RELEASED_FLAG
4614 , ORG_ID
4615 )
4616 SELECT
4617 OE_ORDER_HOLDS_S.NEXTVAL
4618 , SYSDATE
4619 , l_user_id
4620 , SYSDATE
4621 , l_user_id
4622 , NULL
4623 , p_hold_source_rec.hold_source_id
4624 , h.HEADER_ID
4625 , NULL
4626 , 'N'
4627 , l_org_id
4628 FROM OE_ORDER_HEADERS_ALL h
4629 WHERE h.OPEN_FLAG = 'Y'
4630 and h.header_id = p_hold_source_rec.hold_entity_id
4631 -- QUOTING change
4632 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4633 and not exists ( select 'x'
4634 from oe_order_holds_ALL oh
4635 where oh.header_id = h.header_id
4636 and oh.hold_source_id =
4637 p_hold_source_rec.hold_source_id );
4638 ELSE
4639 INSERT INTO OE_ORDER_HOLDS_ALL
4640 ( ORDER_HOLD_ID
4641 , LAST_UPDATE_DATE
4642 , LAST_UPDATED_BY
4643 , CREATION_DATE
4644 , CREATED_BY
4645 , LAST_UPDATE_LOGIN
4646 , HOLD_SOURCE_ID
4647 , HEADER_ID
4648 , LINE_ID
4649 , RELEASED_FLAG
4650 , ORG_ID
4651 )
4652 SELECT
4653 OE_ORDER_HOLDS_S.NEXTVAL
4654 , SYSDATE
4655 , l_user_id
4656 , SYSDATE
4657 , l_user_id
4658 , NULL
4659 , p_hold_source_rec.hold_source_id
4660 , h.HEADER_ID
4661 , p_hold_source_rec.line_id
4662 , 'N'
4663 , l_org_id
4664 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4665 WHERE h.OPEN_FLAG = 'Y'
4666 and h.header_id = p_hold_source_rec.hold_entity_id
4667 and h.header_id = ol.header_id
4668 and ol.line_id = p_hold_source_rec.line_id
4669 and ol.open_flag = 'Y'
4670 -- QUOTING change
4671 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4672 and not exists ( select 'x'
4673 from oe_order_holds_ALL oh
4674 where oh.header_id = h.header_id
4675 and oh.line_id = ol.line_id
4676 and oh.hold_source_id =
4677 p_hold_source_rec.hold_source_id );
4678 END IF;
4679
4680 ELSIF p_hold_source_rec.hold_entity_code = 'C' THEN
4681 -- Use header_id for Customer based hold source
4682 IF p_hold_source_rec.header_id IS NOT NULL THEN
4683 INSERT INTO OE_ORDER_HOLDS_ALL
4684 ( ORDER_HOLD_ID
4685 , LAST_UPDATE_DATE
4686 , LAST_UPDATED_BY
4687 , CREATION_DATE
4688 , CREATED_BY
4689 , LAST_UPDATE_LOGIN
4690 , HOLD_SOURCE_ID
4691 , HEADER_ID
4692 , LINE_ID
4693 , RELEASED_FLAG
4694 , ORG_ID
4695 )
4696 SELECT
4697 OE_ORDER_HOLDS_S.NEXTVAL
4698 , SYSDATE
4699 , l_user_id
4700 , SYSDATE
4701 , l_user_id
4702 , NULL
4703 , p_hold_source_rec.hold_source_id
4704 , h.HEADER_ID
4705 , NULL
4706 , 'N'
4707 , l_org_id
4708 FROM OE_ORDER_HEADERS_ALL h
4709 WHERE h.OPEN_FLAG = 'Y'
4710 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
4711 and h.header_id = p_hold_source_rec.header_id
4712 and h.SOLD_TO_ORG_ID = p_hold_source_rec.hold_entity_id
4713 -- QUOTING change
4714 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4715 and not exists ( select 'x'
4716 from oe_order_holds_ALL oh
4717 where oh.header_id = h.header_id
4718 and oh.hold_source_id =
4719 p_hold_source_rec.hold_source_id );
4720 ELSE
4721 INSERT INTO OE_ORDER_HOLDS_ALL
4722 ( ORDER_HOLD_ID
4723 , LAST_UPDATE_DATE
4724 , LAST_UPDATED_BY
4725 , CREATION_DATE
4726 , CREATED_BY
4727 , LAST_UPDATE_LOGIN
4728 , HOLD_SOURCE_ID
4729 , HEADER_ID
4730 , LINE_ID
4731 , RELEASED_FLAG
4732 , ORG_ID
4733 )
4734 SELECT
4735 OE_ORDER_HOLDS_S.NEXTVAL
4736 , SYSDATE
4737 , l_user_id
4738 , SYSDATE
4739 , l_user_id
4740 , NULL
4741 , p_hold_source_rec.hold_source_id
4742 , h.HEADER_ID
4743 , NULL
4744 , 'N'
4745 , l_org_id
4746 FROM OE_ORDER_HEADERS_ALL h
4747 WHERE h.OPEN_FLAG = 'Y'
4748 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
4749 and h.SOLD_TO_ORG_ID = p_hold_source_rec.hold_entity_id
4750 -- QUOTING change
4751 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4752 and not exists ( select 'x'
4753 from oe_order_holds_ALL oh
4754 where oh.header_id = h.header_id
4755 and oh.hold_source_id =
4756 p_hold_source_rec.hold_source_id );
4757 END IF;
4758 ELSIF p_hold_source_rec.hold_entity_code = 'B' THEN
4759 IF p_hold_source_rec.line_id IS NOT NULL THEN
4760 INSERT INTO OE_ORDER_HOLDS_ALL
4761 ( ORDER_HOLD_ID
4762 , LAST_UPDATE_DATE
4763 , LAST_UPDATED_BY
4764 , CREATION_DATE
4765 , CREATED_BY
4766 , LAST_UPDATE_LOGIN
4767 , HOLD_SOURCE_ID
4768 , HEADER_ID
4769 , LINE_ID
4770 , RELEASED_FLAG
4771 , ORG_ID
4772 )
4773 SELECT
4774 OE_ORDER_HOLDS_S.NEXTVAL
4775 , SYSDATE
4776 , l_user_id
4777 , SYSDATE
4778 , l_user_id
4779 , NULL
4780 , p_hold_source_rec.hold_source_id
4781 , h.HEADER_ID
4782 , ol.line_id
4783 , 'N'
4784 , l_org_id
4785 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4786 WHERE h.OPEN_FLAG = 'Y'
4787 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
4788 and h.header_id = ol.header_id
4789 and ol.line_id = p_hold_source_rec.line_id
4790 and ol.INVOICE_TO_ORG_ID = p_hold_source_rec.hold_entity_id
4791 and ol.OPEN_FLAG = 'Y'
4792 -- QUOTING change
4793 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4794 and not exists ( select 'x'
4795 from oe_order_holds_ALL oh
4796 where oh.header_id = h.header_id
4797 and oh.line_id = ol.line_id
4798 and oh.hold_source_id =
4799 p_hold_source_rec.hold_source_id );
4800 ELSE
4801 INSERT INTO OE_ORDER_HOLDS_ALL
4802 ( ORDER_HOLD_ID
4803 , LAST_UPDATE_DATE
4804 , LAST_UPDATED_BY
4805 , CREATION_DATE
4806 , CREATED_BY
4807 , LAST_UPDATE_LOGIN
4808 , HOLD_SOURCE_ID
4809 , HEADER_ID
4810 , LINE_ID
4811 , RELEASED_FLAG
4812 , ORG_ID
4813 )
4814 SELECT
4815 OE_ORDER_HOLDS_S.NEXTVAL
4816 , SYSDATE
4817 , l_user_id
4818 , SYSDATE
4819 , l_user_id
4820 , NULL
4821 , p_hold_source_rec.hold_source_id
4822 , h.HEADER_ID
4823 , ol.line_id
4824 , 'N'
4825 , l_org_id
4826 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4827 WHERE h.OPEN_FLAG = 'Y'
4828 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
4829 and h.header_id = ol.header_id
4830 and ol.INVOICE_TO_ORG_ID = p_hold_source_rec.hold_entity_id
4831 and ol.OPEN_FLAG = 'Y'
4832 -- QUOTING change
4833 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4834 and not exists ( select 'x'
4835 from oe_order_holds_ALL oh
4836 where oh.header_id = h.header_id
4837 and oh.line_id = ol.line_id
4838 and oh.hold_source_id =
4839 p_hold_source_rec.hold_source_id );
4840 END IF;
4841 ELSIF p_hold_source_rec.hold_entity_code = 'S' THEN
4842 IF p_hold_source_rec.line_id IS NOT NULL THEN
4843 INSERT INTO OE_ORDER_HOLDS_ALL
4844 ( ORDER_HOLD_ID
4845 , LAST_UPDATE_DATE
4846 , LAST_UPDATED_BY
4847 , CREATION_DATE
4848 , CREATED_BY
4849 , LAST_UPDATE_LOGIN
4850 , HOLD_SOURCE_ID
4851 , HEADER_ID
4852 , LINE_ID
4853 , RELEASED_FLAG
4854 , ORG_ID
4855 )
4856 SELECT
4857 OE_ORDER_HOLDS_S.NEXTVAL
4858 , SYSDATE
4859 , l_user_id
4860 , SYSDATE
4861 , l_user_id
4862 , NULL
4863 , p_hold_source_rec.hold_source_id
4864 , h.HEADER_ID
4865 , ol.line_id
4866 , 'N'
4867 , l_org_id
4868 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4869 WHERE h.OPEN_FLAG = 'Y'
4870 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
4871 and h.header_id = ol.header_id
4872 and ol.line_id = p_hold_source_rec.line_id
4873 and ol.SHIP_TO_ORG_ID = p_hold_source_rec.hold_entity_id
4874 and ol.OPEN_FLAG = 'Y'
4875 -- QUOTING change
4876 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4877 and not exists ( select 'x'
4878 from oe_order_holds_ALL oh
4879 where oh.header_id = h.header_id
4880 and oh.line_id = ol.line_id
4881 and oh.hold_source_id =
4882 p_hold_source_rec.hold_source_id );
4883 ELSE
4884 INSERT INTO OE_ORDER_HOLDS_ALL
4885 ( ORDER_HOLD_ID
4886 , LAST_UPDATE_DATE
4887 , LAST_UPDATED_BY
4888 , CREATION_DATE
4889 , CREATED_BY
4890 , LAST_UPDATE_LOGIN
4891 , HOLD_SOURCE_ID
4892 , HEADER_ID
4893 , LINE_ID
4894 , RELEASED_FLAG
4895 , ORG_ID
4896 )
4897 SELECT
4898 OE_ORDER_HOLDS_S.NEXTVAL
4899 , SYSDATE
4900 , l_user_id
4901 , SYSDATE
4902 , l_user_id
4903 , NULL
4904 , p_hold_source_rec.hold_source_id
4905 , h.HEADER_ID
4906 , ol.line_id
4907 , 'N'
4908 , l_org_id
4909 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4910 WHERE h.OPEN_FLAG = 'Y'
4911 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
4912 and h.header_id = ol.header_id
4913 and ol.SHIP_TO_ORG_ID = p_hold_source_rec.hold_entity_id
4914 and ol.OPEN_FLAG = 'Y'
4915 -- QUOTING change
4916 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4917 and not exists ( select 'x'
4918 from oe_order_holds_ALL oh
4919 where oh.header_id = h.header_id
4920 and oh.line_id = ol.line_id
4921 and oh.hold_source_id =
4922 p_hold_source_rec.hold_source_id );
4923 END IF;
4924 ELSIF p_hold_source_rec.hold_entity_code = 'W' THEN
4925 IF p_hold_source_rec.line_id IS NOT NULL THEN
4926 INSERT INTO OE_ORDER_HOLDS_ALL
4927 ( ORDER_HOLD_ID
4928 , LAST_UPDATE_DATE
4929 , LAST_UPDATED_BY
4930 , CREATION_DATE
4931 , CREATED_BY
4932 , LAST_UPDATE_LOGIN
4933 , HOLD_SOURCE_ID
4934 , HEADER_ID
4935 , LINE_ID
4936 , RELEASED_FLAG
4937 , ORG_ID
4938 )
4939 SELECT
4940 OE_ORDER_HOLDS_S.NEXTVAL
4941 , SYSDATE
4942 , l_user_id
4943 , SYSDATE
4944 , l_user_id
4945 , NULL
4946 , p_hold_source_rec.hold_source_id
4947 , h.HEADER_ID
4948 , ol.line_id
4949 , 'N'
4950 , l_org_id
4951 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4952 WHERE h.OPEN_FLAG = 'Y'
4953 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
4954 and h.header_id = ol.header_id
4955 and ol.line_id = p_hold_source_rec.line_id
4956 and ol.SHIP_FROM_ORG_ID = p_hold_source_rec.hold_entity_id
4957 and ol.OPEN_FLAG = 'Y'
4958 -- QUOTING change
4959 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
4960 and not exists ( select 'x'
4961 from oe_order_holds_ALL oh
4962 where oh.header_id = h.header_id
4963 and oh.line_id = ol.line_id
4964 and oh.hold_source_id =
4965 p_hold_source_rec.hold_source_id );
4966 ELSE
4967 INSERT INTO OE_ORDER_HOLDS_ALL
4968 ( ORDER_HOLD_ID
4969 , LAST_UPDATE_DATE
4970 , LAST_UPDATED_BY
4971 , CREATION_DATE
4972 , CREATED_BY
4973 , LAST_UPDATE_LOGIN
4974 , HOLD_SOURCE_ID
4975 , HEADER_ID
4976 , LINE_ID
4977 , RELEASED_FLAG
4978 , ORG_ID
4979 )
4980 SELECT
4981 OE_ORDER_HOLDS_S.NEXTVAL
4982 , SYSDATE
4983 , l_user_id
4984 , SYSDATE
4985 , l_user_id
4986 , NULL
4987 , p_hold_source_rec.hold_source_id
4988 , h.HEADER_ID
4989 , ol.line_id
4990 , 'N'
4991 , l_org_id
4992 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
4993 WHERE h.OPEN_FLAG = 'Y'
4994 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
4995 and h.header_id = ol.header_id
4996 and ol.SHIP_FROM_ORG_ID = p_hold_source_rec.hold_entity_id
4997 and ol.OPEN_FLAG = 'Y'
4998 -- QUOTING change
4999 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
5000 and not exists ( select 'x'
5001 from oe_order_holds_ALL oh
5002 where oh.header_id = h.header_id
5003 and oh.line_id = ol.line_id
5004 and oh.hold_source_id =
5005 p_hold_source_rec.hold_source_id );
5006 END IF;
5007 ELSIF p_hold_source_rec.hold_entity_code = 'I' THEN
5008 IF p_hold_source_rec.line_id IS NOT NULL THEN
5009 INSERT INTO OE_ORDER_HOLDS_ALL
5010 ( ORDER_HOLD_ID
5011 , LAST_UPDATE_DATE
5012 , LAST_UPDATED_BY
5013 , CREATION_DATE
5014 , CREATED_BY
5015 , LAST_UPDATE_LOGIN
5016 , HOLD_SOURCE_ID
5017 , HEADER_ID
5018 , LINE_ID
5019 , RELEASED_FLAG
5020 , ORG_ID
5021 )
5022 SELECT
5023 OE_ORDER_HOLDS_S.NEXTVAL
5024 , SYSDATE
5025 , l_user_id
5026 , SYSDATE
5027 , l_user_id
5028 , NULL
5029 , p_hold_source_rec.hold_source_id
5030 , h.HEADER_ID
5031 , ol.line_id
5032 , 'N'
5033 , l_org_id
5034 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
5035 WHERE h.OPEN_FLAG = 'Y'
5036 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
5037 and h.header_id = ol.header_id
5038 and ol.line_id = p_hold_source_rec.line_id
5039 and ol.INVENTORY_ITEM_ID = p_hold_source_rec.hold_entity_id
5040 and ol.OPEN_FLAG = 'Y'
5041 -- QUOTING change
5042 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
5043 and not exists ( select 'x'
5044 from oe_order_holds_ALL oh
5045 where oh.header_id = h.header_id
5046 and oh.line_id = ol.line_id
5047 and oh.hold_source_id =
5048 p_hold_source_rec.hold_source_id );
5049 ELSE
5050 INSERT INTO OE_ORDER_HOLDS_ALL
5051 ( ORDER_HOLD_ID
5052 , LAST_UPDATE_DATE
5053 , LAST_UPDATED_BY
5054 , CREATION_DATE
5055 , CREATED_BY
5056 , LAST_UPDATE_LOGIN
5057 , HOLD_SOURCE_ID
5058 , HEADER_ID
5059 , LINE_ID
5060 , RELEASED_FLAG
5061 , ORG_ID
5062 )
5063 SELECT
5064 OE_ORDER_HOLDS_S.NEXTVAL
5065 , SYSDATE
5066 , l_user_id
5067 , SYSDATE
5068 , l_user_id
5069 , NULL
5070 , p_hold_source_rec.hold_source_id
5071 , h.HEADER_ID
5072 , ol.line_id
5073 , 'N'
5074 , l_org_id
5075 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
5076 WHERE h.OPEN_FLAG = 'Y'
5077 --and nvl(h.CANCELLED_FLAG, 'N') = 'N'
5078 and h.header_id = ol.header_id
5079 and ol.INVENTORY_ITEM_ID = p_hold_source_rec.hold_entity_id
5080 and ol.OPEN_FLAG = 'Y'
5081 -- QUOTING change
5082 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
5083 and not exists ( select 'x'
5084 from oe_order_holds_ALL oh
5085 where oh.header_id = h.header_id
5086 and oh.line_id = ol.line_id
5087 and oh.hold_source_id =
5088 p_hold_source_rec.hold_source_id );
5089 END IF;
5090 END IF;
5091 -- Moved to Overloaded procedure under Bug 6801108
5092 -- GENESIS --
5093 IF p_hold_source_rec.line_id IS NOT NULL THEN
5094
5095 IF l_debug_level > 0 THEN
5096 oe_debug_pub.add('OE_HOLDS_PVT-CREATE ORDER HOLDS - p_hold_source_rec.line_id IS NOT NULL');
5097 END IF;
5098
5099 OPEN check_line_hold_type_cur(p_hold_source_rec.line_id);
5100 FETCH check_line_hold_type_cur INTO l_check_hold;
5101 CLOSE check_line_hold_type_cur;
5102 IF l_debug_level > 0 THEN
5103 oe_debug_pub.add('OE_HOLDS_PVT-CREATE ORDER HOLDS - l_check_hold' || l_check_hold);
5104 END IF;
5105
5106 ELSIF p_hold_source_rec.line_id IS NULL AND
5107 p_hold_source_rec.header_id IS NOT NULL THEN
5108
5109 IF l_debug_level > 0 THEN
5110 oe_debug_pub.add('OE_HOLDS_PVT-CREATE ORDER HOLDS - p_hold_source_rec.header_id IS NOT NULL');
5111 END IF;
5112 OPEN check_hdr_hold_type_cur(p_hold_source_rec.header_id);
5113 FETCH check_hdr_hold_type_cur INTO l_check_hold;
5114 CLOSE check_hdr_hold_type_cur;
5115 IF l_debug_level > 0 THEN
5116 oe_debug_pub.add('OE_HOLDS_PVT-CREATE ORDER HOLDS - l_check_hold' || l_check_hold);
5117 END IF;
5118
5119 ELSIF p_hold_source_rec.line_id IS NULL AND
5120 p_hold_source_rec.header_id IS NULL AND
5121 p_hold_source_rec.hold_source_id IS NOT NULL THEN
5122
5123 IF l_debug_level > 0 THEN
5124 oe_debug_pub.add('OE_HOLDS_PVT-CREATE ORDER HOLDS - p_hold_source_rec.hold_source_id IS NOT NULL');
5125 END IF;
5126 OPEN check_src_hold_type_cur(p_hold_source_rec.hold_source_id);
5127 FETCH check_src_hold_type_cur INTO l_check_hold;
5128 CLOSE check_src_hold_type_cur;
5129
5130 IF l_debug_level > 0 THEN
5131 oe_debug_pub.add('OE_HOLDS_PVT-CREATE ORDER HOLDS - l_check_hold :' || l_check_hold);
5132 END IF;
5133
5134 END IF;
5135
5136 IF l_debug_level > 0 THEN
5137 oe_debug_pub.add( 'OE_HOLDS_PVT - CREATE ORDER HOLDS - BEFORE SYNC_HEADER_LINE');
5138 END IF;
5139
5140 IF NVL(l_check_hold, 'N') = 'Y' THEN
5141
5142 IF l_debug_level > 0 THEN
5143 oe_debug_pub.add( 'OE_HOLDS_PVT - CREATE ORDER HOLDS - l_check_hold: ' || l_check_hold);
5144 END IF;
5145
5146 IF p_hold_source_rec.hold_entity_code = 'O' THEN
5147 IF l_debug_level > 0 THEN
5148 oe_debug_pub.add(' p_hold_source_rec.hold_entity_code ' || p_hold_source_rec.hold_entity_code);
5149 END IF;
5150 IF p_hold_source_rec.hold_entity_id is NOT NULL THEN
5151 IF l_debug_level > 0 THEN
5152 oe_debug_pub.add(' p_hold_source_rec.hold_entity_id : ' || p_hold_source_rec.hold_entity_id);
5153 END IF;
5154 oe_header_util.query_row ( p_header_id => p_hold_source_rec.hold_entity_id,
5155 x_header_rec => l_header_rec);
5156 END IF; -- p_hold_source_rec.hold_entity_id is NOT NULL
5157
5158 IF p_hold_source_rec.line_id is not NULL THEN
5159 IF l_debug_level > 0 THEN
5160 oe_debug_pub.add(' p_hold_source_rec.line_id : ' || p_hold_source_rec.line_id );
5161 END IF;
5162 oe_line_util.query_row(
5163 p_line_id => p_hold_source_rec.line_id
5164 ,x_line_rec => l_line_rec
5165 );
5166 END IF;
5167
5168 -- XXXX Do we need to generate req_id here
5169 OE_SYNC_ORDER_PVT.SYNC_HEADER_LINE(p_header_rec => l_header_rec
5170 ,p_line_rec => l_line_rec
5171 ,p_hold_source_id => p_hold_source_rec.hold_source_id
5172 ,p_change_type => 'APPLY');
5173 ELSE --p_hold_source_rec.hold_entity_code = 'O'
5174
5175 IF l_debug_level > 0 THEN
5176 oe_debug_pub.add(' p_hold_source_rec.hold_entity_code ' || p_hold_source_rec.hold_entity_code);
5177 END IF;
5178
5179 IF p_hold_source_rec.header_id is NOT NULL THEN
5180 oe_header_util.query_row ( p_header_id => p_hold_source_rec.header_id,
5181 x_header_rec => l_header_rec);
5182 END IF;
5183 IF p_hold_source_rec.line_id is not NULL THEN
5184 oe_line_util.query_row(
5185 p_line_id => p_hold_source_rec.line_id
5186 ,x_line_rec => l_line_rec
5187 );
5188 END IF;
5189 -- IF(p_hold_source_rec.header_id IS NOT NULL OR p_hold_source_rec.line_id IS NOT NULL) THEN
5190 -- XXXX Do we need to generate req_id here
5191 OE_SYNC_ORDER_PVT.SYNC_HEADER_LINE(p_header_rec => l_header_rec
5192 ,p_line_rec => l_line_rec
5193 ,p_hold_source_id => p_hold_source_rec.hold_source_id
5194 ,p_change_type => 'APPLY');
5195 -- END IF; Bug 6791576
5196 END IF; --p_hold_source_rec.hold_entity_code = 'O'
5197 END IF;*/
5198 -- GENESIS --
5199 EXCEPTION
5200 WHEN FND_API.G_EXC_ERROR THEN
5201 --ROLLBACK TO APPLY_HOLDS_PUB;
5202 x_return_status := FND_API.G_RET_STS_ERROR;
5203 OE_MSG_PUB.Count_And_Get
5204 ( p_count => x_msg_count
5205 , p_data => x_msg_data
5206 );
5207 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5208 --ROLLBACK TO APPLY_HOLDS_PUB;
5209 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5210 OE_MSG_PUB.Count_And_Get
5211 ( p_count => x_msg_count
5212 , p_data => x_msg_data
5213 );
5214 WHEN OTHERS THEN
5215 --ROLLBACK TO APPLY_HOLDS_PUB;
5216 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5217 IF OE_MSG_PUB.Check_Msg_Level
5218 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5219 THEN
5220 OE_MSG_PUB.Add_Exc_Msg
5221 ( G_PKG_NAME
5222 , l_api_name
5223 );
5224 END IF;
5225 OE_MSG_PUB.Count_And_Get
5226 ( p_count => x_msg_count
5227 , p_data => x_msg_data
5228 );
5229
5230 END Create_Order_Holds;
5231
5232
5233 Procedure Release_Order_holds (
5234 p_hold_release_rec IN OE_HOLDS_PVT.hold_release_rec_type,
5235 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
5236 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
5237 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2 )
5238 IS
5239 -- GENESIS --
5240 CURSOR check_hold_typ_cur(p_hld_src_id IN NUMBER) IS
5241 SELECT 'Y'
5242 FROM DUAL
5243 WHERE EXISTS (SELECT NULL
5244 FROM oe_hold_sources ohs,
5245 oe_hold_definitions ohd
5246 WHERE ohd.hold_id = ohs.hold_id
5247 -- AND ohd.activity_name IS NULL Bug 6791587
5248 AND ohs.hold_source_id = p_hld_src_id
5249 AND ohs.hold_entity_code <> 'O');
5250
5251 l_chk_hld VARCHAR2(1) := 'N';
5252
5253 -- Bug 8463870
5254 l_line_id number;
5255 l_line_rec oe_order_pub.line_rec_type;
5256
5257 l_header_id number;
5258 l_header_rec oe_order_pub.header_rec_type;
5259
5260 cursor header_line_id_cur(p_ord_hld_id in number) is
5261 select ohld.header_id,
5262 ohld.line_id
5263 from oe_order_holds ohld,
5264 oe_order_headers ooh,
5265 oe_order_sources src
5266 where ohld.order_hold_id = p_ord_hld_id
5267 and ohld.header_id = ooh.header_id
5268 and src.order_source_id = ooh.order_source_id
5269 and src.aia_enabled_flag = 'Y';
5270
5271 -- GENESIS --
5272 -- 16053361
5273 l_nameVal_tbl OE_ORDER_UTIL.nameVal_Tbl_Type;
5274 l_count number;
5275 -- 16053361
5276
5277 l_user_id NUMBER;
5278 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
5279
5280 BEGIN
5281 x_return_status := FND_API.G_RET_STS_SUCCESS;
5282 l_user_id := OE_HOLDS_PVT.get_user_id;
5283 -- Flag all orders and order line holds for this hold source
5284 -- as released
5285 UPDATE oe_order_holds
5286 SET hold_release_id = p_hold_release_rec.hold_release_id,
5287 LAST_UPDATED_BY = l_user_id,
5288 LAST_UPDATE_DATE = sysdate,
5289 RELEASED_FLAG = 'Y'
5290 WHERE hold_source_id = p_hold_release_rec.hold_source_id
5291 AND hold_release_id IS NULL;
5292 -- XXX ??
5293 -- If the entity code is order, then release hold source also, if no
5294 -- other order hold records exist for this hold source. This would
5295 -- be the case if selected lines of an order were put on hold.
5296 -- IF l_entity_code = 'O' THEN
5297 -- END IF;
5298 -- 16053361
5299 oe_debug_pub.add( 'OE_HOLDS_PVT - Raise Integration event for Releasing hold');
5300 If NVL (Fnd_Profile.Value('ONT_RAISE_STATUS_CHANGE_BUSINESS_EVENT'), 'N')='Y'
5301 THEN
5302 IF l_debug_level > 0 THEN
5303 oe_debug_pub.add( 'OE_HOLDS_PVT - Preparing paramters to pass to Integration event for Releasing hold');
5304 END IF;
5305 l_count := 1;
5306 l_nameVal_tbl(l_count).name := 'CHANGE_TYPE';
5307 l_nameVal_tbl(l_count).value := 'RELEASE';
5308 l_nameVal_tbl(l_count+1).name := 'ORDER_HOLD_ID';
5309 l_nameVal_tbl(l_count+1).value := p_hold_release_rec.order_hold_id;
5310 l_nameVal_tbl(l_count+2).name := 'HOLD_SOURCE_ID';
5311 l_nameVal_tbl(l_count+2).value := p_hold_release_rec.hold_source_id;
5312 l_nameVal_tbl(l_count+3).name := 'HOLD_RELEASE_ID';
5313 l_nameVal_tbl(l_count+3).value := p_hold_release_rec.hold_release_id;
5314 BEGIN
5315 SELECT ohld.header_id,
5316 ohld.line_id
5317 INTO l_header_id,
5318 l_line_id
5319 FROM oe_order_holds ohld,
5320 oe_order_headers ooh
5321 WHERE ohld.order_hold_id = p_hold_release_rec.order_hold_id
5322 AND ohld.header_id = ooh.header_id;
5323 EXCEPTION
5324 WHEN OTHERS THEN
5325 oe_debug_pub.add('No data found!');
5326 END;
5327 if l_debug_level > 0 then
5328 oe_debug_pub.add('....header_id = ' || l_header_id);
5329 oe_debug_pub.add('....line_id = ' || l_line_id);
5330 end if;
5331 oe_order_util.raise_business_event( p_header_id => l_header_id,
5332 p_line_id => l_line_id,
5333 p_event_name => 'oracle.apps.ont.hold.action',
5334 p_nameVal_tbl => l_nameVal_tbl);
5335 IF l_debug_level > 0 THEN
5336 oe_debug_pub.add( 'OE_HOLDS_PVT - Done with Raising Integration event for Releasing hold');
5337 END IF;
5338 END IF;
5339 oe_debug_pub.add( 'OE_HOLDS_PVT - Raised Integration event for Releasing hold');
5340 -- 16053361
5341 -- GENESIS --
5342 IF l_debug_level > 0 THEN
5343 oe_debug_pub.add( 'OE_HOLDS_PVT - RELEASE ORDER HOLDS - BEFORE GENESIS CALL');
5344 END IF;
5345 OPEN check_hold_typ_cur(p_hold_release_rec.hold_source_id);
5346 FETCH check_hold_typ_cur INTO l_chk_hld;
5347 CLOSE check_hold_typ_cur;
5348
5349 IF NVL(l_chk_hld, 'N') = 'Y' THEN
5350 IF l_debug_level > 0 THEN
5351 oe_debug_pub.add( 'OE_HOLDS_PVT - 1 RELEASE ORDER HOLDS - BEFORE SYNC_HEADER_LINE');
5352 oe_debug_pub.add( 'OE_HOLDS_PVT - hold_source _id '|| p_hold_release_rec.hold_source_id);
5353 oe_debug_pub.add( 'OE_HOLDS_PVT - hold_release_id' ||p_hold_release_rec.hold_release_id);
5354 END IF;
5355
5356 -- Bug 8463870
5357 for hld_rls_rec in header_line_id_cur(p_hold_release_rec.order_hold_id)
5358 loop
5359 l_header_id := hld_rls_rec.header_id;
5360 l_line_id := hld_rls_rec.line_id;
5361 end loop;
5362
5363 if l_debug_level > 0 then
5364 oe_debug_pub.add('....header_id = ' || l_header_id);
5365 oe_debug_pub.add('....line_id = ' || l_line_id);
5366 end if;
5367
5368 if ( l_header_id is not null ) then
5369 l_header_rec := oe_header_util.query_row(p_header_id => l_header_id);
5370 if ( l_debug_level > 0 ) then
5371 oe_debug_pub.add('.... Queried up header record.');
5372 end if;
5373 end if;
5374
5375 if ( l_line_id is not null ) then
5376 l_line_rec := oe_line_util.query_row(p_line_id => l_line_id);
5377 if ( l_debug_level > 0 ) then
5378 oe_debug_pub.add('.... Queried up line record.');
5379 end if;
5380 end if;
5381
5382 if (l_debug_level > 0 ) then
5383 oe_debug_pub.add('.... Calling oe_sync_order_pvt.sync_header_line...');
5384 end if;
5385
5386 OE_SYNC_ORDER_PVT.SYNC_HEADER_LINE(p_header_rec => l_header_rec -- NULL
5387 ,p_line_rec => l_line_rec -- NULL
5388 ,p_hold_source_id => p_hold_release_rec.hold_source_id
5389 ,p_change_type => 'RELEASE'
5390 ,p_hold_release_id => p_hold_release_rec.hold_release_id);
5391
5392 if (l_debug_level > 0 ) then
5393 oe_debug_pub.add('.... Returned from oe_sync_order_pvt.sync_header_line...');
5394 end if;
5395 END IF;
5396 -- GENESIS --
5397 END Release_Order_holds;
5398
5399
5400
5401 PROCEDURE Create_Release_Source (
5402 p_hold_release_rec IN OE_Holds_Pvt.Hold_Release_Rec_type,
5403 x_hold_release_id OUT NOCOPY /* file.sql.39 change */ oe_hold_releases.HOLD_RELEASE_ID%type,
5404 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
5405 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
5406 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
5407 )
5408 IS
5409 l_dummy VARCHAR2(30);
5410 l_user_id NUMBER;
5411 l_hold_release_rec OE_Holds_Pvt.Hold_Release_Rec_type;
5412 BEGIN
5413
5414 -- Fix For Bug 1903900
5415 SAVEPOINT insert_hold_release;
5416 x_return_status := FND_API.G_RET_STS_SUCCESS;
5417
5418 l_user_id := OE_HOLDS_PVT.get_user_id;
5419
5420 -- Validate Reason Code
5421 BEGIN
5422
5423 SELECT 'x'
5424 INTO l_dummy
5425 FROM OE_LOOKUPS
5426 WHERE LOOKUP_TYPE = 'RELEASE_REASON'
5427 AND LOOKUP_CODE = p_hold_release_rec.release_reason_code;
5428
5429 EXCEPTION
5430
5431 WHEN NO_DATA_FOUND THEN
5432 oe_debug_pub.add('Invalid Reason Code:' ||
5433 p_hold_release_rec.release_reason_code ,2);
5434 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_REASON_CODE');
5435 FND_MESSAGE.SET_TOKEN('REASON_CODE',
5436 p_hold_release_rec.release_reason_code);
5437 OE_MSG_PUB.ADD;
5438 RAISE FND_API.G_EXC_ERROR;
5439
5440 END; -- Validate Reason Code
5441
5442 SELECT OE_HOLD_RELEASES_S.NEXTVAL
5443 INTO x_hold_release_id
5444 FROM DUAL;
5445
5446 oe_debug_pub.add('Creating OE_HOLD_RELEASES record', 1);
5447 /*Bug3042838 Added nvl condition for insertion into CREATED_BY column */
5448 INSERT INTO OE_HOLD_RELEASES
5449 ( HOLD_RELEASE_ID
5450 , CREATION_DATE
5451 , CREATED_BY
5452 , LAST_UPDATE_DATE
5453 , LAST_UPDATED_BY
5454 , LAST_UPDATE_LOGIN
5455 , PROGRAM_APPLICATION_ID
5456 , PROGRAM_ID
5457 , PROGRAM_UPDATE_DATE
5458 , REQUEST_ID
5459 , HOLD_SOURCE_ID
5460 , RELEASE_REASON_CODE
5461 , RELEASE_COMMENT
5462 , CONTEXT
5463 , ATTRIBUTE1
5464 , ATTRIBUTE2
5465 , ATTRIBUTE3
5466 , ATTRIBUTE4
5467 , ATTRIBUTE5
5468 , ATTRIBUTE6
5469 , ATTRIBUTE7
5470 , ATTRIBUTE8
5471 , ATTRIBUTE9
5472 , ATTRIBUTE10
5473 , ATTRIBUTE11
5474 , ATTRIBUTE12
5475 , ATTRIBUTE13
5476 , ATTRIBUTE14
5477 , ATTRIBUTE15
5478 )
5479 VALUES
5480 ( x_hold_release_id
5481 , sysdate
5482 , nvl(p_hold_release_rec.CREATED_BY,l_user_id)
5483 , sysdate
5484 , l_user_id
5485 , p_hold_release_rec.LAST_UPDATE_LOGIN
5486 , p_hold_release_rec.PROGRAM_APPLICATION_ID
5487 , p_hold_release_rec.PROGRAM_ID
5488 , p_hold_release_rec.PROGRAM_UPDATE_DATE
5489 , p_hold_release_rec.REQUEST_ID
5490 , p_hold_release_rec.HOLD_SOURCE_ID
5491 , p_hold_release_rec.RELEASE_REASON_CODE
5492 , p_hold_release_rec.RELEASE_COMMENT
5493 , p_hold_release_rec.CONTEXT
5494 , p_hold_release_rec.ATTRIBUTE1
5495 , p_hold_release_rec.ATTRIBUTE2
5496 , p_hold_release_rec.ATTRIBUTE3
5497 , p_hold_release_rec.ATTRIBUTE4
5498 , p_hold_release_rec.ATTRIBUTE5
5499 , p_hold_release_rec.ATTRIBUTE6
5500 , p_hold_release_rec.ATTRIBUTE7
5501 , p_hold_release_rec.ATTRIBUTE8
5502 , p_hold_release_rec.ATTRIBUTE9
5503 , p_hold_release_rec.ATTRIBUTE10
5504 , p_hold_release_rec.ATTRIBUTE11
5505 , p_hold_release_rec.ATTRIBUTE12
5506 , p_hold_release_rec.ATTRIBUTE13
5507 , p_hold_release_rec.ATTRIBUTE14
5508 , p_hold_release_rec.ATTRIBUTE15
5509 );
5510
5511 -- Flag the hold source as released
5512
5513 oe_debug_pub.add('Updating oe_hold_sources for Release', 1);
5514 --ER#7479609 UPDATE oe_hold_sources
5515 UPDATE oe_hold_sources_all --ER#7479609
5516 SET hold_release_id = x_hold_release_id
5517 , released_flag = 'Y'
5518 , LAST_UPDATED_BY = l_user_id
5519 , LAST_UPDATE_DATE = sysdate
5520 WHERE hold_source_id = p_hold_release_rec.HOLD_SOURCE_ID;
5521
5522 -- l_hold_release_rec := p_hold_release_rec;
5523 -- l_hold_release_rec.hold_release_id := x_hold_release_id;
5524
5525 EXCEPTION
5526 WHEN FND_API.G_EXC_ERROR THEN
5527 x_return_status := FND_API.G_RET_STS_ERROR;
5528 ROLLBACK TO insert_hold_release;
5529 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5530 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5531 ROLLBACK TO insert_hold_release;
5532 WHEN OTHERS THEN
5533 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
5534 OE_MSG_PUB.Add_Exc_Msg
5535 (G_PKG_NAME
5536 ,'Insert_Hold_Release');
5537 END IF;
5538 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5539 ROLLBACK TO insert_hold_release;
5540
5541 END Create_Release_Source;
5542
5543 Procedure Release_Hold_Source (
5544 p_hold_source_rec IN OE_HOLDS_PVT.Hold_source_Rec_Type,
5545 p_hold_release_rec IN OE_HOLDS_PVT.hold_release_rec_type,
5546 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
5547 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
5548 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
5549 )
5550 IS
5551 l_hold_release_rec OE_HOLDS_PVT.hold_release_rec_type;
5552 l_hold_release_id oe_hold_releases.HOLD_RELEASE_ID%type;
5553 --
5554 CURSOR hold_source IS
5555 SELECT HS.HOLD_SOURCE_ID
5556 FROM OE_HOLD_SOURCES HS
5557 WHERE HS.HOLD_ID = p_hold_source_rec.hold_id
5558 AND HS.RELEASED_FLAG = 'N'
5559 --AND NVL(HS.HOLD_UNTIL_DATE, SYSDATE + 1) > SYSDATE
5560 AND HS.HOLD_ENTITY_CODE = p_hold_source_rec.hold_entity_code
5561 AND HS.HOLD_ENTITY_ID = p_hold_source_rec.hold_entity_id
5562 AND nvl(HS.HOLD_ENTITY_CODE2, 'NO_ENTITY_CODE2') =
5563 nvl(p_hold_source_rec.hold_entity_code2, 'NO_ENTITY_CODE2')
5564 AND nvl(HS.HOLD_ENTITY_ID2, -99) =
5565 nvl(p_hold_source_rec.hold_entity_id2, -99);
5566
5567 CURSOR order_hold_source IS
5568 SELECT HS.HOLD_SOURCE_ID
5569 FROM OE_HOLD_SOURCES HS
5570 WHERE HS.HOLD_ID = p_hold_source_rec.hold_id
5571 AND HS.RELEASED_FLAG = 'N'
5572 --AND NVL(HS.HOLD_UNTIL_DATE, SYSDATE + 1) > SYSDATE
5573 AND HS.HOLD_ENTITY_CODE = p_hold_source_rec.hold_entity_code
5574 AND HS.HOLD_ENTITY_ID = p_hold_source_rec.hold_entity_id
5575 AND HS.HOLD_ENTITY_CODE2 is null
5576 AND HS.HOLD_ENTITY_ID2 is null
5577 -- AND nvl(HS.HOLD_ENTITY_CODE2, 'NO_ENTITY_CODE2') =
5578 -- nvl(p_hold_source_rec.hold_entity_code2, 'NO_ENTITY_CODE2')
5579 -- AND nvl(HS.HOLD_ENTITY_ID2, -99) =
5580 -- nvl(p_hold_source_rec.hold_entity_id2, -99)
5581 AND EXISTS (select 1
5582 from oe_order_holds oh
5583 where oh.hold_source_id = hs.hold_source_id
5584 and oh.header_id =
5585 nvl(p_hold_source_rec.header_id, oh.header_id)
5586 and nvl(oh.line_id, -99) =
5587 nvl(p_hold_source_rec.line_id, -99));
5588 BEGIN
5589 x_return_status := FND_API.G_RET_STS_SUCCESS;
5590 l_hold_release_rec := p_hold_release_rec;
5591
5592 -- Retrieving hold source ID if not passed
5593 IF p_hold_source_rec.hold_source_id IS NULL THEN
5594 IF p_hold_source_rec.hold_entity_code = 'O' AND
5595 p_hold_source_rec.hold_entity_code2 is null THEN
5596 oe_debug_pub.add('Releasing Order based holds', 1);
5597 OPEN order_hold_source;
5598 FETCH order_hold_source INTO l_hold_release_rec.hold_source_id;
5599 IF (order_hold_source%NOTFOUND) THEN
5600 /* Note:Fix for bug#2669137 */
5601 /*
5602 oe_debug_pub.add('Missing Order Hold Source ID...',1);
5603 oe_debug_pub.add('Entity Code/ID/Header_id/Line_id' ||
5604 p_hold_source_rec.hold_entity_code || '/' ||
5605 to_char(p_hold_source_rec.hold_entity_id) || '/' ||
5606 p_hold_source_rec.header_id || '/' ||
5607 p_hold_source_rec.line_id,1);
5608 oe_debug_pub.add('Entity Code2/ID2' ||
5609 p_hold_source_rec.hold_entity_code2 || '/' ||
5610 to_char(p_hold_source_rec.hold_entity_id2) ,1);
5611 FND_MESSAGE.SET_NAME('ONT', 'OE_MISSING_HOLD_SOURCE');
5612 OE_MSG_PUB.ADD;
5613 RAISE FND_API.G_EXC_ERROR;
5614 */
5615 CLOSE order_hold_source;
5616 RETURN;
5617 END IF; -- order_hold_source%NOTFOUND
5618 CLOSE order_hold_source;
5619 ELSE
5620 OPEN hold_source;
5621 FETCH hold_source INTO l_hold_release_rec.hold_source_id;
5622 IF (hold_source%NOTFOUND) THEN
5623 oe_debug_pub.add('Missing Hold Source ID...',1);
5624 oe_debug_pub.add('Entity Code/ID' ||
5625 p_hold_source_rec.hold_entity_code || '/' ||
5626 to_char(p_hold_source_rec.hold_entity_id) ,1);
5627 oe_debug_pub.add('Entity Code2/ID2' ||
5628 p_hold_source_rec.hold_entity_code2 || '/' ||
5629 to_char(p_hold_source_rec.hold_entity_id2) ,1);
5630 FND_MESSAGE.SET_NAME('ONT', 'OE_MISSING_HOLD_SOURCE');
5631 OE_MSG_PUB.ADD;
5632 RAISE FND_API.G_EXC_ERROR;
5633 END IF; -- hold_source%NOTFOUND
5634 CLOSE hold_source;
5635 END IF; -- p_hold_source_rec.hold_entity_code = 'O'
5636 ELSE
5637 l_hold_release_rec.hold_source_id := p_hold_source_rec.hold_source_id;
5638 oe_debug_pub.add('Using Hold Source ID:' ||
5639 to_char(l_hold_release_rec.hold_source_id) ,1);
5640 END IF;
5641
5642 OE_HOLDS_PVT.Create_Release_Source(p_hold_release_rec => l_hold_release_rec,
5643 x_hold_release_id => l_hold_release_id,
5644 x_return_status => x_return_status,
5645 x_msg_count => x_msg_count,
5646 x_msg_data => x_msg_data);
5647
5648 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5649 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
5650 RAISE FND_API.G_EXC_ERROR;
5651 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
5652 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5653 END IF;
5654 END IF;
5655 oe_debug_pub.add('Calling Release_Order_holds using l_hold_release_id' ||
5656 to_char(l_hold_release_id) ,1);
5657 l_hold_release_rec.hold_release_id := l_hold_release_id;
5658
5659 OE_HOLDS_PVT.Release_Order_holds(
5660 p_hold_release_rec => l_hold_release_rec,
5661 x_return_status => x_return_status,
5662 x_msg_count => x_msg_count,
5663 x_msg_data => x_msg_data);
5664 --ER 12363706 start
5665 IF p_hold_source_rec.hold_id = 1 AND
5666 p_hold_source_rec.hold_entity_code ='O'
5667 THEN
5668 OE_CREDIT_CHECK_UTIL.UPDATE_RELEASED_AMOUNT(p_hold_source_rec.hold_entity_id,l_hold_release_id);
5669 END IF;
5670 --ER 12363706 end
5671 EXCEPTION
5672 WHEN FND_API.G_EXC_ERROR THEN
5673 x_return_status := FND_API.G_RET_STS_ERROR;
5674 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5675 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5676 WHEN OTHERS THEN
5677 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
5678 OE_MSG_PUB.Add_Exc_Msg (G_PKG_NAME
5679 ,'Insert_Hold_Release');
5680 END IF;
5681 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5682
5683 END Release_Hold_Source;
5684
5685
5686
5687
5688 Procedure Validate_Order(p_header_id IN OE_ORDER_HEADERS.header_id%type,
5689 p_line_id IN OE_ORDER_LINES.line_id%type,
5690 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
5691 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
5692 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
5693 IS
5694 l_api_name CONSTANT VARCHAR2(30) := 'Validate_Order';
5695 l_dummy VARCHAR2(30);
5696 l_header_id OE_ORDER_HEADERS.header_id%type;
5697 BEGIN
5698 x_return_status := FND_API.G_RET_STS_SUCCESS;
5699
5700 IF p_line_id IS NULL AND p_header_id IS NULL THEN
5701 FND_MESSAGE.SET_NAME('ONT', 'OE_ENTER_HEADER_OR_LINE_ID');
5702 OE_MSG_PUB.ADD;
5703 RAISE FND_API.G_EXC_ERROR;
5704 ELSIF p_header_id IS NULL THEN
5705 l_dummy := 'LINE'; -- Added for bug 7112725
5706 SELECT header_id
5707 INTO l_header_id
5708 FROM OE_ORDER_LINES
5709 WHERE LINE_ID = p_line_id;
5710 ELSE
5711 l_dummy := 'HEADER'; -- Added for bug 7112725
5712 SELECT 'Valid Entity'
5713 INTO l_dummy
5714 FROM OE_ORDER_HEADERS
5715 WHERE HEADER_ID = p_header_id;
5716 END IF;
5717 EXCEPTION
5718 WHEN NO_DATA_FOUND THEN
5719 -- Modified below code for bug 7112725
5720 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5721 IF l_dummy = 'HEADER' THEN
5722 FND_MESSAGE.SET_NAME('ONT', 'OE_INVALID_HEADER_ID');
5723 FND_MESSAGE.SET_TOKEN('HEADER_ID',p_header_id);
5724 OE_MSG_PUB.ADD;
5725 ELSIF l_dummy = 'LINE' THEN
5726 FND_MESSAGE.SET_NAME('ONT', 'OE_COGS_INVALID_LINE_ID');
5727 FND_MESSAGE.SET_TOKEN('LINE_ID',p_line_id);
5728 OE_MSG_PUB.ADD;
5729 END IF;
5730 oe_debug_pub.add('Return Status : ' || x_return_status, 5);
5731 -- RAISE FND_API.G_EXC_ERROR; -- Commented for bug 7112725
5732 END Validate_Order;
5733
5734
5735 Procedure Validate (
5736 p_hold_source_rec IN OE_HOLDS_PVT.Hold_Source_Rec_type,
5737 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
5738 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
5739 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
5740 IS
5741 BEGIN
5742 Validate_Hold_source ( p_hold_source_rec => p_hold_source_rec,
5743 x_return_status => x_return_status,
5744 x_msg_count => x_msg_count,
5745 x_msg_data => x_msg_data
5746 );
5747 /*
5748 ** Call Validate_Hold() only if Validate_Hold_Source() was successful
5749 */
5750 IF x_return_status = FND_API.G_RET_STS_SUCCESS THEN
5751
5752 Validate_Hold ( p_hold_id => p_hold_source_rec.hold_id,
5753 x_return_status => x_return_status,
5754 x_msg_count => x_msg_count,
5755 x_msg_data => x_msg_data
5756 );
5757 ELSE
5758 RETURN;
5759 END IF;
5760 END Validate;
5761
5762
5763 ----------------------------------------------------------------------------
5764 -- Delete Holds
5765 -- Deletes from OE_ORDER_HOLDS all hold records for an order (p_header_id)
5766 -- or for a line (p_line_id).
5767 -- Also, if there are ORDER hold sources (hold_entity_code = 'O') for this
5768 -- order, deletes hold source records from OE_HOLD_SOURCES.
5769 -- If the hold or hold source was released and the same release record is
5770 -- not used by an existing hold or hold source, then deletes the
5771 -- release record also from OE_HOLD_RELEASES;
5772 ----------------------------------------------------------------------------
5773 PROCEDURE Delete_Holds (
5774 p_order_rec IN OE_HOLDS_PVT.order_rec_Type,
5775 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
5776 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
5777 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
5778 )
5779 IS
5780 l_api_name CONSTANT VARCHAR2(30) := 'DELETE_HOLDS';
5781 l_api_version CONSTANT NUMBER := 1.0;
5782 l_order_hold_id NUMBER;
5783 l_hold_source_id NUMBER;
5784 l_hold_release_id NUMBER := 0;
5785 CURSOR order_hold IS
5786 SELECT order_hold_id, NVL(hold_release_id,0)
5787 FROM OE_ORDER_HOLDS_all
5788 WHERE HEADER_ID = p_order_rec.header_id;
5789 CURSOR hold_source IS
5790 SELECT hold_source_id, NVL(hold_release_id,0)
5791 FROM OE_HOLD_SOURCES_all
5792 WHERE HOLD_ENTITY_CODE = 'O'
5793 AND HOLD_ENTITY_ID = p_order_rec.header_id;
5794 CURSOR line_hold IS
5795 SELECT order_hold_id, NVL(hold_release_id,0)
5796 FROM OE_ORDER_HOLDS_all
5797 WHERE LINE_ID = p_order_rec.line_id;
5798
5799 BEGIN
5800 -- Standard Start of API savepoint
5801
5802 SAVEPOINT DELETE_HOLDS_PUB;
5803
5804 -- Initialize API return status to success
5805 x_return_status := FND_API.G_RET_STS_SUCCESS;
5806
5807 -- Missing Input arguments
5808
5809 IF (p_order_rec.header_id = FND_API.G_MISS_NUM
5810 AND p_order_rec.line_id = FND_API.G_MISS_NUM) THEN
5811
5812 FND_MESSAGE.SET_NAME('ONT', 'OE_ENTER_HEADER_OR_LINE_ID');
5813 OE_MSG_PUB.ADD;
5814 RAISE FND_API.G_EXC_ERROR;
5815
5816 END IF;
5817
5818 -- Delete the hold records corr. to this order or line in OE_ORDER_HOLDS
5819
5820 IF p_order_rec.line_id = FND_API.G_MISS_NUM THEN
5821
5822 -- Delete order hold records
5823
5824 OPEN order_hold;
5825
5826 LOOP
5827 FETCH order_hold INTO l_order_hold_id, l_hold_release_id;
5828 IF (order_hold%notfound) THEN
5829 EXIT;
5830 END IF;
5831
5832 OE_Debug_PUB.Add('Deleting order hold record',1);
5833
5834 DELETE FROM OE_ORDER_HOLDS_all
5835 WHERE order_hold_id = l_order_hold_id;
5836
5837 OE_Debug_PUB.Add('Deleting hold release record',1);
5838 DELETE FROM OE_HOLD_RELEASES
5839 WHERE HOLD_RELEASE_ID = l_hold_release_id
5840 AND HOLD_RELEASE_ID NOT IN (SELECT NVL(HOLD_RELEASE_ID,0)
5841 FROM OE_ORDER_HOLDS_all
5842 UNION
5843 SELECT NVL(HOLD_RELEASE_ID,0)
5844 FROM OE_HOLD_SOURCES_all
5845 );
5846 END LOOP;
5847
5848 CLOSE order_hold;
5849
5850 -- Delete hold source records
5851 OPEN hold_source;
5852 LOOP
5853 FETCH hold_source INTO l_hold_source_id, l_hold_release_id;
5854 IF (hold_source%notfound) THEN
5855 EXIT;
5856 END IF;
5857 OE_Debug_PUB.Add('Deleting hold source record',1);
5858
5859 DELETE FROM OE_HOLD_SOURCES_all
5860 WHERE HOLD_SOURCE_ID = l_hold_source_id;
5861
5862 OE_Debug_PUB.Add('Deleting hold release record',1);
5863 DELETE FROM OE_HOLD_RELEASES
5864 WHERE HOLD_RELEASE_ID = l_hold_release_id
5865 AND HOLD_RELEASE_ID NOT IN
5866 ( SELECT NVL(HOLD_RELEASE_ID,0)
5867 FROM OE_ORDER_HOLDS_all
5868 UNION
5869 SELECT NVL(HOLD_RELEASE_ID,0)
5870 FROM OE_HOLD_SOURCES_all
5871 );
5872
5873 END LOOP;
5874
5875 CLOSE hold_source;
5876
5877
5878 ELSE
5879
5880 -- Delete line hold records
5881
5882 OPEN line_hold;
5883
5884 LOOP
5885
5886 FETCH line_hold INTO l_order_hold_id, l_hold_release_id;
5887 IF (line_hold%notfound) THEN
5888 EXIT;
5889 END IF;
5890
5891 OE_Debug_PUB.Add('Deleting order hold record',1);
5892
5893 DELETE FROM OE_ORDER_HOLDS
5894 WHERE order_hold_id = l_order_hold_id;
5895
5896 DELETE FROM OE_HOLD_RELEASES
5897 WHERE HOLD_RELEASE_ID = l_hold_release_id
5898 AND HOLD_RELEASE_ID NOT IN
5899 (SELECT NVL(HOLD_RELEASE_ID,0)
5900 FROM OE_ORDER_HOLDS_all
5901 UNION
5902 SELECT NVL(HOLD_RELEASE_ID,0)
5903 FROM OE_HOLD_SOURCES_all
5904 );
5905
5906 END LOOP;
5907
5908 CLOSE line_hold;
5909
5910 END IF;
5911
5912
5913 EXCEPTION
5914 WHEN FND_API.G_EXC_ERROR THEN
5915 IF (order_hold%isopen) THEN
5916 CLOSE order_hold;
5917 END IF;
5918 IF (hold_source%isopen) THEN
5919 CLOSE hold_source;
5920 END IF;
5921 IF (line_hold%isopen) THEN
5922 CLOSE line_hold;
5923 END IF;
5924 ROLLBACK TO DELETE_HOLDS_PUB;
5925 x_return_status := FND_API.G_RET_STS_ERROR;
5926 OE_MSG_PUB.Count_And_Get
5927 ( p_count => x_msg_count
5928 , p_data => x_msg_data
5929 );
5930 WHEN OTHERS THEN
5931 IF (order_hold%isopen) THEN
5932 CLOSE order_hold;
5933 END IF;
5934 IF (hold_source%isopen) THEN
5935 CLOSE hold_source;
5936 END IF;
5937 IF (line_hold%isopen) THEN
5938 CLOSE line_hold;
5939 END IF;
5940 ROLLBACK TO DELETE_HOLDS_PUB;
5941 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5942 IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5943 THEN
5944 OE_MSG_PUB.Add_Exc_Msg
5945 ( G_PKG_NAME
5946 , l_api_name
5947 );
5948 END IF;
5949 OE_MSG_PUB.Count_And_Get
5950 ( p_count => x_msg_count
5951 , p_data => x_msg_data
5952 );
5953 END Delete_Holds;
5954
5955
5956 --------------------
5957 Procedure Apply_Holds (
5958 p_order_tbl IN OE_HOLDS_PVT.order_tbl_type,
5959 p_hold_id IN OE_HOLD_DEFINITIONS.HOLD_ID%TYPE,
5960 p_hold_until_date IN OE_HOLD_SOURCES.HOLD_UNTIL_DATE%TYPE,
5961 p_hold_comment IN OE_HOLD_SOURCES.HOLD_COMMENT%TYPE,
5962 p_check_authorization_flag IN VARCHAR2 DEFAULT 'N', -- bug 8477694
5963 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
5964 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
5965 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2 )
5966 IS
5967 j NUMBER;
5968 l_hold_source_rec OE_HOLDS_PVT.Hold_Source_Rec_Type;
5969 l_hold_source_id OE_HOLD_SOURCES_ALL.HOLD_SOURCE_ID%TYPE;
5970 l_application_id OE_HOLD_AUTHORIZATIONS.APPLICATION_ID%TYPE := FND_GLOBAL.RESP_APPL_ID;
5971 l_resp_id OE_HOLD_AUTHORIZATIONS.RESPONSIBILITY_ID%TYPE := FND_GLOBAL.RESP_ID;
5972 l_hold_exists VARCHAR2(1) :='N'; --bug 5548778
5973 l_msg_token VARCHAR2(100); --8477694
5974 /*Added the Following Variables for WF_HOLDS ER (bug 6449458)*/
5975 l_wf_item_type OE_HOLD_DEFINITIONS.ITEM_TYPE%TYPE := NULL;
5976 l_wf_activity_name OE_HOLD_DEFINITIONS.ACTIVITY_NAME%TYPE := NULL;
5977 l_is_hold_applied BOOLEAN;
5978 l_count_of_holds_applied NUMBER := 0;
5979 l_user_activity_name VARCHAR2(80);
5980
5981 BEGIN
5982 x_return_status := FND_API.G_RET_STS_SUCCESS;
5983 OE_DEBUG_PUB.Add('IN Apply Holds..Orders',1);
5984
5985 -- 8477694
5986
5987 IF NOT OE_GLOBALS.G_SYS_HOLD THEN
5988 IF check_system_holds(
5989 p_hold_id => p_hold_id,
5990 x_return_status => x_return_status,
5991 x_msg_count => x_msg_count,
5992 x_msg_data => x_msg_data) = 'N' THEN
5993
5994 OE_DEBUG_PUB.Add('Not authorize to Apply this Hold:'|| to_char(p_hold_id));
5995 l_msg_token := 'APPLY(System Hold)';
5996 fnd_message.set_name('ONT', 'OE_HOLDS_AUTHORIZATION_FAILED');
5997 fnd_message.set_token('ACTION', l_msg_token);
5998 OE_MSG_PUB.ADD;
5999 x_return_status := FND_API.G_RET_STS_ERROR;
6000 OE_MSG_PUB.Count_And_Get
6001 ( p_count => x_msg_count
6002 , p_data => x_msg_data
6003 );
6004 RETURN;
6005 END IF;
6006 END IF;
6007 OE_DEBUG_PUB.Add('After calling Check_System_Holds');
6008
6009 OE_DEBUG_PUB.Add('Apply Hold before calling Check_Authorization');
6010
6011 -- 8477694
6012 IF p_check_authorization_flag = 'Y' THEN
6013 OE_DEBUG_PUB.Add('8477694 Manual Auth'||p_check_authorization_flag);
6014 ELSE
6015 OE_DEBUG_PUB.Add('8477694 Auto Auth'||p_check_authorization_flag);
6016 END IF;
6017
6018 IF p_check_authorization_flag = 'Y' THEN --bug 8477694
6019 IF check_authorization ( p_hold_id => p_hold_id
6020 ,p_authorized_action_code => 'APPLY'
6021 ,p_responsibility_id => l_resp_id
6022 ,p_application_id => l_application_id
6023 ,x_return_status => x_return_status
6024 ,x_msg_count => x_msg_count
6025 ,x_msg_data => x_msg_data
6026 ) = 'N' THEN
6027 OE_DEBUG_PUB.Add('Not authorize to Apply this Hold:'|| to_char(p_hold_id));
6028 fnd_message.set_name('ONT','ONT_APPLY');
6029 l_msg_token := fnd_message.get;
6030 fnd_message.set_name('ONT', 'OE_HOLDS_AUTHORIZATION_FAILED');
6031 fnd_message.set_token('ACTION', l_msg_token);
6032 OE_MSG_PUB.ADD;
6033 x_return_status := FND_API.G_RET_STS_ERROR;
6034 OE_MSG_PUB.Count_And_Get
6035 ( p_count => x_msg_count
6036 , p_data => x_msg_data
6037 );
6038 RETURN;
6039 END IF;
6040 END IF; --bug 8477694
6041
6042 OE_DEBUG_PUB.Add('Apply Hold After calling Check_Authorization');
6043 --8477694
6044
6045
6046 for j in 1..p_order_tbl.COUNT loop
6047 OE_DEBUG_PUB.Add('IN Apply Holds Loop',3);
6048 l_hold_exists := 'N'; --bug 5548778
6049 x_return_status := FND_API.G_RET_STS_SUCCESS;
6050 l_hold_source_rec.hold_entity_code := 'O';
6051 l_hold_source_rec.hold_entity_id := p_order_tbl(j).header_id;
6052 l_hold_source_rec.line_id := p_order_tbl(j).line_id;
6053
6054 l_hold_source_rec.hold_id := p_hold_id;
6055 l_hold_source_rec.hold_until_date := p_hold_until_date;
6056 l_hold_source_rec.hold_comment := p_hold_comment;
6057
6058 --dbms_output.put_line ('p_order_tbl.header_id'||p_order_tbl(j).header_id);
6059 --dbms_output.put_line ('Hold_id'|| l_hold_source_rec.hold_id);
6060
6061 OE_DEBUG_PUB.Add('headerID'|| to_char(p_order_tbl(j).header_id),3);
6062 OE_DEBUG_PUB.Add('HoldID:' || to_char(l_hold_source_rec.hold_id),3 );
6063
6064 OE_DEBUG_PUB.Add('Validating ORder',1);
6065 Validate_Order (p_order_tbl(j).header_id,
6066 p_order_tbl(j).line_id,
6067 x_return_status => x_return_status,
6068 x_msg_count => x_msg_count,
6069 x_msg_data => x_msg_data
6070 );
6071 --dbms_output.put_line ('Validate_Order:x_return_status' || x_return_status );
6072 --dbms_output.put_line ('Validate_Order:x_msg_count' || to_char(x_msg_count) );
6073 --dbms_output.put_line ('Validate_Order:x_msg_data' || x_msg_data );
6074
6075 OE_DEBUG_PUB.Add('After Validate_Order',2);
6076 OE_DEBUG_PUB.Add('x_return_status:' || x_return_status,1);
6077 OE_DEBUG_PUB.Add('x_msg_count:' || to_char(x_msg_count),2 );
6078 OE_DEBUG_PUB.Add('x_msg_data:' || x_msg_data,2 );
6079
6080 -- Added for bug 7112725
6081 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6082 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
6083 RAISE FND_API.G_EXC_ERROR;
6084 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6085 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6086 END IF;
6087 END IF;
6088
6089 /* Don't need this, cos just putting orders on hold
6090 ** Uncommenting this for ER # 2662206
6091 */
6092 Validate ( p_hold_source_rec => l_hold_source_rec,
6093 x_return_status => x_return_status,
6094 x_msg_count => x_msg_count,
6095 x_msg_data => x_msg_data
6096 );
6097 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6098 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
6099 RAISE FND_API.G_EXC_ERROR;
6100 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
6101 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6102 END IF;
6103 END IF;
6104 --bug 5548778 call overloaded method
6105 Create_Hold_Source (
6106 p_hold_source_rec => l_hold_source_rec,
6107 x_hold_source_id => l_hold_source_id,
6108 x_hold_exists => l_hold_exists,
6109 x_return_status => x_return_status,
6110 x_msg_count => x_msg_count,
6111 x_msg_data => x_msg_data
6112 );
6113 OE_DEBUG_PUB.Add('After Create_Hold_Source, x_return_status:' ||
6114 x_return_status,1);
6115 OE_DEBUG_PUB.Add('x_msg_count:' || to_char(x_msg_count),3 );
6116 OE_DEBUG_PUB.Add('x_msg_data:' || x_msg_data ,3);
6117 OE_DEBUG_PUB.Add('l_hold_exists:' || l_hold_exists ,3);
6118 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6119 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
6120 RAISE FND_API.G_EXC_ERROR;
6121 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
6122 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6123 END IF;
6124 END IF;
6125
6126 OE_DEBUG_PUB.Add('l_hold_source_id->' || to_char(l_hold_source_id) ,1);
6127 l_hold_source_rec.hold_source_id := l_hold_source_id;
6128
6129 IF l_hold_exists = 'N' THEN --bug 5548778
6130 /*Added the Select query and IF Condition below and calling overloaded create_order_holds procedure
6131 for WF_HOLDS ER (bug 6449458)*/
6132 IF l_wf_item_type IS NULL AND l_wf_activity_name IS NULL THEN
6133 select item_type, activity_name
6134 into l_wf_item_type, l_wf_activity_name
6135 from oe_hold_definitions
6136 where hold_id = l_hold_source_rec.hold_id;
6137 END IF;
6138
6139 IF l_wf_item_type IS NOT NULL AND l_wf_activity_name IS NOT
6140 NULL THEN
6141 OE_DEBUG_PUB.Add ('Calling Overloaded Create_Order_Holds Based on Workflow',1);
6142 Create_Order_Holds (
6143 p_hold_source_rec => l_hold_source_rec
6144 ,p_item_type => l_wf_item_type
6145 ,p_activity_name => l_wf_activity_name
6146 ,x_return_status => x_return_status
6147 ,x_msg_count => x_msg_count
6148 ,x_msg_data => x_msg_data
6149 ,x_is_hold_applied => l_is_hold_applied);
6150
6151 ELSE
6152
6153 OE_DEBUG_PUB.Add ('Calling Create_Order_Holds',1);
6154 Create_Order_Holds (
6155 p_hold_source_rec => l_hold_source_rec
6156 ,x_return_status => x_return_status
6157 ,x_msg_count => x_msg_count
6158 ,x_msg_data => x_msg_data
6159 );
6160 OE_DEBUG_PUB.Add('After Create_Order_Holds',1);
6161 END IF; -- l_item_type and l_activity_name
6162
6163 IF NVL(l_is_hold_applied,FALSE) THEN
6164 l_count_of_holds_applied := l_count_of_holds_applied + 1;
6165 OE_DEBUG_PUB.Add('Hold is applied :',2);
6166 END IF;
6167 l_is_hold_applied := FALSE;
6168 /* OE_DEBUG_PUB.Add ('Calling Create_Order_Holds',1);
6169 Create_Order_Holds (
6170 p_hold_source_rec => l_hold_source_rec
6171 ,x_return_status => x_return_status
6172 ,x_msg_count => x_msg_count
6173 ,x_msg_data => x_msg_data
6174 );
6175 OE_DEBUG_PUB.Add('After Create_Order_Holds',1);*/
6176 END IF;
6177 end loop;
6178 /*Added the query and IF Condition below for WF_HOLDS ER (bug 6449458)*/
6179 IF l_wf_item_type is not null and l_wf_activity_name is not null THEN
6180 select meaning into l_user_activity_name
6181 from oe_lookups
6182 where lookup_type = DECODE(l_wf_item_type,
6183 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
6184 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
6185 and lookup_code = l_wf_activity_name;
6186
6187 IF p_order_tbl.COUNT = 1 AND l_count_of_holds_applied = 0 THEN
6188 fnd_message.set_name('ONT', 'OE_NO_HOLD_FOR_ACTIVITY');
6189 fnd_message.set_token('WF_ACT',l_user_activity_name);
6190 OE_MSG_PUB.ADD;
6191 oe_debug_pub.add(' Hold Not applied for the requested line');
6192 RAISE FND_API.G_EXC_ERROR;
6193 ELSIF l_count_of_holds_applied = 0
6194 AND p_order_tbl.COUNT > 1 THEN
6195 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
6196 fnd_message.set_token('WF_ACT',l_user_activity_name);
6197 OE_MSG_PUB.ADD;
6198 oe_debug_pub.add('Hold Not applied for ALL requested lines');
6199 RAISE FND_API.G_EXC_ERROR;
6200 ELSIF p_order_tbl.COUNT > l_count_of_holds_applied
6201 AND p_order_tbl.COUNT > 1 THEN
6202 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
6203 fnd_message.set_token('WF_ACT',l_user_activity_name);
6204 OE_MSG_PUB.ADD;
6205 oe_debug_pub.add('Hold Not applied for FEW requested lines');
6206 ELSE
6207 NULL; -- No messages are required to be logged.
6208 END IF;
6209 END IF;
6210
6211 EXCEPTION
6212 WHEN OTHERS THEN
6213 --dbms_output.put_line ('ApplyHolds-EXCEPTION');
6214 OE_DEBUG_PUB.Add('Error:Apply Holds',1);
6215 OE_DEBUG_PUB.Add('x_return_status:' || x_return_status,1);
6216 OE_DEBUG_PUB.Add('x_msg_count:' || to_char(x_msg_count),1 );
6217 OE_DEBUG_PUB.Add('x_msg_data:' || x_msg_data ,1);
6218 END Apply_Holds;
6219
6220
6221 Procedure Apply_Holds(
6222 p_hold_source_rec IN OE_HOLDS_PVT.Hold_Source_Rec_Type,
6223 p_hold_existing_flg IN VARCHAR2,
6224 p_hold_future_flg IN VARCHAR2,
6225 p_check_authorization_flag IN VARCHAR2 DEFAULT 'N', --bug 8477694
6226 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
6227 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
6228 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2 )
6229 IS
6230 l_application_id OE_HOLD_AUTHORIZATIONS.APPLICATION_ID%TYPE := FND_GLOBAL.RESP_APPL_ID;
6231 l_resp_id OE_HOLD_AUTHORIZATIONS.RESPONSIBILITY_ID%TYPE := FND_GLOBAL.RESP_ID;
6232 l_hold_source_id OE_HOLD_SOURCES_ALL.HOLD_SOURCE_ID%TYPE;
6233 l_hold_source_rec OE_HOLDS_PVT.Hold_Source_Rec_Type;
6234 l_hold_exists VARCHAR2(1) :='N'; --bug 5548778
6235 l_msg_token VARCHAR2(100); --8477694
6236 /* Commented OLD Processing and added the lines below for WF_HOLS ER (bug 6449458)*/
6237 l_hold_msg_applied BOOLEAN DEFAULT NULL;
6238 l_wf_item_type OE_HOLD_DEFINITIONS.ITEM_TYPE%TYPE := NULL;
6239 l_wf_activity_name OE_HOLD_DEFINITIONS.ACTIVITY_NAME%TYPE := NULL;
6240
6241 BEGIN
6242
6243
6244
6245 Begin
6246 select item_type, activity_name
6247 into l_wf_item_type, l_wf_activity_name
6248 from oe_hold_definitions
6249 where hold_id = p_hold_source_rec.hold_id;
6250 Exception
6251 When NO_DATA_FOUND Then
6252 NULL; -- OE_Holds_Pvt.Validate has not yet been called.
6253 End;
6254
6255 Apply_Holds(
6256 p_hold_source_rec => p_hold_source_rec,
6257 p_hold_existing_flg => p_hold_existing_flg,
6258 p_hold_future_flg => p_hold_future_flg,
6259 p_wf_item_type => l_wf_item_type,
6260 p_wf_activity_name => l_wf_activity_name,
6261 p_check_authorization_flag => p_check_authorization_flag, -- bug 8477694
6262 x_return_status => x_return_status,
6263 x_msg_count => x_msg_count,
6264 x_msg_data => x_msg_data,
6265 x_is_hold_applied => l_hold_msg_applied);
6266 /*BEGIN
6267 OE_DEBUG_PUB.Add('In OE_Holds_pvt.Apply Holds, Creating Hold Source',1);
6268
6269 x_return_status := FND_API.G_RET_STS_SUCCESS;
6270 l_hold_source_rec := p_hold_source_rec;
6271 Validate (p_hold_source_rec => p_hold_source_rec,
6272 x_return_status => x_return_status,
6273 x_msg_count => x_msg_count,
6274 x_msg_data => x_msg_data );
6275 OE_DEBUG_PUB.Add('Validate return status:' || x_return_status,1);
6276 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6277 OE_Debug_PUB.Add('Validate not successful',1);
6278 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
6279 RAISE FND_API.G_EXC_ERROR;
6280 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6281 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6282 END IF;
6283 ELSE
6284 OE_DEBUG_PUB.Add ('Calling Create_Hold_Source bug 5548778 overload',1);
6285 Create_Hold_Source (
6286 p_hold_source_rec => p_hold_source_rec,
6287 x_hold_source_id => l_hold_source_id,
6288 x_hold_exists => l_hold_exists,
6289 x_return_status => x_return_status,
6290 x_msg_count => x_msg_count,
6291 x_msg_data => x_msg_data
6292 );
6293 OE_DEBUG_PUB.Add('x_return_status->' || x_return_status,1);
6294 OE_DEBUG_PUB.Add('x_msg_count->' || x_msg_count,1);
6295 OE_DEBUG_PUB.Add('x_msg_data' || x_msg_data,1);
6296 OE_DEBUG_PUB.Add('l_hold_exists' || l_hold_exists,1);
6297 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6298 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
6299 RAISE FND_API.G_EXC_ERROR;
6300 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
6301 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6302 END IF;
6303 END IF;
6304 OE_DEBUG_PUB.Add('l_hold_source_id->' || to_char(l_hold_source_id) ,1);
6305 l_hold_source_rec.hold_source_id := l_hold_source_id;
6306 --bug 5548778
6307 IF l_hold_exists = 'N' THEN
6308 OE_DEBUG_PUB.Add ('Calling Create_Order_Holds',1);
6309 Create_Order_Holds (
6310 p_hold_source_rec => l_hold_source_rec
6311 ,x_return_status => x_return_status
6312 ,x_msg_count => x_msg_count
6313 ,x_msg_data => x_msg_data
6314 );
6315 OE_DEBUG_PUB.Add('After Create_Order_Holds',1);
6316 END IF;
6317 END IF;*/
6318 END Apply_Holds;
6319
6320
6321 ---------------------
6322 Procedure Release_Holds (
6323 p_hold_source_rec IN OE_HOLDS_PVT.hold_source_rec_type,
6324 p_hold_release_rec IN OE_HOLDS_PVT.Hold_Release_Rec_Type,
6325 p_check_authorization_flag IN VARCHAR2 DEFAULT 'N', -- bug 8477694
6326 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
6327 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
6328 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
6329 IS
6330 l_order_rec OE_HOLDS_PVT.order_rec_type;
6331 --bug 5051532
6332 l_hold_source_rec OE_HOLDS_PVT.hold_source_rec_type;
6333 l_application_id OE_HOLD_AUTHORIZATIONS.APPLICATION_ID%TYPE := FND_GLOBAL.RESP_APPL_ID; --8477694
6334 l_resp_id OE_HOLD_AUTHORIZATIONS.RESPONSIBILITY_ID%TYPE := FND_GLOBAL.RESP_ID; --8477694
6335 l_msg_token VARCHAR2(100); --8477694
6336
6337 BEGIN
6338 x_return_status := FND_API.G_RET_STS_SUCCESS;
6339
6340 --8477694
6341 IF NOT OE_GLOBALS.G_SYS_HOLD THEN
6342 IF check_system_holds( p_hold_id => p_hold_source_rec.hold_id
6343 ,x_return_status => x_return_status
6344 ,x_msg_count => x_msg_count
6345 ,x_msg_data => x_msg_data
6346 ) = 'N' THEN
6347 OE_DEBUG_PUB.Add('Not authorize to Release this Hold:'|| to_char(p_hold_source_rec.hold_id));
6348 l_msg_token := 'RELEASE(System Hold)';
6349 fnd_message.set_name('ONT', 'OE_HOLDS_AUTHORIZATION_FAILED');
6350 fnd_message.set_token('ACTION', l_msg_token);
6351 OE_MSG_PUB.ADD;
6352 x_return_status := FND_API.G_RET_STS_ERROR;
6353 OE_MSG_PUB.Count_And_Get
6354 ( p_count => x_msg_count
6355 , p_data => x_msg_data
6356 );
6357 RETURN;
6358 END IF;
6359 END IF;
6360
6361 OE_DEBUG_PUB.Add('After calling Check_System_Holds');
6362
6363 OE_DEBUG_PUB.Add('Release Hold before calling Check_Authorization');
6364
6365 -- bug 8477694
6366 IF p_check_authorization_flag = 'Y' THEN
6367 OE_DEBUG_PUB.Add('8477694 Manual Auth'||p_check_authorization_flag);
6368 ELSE
6369 OE_DEBUG_PUB.Add('8477694 Auto Auth'||p_check_authorization_flag);
6370 END IF;
6371
6372 IF p_check_authorization_flag = 'Y' THEN -- Bug 8477694
6373 IF check_authorization ( p_hold_id => p_hold_source_rec.hold_id
6374 ,p_authorized_action_code => 'REMOVE'
6375 ,p_responsibility_id => l_resp_id
6376 ,p_application_id => l_application_id
6377 ,x_return_status => x_return_status
6378 ,x_msg_count => x_msg_count
6379 ,x_msg_data => x_msg_data
6380 ) = 'N' THEN
6381 OE_DEBUG_PUB.Add('Not authorize to Release this Hold:'|| to_char(p_hold_source_rec.hold_id));
6382 fnd_message.set_name('ONT','ONT_RELEASE');
6383 l_msg_token := fnd_message.get;
6384 fnd_message.set_name('ONT', 'OE_HOLDS_AUTHORIZATION_FAILED');
6385 fnd_message.set_token('ACTION', l_msg_token);
6386 OE_MSG_PUB.ADD;
6387 x_return_status := FND_API.G_RET_STS_ERROR;
6388 OE_MSG_PUB.Count_And_Get
6389 ( p_count => x_msg_count
6390 , p_data => x_msg_data
6391 );
6392 RETURN;
6393 END IF;
6394 END IF; -- BUG 8477694
6395
6396 OE_DEBUG_PUB.Add('Release Hold After calling Check_Authorization');
6397 --8477694
6398
6399
6400 --bug 5051532
6401 l_hold_source_rec := p_hold_source_rec;
6402 -- replaced the occurences of p_hold_source_rec with l_hold_source_rec in theIF part of the IF-ELSE block below, for bug 5051532
6403
6404 --bug 3977747 start--
6405 if (l_hold_source_rec.header_id is not null or
6406 l_hold_source_rec.line_id is not null )
6407 then
6408 l_order_rec.line_id := l_hold_source_rec.line_id;
6409
6410 --bug 5051532
6411 If l_hold_source_rec.header_id is null then
6412 select header_id
6413 into l_hold_source_rec.header_id
6414 from oe_order_lines_all
6415 where line_id = l_hold_source_rec.line_id;
6416 end if;
6417
6418 oe_debug_pub.add('l_hold_source_rec.header_id ' || l_hold_source_rec.header_id);
6419 oe_debug_pub.add('l_hold_source_rec.line_id ' || l_hold_source_rec.line_id);
6420 l_order_rec.header_id := l_hold_source_rec.header_id;
6421 -- bug 5051532
6422
6423 Validate_Order (l_hold_source_rec.header_id,
6424 l_hold_source_rec.line_id,
6425 x_return_status => x_return_status,
6426 x_msg_count => x_msg_count,
6427 x_msg_data => x_msg_data
6428 );
6429 oe_debug_pub.add('After Validate_Order with x_return_status'||x_return_status,2);
6430
6431 -- Added for bug 7112725
6432 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6433 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
6434 RAISE FND_API.G_EXC_ERROR;
6435 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6436 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6437 END IF;
6438 END IF;
6439
6440 Release_orders ( p_hold_release_rec => p_hold_release_rec,
6441 p_order_rec => l_order_rec,
6442 p_hold_source_rec => l_hold_source_rec,
6443 x_return_status => x_return_status,
6444 x_msg_count => x_msg_count,
6445 x_msg_data => x_msg_data );
6446 oe_debug_pub.add('After oe_holds_pvt.release_orders with x_return_status' || x_return_status, 1);
6447 --bug 3977747 ends--
6448 else
6449
6450 if (p_hold_source_rec.hold_source_id is null )then
6451 Validate (p_hold_source_rec => p_hold_source_rec,
6452 x_return_status => x_return_status,
6453 x_msg_count => x_msg_count,
6454 x_msg_data => x_msg_data
6455 );
6456 --dbms_output.put_line ('After ValidateRS->' || x_return_status);
6457 end if;
6458
6459 Release_Hold_Source (p_hold_source_rec => p_hold_source_rec,
6460 p_hold_release_rec => p_hold_release_rec,
6461 x_return_status => x_return_status,
6462 x_msg_count => x_msg_count,
6463 x_msg_data => x_msg_data );
6464 --dbms_output.put_line ('After ReleaseRS->' || x_return_status);
6465
6466 end if;
6467
6468 END Release_Holds;
6469
6470
6471 ---------------------
6472 Procedure Release_Holds (
6473 p_order_tbl IN OE_HOLDS_PVT.order_tbl_type,
6474 p_hold_id IN OE_HOLD_DEFINITIONS.HOLD_ID%TYPE,
6475 p_release_reason_code IN OE_HOLD_RELEASES.RELEASE_REASON_CODE%TYPE,
6476 p_release_comment IN OE_HOLD_RELEASES.RELEASE_COMMENT%TYPE,
6477 p_check_authorization_flag IN VARCHAR2 DEFAULT 'N', -- bug 8477694
6478 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
6479 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
6480 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
6481 IS
6482 j NUMBER;
6483 l_hold_source_rec OE_HOLDS_PVT.Hold_Source_Rec_Type;
6484 l_order_rec OE_HOLDS_PVT.order_rec_type;
6485 l_hold_release_rec OE_HOLDS_PVT.hold_release_rec_type;
6486 l_application_id OE_HOLD_AUTHORIZATIONS.APPLICATION_ID%TYPE := FND_GLOBAL.RESP_APPL_ID; --8477694
6487 l_resp_id OE_HOLD_AUTHORIZATIONS.RESPONSIBILITY_ID%TYPE := FND_GLOBAL.RESP_ID; --8477694
6488 l_msg_token VARCHAR2(100); --8477694
6489
6490 BEGIN
6491 x_return_status := FND_API.G_RET_STS_SUCCESS;
6492 oe_debug_pub.add('In Release Holds..Orders',1);
6493
6494 --8477694
6495 IF NOT OE_GLOBALS.G_SYS_HOLD THEN
6496 IF check_system_holds( p_hold_id => p_hold_id
6497 ,x_return_status => x_return_status
6498 ,x_msg_count => x_msg_count
6499 ,x_msg_data => x_msg_data
6500 ) = 'N' THEN
6501 OE_DEBUG_PUB.Add('Not authorize to Release this Hold:'|| to_char(p_hold_id));
6502 l_msg_token := 'RELEASE(System Hold)';
6503 fnd_message.set_name('ONT', 'OE_HOLDS_AUTHORIZATION_FAILED');
6504 fnd_message.set_token('ACTION', l_msg_token);
6505 OE_MSG_PUB.ADD;
6506 x_return_status := FND_API.G_RET_STS_ERROR;
6507 OE_MSG_PUB.Count_And_Get
6508 ( p_count => x_msg_count
6509 , p_data => x_msg_data
6510 );
6511 RETURN;
6512 END IF;
6513 END IF;
6514
6515 OE_DEBUG_PUB.Add('After calling Check_System_Holds');
6516
6517 OE_DEBUG_PUB.Add('Release Hold overloaded before calling Check_Authorization');
6518 -- bug 8477694
6519 IF p_check_authorization_flag = 'Y' THEN
6520 OE_DEBUG_PUB.Add('8477694 Manual Auth'||p_check_authorization_flag);
6521 ELSE
6522 OE_DEBUG_PUB.Add('8477694 Auto Auth'||p_check_authorization_flag);
6523 END IF;
6524
6525 IF p_check_authorization_flag= 'Y' THEN -- 8477694
6526 IF check_authorization ( p_hold_id => p_hold_id
6527 ,p_authorized_action_code => 'REMOVE'
6528 ,p_responsibility_id => l_resp_id
6529 ,p_application_id => l_application_id
6530 ,x_return_status => x_return_status
6531 ,x_msg_count => x_msg_count
6532 ,x_msg_data => x_msg_data
6533 ) = 'N' THEN
6534 OE_DEBUG_PUB.Add('Not authorize to Release this Hold:'|| to_char(p_hold_id));
6535 fnd_message.set_name('ONT','ONT_RELEASE');
6536 l_msg_token := fnd_message.get;
6537 fnd_message.set_name('ONT', 'OE_HOLDS_AUTHORIZATION_FAILED');
6538 fnd_message.set_token('ACTION', l_msg_token);
6539 OE_MSG_PUB.ADD;
6540 x_return_status := FND_API.G_RET_STS_ERROR;
6541 OE_MSG_PUB.Count_And_Get
6542 ( p_count => x_msg_count
6543 , p_data => x_msg_data
6544 );
6545 RETURN;
6546 END IF;
6547 END IF; -- 8477694
6548 OE_DEBUG_PUB.Add('Release Hold overloaded After calling Check_Authorization');
6549 --8477694
6550
6551
6552 for j in 1..p_order_tbl.COUNT loop
6553 -- IF p_order_tbl(j).header_id IS NULL AND
6554 -- p_order_tbl(j).line_id NULL THEN ERROR
6555 l_order_rec.header_id := p_order_tbl(j).header_id;
6556 l_order_rec.line_id := p_order_tbl(j).line_id;
6557 l_hold_release_rec.release_reason_code := p_release_reason_code;
6558 l_hold_release_rec.release_comment := p_release_comment;
6559 l_hold_source_rec.hold_id := p_hold_id;
6560 oe_debug_pub.add('HeaderID:' || l_order_rec.header_id );
6561 oe_debug_pub.add('LineID:' || l_order_rec.Line_id );
6562 -- XXX Need some analysis
6563 -- When release holds for orders, check to see if this order was put on
6564 -- hold as an
6565 -- Order based hold. If yes, then release the Hold_Source from hold and
6566 -- also order
6567 -- from hold in oe_order_holds and insert record in oe_hold_releases with
6568 -- order_hold_id(No with Hold Source ID).
6569 -- IF the order being releasesed is part of a different hold source (e.g. 'C')
6570 -- then don't release the hold source(what if its the last order)
6571 -- and only release the order from hold in
6572 -- OE_ORDER_HOLDS and create a record in OE_HOLD_RELEASES with the
6573 -- Order_Hold_ID.
6574 Validate_Order (p_order_tbl(j).header_id,
6575 p_order_tbl(j).line_id,
6576 x_return_status => x_return_status,
6577 x_msg_count => x_msg_count,
6578 x_msg_data => x_msg_data
6579 );
6580 oe_debug_pub.add('After Validate_Order with x_return_status'|| x_return_status);
6581
6582 -- Added for bug 7112725
6583 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6584 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
6585 RAISE FND_API.G_EXC_ERROR;
6586 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6587 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6588 END IF;
6589 END IF;
6590
6591 oe_debug_pub.add('l_order_rec.header_id'||l_order_rec.header_id);
6592 oe_debug_pub.add('lhldrlsrec.rel_reas_code' || l_hold_release_rec.release_reason_code);
6593 oe_holds_pvt.release_orders (
6594 p_hold_release_rec => l_hold_release_rec,
6595 p_order_rec => l_order_rec,
6596 p_hold_source_rec => l_hold_source_rec,
6597 x_return_status => x_return_status,
6598 x_msg_count => x_msg_count,
6599 x_msg_data => x_msg_data );
6600 oe_debug_pub.add('After oe_holds_pvt.release_orders:' ||
6601 x_return_status);
6602 -- If the entity code is order, then release hold source also, if no
6603 -- other order hold records exist for this hold source. This would
6604 -- be the case if selected lines of an order were put on hold.
6605 -- Decided not to release source XX
6606 /*
6607 IF entity_code = 'O' THEN
6608 BEGIN
6609 SELECT 'NO HOLDS'
6610 INTO l_dummy
6611 FROM OE_ORDER_HOLDS
6612 WHERE HOLD_SOURCE_ID = l_hold_source_id
6613 AND HOLD_RELEASE_ID IS NULL
6614 AND ROWNUM = 1;
6615
6616 EXCEPTION
6617 WHEN NO_DATA_FOUND THEN
6618 OE_Debug_PUB.Add('Setting hold source status to released');
6619 UPDATE OE_HOLD_SOURCES
6620 SET RELEASED_FLAG = 'Y'
6621 , HOLD_RELEASE_ID = l_hold_release_id
6622 , LAST_UPDATED_BY = l_user_id
6623 , LAST_UPDATE_DATE = SYSDATE
6624 WHERE HOLD_SOURCE_ID = l_hold_source_id;
6625
6626 END;
6627 END IF;
6628 */
6629
6630 end loop;
6631 oe_debug_pub.add('After release_orders with x_return_status'|| x_return_status,3);
6632 END Release_Holds;
6633
6634 /*8477694
6635 function check_system_holds(
6636 p_hold_id IN NUMBER,
6637 x_return_status OUT NOCOPY file.sql.39 change VARCHAR2,
6638 x_msg_count OUT NOCOPY file.sql.39 change NUMBER,
6639 x_msg_data OUT NOCOPY file.sql.39 change VARCHAR2
6640 )
6641 RETURN varchar2
6642 IS
6643 l_authorized_or_not varchar2(1) := 'Y';
6644 l_return_status Varchar2(1) := FND_API.G_RET_STS_SUCCESS;
6645 BEGIN
6646
6647 x_return_status := l_return_status;
6648 x_msg_count := 0;
6649 x_msg_data := NULL;
6650
6651
6652 /* 7576948: IR ISO Change Management project Start
6653
6654 -- In the below IF check for system holds, Hold_id 17 is added
6655 -- for IR ISO change management project. This is a seeded system
6656 -- hold, responsible for applying and release IR ISO hold, which
6657 -- can be applied/released only by the Purchasing product, while
6658 -- internal requisition / requisition line gets changed by the
6659 -- requesting organization user. The judiciously application
6660 -- and releasing of this hold will be done by Purchasing APIs.
6661 -- OM has no APIs for calling the direct Application or Releasing
6662 -- of this seeded system hold for any business flow other than
6663 -- Internal Sales Order flow.
6664 --
6665 -- The application of this seeded hold can be done via OM API
6666 -- OE_Internal_Requisition_Pvt.Apply_Hold_for_IReq, while it can
6667 -- be released via OE_Internal_Requisition_Pvt.Release_Hold_for_IReq
6668 -- The call to both these APIs will be done from Purchasing APIs only.
6669 --
6670 -- For details on IR ISO CMS project, please refer to FOL >
6671 -- OM Development > OM GM > 12.1.1 > TDD > IR_ISO_CMS_TDD.doc
6672
6673 IF p_hold_id in (13,14,15,17) THEN
6674
6675 =============================
6676 IR ISO Change Management Ends
6677 oe_debug_pub.add('renga: hold not authorized - ');
6678 l_authorized_or_not := 'N';
6679 END IF;
6680 return l_authorized_or_not;
6681 END check_system_holds;
6682 8477694 */
6683
6684 procedure process_apply_holds_lines (
6685 p_num_of_records IN NUMBER
6686 , p_sel_rec_tbl IN OE_GLOBALS.Selected_Record_Tbl
6687 , p_hold_id IN OE_HOLD_DEFINITIONS.HOLD_ID%TYPE
6688 , p_hold_until_date IN OE_HOLD_SOURCES.HOLD_UNTIL_DATE%TYPE
6689 , p_hold_comment IN OE_HOLD_SOURCES.HOLD_COMMENT%TYPE
6690 , x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2
6691 , x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER
6692 , x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
6693 )
6694 IS
6695
6696 l_header_rec OE_ORDER_PUB.Header_Rec_Type;
6697 l_line_rec OE_ORDER_PUB.line_rec_type;
6698 l_api_name CONSTANT VARCHAR2(30) := 'process_apply_holds_lines';
6699 l_line_id NUMBER;
6700 l_return_status VARCHAR2(30);
6701 l_order_tbl OE_HOLDS_PVT.order_tbl_type;
6702 l_error_count NUMBER :=0;
6703 l_ordered_quantity NUMBER ;
6704 j INTEGER;
6705 initial INTEGER;
6706 nextpos INTEGER;
6707
6708 l_prev_org_id number;
6709 l_hold_source_rec OE_HOLDS_PVT.Hold_Source_Rec_Type;
6710 l_application_id OE_HOLD_AUTHORIZATIONS.APPLICATION_ID%TYPE := FND_GLOBAL.RESP_APPL_ID;
6711 l_resp_id OE_HOLD_AUTHORIZATIONS.RESPONSIBILITY_ID%TYPE := FND_GLOBAL.RESP_ID;
6712 l_msg_token VARCHAR2(100);
6713 /*Added the following variables for WF_HOLDS ER (bug 6449458)*/
6714 l_item_type OE_HOLD_DEFINITIONS.ITEM_TYPE%TYPE := NULL;
6715 l_activity_name OE_HOLD_DEFINITIONS.ACTIVITY_NAME%TYPE := NULL;
6716 l_is_hold_applied BOOLEAN;
6717 l_count_of_holds_applied NUMBER := 0;
6718 l_user_activity_name VARCHAR2(80);
6719
6720
6721 BEGIN
6722 oe_msg_pub.initialize;
6723
6724 OE_DEBUG_PUB.Add('Entering OE_Holds_PVT.process_apply_holds_lines',1);
6725
6726 IF check_system_holds(
6727 p_hold_id => p_hold_id,
6728 x_return_status => x_return_status,
6729 x_msg_count => x_msg_count,
6730 x_msg_data => x_msg_data) = 'N' THEN
6731
6732 OE_DEBUG_PUB.Add('Not authorize to Apply this Hold:'|| to_char(p_hold_id));
6733 fnd_message.set_name('ONT', 'ONT_HOLDS_SYSTEM_CHECK');
6734 OE_MSG_PUB.ADD;
6735 x_return_status := FND_API.G_RET_STS_ERROR;
6736 OE_MSG_PUB.Count_And_Get
6737 ( p_count => x_msg_count
6738 , p_data => x_msg_data
6739 );
6740 RETURN;
6741 END IF;
6742 OE_DEBUG_PUB.Add('After calling Check_System_Holds');
6743
6744 IF check_authorization ( p_hold_id => p_hold_id
6745 ,p_authorized_action_code => 'APPLY'
6746 ,p_responsibility_id => l_resp_id
6747 ,p_application_id => l_application_id
6748 ,x_return_status => x_return_status
6749 ,x_msg_count => x_msg_count
6750 ,x_msg_data => x_msg_data
6751 ) = 'N' THEN
6752 OE_DEBUG_PUB.Add('Not authorize to Apply this Hold:'|| to_char(p_hold_id));
6753
6754 fnd_message.set_name('ONT','ONT_APPLY');
6755 l_msg_token := fnd_message.get;
6756
6757 fnd_message.set_name('ONT', 'OE_HOLDS_AUTHORIZATION_FAILED');
6758 fnd_message.set_token('ACTION', l_msg_token);
6759
6760 OE_MSG_PUB.ADD;
6761 --RAISE FND_API.G_EXC_ERROR;
6762 x_return_status := FND_API.G_RET_STS_ERROR;
6763 OE_MSG_PUB.Count_And_Get
6764 ( p_count => x_msg_count
6765 , p_data => x_msg_data
6766 );
6767 RETURN;
6768 END IF;
6769
6770 OE_DEBUG_PUB.Add('After calling Check_Authorization');
6771
6772 SAVEPOINT process_apply_holds_lines;
6773
6774 l_prev_org_id := null;
6775 FOR j in 1.. p_sel_rec_tbl.COUNT LOOP
6776 IF p_sel_rec_tbl(j).org_id <> nvl(l_prev_org_id, -99)
6777 THEN
6778 OE_DEBUG_PUB.Add('Mo_Global.Set_Policy_Context to:' || p_sel_rec_tbl(j).Org_Id );
6779 Mo_Global.Set_Policy_Context (p_access_mode => 'S',
6780 p_org_id => p_sel_rec_tbl(j).Org_Id);
6781 l_prev_org_id := p_sel_rec_tbl(j).org_id;
6782 END IF;
6783
6784 l_line_id := p_sel_rec_tbl(j).id1;
6785 OE_LINE_UTIL.Query_Row
6786 ( p_line_id => l_line_id,
6787 x_line_rec => l_line_rec
6788 );
6789
6790 OE_DEBUG_PUB.Add('Header_id: '||l_line_rec.header_id);
6791 OE_DEBUG_PUB.Add('Line_id: '||to_char(l_line_rec.line_id));
6792
6793 l_hold_source_rec.hold_entity_code := 'O';
6794 l_hold_source_rec.hold_entity_id := l_line_rec.header_id;
6795 l_hold_source_rec.LINE_ID := l_line_rec.line_id;
6796 l_hold_source_rec.hold_id := p_hold_id;
6797 l_hold_source_rec.hold_until_date := p_hold_until_date;
6798 l_hold_source_rec.hold_comment := p_hold_comment;
6799 /*Added the IF condition for WF_HOLDS ER (bug 6449458)*/
6800 IF l_item_type IS NULL AND l_activity_name IS NULL THEN
6801 select item_type, activity_name
6802 into l_item_type, l_activity_name
6803 from oe_hold_definitions
6804 where hold_id = l_hold_source_rec.hold_id;
6805 END IF;
6806
6807 OE_DEBUG_PUB.Add('Before calling oe_holds_pvt.apply_holds');
6808 /*Calling overloaded procedure apply_holds, modified for WF_HOLDS ER (bug 6449458)*/
6809 /*oe_holds_pvt.apply_Holds(
6810 p_hold_source_rec => l_hold_source_rec
6811 ,p_hold_existing_flg => 'Y'
6812 ,p_hold_future_flg => 'Y'
6813 ,x_return_status => x_return_status
6814 ,x_msg_count => x_msg_count
6815 ,x_msg_data => x_msg_data);*/
6816 oe_holds_pvt.apply_Holds(
6817 p_hold_source_rec => l_hold_source_rec
6818 ,p_hold_existing_flg => 'Y'
6819 ,p_hold_future_flg => 'Y'
6820 ,p_org_id =>p_sel_rec_tbl(j).org_id --ER#7479609
6821 ,p_wf_item_type => l_item_type
6822 ,p_wf_activity_name => l_activity_name
6823 ,p_check_authorization_flag => 'N' -- bug 8477694
6824 ,x_return_status => x_return_status
6825 ,x_msg_count => x_msg_count
6826 ,x_msg_data => x_msg_data
6827 ,x_is_hold_applied => l_is_hold_applied);
6828
6829 IF NVL(l_is_hold_applied,FALSE) THEN
6830 l_count_of_holds_applied := l_count_of_holds_applied + 1;
6831 OE_DEBUG_PUB.Add('Hold is applied : TRUE',2);
6832 END IF;
6833 l_is_hold_applied := FALSE;
6834
6835
6836 OE_DEBUG_PUB.Add('x_return_status:' || x_return_status,2);
6837 OE_DEBUG_PUB.Add('x_msg_count:' || to_char(x_msg_count),2);
6838 OE_DEBUG_PUB.Add('x_msg_data:' || x_msg_data,2);
6839
6840 /*OE_DEBUG_PUB.Add('Before calling OE_Holds_PVT.Apply_Holds');
6841 oe_holds_pvt.apply_Holds(
6842 p_hold_source_rec => l_hold_source_rec
6843 ,p_hold_existing_flg => 'Y'
6844 ,p_hold_future_flg => 'Y'
6845 ,x_return_status => x_return_status
6846 ,x_msg_count => x_msg_count
6847 ,x_msg_data => x_msg_data);*/
6848
6849 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6850 oe_debug_pub.add('process_apply_holds_lines unexpected failure',1);
6851 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6852 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
6853 oe_debug_pub.add('process_apply_holds_lines expected failure',1);
6854 RAISE FND_API.G_EXC_ERROR;
6855 END IF;
6856
6857 END LOOP;
6858 /*Added the Select query and IF Condition below for WF_HOLDS ER (bug 6449458)*/
6859 IF l_item_type IS NOT NULL AND l_activity_name IS NOT NULL THEN
6860 select meaning into l_user_activity_name
6861 from oe_lookups
6862 where lookup_type = DECODE(l_item_type,
6863 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
6864 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES',
6865 '-XX')
6866 and lookup_code = l_activity_name;
6867
6868 IF p_sel_rec_tbl.COUNT = 1 AND l_count_of_holds_applied = 0
6869 THEN
6870 fnd_message.set_name('ONT', 'OE_NO_HOLD_FOR_ACTIVITY');
6871 fnd_message.set_token('WF_ACT',l_user_activity_name);
6872 OE_MSG_PUB.ADD;
6873 oe_debug_pub.add(' Hold Not applied for the requested line');
6874 RAISE FND_API.G_EXC_ERROR;
6875 ELSIF l_count_of_holds_applied = 0
6876 AND p_sel_rec_tbl.COUNT > 1 THEN
6877 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
6878 fnd_message.set_token('WF_ACT',l_user_activity_name);
6879 OE_MSG_PUB.ADD;
6880 oe_debug_pub.add('Hold Not applied for ALL requested lines');
6881 RAISE FND_API.G_EXC_ERROR;
6882 ELSIF p_sel_rec_tbl.COUNT > l_count_of_holds_applied
6883 AND p_sel_rec_tbl.COUNT > 1 THEN
6884 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
6885 fnd_message.set_token('WF_ACT',l_user_activity_name);
6886 OE_MSG_PUB.ADD;
6887 oe_debug_pub.add('Hold Not applied for FEW requested lines');
6888 ELSE
6889 NULL; -- No messages are required to be logged.
6890 END IF;
6891 END IF; -- End of WF_HOLDS ER (bug 6449458) IF Condition
6892
6893 x_return_status := FND_API.G_RET_STS_SUCCESS;
6894 -- Get message count and data
6895 OE_MSG_PUB.Count_And_Get
6896 ( p_count => x_msg_count
6897 , p_data => x_msg_data
6898 );
6899
6900 OE_DEBUG_PUB.Add('Exiting OE_Holds_PVT.process_apply_holds_lines',1);
6901
6902 EXCEPTION /* Procedure exception handler */
6903
6904 WHEN FND_API.G_EXC_ERROR THEN
6905 x_return_status := FND_API.G_RET_STS_ERROR ;
6906 OE_MSG_PUB.Count_And_Get
6907 ( p_count => x_msg_count,
6908 p_data => x_msg_data
6909 );
6910 ROLLBACK TO SAVEPOINT process_apply_holds_lines;
6911
6912 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6913 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6914 OE_MSG_PUB.Count_And_Get
6915 ( p_count => x_msg_count,
6916 p_data => x_msg_data
6917 );
6918 ROLLBACK TO SAVEPOINT process_apply_holds_lines;
6919
6920 WHEN OTHERS THEN
6921 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6922 IF OE_MSG_PUB.Check_Msg_Level
6923 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6924 THEN
6925 OE_MSG_PUB.Add_Exc_Msg
6926 (G_PKG_NAME,
6927 l_api_name
6928 );
6929 END IF;
6930 OE_MSG_PUB.Count_And_Get
6931 ( p_count => x_msg_count,
6932 p_data => x_msg_data);
6933 ROLLBACK TO SAVEPOINT process_apply_holds_lines;
6934
6935 end process_apply_holds_lines;
6936
6937 /*=================================*/
6938 procedure process_apply_holds_orders (
6939 p_num_of_records IN NUMBER
6940 , p_sel_rec_tbl IN OE_GLOBALS.Selected_Record_Tbl
6941 , p_hold_id IN OE_HOLD_DEFINITIONS.HOLD_ID%TYPE
6942 , p_hold_until_date IN OE_HOLD_SOURCES.HOLD_UNTIL_DATE%TYPE
6943 , p_hold_comment IN OE_HOLD_SOURCES.HOLD_COMMENT%TYPE
6944 , x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2
6945 , x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER
6946 , x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
6947 )
6948 IS
6949 --l_header_rec OE_ORDER_PUB.Header_Rec_Type;
6950 l_line_rec OE_ORDER_PUB.line_rec_type;
6951 --l_old_header_rec OE_ORDER_PUB.Header_Rec_Type;
6952 l_api_name CONSTANT VARCHAR2(30) := 'process_apply_holds_orders';
6953 l_header_id NUMBER;
6954 l_return_status VARCHAR2(30);
6955 l_order_tbl OE_HOLDS_PVT.order_tbl_type;
6956 l_error_count NUMBER :=0;
6957 j INTEGER;
6958
6959 L_prev_org_id number;
6960 l_hold_source_rec OE_HOLDS_PVT.Hold_Source_Rec_Type;
6961 l_application_id OE_HOLD_AUTHORIZATIONS.APPLICATION_ID%TYPE := FND_GLOBAL.RESP_APPL_ID;
6962 l_resp_id OE_HOLD_AUTHORIZATIONS.RESPONSIBILITY_ID%TYPE := FND_GLOBAL.RESP_ID;
6963 l_msg_token VARCHAR2(100);
6964 /*Added the following variables for WF_HOLDS ER (bug 6449458)*/
6965 l_item_type OE_HOLD_DEFINITIONS.ITEM_TYPE%TYPE := NULL;
6966 l_activity_name OE_HOLD_DEFINITIONS.ACTIVITY_NAME%TYPE := NULL;
6967 l_is_hold_applied BOOLEAN;
6968 l_count_of_holds_applied NUMBER := 0;
6969 l_user_activity_name VARCHAR2(80);
6970
6971 BEGIN
6972 oe_msg_pub.initialize;
6973
6974 OE_DEBUG_PUB.Add('Entering OE_Holds_PVT.process_apply_holds_orders',1);
6975
6976 IF check_system_holds( p_hold_id => p_hold_id
6977 , x_return_status => x_return_status
6978 , x_msg_count => x_msg_count
6979 , x_msg_data => x_msg_data
6980 ) = 'N' THEN
6981 OE_DEBUG_PUB.Add('Not authorize to Apply this Hold:'|| to_char(p_hold_id));
6982 fnd_message.set_name('ONT', 'ONT_HOLDS_SYSTEM_CHECK');
6983 OE_MSG_PUB.ADD;
6984 x_return_status := FND_API.G_RET_STS_ERROR;
6985 OE_MSG_PUB.Count_And_Get
6986 ( p_count => x_msg_count
6987 , p_data => x_msg_data
6988 );
6989 RETURN;
6990 END IF;
6991
6992 OE_DEBUG_PUB.Add('After calling Check_System_Holds');
6993
6994 IF check_authorization ( p_hold_id => p_hold_id
6995 , p_authorized_action_code => 'APPLY'
6996 , p_responsibility_id => l_resp_id
6997 , p_application_id => l_application_id
6998 , x_return_status => x_return_status
6999 , x_msg_count => x_msg_count
7000 , x_msg_data => x_msg_data
7001 ) = 'N' THEN
7002 OE_DEBUG_PUB.Add('Not authorize to Apply this Hold:'|| to_char(p_hold_id));
7003
7004 fnd_message.set_name('ONT','ONT_APPLY');
7005 l_msg_token := fnd_message.get;
7006
7007 fnd_message.set_name('ONT', 'OE_HOLDS_AUTHORIZATION_FAILED');
7008 fnd_message.set_token('ACTION', l_msg_token);
7009
7010 OE_MSG_PUB.ADD;
7011 -- RAISE FND_API.G_EXC_ERROR;
7012 x_return_status := FND_API.G_RET_STS_ERROR;
7013 OE_MSG_PUB.Count_And_Get
7014 ( p_count => x_msg_count
7015 , p_data => x_msg_data
7016 );
7017 RETURN;
7018 END IF;
7019
7020 OE_DEBUG_PUB.Add('After calling Check_Authorization');
7021
7022 SAVEPOINT process_apply_holds_orders;
7023 l_prev_org_id := null;
7024 FOR j in 1.. p_sel_rec_tbl.COUNT LOOP
7025 OE_DEBUG_PUB.Add('p_sel_rec_tbl orgID:' || p_sel_rec_tbl(j).org_id ||
7026 ', l_prev_org_id:' || l_prev_org_id);
7027
7028 IF p_sel_rec_tbl(j).org_id <> nvl(l_prev_org_id, -99)
7029 THEN
7030 OE_DEBUG_PUB.Add('Mo_Global.Set_Policy_Context to:' || p_sel_rec_tbl(j).Org_Id );
7031 Mo_Global.Set_Policy_Context (p_access_mode => 'S',
7032 p_org_id => p_sel_rec_tbl(j).Org_Id);
7033 OE_DEBUG_PUB.Add('After the ORG is :' || MO_GLOBAL.get_current_org_id);
7034 l_prev_org_id := p_sel_rec_tbl(j).org_id;
7035 END IF;
7036
7037 l_hold_source_rec.hold_entity_code := 'O';
7038 l_hold_source_rec.hold_entity_id := p_sel_rec_tbl(j).id1;
7039 l_hold_source_rec.hold_id := p_hold_id;
7040 l_hold_source_rec.hold_until_date := p_hold_until_date;
7041 l_hold_source_rec.hold_comment := p_hold_comment;
7042
7043 /*Added the IF condition for WF_HOLDS ER (bug 6449458)*/
7044 IF l_item_type IS NULL AND l_activity_name IS NULL THEN
7045 select item_type, activity_name
7046 into l_item_type, l_activity_name
7047 from oe_hold_definitions
7048 where hold_id = l_hold_source_rec.hold_id;
7049 END IF;
7050
7051 OE_DEBUG_PUB.Add('Before calling oe_holds_pvt.apply_holds');
7052 /*oe_holds_pvt.apply_Holds(
7053 p_hold_source_rec => l_hold_source_rec
7054 ,p_hold_existing_flg => 'Y'
7055 ,p_hold_future_flg => 'Y'
7056 ,x_return_status => x_return_status
7057 ,x_msg_count => x_msg_count
7058 ,x_msg_data => x_msg_data);*/
7059
7060 oe_holds_pvt.apply_Holds(
7061 p_hold_source_rec => l_hold_source_rec
7062 ,p_hold_existing_flg => 'Y'
7063 ,p_hold_future_flg => 'Y'
7064 ,p_org_id =>p_sel_rec_tbl(j).org_id --ER#7479609
7065 ,p_wf_item_type => l_item_type
7066 ,p_wf_activity_name => l_activity_name
7067 ,p_check_authorization_flag => 'N' -- bug 8477694
7068 ,x_return_status => x_return_status
7069 ,x_msg_count => x_msg_count
7070 ,x_msg_data => x_msg_data
7071 ,x_is_hold_applied => l_is_hold_applied);
7072
7073 IF NVL(l_is_hold_applied,FALSE) THEN
7074 l_count_of_holds_applied := l_count_of_holds_applied + 1;
7075 OE_DEBUG_PUB.Add('Hold is applied : TRUE',2);
7076 END IF;
7077 l_is_hold_applied := FALSE;
7078
7079 OE_DEBUG_PUB.Add('x_return_status:' || x_return_status,2);
7080 OE_DEBUG_PUB.Add('x_msg_count:' || to_char(x_msg_count),2);
7081 OE_DEBUG_PUB.Add('x_msg_data:' || x_msg_data,2);
7082
7083 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7084 Oe_debug_pub.add('process_apply_holds_orders unexpected failure',3);
7085 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7086 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
7087 oe_debug_pub.add('process_apply_holds_orders expected failure',3);
7088 RAISE FND_API.G_EXC_ERROR;
7089 END IF;
7090
7091 END LOOP;
7092 /*Added the Select query and IF Condition below for WF_HOLDS ER (bug 6449458)*/
7093 IF l_item_type IS NOT NULL AND l_activity_name IS NOT NULL THEN
7094 select meaning into l_user_activity_name
7095 from oe_lookups
7096 where lookup_type = DECODE(l_item_type,
7097 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
7098 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES',
7099 '-XX')
7100 and lookup_code = l_activity_name;
7101
7102 IF p_sel_rec_tbl.COUNT = 1 AND l_count_of_holds_applied = 0
7103 THEN
7104 fnd_message.set_name('ONT', 'OE_NO_HOLD_FOR_ACTIVITY');
7105 fnd_message.set_token('WF_ACT',l_user_activity_name);
7106 OE_MSG_PUB.ADD;
7107 oe_debug_pub.add(' Hold Not applied for the requested line');
7108 RAISE FND_API.G_EXC_ERROR;
7109 ELSIF l_count_of_holds_applied = 0
7110 AND p_sel_rec_tbl.COUNT > 1 THEN
7111 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
7112 fnd_message.set_token('WF_ACT',l_user_activity_name);
7113 OE_MSG_PUB.ADD;
7114 oe_debug_pub.add('Hold Not applied for ALL requested lines');
7115 RAISE FND_API.G_EXC_ERROR;
7116 ELSIF p_sel_rec_tbl.COUNT > l_count_of_holds_applied
7117 AND p_sel_rec_tbl.COUNT > 1 THEN
7118 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
7119 fnd_message.set_token('WF_ACT',l_user_activity_name);
7120 OE_MSG_PUB.ADD;
7121 oe_debug_pub.add('Hold Not applied for FEW requested lines');
7122 ELSE
7123 NULL; -- No messages are required to be logged.
7124 END IF;
7125 END IF; -- End of WF_HOLDS ER (bug 6449458) IF Condition
7126
7127 x_return_status := FND_API.G_RET_STS_SUCCESS;
7128 -- Get message count and data
7129 OE_MSG_PUB.Count_And_Get
7130 ( p_count => x_msg_count
7131 , p_data => x_msg_data
7132 );
7133
7134 OE_DEBUG_PUB.Add('Exiting OE_Holds_PVT.process_apply_holds_orders',1);
7135
7136 EXCEPTION /* Procedure exception handler */
7137
7138 WHEN FND_API.G_EXC_ERROR THEN
7139 x_return_status := FND_API.G_RET_STS_ERROR ;
7140 OE_MSG_PUB.Count_And_Get
7141 ( p_count => x_msg_count,
7142 p_data => x_msg_data
7143 );
7144 ROLLBACK TO SAVEPOINT process_apply_holds_orders;
7145
7146 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7147 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7148 OE_MSG_PUB.Count_And_Get
7149 ( p_count => x_msg_count,
7150 p_data => x_msg_data
7151 );
7152 ROLLBACK TO SAVEPOINT process_apply_holds_orders;
7153
7154 WHEN OTHERS THEN
7155 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7156 IF OE_MSG_PUB.Check_Msg_Level
7157 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
7158 THEN
7159 OE_MSG_PUB.Add_Exc_Msg
7160 (G_PKG_NAME,
7161 l_api_name
7162 );
7163 END IF;
7164 OE_MSG_PUB.Count_And_Get
7165 ( p_count => x_msg_count,
7166 p_data => x_msg_data);
7167 ROLLBACK TO SAVEPOINT process_apply_holds_orders;
7168
7169 end process_apply_holds_orders;
7170
7171 /***********************************************/
7172 /* Releasing Orders from Sales Order Form - Old*/
7173 /***********************************************/
7174
7175 -- Kept for backward compatibility with third party applications
7176 -- using the holds framework. The new overloaded version will be
7177 -- called after ER 1373910
7178
7179 procedure process_release_holds_lines (
7180 p_num_of_records IN NUMBER
7181 , p_sel_rec_tbl IN OE_GLOBALS.Selected_Record_Tbl
7182 , p_hold_id IN OE_HOLD_DEFINITIONS.HOLD_ID%TYPE
7183 , p_release_reason_code IN OE_HOLD_RELEASES.RELEASE_REASON_CODE%TYPE
7184 , p_release_comment IN OE_HOLD_RELEASES.RELEASE_COMMENT%TYPE
7185 , x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2
7186 , x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER
7187 , x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
7188 )
7189 IS
7190
7191 --l_header_rec OE_ORDER_PUB.Header_Rec_Type;
7192 l_line_rec OE_ORDER_PUB.line_rec_type;
7193 l_api_name CONSTANT VARCHAR2(30) := 'process_release_holds_lines';
7194 l_line_id NUMBER;
7195 l_return_status VARCHAR2(30);
7196 l_order_tbl OE_HOLDS_PVT.order_tbl_type;
7197 l_error_count NUMBER :=0;
7198 l_ordered_quantity NUMBER ;
7199 j INTEGER;
7200 initial INTEGER;
7201 nextpos INTEGER;
7202
7203 l_prev_org_id number;
7204 l_hold_source_rec OE_HOLDS_PVT.Hold_Source_Rec_Type;
7205 l_hold_release_rec OE_HOLDS_PVT.Hold_Release_Rec_Type;
7206 l_application_id OE_HOLD_AUTHORIZATIONS.APPLICATION_ID%TYPE := FND_GLOBAL.RESP_APPL_ID;
7207 l_resp_id OE_HOLD_AUTHORIZATIONS.RESPONSIBILITY_ID%TYPE := FND_GLOBAL.RESP_ID;
7208 l_msg_token VARCHAR2(100);
7209 BEGIN
7210 oe_msg_pub.initialize;
7211
7212 OE_DEBUG_PUB.Add('Entering OE_Holds_PVT.process_release_holds_lines',1);
7213
7214 IF check_system_holds( p_hold_id => p_hold_id
7215 ,x_return_status => x_return_status
7216 ,x_msg_count => x_msg_count
7217 ,x_msg_data => x_msg_data
7218 ) = 'N' THEN
7219 OE_DEBUG_PUB.Add('Not authorize to Apply this Hold:'|| to_char(p_hold_id));
7220 fnd_message.set_name('ONT', 'ONT_HOLDS_SYSTEM_CHECK');
7221 OE_MSG_PUB.ADD;
7222 x_return_status := FND_API.G_RET_STS_ERROR;
7223 OE_MSG_PUB.Count_And_Get
7224 ( p_count => x_msg_count
7225 , p_data => x_msg_data
7226 );
7227 RETURN;
7228 END IF;
7229
7230 OE_DEBUG_PUB.Add('After calling Check_System_Holds');
7231
7232 IF check_authorization ( p_hold_id => p_hold_id
7233 ,p_authorized_action_code => 'REMOVE'
7234 ,p_responsibility_id => l_resp_id
7235 ,p_application_id => l_application_id
7236 ,x_return_status => x_return_status
7237 ,x_msg_count => x_msg_count
7238 ,x_msg_data => x_msg_data
7239 ) = 'N' THEN
7240 OE_DEBUG_PUB.Add('Not authorize to Release this Hold:'||to_char(p_hold_id));
7241 fnd_message.set_name('ONT','ONT_RELEASE');
7242 l_msg_token := fnd_message.get;
7243
7244 fnd_message.set_name('ONT', 'OE_HOLDS_AUTHORIZATION_FAILED');
7245 fnd_message.set_token('ACTION', l_msg_token);
7246
7247 OE_MSG_PUB.ADD;
7248 -- RAISE FND_API.G_EXC_ERROR;
7249 x_return_status := FND_API.G_RET_STS_ERROR;
7250 OE_MSG_PUB.Count_And_Get
7251 ( p_count => x_msg_count
7252 , p_data => x_msg_data
7253 );
7254 RETURN;
7255 END IF;
7256
7257 OE_DEBUG_PUB.Add('After calling Check_Authorization');
7258
7259 SAVEPOINT process_release_holds_lines;
7260
7261 l_prev_org_id := null;
7262 FOR j in 1.. p_sel_rec_tbl.COUNT LOOP
7263 IF p_sel_rec_tbl(j).org_id <> nvl(l_prev_org_id, -99)
7264 THEN
7265 OE_DEBUG_PUB.Add('Mo_Global.Set_Policy_Context to:' || p_sel_rec_tbl(j).Org_Id );
7266 Mo_Global.Set_Policy_Context (p_access_mode => 'S',
7267 p_org_id => p_sel_rec_tbl(j).Org_Id);
7268 l_prev_org_id := p_sel_rec_tbl(j).org_id;
7269 END IF;
7270
7271
7272 L_line_id := p_sel_rec_tbl(j).id1;
7273 OE_LINE_UTIL.Query_Row
7274 ( p_line_id => l_line_id,
7275 x_line_rec => l_line_rec
7276 );
7277 OE_DEBUG_PUB.Add('header_id: '||l_line_rec.header_id);
7278 OE_DEBUG_PUB.Add('Line_id: '||to_char(l_line_rec.line_id));
7279 l_order_tbl(1).header_id := l_line_rec.header_id;
7280 l_order_tbl(1).line_id := l_line_rec.line_id;
7281
7282
7283 OE_DEBUG_PUB.Add('B4 Calling oe_holds_pvt.release_holds:HeaderID'
7284 || l_order_tbl(1).header_id || ', LineID:' || l_order_tbl(1).line_id);
7285 oe_holds_pvt.release_holds(
7286 p_order_tbl => l_order_tbl,
7287 p_hold_id => p_hold_id,
7288 p_release_reason_code => p_release_reason_code,
7289 p_release_comment => p_release_comment,
7290 p_check_authorization_flag => 'N' , -- bug 8477694
7291 x_return_status => x_return_status,
7292 x_msg_count => x_msg_count,
7293 x_msg_data => x_msg_data
7294 );
7295
7296 OE_DEBUG_PUB.Add('After oe_holds_pvt.release_holds:' || x_return_status,3);
7297
7298
7299 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7300 oe_debug_pub.add('process_release_holds_lines unexpected failure',3);
7301 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7302 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
7303 oe_debug_pub.add('process_release_holds_lines failure',3);
7304 RAISE FND_API.G_EXC_ERROR;
7305 END IF;
7306
7307 END LOOP;
7308
7309 x_return_status := FND_API.G_RET_STS_SUCCESS;
7310 -- Get message count and data
7311 OE_MSG_PUB.Count_And_Get
7312 ( p_count => x_msg_count
7313 , p_data => x_msg_data
7314 );
7315
7316 OE_DEBUG_PUB.Add('Exiting OE_Holds_PVT.process_release_holds_lines',1);
7317
7318 EXCEPTION /* Procedure exception handler */
7319
7320 WHEN FND_API.G_EXC_ERROR THEN
7321 x_return_status := FND_API.G_RET_STS_ERROR ;
7322 OE_MSG_PUB.Count_And_Get
7323 ( p_count => x_msg_count,
7324 p_data => x_msg_data
7325 );
7326 ROLLBACK TO SAVEPOINT process_release_holds_lines;
7327
7328 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7329 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7330 OE_MSG_PUB.Count_And_Get
7331 ( p_count => x_msg_count,
7332 p_data => x_msg_data
7333 );
7334 ROLLBACK TO SAVEPOINT process_release_holds_lines;
7335
7336 WHEN OTHERS THEN
7337 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7338 IF OE_MSG_PUB.Check_Msg_Level
7339 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
7340 THEN
7341 OE_MSG_PUB.Add_Exc_Msg
7342 (G_PKG_NAME,
7343 l_api_name
7344 );
7345 END IF;
7346 OE_MSG_PUB.Count_And_Get
7347 ( p_count => x_msg_count,
7348 p_data => x_msg_data);
7349 ROLLBACK TO SAVEPOINT process_release_holds_lines;
7350
7351 end process_release_holds_lines;
7352
7353 /*
7354 PROCESS_RELEASE_HOLDS_ORDERS
7355 */
7356 procedure process_release_holds_orders (
7357 p_num_of_records IN NUMBER
7358 , p_sel_rec_tbl IN OE_GLOBALS.Selected_Record_Tbl
7359 , p_hold_id IN OE_HOLD_DEFINITIONS.HOLD_ID%TYPE
7360 , p_release_reason_code IN OE_HOLD_RELEASES.RELEASE_REASON_CODE%TYPE
7361 , p_release_comment IN OE_HOLD_RELEASES.RELEASE_COMMENT%TYPE
7362 , x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2
7363 , x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER
7364 , x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
7365 )
7366 IS
7367 l_line_rec OE_ORDER_PUB.line_rec_type;
7368 l_api_name CONSTANT VARCHAR2(30) := 'process_release_holds_orders';
7369 l_header_id NUMBER;
7370 l_return_status VARCHAR2(30);
7371 l_order_tbl OE_HOLDS_PVT.order_tbl_type;
7372 l_error_count NUMBER :=0;
7373 j INTEGER;
7374 initial INTEGER;
7375 nextpos INTEGER;
7376 L_prev_org_id number; -- MOAC
7377 l_hold_source_rec OE_HOLDS_PVT.Hold_Source_Rec_Type;
7378 l_hold_release_rec OE_HOLDS_PVT.Hold_Release_Rec_Type;
7379 --l_record_ids varchar2(2000) := p_record_ids || ',';
7380 --l_num_of_records number;
7381
7382 l_application_id OE_HOLD_AUTHORIZATIONS.APPLICATION_ID%TYPE := FND_GLOBAL.RESP_APPL_ID;
7383 l_resp_id OE_HOLD_AUTHORIZATIONS.RESPONSIBILITY_ID%TYPE := FND_GLOBAL.RESP_ID;
7384 l_msg_token VARCHAR2(100);
7385 BEGIN
7386 oe_msg_pub.initialize;
7387
7388 OE_DEBUG_PUB.Add('Entering OE_Holds_PVT.process_release_holds_orders',1);
7389
7390 IF check_system_holds( p_hold_id => p_hold_id
7391 ,x_return_status => x_return_status
7392 ,x_msg_count => x_msg_count
7393 ,x_msg_data => x_msg_data
7394 ) = 'N' THEN
7395 OE_DEBUG_PUB.Add('Not authorize to Apply this Hold:'|| to_char(p_hold_id));
7396 fnd_message.set_name('ONT', 'ONT_HOLDS_SYSTEM_CHECK');
7397 OE_MSG_PUB.ADD;
7398 x_return_status := FND_API.G_RET_STS_ERROR;
7399 OE_MSG_PUB.Count_And_Get
7400 ( p_count => x_msg_count
7401 , p_data => x_msg_data
7402 );
7403 RETURN;
7404 END IF;
7405
7406 OE_DEBUG_PUB.Add('After calling Check_System_Holds');
7407
7408 IF check_authorization ( p_hold_id => p_hold_id
7409 ,p_authorized_action_code => 'REMOVE'
7410 ,p_responsibility_id => l_resp_id
7411 ,p_application_id => l_application_id
7412 ,x_return_status => x_return_status
7413 ,x_msg_count => x_msg_count
7414 ,x_msg_data => x_msg_data
7415 ) = 'N' THEN
7416 OE_DEBUG_PUB.Add('Not authorize to Release this Hold:'|| to_char(p_hold_id),1);
7417 fnd_message.set_name('ONT','ONT_RELEASE');
7418 l_msg_token := fnd_message.get;
7419
7420 fnd_message.set_name('ONT', 'OE_HOLDS_AUTHORIZATION_FAILED');
7421 fnd_message.set_token('ACTION', l_msg_token);
7422
7423 OE_MSG_PUB.ADD;
7424 -- RAISE FND_API.G_EXC_ERROR;
7425 x_return_status := FND_API.G_RET_STS_ERROR;
7426
7427 OE_MSG_PUB.Count_And_Get
7428 ( p_count => x_msg_count
7429 , p_data => x_msg_data
7430 );
7431
7432 RETURN;
7433 END IF;
7434
7435 OE_DEBUG_PUB.Add('After calling Check_Authorization');
7436
7437 SAVEPOINT process_release_holds_orders;
7438
7439 OE_DEBUG_PUB.Add('Release_Reason_Code: '||p_release_reason_code);
7440
7441 l_prev_org_id := null;
7442 FOR j in 1.. p_sel_rec_tbl.COUNT LOOP
7443 IF p_sel_rec_tbl(j).org_id <> nvl(l_prev_org_id, -99)
7444 THEN
7445 OE_DEBUG_PUB.Add('Mo_Global.Set_Policy_Context to:' || p_sel_rec_tbl(j).Org_Id );
7446 Mo_Global.Set_Policy_Context (p_access_mode => 'S',
7447 p_org_id => p_sel_rec_tbl(j).Org_Id);
7448 l_prev_org_id := p_sel_rec_tbl(j).org_id;
7449 END IF;
7450 l_order_tbl(1).header_id := p_sel_rec_tbl(j).Id1;
7451
7452 OE_DEBUG_PUB.Add('B4 Calling oe_holds_pvt.release_holds 4 HeaderID' || l_order_tbl(1).header_id);
7453 oe_holds_pvt.release_holds(
7454 p_order_tbl => l_order_tbl,
7455 p_hold_id => p_hold_id,
7456 p_release_reason_code => p_release_reason_code,
7457 p_release_comment => p_release_comment,
7458 p_check_authorization_flag => 'N' , -- bug 8477694
7459 x_return_status => x_return_status,
7460 x_msg_count => x_msg_count,
7461 x_msg_data => x_msg_data
7462 );
7463
7464 OE_DEBUG_PUB.Add('x_return_status:' || x_return_status,2);
7465 OE_DEBUG_PUB.Add('x_msg_count:' || to_char(x_msg_count),2);
7466 OE_DEBUG_PUB.Add('x_msg_data:' || x_msg_data,2);
7467
7468 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7469 oe_debug_pub.add('process_release_holds_orders unexpected failure',3);
7470 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7471 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
7472 oe_debug_pub.add('process_release_holds_orders failure',3);
7473 RAISE FND_API.G_EXC_ERROR;
7474 END IF;
7475
7476
7477 END LOOP;
7478
7479 x_return_status := FND_API.G_RET_STS_SUCCESS;
7480 -- Get message count and data
7481 OE_MSG_PUB.Count_And_Get
7482 ( p_count => x_msg_count
7483 , p_data => x_msg_data
7484 );
7485
7486 OE_DEBUG_PUB.Add('Exiting OE_Holds_PVT.process_release_holds_orders',1);
7487
7488 EXCEPTION /* Procedure exception handler */
7489
7490 WHEN FND_API.G_EXC_ERROR THEN
7491 x_return_status := FND_API.G_RET_STS_ERROR ;
7492 OE_MSG_PUB.Count_And_Get
7493 ( p_count => x_msg_count,
7494 p_data => x_msg_data
7495 );
7496 ROLLBACK TO SAVEPOINT process_release_holds_orders;
7497
7498 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7499 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7500 OE_MSG_PUB.Count_And_Get
7501 ( p_count => x_msg_count,
7502 p_data => x_msg_data
7503 );
7504 ROLLBACK TO SAVEPOINT process_release_holds_orders;
7505
7506 WHEN OTHERS THEN
7507 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7508 IF OE_MSG_PUB.Check_Msg_Level
7509 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
7510 THEN
7511 OE_MSG_PUB.Add_Exc_Msg
7512 (G_PKG_NAME,
7513 l_api_name
7514 );
7515 END IF;
7516 OE_MSG_PUB.Count_And_Get
7517 ( p_count => x_msg_count,
7518 p_data => x_msg_data);
7519 ROLLBACK TO SAVEPOINT process_release_holds_orders;
7520
7521
7522 end process_release_holds_orders;
7523
7524 /*******************************/
7525 /* process_create_source */
7526 /*******************************/
7527 /* This procedure gets called when Create Holds Source is selected
7528 from the special menu.
7529 */
7530 procedure process_create_source(
7531 p_hold_source_rec IN OE_HOLDS_PVT.Hold_Source_Rec_Type
7532 ,p_hold_existing_flg IN varchar2
7533 ,p_hold_future_flg IN varchar2
7534 ,p_org_id IN NUMBER DEFAULT MO_GLOBAL.get_current_org_id --ER#7479609
7535 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2
7536 ,x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER
7537 ,x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
7538 )
7539 IS
7540 l_hold_source_rec OE_HOLDS_PVT.Hold_Source_Rec_Type;
7541 l_hold_source_id OE_HOLD_SOURCES_ALL.HOLD_SOURCE_ID%TYPE;
7542 l_hold_release_rec OE_HOLDS_PVT.hold_release_rec_type;
7543 l_hold_release_id oe_hold_releases.HOLD_RELEASE_ID%type;
7544 l_api_name CONSTANT VARCHAR2(30) := 'process_create_holds';
7545 l_application_id OE_HOLD_AUTHORIZATIONS.APPLICATION_ID%TYPE := FND_GLOBAL.RESP_APPL_ID;
7546 l_resp_id OE_HOLD_AUTHORIZATIONS.RESPONSIBILITY_ID%TYPE := FND_GLOBAL.RESP_ID;
7547 l_msg_token VARCHAR2(100);
7548 /*Added the following variables for WF_HOLDS ER (bug 6449458)*/
7549 l_item_type OE_HOLD_DEFINITIONS.ITEM_TYPE%TYPE := NULL;
7550 l_activity_name OE_HOLD_DEFINITIONS.ACTIVITY_NAME%TYPE := NULL;
7551 l_is_hold_applied BOOLEAN;
7552 l_count_of_holds_applied NUMBER := 0;
7553
7554 --
7555 BEGIN
7556 oe_debug_pub.add('In process_create_holds', 1);
7557 oe_msg_pub.initialize; --bug 5548778
7558 l_hold_source_rec := p_hold_source_rec;
7559
7560
7561 -- ER #11824468
7562 if (l_hold_source_rec.hold_entity_code='CN') then
7563 oe_debug_pub.add('Hold Entity Code Reset to C from CN');
7564 l_hold_source_rec.hold_entity_code:='C';
7565 end if;
7566 if (l_hold_source_rec.hold_entity_code2='CN') then
7567 oe_debug_pub.add('Hold Entity Code2 Reset to C from CN');
7568 l_hold_source_rec.hold_entity_code2:='C';
7569 end if;
7570 -- ER #11824468
7571
7572 --ER#12571983 converting'EC' to 'EN'
7573 if (l_hold_source_rec.hold_entity_code='EN') then
7574 oe_debug_pub.add('Hold Entity Code Reset to EC from EN');
7575 l_hold_source_rec.hold_entity_code:='EC';
7576 end if;
7577 if (l_hold_source_rec.hold_entity_code2='EN') then
7578 oe_debug_pub.add('Hold Entity Code2 Reset to EC from EN');
7579 l_hold_source_rec.hold_entity_code2:='EC';
7580 end if;
7581 --ER#12571983 end
7582
7583 if check_system_holds( p_hold_id => l_hold_source_rec.hold_id
7584 ,x_return_status => x_return_status
7585 ,x_msg_count => x_msg_count
7586 ,x_msg_data => x_msg_data
7587 ) = 'N' THEN
7588 OE_DEBUG_PUB.Add('Not authorize to Apply this Hold:'|| to_char(l_hold_source_rec.hold_id));
7589 fnd_message.set_name('ONT', 'ONT_HOLDS_SYSTEM_CHECK');
7590 OE_MSG_PUB.ADD;
7591 x_return_status := FND_API.G_RET_STS_ERROR;
7592 OE_MSG_PUB.Count_And_Get
7593 ( p_count => x_msg_count
7594 , p_data => x_msg_data
7595 );
7596 return;
7597 END IF;
7598
7599 if check_authorization ( p_hold_id => l_hold_source_rec.hold_id
7600 ,p_authorized_action_code => 'APPLY'
7601 ,p_responsibility_id => l_resp_id
7602 ,p_application_id => l_application_id
7603 ,x_return_status => x_return_status
7604 ,x_msg_count => x_msg_count
7605 ,x_msg_data => x_msg_data
7606 ) = 'N' THEN
7607 OE_DEBUG_PUB.Add('Not authorize to Apply this Hold:'||
7608 to_char(l_hold_source_rec.hold_id));
7609
7610 fnd_message.set_name('ONT','ONT_APPLY');
7611 l_msg_token := fnd_message.get;
7612
7613 fnd_message.set_name('ONT', 'OE_HOLDS_AUTHORIZATION_FAILED');
7614 fnd_message.set_token('ACTION', l_msg_token);
7615
7616 OE_MSG_PUB.ADD;
7617 RAISE FND_API.G_EXC_ERROR;
7618 x_return_status := FND_API.G_RET_STS_ERROR;
7619 OE_MSG_PUB.Count_And_Get
7620 ( p_count => x_msg_count
7621 , p_data => x_msg_data
7622 );
7623 return;
7624 END IF;
7625
7626
7627 oe_debug_pub.add('p_hold_existing_flg->' || p_hold_existing_flg,3);
7628 oe_debug_pub.add('p_hold_future_flg->' || p_hold_future_flg,3);
7629 /*added the select statement for WF_HOLDS ER (bug 6449458)*/
7630 select item_type, activity_name
7631 into l_item_type, l_activity_name
7632 from oe_hold_definitions
7633 where hold_id = l_hold_source_rec.hold_id;
7634
7635 if (p_hold_existing_flg = 'Y' AND p_hold_future_flg = 'Y') then
7636 oe_debug_pub.add('Calling oe_holds_pvt.apply_Holds',3);
7637 /*oe_holds_pvt.apply_Holds(
7638 p_hold_source_rec => l_hold_source_rec
7639 ,x_return_status => x_return_status
7640 ,x_msg_count => x_msg_count
7641 ,x_msg_data => x_msg_data
7642 );*/
7643 /*Calling Overloaded Apply_hold Procedure for WF_HOLDS ER (bug 6449458)*/
7644 oe_holds_pvt.apply_Holds(
7645 p_hold_source_rec => l_hold_source_rec
7646 ,p_hold_existing_flg => 'Y'
7647 ,p_hold_future_flg => 'Y'
7648 ,p_org_id => p_org_id --ER#7479609
7649 ,p_wf_item_type => l_item_type
7650 ,p_wf_activity_name => l_activity_name
7651 ,x_return_status => x_return_status
7652 ,x_msg_count => x_msg_count
7653 ,x_msg_data => x_msg_data
7654 ,x_is_hold_applied => l_is_hold_applied
7655 );
7656
7657 OE_DEBUG_PUB.Add('x_return_status:' || x_return_status,2);
7658 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7659 oe_debug_pub.add('process_create_holds unexpected failure',1);
7660 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7661 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
7662 oe_debug_pub.add('process_create_holds expected failure',1);
7663 RAISE FND_API.G_EXC_ERROR;
7664 END IF;
7665 x_return_status := FND_API.G_RET_STS_SUCCESS;
7666 elsif (p_hold_existing_flg = 'Y' AND p_hold_future_flg = 'N') then
7667 -- Create_Hold_Source (Create the Hold Source)
7668 -- Create_Order_Holds (Put the existing Orders on Hold)
7669 -- Create_Release_Source (Release the source.Do not release orders from hold)
7670 oe_debug_pub.add('Calling Create_Hold_Source',3);
7671 Create_Hold_Source (
7672 p_hold_source_rec => l_hold_source_rec,
7673 p_org_id =>p_org_id, --ER#7479609
7674 x_hold_source_id => l_hold_source_id,
7675 x_return_status => x_return_status,
7676 x_msg_count => x_msg_count,
7677 x_msg_data => x_msg_data
7678 );
7679
7680 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
7681 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
7682 RAISE FND_API.G_EXC_ERROR;
7683 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
7684 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7685 END IF;
7686 END IF;
7687 OE_DEBUG_PUB.Add('l_hold_source_id->' || to_char(l_hold_source_id) ,3);
7688 l_hold_source_rec.hold_source_id := l_hold_source_id;
7689 OE_DEBUG_PUB.Add ('Calling Create_Order_Holds',3);
7690 Create_Order_Holds (
7691 p_hold_source_rec => l_hold_source_rec
7692 ,p_org_id =>p_org_id --ER#7479609
7693 ,x_return_status => x_return_status
7694 ,x_msg_count => x_msg_count
7695 ,x_msg_data => x_msg_data
7696 );
7697 OE_DEBUG_PUB.Add('After Create_Order_Holds',3);
7698 -- XX Should be a new reason code
7699 l_hold_release_rec.hold_source_id := l_hold_source_id;
7700 l_hold_release_rec.release_reason_code := 'EXPIRE';
7701 l_hold_release_rec.release_comment := 'Released automatically by System';
7702 oe_debug_pub.add('Calling Create_Release_Source',3);
7703 OE_HOLDS_PVT.Create_Release_Source(p_hold_release_rec => l_hold_release_rec,
7704 x_hold_release_id => l_hold_release_id,
7705 x_return_status => x_return_status,
7706 x_msg_count => x_msg_count,
7707 x_msg_data => x_msg_data);
7708 OE_DEBUG_PUB.Add('Create_Order_Holds Status' || x_return_status,3);
7709
7710 elsif (p_hold_existing_flg = 'N' AND p_hold_future_flg = 'Y') then
7711 -- call create_hold_source for only future holds to go on hold.
7712 OE_DEBUG_PUB.Add('Calling Create_Hold_Source',3);
7713 Create_Hold_Source (
7714 p_hold_source_rec => l_hold_source_rec,
7715 p_org_id =>p_org_id, --ER#7479609
7716 x_hold_source_id => l_hold_source_id,
7717 x_return_status => x_return_status,
7718 x_msg_count => x_msg_count,
7719 x_msg_data => x_msg_data
7720 );
7721 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
7722 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
7723 RAISE FND_API.G_EXC_ERROR;
7724 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
7725 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7726 END IF;
7727 END IF;
7728 else
7729 -- Should not get here
7730 oe_debug_pub.add ('Both of Hold Future and Existing Flag are unset',3);
7731 oe_debug_pub.add ('Do nothing',3);
7732 end if; -- (p_hold_existing_flg = 'Y' AND p_hold_future_flg 'Y')
7733 -- Get message count and data
7734
7735 OE_MSG_PUB.Count_And_Get
7736 ( p_count => x_msg_count
7737 , p_data => x_msg_data
7738 );
7739
7740
7741 EXCEPTION /* Procedure exception handler */
7742
7743 WHEN FND_API.G_EXC_ERROR THEN
7744 x_return_status := FND_API.G_RET_STS_ERROR ;
7745 OE_MSG_PUB.Count_And_Get
7746 ( p_count => x_msg_count,
7747 p_data => x_msg_data
7748 );
7749
7750 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7751 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7752 OE_MSG_PUB.Count_And_Get
7753 ( p_count => x_msg_count,
7754 p_data => x_msg_data
7755 );
7756
7757 WHEN OTHERS THEN
7758 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7759 IF OE_MSG_PUB.Check_Msg_Level
7760 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
7761 THEN
7762 OE_MSG_PUB.Add_Exc_Msg
7763 (G_PKG_NAME,
7764 l_api_name
7765 );
7766 END IF;
7767 OE_MSG_PUB.Count_And_Get
7768 ( p_count => x_msg_count,
7769 p_data => x_msg_data);
7770
7771
7772 end process_create_source;
7773
7774
7775 /*******************************/
7776 /* process_release_source */
7777 /*******************************/
7778 /* This procedure gets called when Release Source button is pressed
7779 from the Release Source window.
7780 */
7781 procedure process_release_source(
7782 p_hold_source_id IN OE_Hold_Sources_ALL.HOLD_SOURCE_ID%TYPE
7783 ,p_hold_release_rec IN OE_HOLDS_PVT.Hold_Release_Rec_Type
7784 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2
7785 ,x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER
7786 ,x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
7787 )
7788 IS
7789 l_hold_source_rec OE_HOLDS_PVT.Hold_Source_Rec_Type;
7790 l_hold_release_rec OE_HOLDS_PVT.Hold_Release_Rec_Type;
7791 l_api_name CONSTANT VARCHAR2(30) := 'process_release_source';
7792 l_hold_id OE_HOLD_DEFINITIONS.HOLD_ID%TYPE;
7793 l_application_id OE_HOLD_AUTHORIZATIONS.APPLICATION_ID%TYPE := FND_GLOBAL.RESP_APPL_ID;
7794 l_resp_id OE_HOLD_AUTHORIZATIONS.RESPONSIBILITY_ID%TYPE := FND_GLOBAL.RESP_ID;
7795 --ER#7479609 l_hold_entity_code varchar2(1); /* Added for Bug 1946783 */
7796 l_hold_entity_code OE_HOLD_SOURCES_ALL.HOLD_ENTITY_CODE%TYPE; --ER#7479609
7797 l_msg_token VARCHAR2(100);
7798 BEGIN
7799
7800 BEGIN
7801 select hold_id, hold_entity_code
7802 into l_hold_id, l_hold_entity_code
7803 from OE_HOLD_SOURCES_all
7804 where hold_source_id = p_hold_source_id;
7805 EXCEPTION
7806 WHEN NO_DATA_FOUND THEN
7807 null;
7808 END;
7809
7810
7811 /* Bug 1946783 - Added Check for credit hold created from AR */
7812
7813 If l_hold_id = 1 AND (l_hold_entity_code ='C' OR l_hold_entity_code = 'B') then
7814 OE_DEBUG_PUB.Add('Bug 1946783 Credit Hold should be released from AR',1);
7815
7816 fnd_message.set_name('ONT', 'OE_CC_AR_HOLD_NOT_RELEASED');
7817 OE_MSG_PUB.ADD;
7818 RAISE FND_API.G_EXC_ERROR;
7819 x_return_status := FND_API.G_RET_STS_ERROR;
7820 OE_MSG_PUB.Count_And_Get
7821 ( p_count => x_msg_count
7822 , p_data => x_msg_data
7823 );
7824 return;
7825 end if;
7826
7827 /* End of code added for Bug 1946783 */
7828
7829
7830 if check_system_holds( p_hold_id => l_hold_id
7831 ,x_return_status => x_return_status
7832 ,x_msg_count => x_msg_count
7833 ,x_msg_data => x_msg_data
7834 ) = 'N' THEN
7835 OE_DEBUG_PUB.Add('Not authorize to Apply this Hold:'|| to_char(l_hold_id));
7836 fnd_message.set_name('ONT', 'ONT_HOLDS_SYSTEM_CHECK');
7837 fnd_message.set_token('ACTION', 'Release');
7838 OE_MSG_PUB.ADD;
7839 x_return_status := FND_API.G_RET_STS_ERROR;
7840 OE_MSG_PUB.Count_And_Get
7841 ( p_count => x_msg_count
7842 , p_data => x_msg_data
7843 );
7844 return;
7845 END IF;
7846
7847 if check_authorization ( p_hold_id => l_hold_id
7848 ,p_authorized_action_code => 'REMOVE'
7849 ,p_responsibility_id => l_resp_id
7850 ,p_application_id => l_application_id
7851 ,x_return_status => x_return_status
7852 ,x_msg_count => x_msg_count
7853 ,x_msg_data => x_msg_data
7854 ) = 'N' THEN
7855 OE_DEBUG_PUB.Add('Not authorize to Release this Hold:'|| to_char(l_hold_id));
7856
7857 fnd_message.set_name('ONT','ONT_RELEASE');
7858 l_msg_token := fnd_message.get;
7859
7860 fnd_message.set_name('ONT', 'OE_HOLDS_AUTHORIZATION_FAILED');
7861 fnd_message.set_token('ACTION', l_msg_token);
7862
7863 OE_MSG_PUB.ADD;
7864 RAISE FND_API.G_EXC_ERROR;
7865 x_return_status := FND_API.G_RET_STS_ERROR;
7866 OE_MSG_PUB.Count_And_Get
7867 ( p_count => x_msg_count
7868 , p_data => x_msg_data
7869 );
7870 return;
7871 END IF;
7872
7873 l_hold_source_rec.hold_source_id := p_hold_source_id;
7874 l_hold_release_rec := p_hold_release_rec;
7875 --l_hold_release_rec.RELEASE_REASON_CODE := p_release_reason_code;
7876 --l_hold_release_rec.RELEASE_COMMENT := p_release_comment;
7877
7878 oe_holds_pvt.Release_Holds(
7879 p_hold_source_rec => l_hold_source_rec
7880 ,p_hold_release_rec => l_hold_release_rec
7881 ,p_check_authorization_flag => 'N' -- bug 8477694
7882 ,x_return_status => x_return_status
7883 ,x_msg_count => x_msg_count
7884 ,x_msg_data => x_msg_data
7885 );
7886 OE_DEBUG_PUB.Add('x_return_status:' || x_return_status,1);
7887
7888 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
7889 oe_debug_pub.add('process_release_source unexpected failure',3);
7890 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7891 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
7892 oe_debug_pub.add('process_release_source expected failure',3);
7893 RAISE FND_API.G_EXC_ERROR;
7894 END IF;
7895
7896 x_return_status := FND_API.G_RET_STS_SUCCESS;
7897 -- Get message count and data
7898 OE_MSG_PUB.Count_And_Get
7899 ( p_count => x_msg_count
7900 , p_data => x_msg_data
7901 );
7902
7903
7904 EXCEPTION /* Procedure exception handler */
7905
7906 WHEN FND_API.G_EXC_ERROR THEN
7907 x_return_status := FND_API.G_RET_STS_ERROR ;
7908 OE_MSG_PUB.Count_And_Get
7909 ( p_count => x_msg_count,
7910 p_data => x_msg_data
7911 );
7912
7913 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7914 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7915 OE_MSG_PUB.Count_And_Get
7916 ( p_count => x_msg_count,
7917 p_data => x_msg_data
7918 );
7919
7920 WHEN OTHERS THEN
7921 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7922 IF OE_MSG_PUB.Check_Msg_Level
7923 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
7924 THEN
7925 OE_MSG_PUB.Add_Exc_Msg
7926 (G_PKG_NAME,
7927 l_api_name
7928 );
7929 END IF;
7930 OE_MSG_PUB.Count_And_Get
7931 ( p_count => x_msg_count,
7932 p_data => x_msg_data);
7933
7934 end process_release_source;
7935
7936 /* ========================================== */
7937 /* Overloaded procedures for ER 1373910 begin */
7938 /* ========================================== */
7939
7940 /*
7941 NAME :
7942 process_release_holds_lines
7943 BRIEF DESCRIPTION :
7944 This API is called when workflow based hold on lines is released from
7945 the sales order form.
7946 CALLER :
7947 1. Oe_holds_release_window.action_release
7948 RELEASE LEVEL :
7949 12.1.1 and higher.
7950 PARAMETERS :
7951 p_num_of_records Number of records affected by the hold release.
7952 p_sel_rec_tbl Table of lines affected by hold release.
7953 p_hold_id Hold being released
7954 p_release_reason_code Hold release reason code
7955 p_release_comment Hold release comments
7956 p_wf_release_action Decides if workflow is to be progressed if hold
7957 being released is workflow based.
7958 x_return_status Return status
7959 */
7960
7961 procedure process_release_holds_lines (
7962 p_num_of_records IN NUMBER
7963 , p_sel_rec_tbl IN OE_GLOBALS.Selected_Record_Tbl
7964 , p_hold_id IN OE_HOLD_DEFINITIONS.HOLD_ID%TYPE
7965 , p_release_reason_code IN OE_HOLD_RELEASES.RELEASE_REASON_CODE%TYPE
7966 , p_release_comment IN OE_HOLD_RELEASES.RELEASE_COMMENT%TYPE
7967 , p_wf_release_action IN VARCHAR2
7968 , x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2
7969 , x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER
7970 , x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
7971 )
7972 IS
7973
7974 --l_header_rec OE_ORDER_PUB.Header_Rec_Type;
7975 l_line_rec OE_ORDER_PUB.line_rec_type;
7976 l_api_name CONSTANT VARCHAR2(30) := 'process_release_holds_lines';
7977 l_line_id NUMBER;
7978 l_return_status VARCHAR2(30);
7979 l_order_tbl OE_HOLDS_PVT.order_tbl_type;
7980 l_error_count NUMBER :=0;
7981 l_ordered_quantity NUMBER ;
7982 j INTEGER;
7983 initial INTEGER;
7984 nextpos INTEGER;
7985
7986 l_prev_org_id number;
7987 l_hold_source_rec OE_HOLDS_PVT.Hold_Source_Rec_Type;
7988 l_hold_release_rec OE_HOLDS_PVT.Hold_Release_Rec_Type;
7989 l_application_id OE_HOLD_AUTHORIZATIONS.APPLICATION_ID%TYPE := FND_GLOBAL.RESP_APPL_ID;
7990 l_resp_id OE_HOLD_AUTHORIZATIONS.RESPONSIBILITY_ID%TYPE := FND_GLOBAL.RESP_ID;
7991 l_msg_token VARCHAR2(100);
7992 BEGIN
7993 oe_msg_pub.initialize;
7994
7995 OE_DEBUG_PUB.Add('Entering OE_Holds_PVT.process_release_holds_lines',1);
7996
7997 IF check_system_holds( p_hold_id => p_hold_id
7998 ,x_return_status => x_return_status
7999 ,x_msg_count => x_msg_count
8000 ,x_msg_data => x_msg_data
8001 ) = 'N' THEN
8002 OE_DEBUG_PUB.Add('Not authorize to Apply this Hold:'|| to_char(p_hold_id));
8003 fnd_message.set_name('ONT', 'ONT_HOLDS_SYSTEM_CHECK');
8004 OE_MSG_PUB.ADD;
8005 x_return_status := FND_API.G_RET_STS_ERROR;
8006 OE_MSG_PUB.Count_And_Get
8007 ( p_count => x_msg_count
8008 , p_data => x_msg_data
8009 );
8010 RETURN;
8011 END IF;
8012
8013 OE_DEBUG_PUB.Add('After calling Check_System_Holds');
8014
8015 IF check_authorization ( p_hold_id => p_hold_id
8016 ,p_authorized_action_code => 'REMOVE'
8017 ,p_responsibility_id => l_resp_id
8018 ,p_application_id => l_application_id
8019 ,x_return_status => x_return_status
8020 ,x_msg_count => x_msg_count
8021 ,x_msg_data => x_msg_data
8022 ) = 'N' THEN
8023 OE_DEBUG_PUB.Add('Not authorize to Release this Hold:'||to_char(p_hold_id));
8024 fnd_message.set_name('ONT','ONT_RELEASE');
8025 l_msg_token := fnd_message.get;
8026
8027 fnd_message.set_name('ONT', 'OE_HOLDS_AUTHORIZATION_FAILED');
8028 fnd_message.set_token('ACTION', l_msg_token);
8029
8030 OE_MSG_PUB.ADD;
8031 -- RAISE FND_API.G_EXC_ERROR;
8032 x_return_status := FND_API.G_RET_STS_ERROR;
8033 OE_MSG_PUB.Count_And_Get
8034 ( p_count => x_msg_count
8035 , p_data => x_msg_data
8036 );
8037 RETURN;
8038 END IF;
8039
8040 OE_DEBUG_PUB.Add('After calling Check_Authorization');
8041
8042 SAVEPOINT process_release_holds_lines;
8043
8044 l_prev_org_id := null;
8045 FOR j in 1.. p_sel_rec_tbl.COUNT LOOP
8046 IF p_sel_rec_tbl(j).org_id <> nvl(l_prev_org_id, -99)
8047 THEN
8048 OE_DEBUG_PUB.Add('Mo_Global.Set_Policy_Context to:' || p_sel_rec_tbl(j).Org_Id );
8049 Mo_Global.Set_Policy_Context (p_access_mode => 'S',
8050 p_org_id => p_sel_rec_tbl(j).Org_Id);
8051 l_prev_org_id := p_sel_rec_tbl(j).org_id;
8052 END IF;
8053
8054 L_line_id := p_sel_rec_tbl(j).id1;
8055 OE_LINE_UTIL.Query_Row
8056 ( p_line_id => l_line_id,
8057 x_line_rec => l_line_rec
8058 );
8059 OE_DEBUG_PUB.Add('header_id: '||l_line_rec.header_id);
8060 OE_DEBUG_PUB.Add('Line_id: '||to_char(l_line_rec.line_id));
8061 l_order_tbl(1).header_id := l_line_rec.header_id;
8062 l_order_tbl(1).line_id := l_line_rec.line_id;
8063
8064
8065 OE_DEBUG_PUB.Add('B4 Calling oe_holds_pvt.release_holds:HeaderID'
8066 || l_order_tbl(1).header_id || ', LineID:' || l_order_tbl(1).line_id);
8067 oe_holds_pvt.release_holds(
8068 p_order_tbl => l_order_tbl,
8069 p_hold_id => p_hold_id,
8070 p_release_reason_code => p_release_reason_code,
8071 p_release_comment => p_release_comment,
8072 p_check_authorization_flag => 'N' , -- bug 8477694
8073 x_return_status => x_return_status,
8074 x_msg_count => x_msg_count,
8075 x_msg_data => x_msg_data
8076 );
8077
8078 OE_DEBUG_PUB.Add('After oe_holds_pvt.release_holds:' || x_return_status,3);
8079
8080 -- Changes begin : ER 1373910
8081 IF x_return_status = FND_API.G_RET_STS_SUCCESS THEN
8082
8083 IF p_wf_release_action = 'Y' THEN
8084 OE_DEBUG_PUB.Add('Before calling Oe_holds_pvt.progress_order');
8085 progress_order( p_hold_id,
8086 p_num_of_records,
8087 l_order_tbl,
8088 x_return_status,
8089 x_msg_count,
8090 x_msg_data );
8091 OE_DEBUG_PUB.Add('After Oe_holds_pvt.progress_order : ' || x_return_status,3);
8092 END IF;
8093 END IF;
8094 -- Changes End : ER 1373910
8095
8096 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
8097 oe_debug_pub.add('process_release_holds_lines unexpected failure',3);
8098 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8099 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
8100 oe_debug_pub.add('process_release_holds_lines failure',3);
8101 RAISE FND_API.G_EXC_ERROR;
8102 END IF;
8103
8104 END LOOP;
8105
8106 x_return_status := FND_API.G_RET_STS_SUCCESS;
8107 -- Get message count and data
8108 OE_MSG_PUB.Count_And_Get
8109 ( p_count => x_msg_count
8110 , p_data => x_msg_data
8111 );
8112
8113 OE_DEBUG_PUB.Add('Exiting OE_Holds_PVT.process_release_holds_lines',1);
8114
8115 EXCEPTION /* Procedure exception handler */
8116
8117 WHEN FND_API.G_EXC_ERROR THEN
8118 x_return_status := FND_API.G_RET_STS_ERROR ;
8119 OE_MSG_PUB.Count_And_Get
8120 ( p_count => x_msg_count,
8121 p_data => x_msg_data
8122 );
8123 ROLLBACK TO SAVEPOINT process_release_holds_lines;
8124
8125 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
8126 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
8127 OE_MSG_PUB.Count_And_Get
8128 ( p_count => x_msg_count,
8129 p_data => x_msg_data
8130 );
8131 ROLLBACK TO SAVEPOINT process_release_holds_lines;
8132
8133 WHEN OTHERS THEN
8134 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
8135 IF OE_MSG_PUB.Check_Msg_Level
8136 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
8137 THEN
8138 OE_MSG_PUB.Add_Exc_Msg
8139 (G_PKG_NAME,
8140 l_api_name
8141 );
8142 END IF;
8143 OE_MSG_PUB.Count_And_Get
8144 ( p_count => x_msg_count,
8145 p_data => x_msg_data);
8146 ROLLBACK TO SAVEPOINT process_release_holds_lines;
8147
8148 end process_release_holds_lines;
8149
8150 /*
8151 NAME :
8152 process_release_holds_orders
8153 BRIEF DESCRIPTION :
8154 This API is called when workflow based hold on orders is released from
8155 the sales order form.
8156 CALLER :
8157 1. Oe_holds_release_window.action_release
8158 RELEASE LEVEL :
8159 12.1.1 and higher.
8160 PARAMETERS :
8161 p_num_of_records Number of records affected by the hold release.
8162 p_sel_rec_tbl Table of orders affected by hold release.
8163 p_hold_id Hold being released
8164 p_release_reason_code Hold release reason code
8165 p_release_comment Hold release comments
8166 p_wf_release_action Decides if workflow is to be progressed if hold
8167 being released is workflow based.
8168 x_return_status Return status
8169 */
8170
8171 procedure process_release_holds_orders (
8172 p_num_of_records IN NUMBER
8173 , p_sel_rec_tbl IN OE_GLOBALS.Selected_Record_Tbl
8174 , p_hold_id IN OE_HOLD_DEFINITIONS.HOLD_ID%TYPE
8175 , p_release_reason_code IN OE_HOLD_RELEASES.RELEASE_REASON_CODE%TYPE
8176 , p_release_comment IN OE_HOLD_RELEASES.RELEASE_COMMENT%TYPE
8177 , p_wf_release_action IN VARCHAR2
8178 , x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2
8179 , x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER
8180 , x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
8181 )
8182 IS
8183 l_line_rec OE_ORDER_PUB.line_rec_type;
8184 l_api_name CONSTANT VARCHAR2(30) := 'process_release_holds_orders';
8185 l_header_id NUMBER;
8186 l_return_status VARCHAR2(30);
8187 l_order_tbl OE_HOLDS_PVT.order_tbl_type;
8188 l_error_count NUMBER :=0;
8189 j INTEGER;
8190 initial INTEGER;
8191 nextpos INTEGER;
8192 l_prev_org_id number; -- MOAC
8193 l_hold_source_rec OE_HOLDS_PVT.Hold_Source_Rec_Type;
8194 l_hold_release_rec OE_HOLDS_PVT.Hold_Release_Rec_Type;
8195 --l_record_ids varchar2(2000) := p_record_ids || ',';
8196 --l_num_of_records number;
8197
8198 l_application_id OE_HOLD_AUTHORIZATIONS.APPLICATION_ID%TYPE := FND_GLOBAL.RESP_APPL_ID;
8199 l_resp_id OE_HOLD_AUTHORIZATIONS.RESPONSIBILITY_ID%TYPE := FND_GLOBAL.RESP_ID;
8200 l_msg_token VARCHAR2(100);
8201 BEGIN
8202 oe_msg_pub.initialize;
8203
8204 OE_DEBUG_PUB.Add('Entering OE_Holds_PVT.process_release_holds_orders',1);
8205
8206 IF check_system_holds( p_hold_id => p_hold_id
8207 ,x_return_status => x_return_status
8208 ,x_msg_count => x_msg_count
8209 ,x_msg_data => x_msg_data
8210 ) = 'N' THEN
8211 OE_DEBUG_PUB.Add('Not authorize to Apply this Hold:'|| to_char(p_hold_id));
8212 fnd_message.set_name('ONT', 'ONT_HOLDS_SYSTEM_CHECK');
8213 OE_MSG_PUB.ADD;
8214 x_return_status := FND_API.G_RET_STS_ERROR;
8215 OE_MSG_PUB.Count_And_Get
8216 ( p_count => x_msg_count
8217 , p_data => x_msg_data
8218 );
8219 RETURN;
8220 END IF;
8221
8222 OE_DEBUG_PUB.Add('After calling Check_System_Holds');
8223
8224 IF check_authorization ( p_hold_id => p_hold_id
8225 ,p_authorized_action_code => 'REMOVE'
8226 ,p_responsibility_id => l_resp_id
8227 ,p_application_id => l_application_id
8228 ,x_return_status => x_return_status
8229 ,x_msg_count => x_msg_count
8230 ,x_msg_data => x_msg_data
8231 ) = 'N' THEN
8232 OE_DEBUG_PUB.Add('Not authorize to Release this Hold:'|| to_char(p_hold_id),1);
8233 fnd_message.set_name('ONT','ONT_RELEASE');
8234 l_msg_token := fnd_message.get;
8235
8236 fnd_message.set_name('ONT', 'OE_HOLDS_AUTHORIZATION_FAILED');
8237 fnd_message.set_token('ACTION', l_msg_token);
8238
8239 OE_MSG_PUB.ADD;
8240 -- RAISE FND_API.G_EXC_ERROR;
8241 x_return_status := FND_API.G_RET_STS_ERROR;
8242
8243 OE_MSG_PUB.Count_And_Get
8244 ( p_count => x_msg_count
8245 , p_data => x_msg_data
8246 );
8247
8248 RETURN;
8249 END IF;
8250
8251 OE_DEBUG_PUB.Add('After calling Check_Authorization');
8252
8253 SAVEPOINT process_release_holds_orders;
8254
8255 OE_DEBUG_PUB.Add('Release_Reason_Code: '||p_release_reason_code);
8256
8257 l_prev_org_id := null;
8258 FOR j in 1.. p_sel_rec_tbl.COUNT LOOP
8259 IF p_sel_rec_tbl(j).org_id <> nvl(l_prev_org_id, -99) THEN
8260 OE_DEBUG_PUB.Add('Mo_Global.Set_Policy_Context to:' || p_sel_rec_tbl(j).Org_Id );
8261 Mo_Global.Set_Policy_Context (p_access_mode => 'S',
8262 p_org_id => p_sel_rec_tbl(j).Org_Id);
8263 l_prev_org_id := p_sel_rec_tbl(j).org_id;
8264 END IF;
8265 l_order_tbl(1).header_id := p_sel_rec_tbl(j).Id1;
8266
8267 OE_DEBUG_PUB.Add('B4 Calling oe_holds_pvt.release_holds 4 HeaderID' || l_order_tbl(1).header_id);
8268 oe_holds_pvt.release_holds(
8269 p_order_tbl => l_order_tbl,
8270 p_hold_id => p_hold_id,
8271 p_release_reason_code => p_release_reason_code,
8272 p_release_comment => p_release_comment,
8273 p_check_authorization_flag => 'N' , -- bug 8477694
8274 x_return_status => x_return_status,
8275 x_msg_count => x_msg_count,
8276 x_msg_data => x_msg_data
8277 );
8278
8279 OE_DEBUG_PUB.Add('x_return_status:' || x_return_status,2);
8280 OE_DEBUG_PUB.Add('x_msg_count:' || to_char(x_msg_count),2);
8281 OE_DEBUG_PUB.Add('x_msg_data:' || x_msg_data,2);
8282
8283 -- Changes begin : ER 1373910
8284 IF x_return_status = FND_API.G_RET_STS_SUCCESS THEN
8285 IF p_wf_release_action = 'Y' THEN
8286 OE_DEBUG_PUB.Add('Before calling Oe_holds_pvt.progress_order');
8287 progress_order( p_hold_id,
8288 p_num_of_records,
8289 l_order_tbl,
8290 x_return_status,
8291 x_msg_count,
8292 x_msg_data);
8293 OE_DEBUG_PUB.Add('After Oe_holds_pvt.progress_order : ' || x_return_status,3);
8294 END IF;
8295 END IF;
8296 -- Changes end : ER 1373910
8297
8298 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
8299 oe_debug_pub.add('process_release_holds_orders unexpected failure',3);
8300 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8301 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
8302 oe_debug_pub.add('process_release_holds_orders failure',3);
8303 RAISE FND_API.G_EXC_ERROR;
8304 END IF;
8305
8306
8307 END LOOP;
8308
8309 x_return_status := FND_API.G_RET_STS_SUCCESS;
8310 -- Get message count and data
8311 OE_MSG_PUB.Count_And_Get
8312 ( p_count => x_msg_count
8313 , p_data => x_msg_data
8314 );
8315
8316 OE_DEBUG_PUB.Add('Exiting OE_Holds_PVT.process_release_holds_orders',1);
8317
8318 EXCEPTION /* Procedure exception handler */
8319
8320 WHEN FND_API.G_EXC_ERROR THEN
8321 x_return_status := FND_API.G_RET_STS_ERROR ;
8322 OE_MSG_PUB.Count_And_Get
8323 ( p_count => x_msg_count,
8324 p_data => x_msg_data
8325 );
8326 ROLLBACK TO SAVEPOINT process_release_holds_orders;
8327
8328 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
8329 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
8330 OE_MSG_PUB.Count_And_Get
8331 ( p_count => x_msg_count,
8332 p_data => x_msg_data
8333 );
8334 ROLLBACK TO SAVEPOINT process_release_holds_orders;
8335
8336 WHEN OTHERS THEN
8337 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
8338 IF OE_MSG_PUB.Check_Msg_Level
8339 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
8340 THEN
8341 OE_MSG_PUB.Add_Exc_Msg
8342 (G_PKG_NAME,
8343 l_api_name
8344 );
8345 END IF;
8346 OE_MSG_PUB.Count_And_Get
8347 ( p_count => x_msg_count,
8348 p_data => x_msg_data);
8349 ROLLBACK TO SAVEPOINT process_release_holds_orders;
8350
8351
8352 end process_release_holds_orders;
8353
8354 /*
8355 NAME :
8356 process_release_source
8357 BRIEF DESCRIPTION :
8358 This API is called when Release Source button is pressed
8359 from the Release Source window.
8360 CALLER :
8361 1. Oe_holds_release_window.create_release_source
8362 RELEASE LEVEL :
8363 12.1.1 and higher.
8364 PARAMETERS :
8365 p_hold_source_id Hold source being released.
8366 p_hold_release_rec Hold source release record.
8367 p_wf_release_action Decides if workflow is to be progressed if hold
8368 source being released is defined on a workflow
8369 based hold.
8370 x_return_status Return status
8371 */
8372
8373 procedure process_release_source(
8374 p_hold_source_id IN OE_Hold_Sources_ALL.HOLD_SOURCE_ID%TYPE
8375 ,p_hold_release_rec IN OE_HOLDS_PVT.Hold_Release_Rec_Type
8376 ,p_wf_release_action IN VARCHAR2
8377 ,x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2
8378 ,x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER
8379 ,x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
8380 )
8381 IS
8382 l_hold_source_rec OE_HOLDS_PVT.Hold_Source_Rec_Type;
8383 l_hold_release_rec OE_HOLDS_PVT.Hold_Release_Rec_Type;
8384 l_api_name CONSTANT VARCHAR2(30) := 'process_release_source';
8385 l_hold_id OE_HOLD_DEFINITIONS.HOLD_ID%TYPE;
8386 l_application_id OE_HOLD_AUTHORIZATIONS.APPLICATION_ID%TYPE := FND_GLOBAL.RESP_APPL_ID;
8387 l_resp_id OE_HOLD_AUTHORIZATIONS.RESPONSIBILITY_ID%TYPE := FND_GLOBAL.RESP_ID;
8388 --ER#7479609 l_hold_entity_code VARCHAR2(1); /* Added for Bug 1946783 */
8389 l_hold_entity_code OE_HOLD_SOURCES_ALL.HOLD_ENTITY_CODE%TYPE; --ER#7479609
8390 l_msg_token VARCHAR2(100);
8391 BEGIN
8392
8393
8394 BEGIN
8395 select hold_id, hold_entity_code
8396 into l_hold_id, l_hold_entity_code
8397 from OE_HOLD_SOURCES_all
8398 where hold_source_id = p_hold_source_id;
8399 EXCEPTION
8400 WHEN NO_DATA_FOUND THEN
8401 null;
8402 END;
8403
8404 /* Bug 1946783 - Added Check for credit hold created from AR */
8405
8406 If l_hold_id = 1 AND (l_hold_entity_code ='C' OR l_hold_entity_code = 'B') then
8407 OE_DEBUG_PUB.Add('Bug 1946783 Credit Hold should be released from AR',1);
8408
8409 fnd_message.set_name('ONT', 'OE_CC_AR_HOLD_NOT_RELEASED');
8410 OE_MSG_PUB.ADD;
8411 RAISE FND_API.G_EXC_ERROR;
8412 x_return_status := FND_API.G_RET_STS_ERROR;
8413 OE_MSG_PUB.Count_And_Get
8414 ( p_count => x_msg_count
8415 , p_data => x_msg_data
8416 );
8417 return;
8418 end if;
8419
8420 /* End of code added for Bug 1946783 */
8421
8422
8423 if check_system_holds( p_hold_id => l_hold_id
8424 ,x_return_status => x_return_status
8425 ,x_msg_count => x_msg_count
8426 ,x_msg_data => x_msg_data
8427 ) = 'N' THEN
8428 OE_DEBUG_PUB.Add('Not authorize to Apply this Hold:'|| to_char(l_hold_id));
8429 fnd_message.set_name('ONT', 'ONT_HOLDS_SYSTEM_CHECK');
8430 fnd_message.set_token('ACTION', 'Release');
8431 OE_MSG_PUB.ADD;
8432 x_return_status := FND_API.G_RET_STS_ERROR;
8433 OE_MSG_PUB.Count_And_Get
8434 ( p_count => x_msg_count
8435 , p_data => x_msg_data
8436 );
8437 return;
8438 END IF;
8439
8440
8441 if check_authorization ( p_hold_id => l_hold_id
8442 ,p_authorized_action_code => 'REMOVE'
8443 ,p_responsibility_id => l_resp_id
8444 ,p_application_id => l_application_id
8445 ,x_return_status => x_return_status
8446 ,x_msg_count => x_msg_count
8447 ,x_msg_data => x_msg_data
8448 ) = 'N' THEN
8449 OE_DEBUG_PUB.Add('Not authorize to Release this Hold:'|| to_char(l_hold_id));
8450
8451 fnd_message.set_name('ONT','ONT_RELEASE');
8452 l_msg_token := fnd_message.get;
8453
8454 fnd_message.set_name('ONT', 'OE_HOLDS_AUTHORIZATION_FAILED');
8455 fnd_message.set_token('ACTION', l_msg_token);
8456
8457 OE_MSG_PUB.ADD;
8458 RAISE FND_API.G_EXC_ERROR;
8459 x_return_status := FND_API.G_RET_STS_ERROR;
8460 OE_MSG_PUB.Count_And_Get
8461 ( p_count => x_msg_count
8462 , p_data => x_msg_data
8463 );
8464 return;
8465 END IF;
8466
8467 l_hold_source_rec.hold_source_id := p_hold_source_id;
8468 l_hold_release_rec := p_hold_release_rec;
8469 --l_hold_release_rec.RELEASE_REASON_CODE := p_release_reason_code;
8470 --l_hold_release_rec.RELEASE_COMMENT := p_release_comment;
8471
8472 oe_holds_pvt.Release_Holds(
8473 p_hold_source_rec => l_hold_source_rec
8474 ,p_hold_release_rec => l_hold_release_rec
8475 ,p_check_authorization_flag => 'N' -- bug 8477694
8476 ,x_return_status => x_return_status
8477 ,x_msg_count => x_msg_count
8478 ,x_msg_data => x_msg_data
8479 );
8480
8481
8482 OE_DEBUG_PUB.Add('x_return_status:' || x_return_status,1);
8483
8484 -- Changes begin : ER 1373910
8485 IF x_return_status = FND_API.G_RET_STS_SUCCESS THEN
8486 IF p_wf_release_action = 'Y' THEN
8487 Oe_debug_pub.Add('Before calling Oe_holds_pvt.progress_order');
8488 progress_order( p_hold_source_id,
8489 x_return_status,
8490 x_msg_count,
8491 x_msg_data);
8492 Oe_debug_pub.ADD('Oe_holds_pvt.progress order returned with : ' || x_return_status);
8493 END IF;
8494 END IF;
8495 -- Changes end : ER 1373910
8496
8497 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
8498 oe_debug_pub.add('process_release_source unexpected failure',3);
8499 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8500 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
8501 oe_debug_pub.add('process_release_source expected failure',3);
8502 RAISE FND_API.G_EXC_ERROR;
8503 END IF;
8504
8505 x_return_status := FND_API.G_RET_STS_SUCCESS;
8506 -- Get message count and data
8507 OE_MSG_PUB.Count_And_Get
8508 ( p_count => x_msg_count
8509 , p_data => x_msg_data
8510 );
8511
8512
8513 EXCEPTION /* Procedure exception handler */
8514
8515 WHEN FND_API.G_EXC_ERROR THEN
8516 x_return_status := FND_API.G_RET_STS_ERROR ;
8517 OE_MSG_PUB.Count_And_Get
8518 ( p_count => x_msg_count,
8519 p_data => x_msg_data
8520 );
8521
8522 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
8523 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
8524 OE_MSG_PUB.Count_And_Get
8525 ( p_count => x_msg_count,
8526 p_data => x_msg_data
8527 );
8528
8529 WHEN OTHERS THEN
8530 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
8531 IF OE_MSG_PUB.Check_Msg_Level
8532 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
8533 THEN
8534 OE_MSG_PUB.Add_Exc_Msg
8535 (G_PKG_NAME,
8536 l_api_name
8537 );
8538 END IF;
8539 OE_MSG_PUB.Count_And_Get
8540 ( p_count => x_msg_count,
8541 p_data => x_msg_data);
8542
8543 end process_release_source;
8544
8545 /* ========================================== */
8546 /* Overloaded procedures for ER 1373910 end */
8547 /* ========================================== */
8548
8549
8550 ------------------------------------
8551 -- SPLIT_HOLDS --
8552 ------------------------------------
8553 procedure split_hold (
8554 p_line_id IN NUMBER,
8555 p_split_from_line_id IN NUMBER,
8556 x_return_status OUT NOCOPY /* file.sql.39 change */ VARCHAR2,
8557 x_msg_count OUT NOCOPY /* file.sql.39 change */ NUMBER,
8558 x_msg_data OUT NOCOPY /* file.sql.39 change */ VARCHAR2
8559 )
8560 IS
8561 l_user_id NUMBER;
8562 l_org_id NUMBER;
8563 l_api_name CONSTANT VARCHAR2(30) := 'SPLIT_HOLD';
8564
8565 l_line_number NUMBER;
8566 l_hold_source_id OE_HOLD_SOURCES_ALL.HOLD_SOURCE_ID%TYPE;
8567 l_hold_source_rec OE_HOLDS_PVT.Hold_Source_Rec_Type;
8568
8569 CURSOR c_order_holds IS
8570 SELECT oh.HOLD_SOURCE_ID
8571 , oh.HEADER_ID
8572 , hs.hold_entity_code
8573 , hs.hold_id
8574 , hs.hold_until_date
8575 , hs.hold_comment
8576 , hs.CONTEXT
8577 , hs.ATTRIBUTE1
8578 , hs.ATTRIBUTE2
8579 , hs.ATTRIBUTE3
8580 , hs.ATTRIBUTE4
8581 , hs.ATTRIBUTE5
8582 , hs.ATTRIBUTE6
8583 , hs.ATTRIBUTE7
8584 , hs.ATTRIBUTE8
8585 , hs.ATTRIBUTE9
8586 , hs.ATTRIBUTE10
8587 , hs.ATTRIBUTE11
8588 , hs.ATTRIBUTE12
8589 , hs.ATTRIBUTE13
8590 , hs.ATTRIBUTE14
8591 , hs.ATTRIBUTE15
8592 , oh.org_id
8593 FROM OE_ORDER_HOLDS_all oh,
8594 OE_HOLD_SOURCES_all hs
8595 WHERE oh.line_id = p_split_from_line_id
8596 AND oh.RELEASED_FLAG = 'N'
8597 AND OH.HOLD_SOURCE_ID = HS.HOLD_SOURCE_ID;
8598
8599
8600 BEGIN
8601 x_return_status := FND_API.G_RET_STS_SUCCESS;
8602
8603 l_user_id := OE_HOLDS_PVT.get_user_id;
8604 l_org_id := OE_GLOBALS.G_ORG_ID;
8605 if l_org_id IS NULL THEN
8606 OE_GLOBALS.Set_Context;
8607 l_org_id := OE_GLOBALS.G_ORG_ID;
8608 end if;
8609
8610 for c_rec IN c_order_holds
8611 loop
8612 IF c_rec.HOLD_ENTITY_CODE = 'O' THEN
8613 l_hold_source_rec.hold_entity_code := c_rec.HOLD_ENTITY_CODE;
8614 l_hold_source_rec.hold_entity_id := c_rec.header_id;
8615 l_hold_source_rec.line_id := p_line_id;
8616 l_hold_source_rec.hold_id := c_rec.hold_id;
8617 l_hold_source_rec.hold_until_date := c_rec.hold_until_date;
8618 l_hold_source_rec.hold_comment := c_rec.hold_comment;
8619 l_hold_source_rec.CONTEXT := c_rec.CONTEXT;
8620 l_hold_source_rec.ATTRIBUTE1 := c_rec.ATTRIBUTE1;
8621 l_hold_source_rec.ATTRIBUTE2 := c_rec.ATTRIBUTE2;
8622 l_hold_source_rec.ATTRIBUTE3 := c_rec.ATTRIBUTE3;
8623 l_hold_source_rec.ATTRIBUTE4 := c_rec.ATTRIBUTE4;
8624 l_hold_source_rec.ATTRIBUTE5 := c_rec.ATTRIBUTE5;
8625 l_hold_source_rec.ATTRIBUTE6 := c_rec.ATTRIBUTE6;
8626 l_hold_source_rec.ATTRIBUTE7 := c_rec.ATTRIBUTE7;
8627 l_hold_source_rec.ATTRIBUTE8 := c_rec.ATTRIBUTE8;
8628 l_hold_source_rec.ATTRIBUTE9 := c_rec.ATTRIBUTE9;
8629 l_hold_source_rec.ATTRIBUTE10 := c_rec.ATTRIBUTE10;
8630 l_hold_source_rec.ATTRIBUTE11 := c_rec.ATTRIBUTE11;
8631 l_hold_source_rec.ATTRIBUTE12 := c_rec.ATTRIBUTE12;
8632 l_hold_source_rec.ATTRIBUTE13 := c_rec.ATTRIBUTE13;
8633 l_hold_source_rec.ATTRIBUTE14 := c_rec.ATTRIBUTE14;
8634 l_hold_source_rec.ATTRIBUTE15 := c_rec.ATTRIBUTE15;
8635 l_hold_source_rec.org_id := c_rec.org_id;
8636
8637 oe_holds_pvt.Create_Hold_Source (
8638 p_hold_source_rec => l_hold_source_rec,
8639 p_org_id =>l_org_id, --ER#7479609
8640 x_hold_source_id => l_hold_source_id,
8641 x_return_status => x_return_status,
8642 x_msg_count => x_msg_count,
8643 x_msg_data => x_msg_data
8644 );
8645 --l_hold_source_rec.hold_source_id := l_hold_source_id;
8646 ELSE
8647 l_hold_source_id := c_rec.hold_source_id;
8648 --l_hold_source_rec.hold_source_id := c_rec.hold_source_id;
8649 END IF;
8650
8651 INSERT INTO OE_ORDER_HOLDS_all
8652 ( ORDER_HOLD_ID
8653 , LAST_UPDATE_DATE
8654 , LAST_UPDATED_BY
8655 , CREATION_DATE
8656 , CREATED_BY
8657 , LAST_UPDATE_LOGIN
8658 , HOLD_SOURCE_ID
8659 , HEADER_ID
8660 , LINE_ID
8661 , RELEASED_FLAG
8662 , ORG_ID
8663 )
8664 VALUES (
8665 OE_ORDER_HOLDS_S.NEXTVAL
8666 , SYSDATE
8667 , l_user_id
8668 , SYSDATE
8669 , l_user_id
8670 , NULL
8671 , l_HOLD_SOURCE_ID
8672 , c_rec.HEADER_ID
8673 , p_line_id
8674 , 'N'
8675 , c_rec.org_id);
8676
8677 end loop;
8678
8679 exception
8680 WHEN NO_DATA_FOUND then
8681 null; -- its ok if there is not holds on the orignal line
8682 WHEN FND_API.G_EXC_ERROR THEN
8683 x_return_status := FND_API.G_RET_STS_ERROR;
8684 OE_MSG_PUB.Count_And_Get
8685 ( p_count => x_msg_count
8686 , p_data => x_msg_data
8687 );
8688 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
8689 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8690 OE_MSG_PUB.Count_And_Get
8691 ( p_count => x_msg_count
8692 , p_data => x_msg_data
8693 );
8694 WHEN OTHERS THEN
8695 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8696 IF OE_MSG_PUB.Check_Msg_Level
8697 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
8698 THEN
8699 OE_MSG_PUB.Add_Exc_Msg
8700 ( G_PKG_NAME,
8701 l_api_name);
8702 END IF;
8703 OE_MSG_PUB.Count_And_Get
8704 ( p_count => x_msg_count
8705 , p_data => x_msg_data
8706 );
8707
8708 END split_hold;
8709
8710 /*Added Overloaded procedure apply_holds for WF_HOLDS ER (bug 6449458)*/
8711 Procedure Apply_Holds(
8712 p_hold_source_rec IN OE_HOLDS_PVT.Hold_Source_Rec_Type,
8713 p_hold_existing_flg IN VARCHAR2,
8714 p_hold_future_flg IN VARCHAR2,
8715 p_org_id IN NUMBER DEFAULT MO_GLOBAL.get_current_org_id, --ER#7479609
8716 p_wf_item_type IN VARCHAR2 DEFAULT NULL,
8717 p_wf_activity_name IN VARCHAR2 DEFAULT NULL,
8718 p_check_authorization_flag IN VARCHAR2 DEFAULT 'N', --bug 8477694
8719 x_return_status OUT NOCOPY VARCHAR2,
8720 x_msg_count OUT NOCOPY NUMBER,
8721 x_msg_data OUT NOCOPY VARCHAR2,
8722 x_is_hold_applied OUT NOCOPY BOOLEAN )
8723
8724 IS
8725
8726 l_application_id OE_HOLD_AUTHORIZATIONS.APPLICATION_ID%TYPE :=
8727 FND_GLOBAL.RESP_APPL_ID;
8728 l_resp_id OE_HOLD_AUTHORIZATIONS.RESPONSIBILITY_ID%TYPE
8729 := FND_GLOBAL.RESP_ID;
8730 l_hold_source_id OE_HOLD_SOURCES_ALL.HOLD_SOURCE_ID%TYPE;
8731 l_hold_source_rec OE_HOLDS_PVT.Hold_Source_Rec_Type;
8732 l_hold_exists VARCHAR2(1) :='N'; --bug 5548778
8733 l_msg_token VARCHAR2(100); --8477694
8734
8735 l_is_hold_applied BOOLEAN;
8736
8737 BEGIN
8738
8739 OE_DEBUG_PUB.Add('In OE_Holds_pvt.Apply Holds, Creating Hold Source',1);
8740
8741 x_return_status := FND_API.G_RET_STS_SUCCESS;
8742
8743 -- 8477694
8744
8745 IF NOT OE_GLOBALS.G_SYS_HOLD THEN
8746 IF check_system_holds(
8747 p_hold_id => p_hold_source_rec.hold_id,
8748 x_return_status => x_return_status,
8749 x_msg_count => x_msg_count,
8750 x_msg_data => x_msg_data) = 'N' THEN
8751
8752 OE_DEBUG_PUB.Add('Not authorize to Apply this Hold:'|| to_char(p_hold_source_rec.hold_id));
8753 l_msg_token := 'APPLY(System Hold)';
8754 fnd_message.set_name('ONT', 'OE_HOLDS_AUTHORIZATION_FAILED');
8755 fnd_message.set_token('ACTION', l_msg_token);
8756 OE_MSG_PUB.ADD;
8757 x_return_status := FND_API.G_RET_STS_ERROR;
8758 OE_MSG_PUB.Count_And_Get
8759 ( p_count => x_msg_count
8760 , p_data => x_msg_data
8761 );
8762 RETURN;
8763 END IF;
8764 END IF;
8765 OE_DEBUG_PUB.Add('After calling Check_System_Holds');
8766
8767 OE_DEBUG_PUB.Add('Apply Hold overloaded before calling Check_Authorization');
8768
8769 --bug 8477694
8770 IF p_check_authorization_flag = 'Y' THEN
8771 OE_DEBUG_PUB.Add('8477694 Manual Auth'||p_check_authorization_flag);
8772 ELSE
8773 OE_DEBUG_PUB.Add('8477694 Auto Auth'||p_check_authorization_flag);
8774 END IF;
8775
8776 IF p_check_authorization_flag = 'Y' THEN -- bug 8477694
8777 IF check_authorization ( p_hold_id => p_hold_source_rec.hold_id
8778 ,p_authorized_action_code => 'APPLY'
8779 ,p_responsibility_id => l_resp_id
8780 ,p_application_id => l_application_id
8781 ,x_return_status => x_return_status
8782 ,x_msg_count => x_msg_count
8783 ,x_msg_data => x_msg_data
8784 ) = 'N' THEN
8785 OE_DEBUG_PUB.Add('Not authorize to Apply this Hold:'|| to_char(p_hold_source_rec.hold_id));
8786 fnd_message.set_name('ONT','ONT_APPLY');
8787 l_msg_token := fnd_message.get;
8788 fnd_message.set_name('ONT', 'OE_HOLDS_AUTHORIZATION_FAILED');
8789 fnd_message.set_token('ACTION', l_msg_token);
8790 OE_MSG_PUB.ADD;
8791 x_return_status := FND_API.G_RET_STS_ERROR;
8792 OE_MSG_PUB.Count_And_Get
8793 ( p_count => x_msg_count
8794 , p_data => x_msg_data
8795 );
8796 RETURN;
8797 END IF;
8798 END IF; --bug 8477694
8799 OE_DEBUG_PUB.Add('Apply Hold overloaded After calling Check_Authorization');
8800 --8477694
8801
8802
8803 l_hold_source_rec := p_hold_source_rec;
8804
8805 Validate (p_hold_source_rec => p_hold_source_rec,
8806 x_return_status => x_return_status,
8807 x_msg_count => x_msg_count,
8808 x_msg_data => x_msg_data );
8809 OE_DEBUG_PUB.Add('Validate return status:' || x_return_status,1);
8810
8811 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
8812 OE_Debug_PUB.Add('Validate not successful',1);
8813 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
8814 RAISE FND_API.G_EXC_ERROR;
8815 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
8816 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8817 END IF;
8818 ELSE
8819 OE_DEBUG_PUB.Add ('Calling Create_Hold_Source bug 5548778 overload',1);
8820 Create_Hold_Source (
8821 p_hold_source_rec => p_hold_source_rec,
8822 p_org_id => p_org_id, --ER#7479609
8823 x_hold_source_id => l_hold_source_id,
8824 x_hold_exists => l_hold_exists,
8825 x_return_status => x_return_status,
8826 x_msg_count => x_msg_count,
8827 x_msg_data => x_msg_data);
8828
8829 OE_DEBUG_PUB.Add('x_return_status->' || x_return_status,1);
8830 OE_DEBUG_PUB.Add('x_msg_count->' || x_msg_count,1);
8831 OE_DEBUG_PUB.Add('x_msg_data' || x_msg_data,1);
8832 OE_DEBUG_PUB.Add('l_hold_exists' || l_hold_exists,1);
8833 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
8834 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
8835 RAISE FND_API.G_EXC_ERROR;
8836 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
8837 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8838 END IF;
8839 END IF;
8840
8841 OE_DEBUG_PUB.Add('l_hold_source_id->' ||
8842 to_char(l_hold_source_id) ,1);
8843 l_hold_source_rec.hold_source_id := l_hold_source_id;
8844 --bug 5548778
8845
8846 -- bug 14494236
8847 OE_DEBUG_PUB.Add ('p_hold_source_rec.hold_entity_code -- '|| p_hold_source_rec.hold_entity_code,1);
8848 OE_DEBUG_PUB.Add ('p_hold_source_rec.hold_id -- ' || p_hold_source_rec.hold_id,1);
8849 l_hold_source_rec.hold_entity_code := p_hold_source_rec.hold_entity_code;
8850 l_hold_source_rec.hold_id := p_hold_source_rec.hold_id;
8851
8852 IF l_hold_exists = 'N' THEN
8853 IF p_wf_item_type IS NOT NULL AND p_wf_activity_name IS NOT
8854 NULL THEN
8855 OE_DEBUG_PUB.Add ('Calling Overloaded Create_Order_Holds Based on Workflow',1);
8856 Create_Order_Holds (
8857 p_hold_source_rec => l_hold_source_rec
8858 ,p_org_id => p_org_id --ER#7479609
8859 ,p_item_type => p_wf_item_type
8860 ,p_activity_name => p_wf_activity_name
8861 ,x_return_status => x_return_status
8862 ,x_msg_count => x_msg_count
8863 ,x_msg_data => x_msg_data
8864 ,x_is_hold_applied => l_is_hold_applied);
8865
8866 ELSE
8867 OE_DEBUG_PUB.Add ('Calling Create_Order_Holds',1);
8868 Create_Order_Holds (
8869 p_hold_source_rec => l_hold_source_rec
8870 ,p_org_id =>p_org_id --ER#7479609
8871 ,x_return_status => x_return_status
8872 ,x_msg_count => x_msg_count
8873 ,x_msg_data => x_msg_data);
8874
8875 END IF; -- l_item_type and l_activity_name
8876
8877 x_is_hold_applied := l_is_hold_applied;
8878
8879 OE_DEBUG_PUB.Add('After Create_Order_Holds',1);
8880 END IF;
8881 END IF;
8882
8883 END Apply_Holds;
8884
8885 /*Added New Overloaded Procedure Create_Order_hols for WF_HOLDS ER (bug 6449458)*/
8886 Procedure Create_Order_Holds(
8887 p_hold_source_rec IN OE_HOLDS_PVT.Hold_Source_Rec_Type,
8888 p_org_id IN NUMBER DEFAULT MO_GLOBAL.get_current_org_id, --ER#7479609
8889 p_item_type IN VARCHAR2,
8890 p_activity_name IN VARCHAR2,
8891 x_return_status OUT NOCOPY VARCHAR2,
8892 x_msg_count OUT NOCOPY NUMBER,
8893 x_msg_data OUT NOCOPY VARCHAR2,
8894 x_is_hold_applied OUT NOCOPY BOOLEAN)
8895
8896 IS
8897 l_user_id NUMBER;
8898 l_org_id NUMBER;
8899 l_api_name CONSTANT VARCHAR2(30) := 'Create_Order_Holds';
8900 l_site_use_code VARCHAR2(30);
8901 l_act_status VARCHAR2(30):= 'COMPLETE';
8902 l_additional_where_clause VARCHAR2(30) := 'XXX';
8903 l_hold_entity_where_clause VARCHAR2(1000); --ER#7479609
8904 l_sqlmt VARCHAR2(3000);
8905 l_parent_count NUMBER;
8906 l_user_activity_name VARCHAR2(80);
8907 l_activity_name VARCHAR2(80);
8908 l_sql_rowcount NUMBER;
8909 -- GENESIS --
8910 l_check_hold VARCHAR2(1) := 'N';
8911
8912 --ER#7479609 start
8913 TYPE line_id_tab is TABLE OF NUMBER INDEX BY binary_integer;
8914 l_line_id_tab line_id_tab;
8915 --ER#7479609 end
8916
8917 /*ER#7479609
8918 CURSOR check_line_hold_type_cur(p_line_id IN NUMBER) IS
8919 SELECT 'Y'
8920 FROM DUAL
8921 WHERE EXISTS (SELECT NULL
8922 FROM oe_order_holds ooh,
8923 oe_hold_sources ohs,
8924 oe_hold_definitions ohd,
8925 oe_order_headers_all h,
8926 oe_order_sources oos
8927 WHERE ohd.hold_id = ohs.hold_id
8928 -- AND ohd.activity_name IS NULL Bug 6791587
8929 AND ooh.header_id = h.header_id
8930 AND h.order_source_id = oos.order_source_id
8931 AND oos.aia_enabled_flag = 'Y'
8932 AND ohs.hold_source_id = ooh.hold_source_id
8933 AND ooh.line_id = p_line_id);
8934
8935 CURSOR check_hdr_hold_type_cur(p_hdr_id IN NUMBER) IS
8936 SELECT 'Y'
8937 FROM DUAL
8938 WHERE EXISTS (SELECT NULL
8939 FROM oe_order_holds ooh,
8940 oe_hold_sources ohs,
8941 oe_hold_definitions ohd,
8942 oe_order_headers_all h,
8943 oe_order_sources oos
8944 WHERE ohd.hold_id = ohs.hold_id
8945 -- AND ohd.activity_name IS NULL Bug 6791587
8946 AND h.order_source_id = oos.order_source_id
8947 AND oos.aia_enabled_flag = 'Y'
8948 AND ooh.header_id = h.header_id
8949 AND ohs.hold_source_id = ooh.hold_source_id
8950 AND ooh.header_id = p_hdr_id);
8951
8952 CURSOR check_src_hold_type_cur(p_hld_src_id IN NUMBER) IS
8953 SELECT 'Y'
8954 FROM DUAL
8955 WHERE EXISTS (SELECT NULL
8956 FROM oe_hold_sources ohs,
8957 oe_hold_definitions ohd
8958 WHERE ohd.hold_id = ohs.hold_id
8959 --AND ohd.activity_name IS NULL Bug 6791587
8960 AND ohs.hold_source_id = p_hld_src_id);
8961 ER#7479609*/
8962
8963 --ER#7479609 start
8964 CURSOR check_line_hold_type_cur(p_line_id IN NUMBER) IS
8965 SELECT 'Y'
8966 FROM DUAL
8967 WHERE EXISTS (SELECT NULL
8968 FROM oe_order_holds_all ooh,
8969 oe_hold_sources_all ohs,
8970 oe_hold_definitions ohd,
8971 oe_order_headers_all h,
8972 oe_order_sources oos
8973 WHERE ohd.hold_id = ohs.hold_id
8974 AND ooh.header_id = h.header_id
8975 AND ooh.org_id = p_org_id
8976 AND ooh.org_id = ohs.org_id
8977 AND ooh.org_id = h.org_id
8978 AND h.order_source_id = oos.order_source_id
8979 AND oos.aia_enabled_flag = 'Y'
8980 AND ohs.hold_source_id = ooh.hold_source_id
8981 AND ooh.line_id = p_line_id);
8982
8983 CURSOR check_hdr_hold_type_cur(p_hdr_id IN NUMBER) IS
8984 SELECT 'Y'
8985 FROM DUAL
8986 WHERE EXISTS (SELECT NULL
8987 FROM oe_order_holds_all ooh,
8988 oe_hold_sources_all ohs,
8989 oe_hold_definitions ohd,
8990 oe_order_headers_all h,
8991 oe_order_sources oos
8992 WHERE ohd.hold_id = ohs.hold_id
8993 AND ooh.org_id = p_org_id
8994 AND ooh.org_id = ohs.org_id
8995 AND ooh.org_id = h.org_id
8996 AND h.order_source_id = oos.order_source_id
8997 AND oos.aia_enabled_flag = 'Y'
8998 AND ooh.header_id = h.header_id
8999 AND ohs.hold_source_id = ooh.hold_source_id
9000 AND ooh.header_id = p_hdr_id);
9001
9002 CURSOR check_src_hold_type_cur(p_hld_src_id IN NUMBER) IS
9003 SELECT 'Y'
9004 FROM DUAL
9005 WHERE EXISTS (SELECT NULL
9006 FROM oe_hold_sources_all ohs,
9007 oe_hold_definitions ohd
9008 WHERE ohd.hold_id = ohs.hold_id
9009 AND ohs.org_id = p_org_id
9010 AND ohs.hold_source_id = p_hld_src_id);
9011 --ER#7479609 end
9012
9013 l_header_rec OE_Order_PUB.Header_Rec_Type;
9014 l_line_rec OE_Order_PUB.Line_Rec_Type;
9015 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
9016 -- GENESIS --
9017 -- 16053361
9018 l_nameVal_tbl OE_ORDER_UTIL.nameVal_Tbl_Type;
9019 l_count number;
9020 -- 16053361
9021 -- ER#3667551 to hold System Parameter value
9022 l_credithold_cust VARCHAR2(10) := NVL(OE_SYS_PARAMETERS.value('ONT_CREDITHOLD_TYPE'),'S') ;--ER# 3667551
9023 l_master_orgid VARCHAR2(10) := oe_sys_parameters.Value('MASTER_ORGANIZATION_ID'); --13653352
9024 BEGIN
9025 x_return_status := FND_API.G_RET_STS_SUCCESS;
9026 l_user_id := OE_HOLDS_PVT.get_user_id;
9027 l_org_id := MO_GLOBAL.get_current_org_id;
9028 x_is_hold_applied := NULL;
9029 IF l_org_id IS NULL THEN
9030 -- org_id is null, raise an error.
9031 oe_debug_pub.add('Org_Id is NULL',1);
9032 x_return_status := FND_API.G_RET_STS_ERROR;
9033 FND_MESSAGE.SET_NAME('FND','MO_ORG_REQUIRED');
9034 FND_MSG_PUB.ADD;
9035 RAISE FND_API.G_EXC_ERROR;
9036 END IF;
9037
9038 oe_debug_pub.add('p_hold_source_rec.hold_source_id:' ||
9039 p_hold_source_rec.hold_source_id);
9040 oe_debug_pub.add('Hold_entity_code/Hold_entity_id/' ||
9041 'Hold_entity_code2/Hold_entity_id2:' ||
9042 p_hold_source_rec.Hold_entity_code || '/' ||
9043 p_hold_source_rec.Hold_entity_id || '/' ||
9044 p_hold_source_rec.Hold_entity_code2 || '/' ||
9045 p_hold_source_rec.Hold_entity_id2);
9046 oe_debug_pub.add('p_hold_source_rec.header_id:' || p_hold_source_rec.header_id);
9047 oe_debug_pub.add('p_hold_source_rec.line_id:' || p_hold_source_rec.line_id);
9048 oe_debug_pub.add('Org Id:' || p_org_id);
9049 -- Insert a hold record for the order header or the order line.
9050 IF p_item_type = 'OEOH' and p_activity_name = 'CLOSE_ORDER' THEN
9051 l_activity_name := 'CLOSE_HEADER';
9052 ELSIF p_item_type = 'OEOL' and p_activity_name = 'PICK_LINE' THEN
9053 l_activity_name := 'SHIP_LINE';
9054 l_additional_where_clause := 'PICK_TRUE';
9055 ELSIF p_item_type = 'OEOL' and p_activity_name = 'PACK_LINE' THEN
9056 l_activity_name := 'SHIP_LINE';
9057 l_additional_where_clause := 'PACK_TRUE';
9058 ELSE
9059 l_activity_name := p_activity_name;
9060 END IF;
9061
9062 /*********************************************************
9063 HOLD CRITERIA 1 : ITEM
9064 *********************************************************/
9065 IF p_hold_source_rec.hold_entity_code = 'I' and
9066 --p_hold_source_rec.hold_entity_code2 = 'C' THEN --ER# 11824468
9067 p_hold_source_rec.hold_entity_code2 IN ('C','CN') THEN --ER# 11824468
9068
9069 --ER#7479609 start
9070 l_hold_entity_where_clause := 'and ol.INVENTORY_ITEM_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
9071 ||' and h.SOLD_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
9072
9073
9074 oe_debug_pub.add('Calling InsertTable_OOH_Line for I and C/CN');
9075 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
9076 ,p_line_id => p_hold_source_rec.line_id
9077 ,p_org_id => p_org_id
9078 ,p_hold_entity_where_clause => l_hold_entity_where_clause
9079 ,p_item_type => p_item_type
9080 ,p_activity_name => l_activity_name
9081 ,p_activity_status => l_act_status
9082 ,p_additional_where_clause => l_additional_where_clause
9083 ,x_is_hold_applied => x_is_hold_applied);
9084 oe_debug_pub.add('After Calling InsertTable_OOH_Line for I and C/CN');
9085 --ER#7479609 end
9086
9087
9088 /*ER#7479609 start
9089 IF p_hold_source_rec.line_id IS NOT NULL THEN
9090 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
9091 ( ORDER_HOLD_ID
9092 , LAST_UPDATE_DATE
9093 , LAST_UPDATED_BY
9094 , CREATION_DATE
9095 , CREATED_BY
9096 , LAST_UPDATE_LOGIN
9097 , HOLD_SOURCE_ID
9098 , HEADER_ID
9099 , LINE_ID
9100 , RELEASED_FLAG
9101 , ORG_ID
9102 )
9103 SELECT
9104 OE_ORDER_HOLDS_S.NEXTVAL
9105 , SYSDATE
9106 , :l_user_id
9107 , SYSDATE
9108 , :l_user_id
9109 , NULL
9110 , :hold_source_id
9111 , h.HEADER_ID
9112 , ol.line_id
9113 , ''N''
9114 , h.org_id --ER#7479609 :l_org_id
9115 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
9116 WHERE h.OPEN_FLAG = ''Y''
9117 --and nvl(h.CANCELLED_FLAG, ''N'') = ''N''
9118 and h.SOLD_TO_ORG_ID = :hold_entity_id2
9119 and h.header_id = ol.header_id
9120 and h.header_id = :l_org_id --ER#7479609
9121 and ol.line_id = :line_id
9122 and ol.INVENTORY_ITEM_ID = :hold_entity_id
9123 and ol.OPEN_FLAG = ''Y''
9124 -- QUOTING change
9125 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
9126 and not exists ( select ''x''
9127 from oe_order_holds_ALL oh
9128 where oh.header_id = h.header_id
9129 and oh.line_id = ol.line_id
9130 and oh.hold_source_id = :hold_source_id )';
9131 IF p_item_type is not null and p_activity_name is not null then
9132 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
9133 , wf_process_activities wpa
9134 where was.process_activity = wpa.instance_id
9135 and item_type = :p_item_type
9136 and item_key = to_char(ol.line_id)
9137 and activity_name = :l_activity_name
9138 and activity_status = :l_activity_status)';
9139 END IF;
9140
9141 IF l_additional_where_clause = 'PICK_TRUE' THEN
9142 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
9143 where w.source_line_id = ol.line_id
9144 and w.source_code = ''OE''
9145 and w.released_status in (''Y'', ''C''))';
9146 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
9147 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
9148 where wdd.source_line_id = ol.LINE_ID
9149 and wdd.source_code = ''OE''
9150 and wda.delivery_detail_id = wdd.delivery_detail_id
9151 and wda.parent_delivery_detail_id is not null)';
9152 END IF;
9153 IF p_item_type is null and p_activity_name is null then
9154 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_hold_source_rec.hold_entity_id2,p_org_id, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
9155 ELSE
9156 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_hold_source_rec.hold_entity_id2,p_org_id , p_hold_source_rec.line_id,
9157 p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
9158
9159 IF sql%rowcount = 0 THEN
9160 x_is_hold_applied := FALSE;
9161 ELSIF sql%rowcount = 1 THEN
9162 x_is_hold_applied := TRUE;
9163 END IF;
9164 END IF;
9165
9166 ELSE
9167 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
9168 ( ORDER_HOLD_ID
9169 , LAST_UPDATE_DATE
9170 , LAST_UPDATED_BY
9171 , CREATION_DATE
9172 , CREATED_BY
9173 , LAST_UPDATE_LOGIN
9174 , HOLD_SOURCE_ID
9175 , HEADER_ID
9176 , LINE_ID
9177 , RELEASED_FLAG
9178 , ORG_ID
9179 )
9180 SELECT
9181 OE_ORDER_HOLDS_S.NEXTVAL
9182 , SYSDATE
9183 , :l_user_id
9184 , SYSDATE
9185 , :l_user_id
9186 , NULL
9187 , :hold_source_id
9188 , h.HEADER_ID
9189 , ol.line_id
9190 , ''N''
9191 , h.org_id --ER#7479609 :l_org_id
9192 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
9193 WHERE h.OPEN_FLAG = ''Y''
9194 --and nvl(h.CANCELLED_FLAG, ''N'') = ''N''
9195 and h.SOLD_TO_ORG_ID = :hold_entity_id2
9196 and h.header_id = ol.header_id
9197 and h.org_ud = :l_org_id --ER#7479609
9198 and ol.INVENTORY_ITEM_ID = :hold_entity_id
9199 and ol.OPEN_FLAG = ''Y''
9200 -- QUOTING change
9201 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
9202 and not exists ( select ''x''
9203 from oe_order_holds_ALL oh
9204 where oh.header_id = h.header_id
9205 and oh.line_id = ol.line_id
9206 and oh.hold_source_id =:hold_source_id )';
9207
9208 IF p_item_type is not null and p_activity_name is not null then
9209 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
9210 , wf_process_activities wpa
9211 where was.process_activity = wpa.instance_id
9212 and item_type = :p_item_type
9213 and item_key = to_char(ol.line_id)
9214 and activity_name = :l_activity_name
9215 and activity_status = :l_activity_status)';
9216 END IF;
9217
9218 IF l_additional_where_clause = 'PICK_TRUE' THEN
9219 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
9220 where w.source_line_id = ol.line_id and w.source_code = ''OE''
9221 and w.released_status in (''Y'', ''C''))';
9222 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
9223 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
9224 where wdd.source_line_id = ol.LINE_ID and wdd.source_code = ''OE''
9225 and wda.delivery_detail_id = wdd.delivery_detail_id
9226 and wda.parent_delivery_detail_id is not null)';
9227 END IF;
9228 IF p_item_type is null and p_activity_name is null then
9229 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id,p_hold_source_rec.hold_entity_id2,p_org_id , p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
9230 ELSE
9231 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id,
9232 p_hold_source_rec.hold_entity_id2,p_org_id ,
9233 p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
9234 l_sql_rowcount := sql%rowcount;
9235 IF l_sql_rowcount = 0 THEN
9236
9237 select meaning into l_user_activity_name
9238 from oe_lookups
9239 where lookup_type = DECODE(p_item_type,
9240 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
9241 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
9242 and lookup_code = p_activity_name;
9243
9244 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
9245 fnd_message.set_token('WF_ACT', l_user_activity_name);
9246 OE_MSG_PUB.ADD;
9247 oe_debug_pub.add(' Hold Not applied for All requested records');
9248 RAISE FND_API.G_EXC_ERROR;
9249 ELSIF l_sql_rowcount > 0 THEN
9250 SELECT count(*)
9251 into l_parent_count
9252 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
9253 WHERE h.OPEN_FLAG = 'Y'
9254 and h.SOLD_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
9255 and h.header_id = ol.header_id
9256 and ol.INVENTORY_ITEM_ID = p_hold_source_rec.hold_entity_id
9257 and ol.OPEN_FLAG = 'Y'
9258 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
9259 and not exists ( select 'x'
9260 from oe_order_holds_ALL oh
9261 where oh.header_id = h.header_id
9262 and oh.line_id = ol.line_id
9263 and oh.hold_source_id =
9264 p_hold_source_rec.hold_source_id );
9265 oe_debug_pub.add('l_parent_count/sql_count'||l_parent_count||sql%rowcount);
9266 -- Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables.
9267
9268 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
9269
9270 select meaning into l_user_activity_name
9271 from oe_lookups
9272 where lookup_type = DECODE(p_item_type,
9273 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
9274 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
9275 and lookup_code = p_activity_name;
9276
9277 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
9278 fnd_message.set_token('WF_ACT', l_user_activity_name);
9279 OE_MSG_PUB.ADD;
9280 oe_debug_pub.add(' Hold Not applied for FEW of the requested records');
9281 END IF;
9282 END IF;
9283 END IF;
9284 END IF;
9285 ER#7479609 end */
9286 /* Only used by Credit checking */
9287 --ER#7479609 start
9288 ELSIF p_hold_source_rec.hold_entity_code = 'I' and
9289 p_hold_source_rec.hold_entity_code2 = 'SM' THEN
9290
9291 l_hold_entity_where_clause := 'and ol.INVENTORY_ITEM_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
9292 ||' and ol.SHIPPING_METHOD_CODE = '||''''||p_hold_source_rec.hold_entity_id2||'''';
9293
9294
9295 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for I and SM');
9296 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
9297 ,p_line_id => p_hold_source_rec.line_id
9298 ,p_org_id => p_org_id
9299 ,p_hold_entity_where_clause => l_hold_entity_where_clause
9300 ,p_item_type => p_item_type
9301 ,p_activity_name => l_activity_name
9302 ,p_activity_status => l_act_status
9303 ,p_additional_where_clause => l_additional_where_clause
9304 ,x_is_hold_applied => x_is_hold_applied);
9305 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for I and SM');
9306 --ER#7479609 end
9307
9308
9309 --ER#7479609 start
9310 ELSIF p_hold_source_rec.hold_entity_code = 'I' and
9311 p_hold_source_rec.hold_entity_code2 = 'D' THEN
9312
9313 l_hold_entity_where_clause := 'and ol.INVENTORY_ITEM_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
9314 ||' and ol.DELIVER_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
9315
9316
9317 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for I and D');
9318 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
9319 ,p_line_id => p_hold_source_rec.line_id
9320 ,p_org_id => p_org_id
9321 ,p_hold_entity_where_clause => l_hold_entity_where_clause
9322 ,p_item_type => p_item_type
9323 ,p_activity_name => l_activity_name
9324 ,p_activity_status => l_act_status
9325 ,p_additional_where_clause => l_additional_where_clause
9326 ,x_is_hold_applied => x_is_hold_applied);
9327 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for I and D');
9328 --ER#7479609 end
9329
9330 --ER#7479609 start
9331 ELSIF p_hold_source_rec.hold_entity_code = 'I' and
9332 p_hold_source_rec.hold_entity_code2 = 'PL' THEN
9333
9334 l_hold_entity_where_clause := 'and ol.INVENTORY_ITEM_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
9335 ||' and ol.PRICE_LIST_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
9336
9337
9338 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for I and PL');
9339 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
9340 ,p_line_id => p_hold_source_rec.line_id
9341 ,p_org_id => p_org_id
9342 ,p_hold_entity_where_clause => l_hold_entity_where_clause
9343 ,p_item_type => p_item_type
9344 ,p_activity_name => l_activity_name
9345 ,p_activity_status => l_act_status
9346 ,p_additional_where_clause => l_additional_where_clause
9347 ,x_is_hold_applied => x_is_hold_applied);
9348 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for I and PL');
9349 --ER#7479609 end
9350
9351 --ER#7479609 start
9352 ELSIF p_hold_source_rec.hold_entity_code = 'I' and
9353 p_hold_source_rec.hold_entity_code2 = 'LT' THEN
9354
9355 l_hold_entity_where_clause := 'and ol.INVENTORY_ITEM_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
9356 ||' and ol.LINE_TYPE_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
9357
9358
9359 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for I and LT');
9360 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
9361 ,p_line_id => p_hold_source_rec.line_id
9362 ,p_org_id => p_org_id
9363 ,p_hold_entity_where_clause => l_hold_entity_where_clause
9364 ,p_item_type => p_item_type
9365 ,p_activity_name => l_activity_name
9366 ,p_activity_status => l_act_status
9367 ,p_additional_where_clause => l_additional_where_clause
9368 ,x_is_hold_applied => x_is_hold_applied);
9369 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for I and LT');
9370 --ER#7479609 end
9371
9372 --ER#7479609 start
9373 ELSIF p_hold_source_rec.hold_entity_code = 'I' and
9374 p_hold_source_rec.hold_entity_code2 = 'PR' THEN
9375
9376 l_hold_entity_where_clause := 'and ol.INVENTORY_ITEM_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
9377 ||' and ol.PROJECT_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
9378
9379
9380 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for I and PR');
9381 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
9382 ,p_line_id => p_hold_source_rec.line_id
9383 ,p_org_id => p_org_id
9384 ,p_hold_entity_where_clause => l_hold_entity_where_clause
9385 ,p_item_type => p_item_type
9386 ,p_activity_name => l_activity_name
9387 ,p_activity_status => l_act_status
9388 ,p_additional_where_clause => l_additional_where_clause
9389 ,x_is_hold_applied => x_is_hold_applied);
9390 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for I and PR');
9391 --ER#7479609 end
9392
9393 ELSIF p_hold_source_rec.hold_entity_code = 'B' and
9394 p_hold_source_rec.hold_entity_code2 = 'O' THEN
9395
9396 --ER#7479609 start
9397 l_hold_entity_where_clause := 'and ol.INVOICE_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
9398 ||' and h.HEADER_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
9399
9400
9401 oe_debug_pub.add('Calling InsertTable_OOH_Line for B and O');
9402 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
9403 ,p_line_id => p_hold_source_rec.line_id
9404 ,p_org_id => p_org_id
9405 ,p_hold_entity_where_clause => l_hold_entity_where_clause
9406 ,p_item_type => p_item_type
9407 ,p_activity_name => l_activity_name
9408 ,p_activity_status => l_act_status
9409 ,p_additional_where_clause => l_additional_where_clause
9410 ,x_is_hold_applied => x_is_hold_applied);
9411 oe_debug_pub.add('After Calling InsertTable_OOH_Line for B and O');
9412 --ER#7479609 end
9413
9414 /*ER#7479609 start
9415 IF p_hold_source_rec.line_id IS NOT NULL THEN
9416 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
9417 ( ORDER_HOLD_ID
9418 , LAST_UPDATE_DATE
9419 , LAST_UPDATED_BY
9420 , CREATION_DATE
9421 , CREATED_BY
9422 , LAST_UPDATE_LOGIN
9423 , HOLD_SOURCE_ID
9424 , HEADER_ID
9425 , LINE_ID
9426 , RELEASED_FLAG
9427 , ORG_ID
9428 )
9429 SELECT
9430 OE_ORDER_HOLDS_S.NEXTVAL
9431 , SYSDATE
9432 , :l_user_id
9433 , SYSDATE
9434 , :l_user_id
9435 , NULL
9436 , :hold_source_id
9437 , h.HEADER_ID
9438 , ol.line_id
9439 , ''N''
9440 , h.org_id --ER#7479609 :l_org_id
9441 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol,
9442 ra_terms_b rt
9443 WHERE h.OPEN_FLAG = ''Y''
9444 and h.header_id = :hold_entity_id2
9445 and h.header_id = ol.header_id
9446 and h.org_id =:l_org_id --ER#7479609
9447 and ol.INVOICE_TO_ORG_ID = :hold_entity_id
9448 and ol.line_id = :line_id
9449 and ol.OPEN_FLAG = ''Y''
9450 and ol.PAYMENT_TERM_ID = rt.TERM_ID
9451 and rt.CREDIT_CHECK_FLAG = ''Y''
9452 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
9453 and not exists ( select ''x''
9454 from oe_order_holds_ALL oh
9455 where oh.header_id = h.header_id
9456 and oh.line_id = ol.line_id
9457 and oh.hold_source_id =:hold_source_id )';
9458 IF p_item_type is not null and p_activity_name is not null then
9459 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
9460 , wf_process_activities wpa
9461 where was.process_activity = wpa.instance_id
9462 and item_type = :p_item_type
9463 and item_key = to_char(ol.line_id)
9464 and activity_name = :l_activity_name
9465 and activity_status = :l_activity_status)';
9466 END IF;
9467 IF l_additional_where_clause = 'PICK_TRUE' THEN
9468 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w where w.source_line_id = ol.line_id and w.source_code = ''OE'' and w.released_status in (''Y'', ''C''))';
9469 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
9470 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
9471 where wdd.source_line_id = ol.LINE_ID and wdd.source_code = ''OE''
9472 and wda.delivery_detail_id = wdd.delivery_detail_id
9473 and wda.parent_delivery_detail_id is not null)';
9474 END IF;
9475 IF p_item_type is null and p_activity_name is null then
9476 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_hold_source_rec.hold_entity_id2,p_org_id , p_hold_source_rec.hold_entity_id, p_hold_source_rec.line_id, p_hold_source_rec.hold_source_id;
9477 ELSE
9478 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id,
9479 p_hold_source_rec.hold_entity_id2,p_org_id , p_hold_source_rec.hold_entity_id, p_hold_source_rec.line_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
9480 IF sql%rowcount = 0 THEN
9481 x_is_hold_applied := FALSE;
9482 ELSIF sql%rowcount = 1 THEN
9483 x_is_hold_applied := TRUE;
9484 END IF;
9485 END IF;
9486
9487 ELSE
9488 l_sqlmt :='INSERT INTO OE_ORDER_HOLDS_ALL
9489 ( ORDER_HOLD_ID
9490 , LAST_UPDATE_DATE
9491 , LAST_UPDATED_BY
9492 , CREATION_DATE
9493 , CREATED_BY
9494 , LAST_UPDATE_LOGIN
9495 , HOLD_SOURCE_ID
9496 , HEADER_ID
9497 , LINE_ID
9498 , RELEASED_FLAG
9499 , ORG_ID
9500 )
9501 SELECT
9502 OE_ORDER_HOLDS_S.NEXTVAL
9503 , SYSDATE
9504 , :l_user_id
9505 , SYSDATE
9506 , :l_user_id
9507 , NULL
9508 , :hold_source_id
9509 , h.HEADER_ID
9510 , ol.line_id
9511 , ''N''
9512 , h.org_id --ER#7479609 :l_org_id
9513 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol,
9514 ra_terms_b rt
9515 WHERE h.OPEN_FLAG = ''Y''
9516 and h.header_id = :hold_entity_id2
9517 and h.header_id = ol.header_id
9518 and h.org_id = :l_org_id --ER#7479609
9519 and ol.INVOICE_TO_ORG_ID = :hold_entity_id
9520 and ol.OPEN_FLAG = ''Y''
9521 and ol.PAYMENT_TERM_ID = rt.TERM_ID
9522 and rt.CREDIT_CHECK_FLAG = ''Y''
9523 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
9524 and not exists ( select ''x''
9525 from oe_order_holds_ALL oh
9526 where oh.header_id = h.header_id
9527 and oh.line_id = ol.line_id
9528 and oh.hold_source_id =:hold_source_id )';
9529 IF p_item_type is not null and p_activity_name is not null then
9530 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
9531 , wf_process_activities wpa
9532 where was.process_activity = wpa.instance_id
9533 and item_type = :p_item_type
9534 and item_key = to_char(ol.line_id)
9535 and activity_name = :l_activity_name
9536 and activity_status = :l_activity_status)';
9537 END IF;
9538
9539 IF l_additional_where_clause = 'PICK_TRUE' THEN
9540 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
9541 where w.source_line_id = ol.line_id
9542 and w.source_code = ''OE''
9543 and w.released_status in (''Y'', ''C''))';
9544 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
9545 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
9546 where wdd.source_line_id = ol.LINE_ID
9547 and wdd.source_code = ''OE''
9548 and wda.delivery_detail_id = wdd.delivery_detail_id
9549 and wda.parent_delivery_detail_id is not null)';
9550 END IF;
9551 IF p_item_type is null and p_activity_name is null then
9552 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, l_org_id, p_hold_source_rec.hold_entity_id2, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
9553 ELSE
9554 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, l_org_id, p_hold_source_rec.hold_entity_id2,
9555 p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
9556 l_sql_rowcount := sql%rowcount;
9557 IF l_sql_rowcount = 0 THEN
9558
9559 select meaning into l_user_activity_name
9560 from oe_lookups
9561 where lookup_type = DECODE(p_item_type,
9562 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
9563 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
9564 and lookup_code = p_activity_name;
9565
9566 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
9567 fnd_message.set_token('WF_ACT', l_user_activity_name);
9568 OE_MSG_PUB.ADD;
9569 oe_debug_pub.add(' Hold Not applied for All requested records');
9570 RAISE FND_API.G_EXC_ERROR;
9571 ELSIF l_sql_rowcount > 0 THEN
9572 SELECT count(*)
9573 into l_parent_count
9574 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol , ra_terms_b rt
9575 WHERE h.OPEN_FLAG = 'Y'
9576 and h.header_id = p_hold_source_rec.hold_entity_id2
9577 and h.header_id = ol.header_id
9578 and ol.INVOICE_TO_ORG_ID = p_hold_source_rec.hold_entity_id
9579 and ol.OPEN_FLAG = 'Y'
9580 and ol.PAYMENT_TERM_ID = rt.TERM_ID
9581 and rt.CREDIT_CHECK_FLAG = 'Y'
9582 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
9583 and not exists ( select 'x'
9584 from oe_order_holds_ALL oh
9585 where oh.header_id = h.header_id
9586 and oh.line_id = ol.line_id
9587 and oh.hold_source_id =
9588 p_hold_source_rec.hold_source_id );
9589
9590 -- Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables.
9591
9592 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
9593
9594 select meaning into l_user_activity_name
9595 from oe_lookups
9596 where lookup_type = DECODE(p_item_type,
9597 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
9598 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
9599 and lookup_code = p_activity_name;
9600
9601 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
9602 fnd_message.set_token('WF_ACT', l_user_activity_name);
9603 OE_MSG_PUB.ADD;
9604 oe_debug_pub.add(' Hold Not applied for FEW of the requested records');
9605 END IF;
9606 END IF;
9607 END IF;
9608 END IF;
9609 ER#7479609 end*/
9610 ELSIF p_hold_source_rec.hold_entity_code = 'I' and
9611 p_hold_source_rec.hold_entity_code2 = 'B' THEN
9612
9613 --ER#7479609 start
9614 l_hold_entity_where_clause := 'and ol.INVENTORY_ITEM_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
9615 ||' and ol.INVOICE_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
9616
9617
9618 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for I and B');
9619 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
9620 ,p_line_id => p_hold_source_rec.line_id
9621 ,p_org_id => p_org_id
9622 ,p_hold_entity_where_clause => l_hold_entity_where_clause
9623 ,p_item_type => p_item_type
9624 ,p_activity_name => l_activity_name
9625 ,p_activity_status => l_act_status
9626 ,p_additional_where_clause => l_additional_where_clause
9627 ,x_is_hold_applied => x_is_hold_applied);
9628 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for I and B');
9629 --ER#7479609 end
9630
9631 /*ER#7479609 start
9632 IF p_hold_source_rec.line_id IS NOT NULL THEN
9633 l_sqlmt :='INSERT INTO OE_ORDER_HOLDS_ALL
9634 ( ORDER_HOLD_ID
9635 , LAST_UPDATE_DATE
9636 , LAST_UPDATED_BY
9637 , CREATION_DATE
9638 , CREATED_BY
9639 , LAST_UPDATE_LOGIN
9640 , HOLD_SOURCE_ID
9641 , HEADER_ID
9642 , LINE_ID
9643 , RELEASED_FLAG
9644 , ORG_ID
9645 )
9646 SELECT
9647 OE_ORDER_HOLDS_S.NEXTVAL
9648 , SYSDATE
9649 , :l_user_id
9650 , SYSDATE
9651 , :l_user_id
9652 , NULL
9653 , :hold_source_id
9654 , h.HEADER_ID
9655 , ol.line_id
9656 , ''N''
9657 , h.org_id --ER#7479609 :l_org_id
9658 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
9659 WHERE h.OPEN_FLAG = ''Y''
9660
9661 and h.header_id = ol.header_id
9662 and h.org_id = :l_org_id --ER#7479609
9663 and ol.INVOICE_TO_ORG_ID = :hold_entity_id2
9664 and ol.line_id = :line_id
9665 and ol.INVENTORY_ITEM_ID = :hold_entity_id
9666 and ol.OPEN_FLAG = ''Y''
9667 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
9668 and not exists ( select ''x''
9669 from oe_order_holds_ALL oh
9670 where oh.header_id = h.header_id
9671 and oh.line_id = ol.line_id
9672 and oh.hold_source_id = :hold_source_id )';
9673 IF p_item_type is not null and p_activity_name is not null then
9674 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
9675 , wf_process_activities wpa
9676 where was.process_activity = wpa.instance_id
9677 and item_type = :p_item_type
9678 and item_key = to_char(ol.line_id)
9679 and activity_name = :l_activity_name
9680 and activity_status = :l_activity_status)';
9681 END IF;
9682
9683 IF l_additional_where_clause = 'PICK_TRUE' THEN
9684 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
9685 where w.source_line_id = ol.line_id
9686 and w.source_code = ''OE''
9687 and w.released_status in (''Y'', ''C''))';
9688 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
9689 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
9690 where wdd.source_line_id = ol.LINE_ID
9691 and wdd.source_code = ''OE''
9692 and wda.delivery_detail_id = wdd.delivery_detail_id
9693 and wda.parent_delivery_detail_id is not null)';
9694 END IF;
9695 IF p_item_type is null and p_activity_name is null then
9696 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
9697 ELSE
9698 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2, p_hold_source_rec.line_id,
9699 p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
9700 IF sql%rowcount = 0 THEN
9701 x_is_hold_applied := FALSE;
9702 ELSIF sql%rowcount = 1 THEN
9703 x_is_hold_applied := TRUE;
9704 END IF;
9705 END IF;
9706 ELSE
9707 l_sqlmt := 'Insert into oe_order_holds_all
9708 ( ORDER_HOLD_ID
9709 , LAST_UPDATE_DATE
9710 , LAST_UPDATED_BY
9711 , CREATION_DATE
9712 , CREATED_BY
9713 , LAST_UPDATE_LOGIN
9714 , HOLD_SOURCE_ID
9715 , HEADER_ID
9716 , LINE_ID
9717 , RELEASED_FLAG
9718 , ORG_ID
9719 )
9720 SELECT
9721 OE_ORDER_HOLDS_S.NEXTVAL
9722 , SYSDATE
9723 , :l_user_id
9724 , SYSDATE
9725 , :l_user_id
9726 , NULL
9727 , :hold_source_id
9728 , h.HEADER_ID
9729 , ol.line_id
9730 , ''N''
9731 , h.org_id --ER#7479609 :l_org_id
9732 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
9733 WHERE h.OPEN_FLAG = ''Y''
9734
9735 and h.header_id = ol.header_id
9736 and h.org_id = :l_org_id --ER#7479609
9737 and ol.INVOICE_TO_ORG_ID = :hold_entity_id2
9738 and ol.INVENTORY_ITEM_ID = :hold_entity_id
9739 and ol.OPEN_FLAG = ''Y''
9740 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
9741 and not exists ( select ''x''
9742 from oe_order_holds_ALL oh
9743 where oh.header_id = h.header_id
9744 and oh.line_id = ol.line_id
9745 and oh.hold_source_id = :hold_source_id )';
9746 IF p_item_type is not null and p_activity_name is not null then
9747 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
9748 , wf_process_activities wpa
9749 where was.process_activity = wpa.instance_id
9750 and item_type = :p_item_type
9751 and item_key = to_char(ol.line_id)
9752 and activity_name = :l_activity_name
9753 and activity_status = :l_activity_status)';
9754 END IF;
9755
9756 IF l_additional_where_clause = 'PICK_TRUE' THEN
9757 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
9758 where w.source_line_id = ol.line_id
9759 and w.source_code = ''OE''
9760 and w.released_status in (''Y'', ''C''))';
9761 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
9762 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
9763 where wdd.source_line_id = ol.LINE_ID
9764 and wdd.source_code = ''OE''
9765 and wda.delivery_detail_id = wdd.delivery_detail_id
9766 and wda.parent_delivery_detail_id is not null)';
9767 END IF;
9768 IF p_item_type is null and p_activity_name is null then
9769 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
9770 ELSE
9771 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2,
9772 p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
9773 l_sql_rowcount := sql%rowcount;
9774 IF l_sql_rowcount = 0 THEN
9775
9776 select meaning into l_user_activity_name
9777 from oe_lookups
9778 where lookup_type = DECODE(p_item_type,
9779 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
9780 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
9781 and lookup_code = p_activity_name;
9782
9783 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
9784 fnd_message.set_token('WF_ACT', l_user_activity_name);
9785 OE_MSG_PUB.ADD;
9786 oe_debug_pub.add(' Hold Not applied for All requested records');
9787 RAISE FND_API.G_EXC_ERROR;
9788 ELSIF l_sql_rowcount > 0 THEN
9789 SELECT count(*)
9790 into l_parent_count
9791 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
9792 WHERE h.OPEN_FLAG = 'Y'
9793 and h.header_id = ol.header_id
9794 and ol.INVOICE_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
9795 and ol.INVENTORY_ITEM_ID = p_hold_source_rec.hold_entity_id
9796 and ol.OPEN_FLAG = 'Y'
9797 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
9798 and not exists ( select 'x'
9799 from oe_order_holds_ALL oh
9800 where oh.header_id = h.header_id
9801 and oh.line_id = ol.line_id
9802 and oh.hold_source_id =
9803 p_hold_source_rec.hold_source_id );
9804
9805 -- Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables.
9806
9807 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
9808
9809 select meaning into l_user_activity_name
9810 from oe_lookups
9811 where lookup_type = DECODE(p_item_type,
9812 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
9813 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
9814 and lookup_code = p_activity_name;
9815
9816 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
9817 fnd_message.set_token('WF_ACT', l_user_activity_name);
9818 OE_MSG_PUB.ADD;
9819 oe_debug_pub.add(' Hold Not applied for FEW of the requested records');
9820 END IF;
9821 END IF;
9822 END IF;
9823 END IF;
9824
9825 ELSIF p_hold_source_rec.hold_entity_code = 'I' and
9826 p_hold_source_rec.hold_entity_code2 = 'S' THEN
9827
9828 --ER#7479609 start
9829 l_hold_entity_where_clause := 'and ol.INVENTORY_ITEM_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
9830 ||' and ol.SHIP_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
9831
9832
9833 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for I and S');
9834 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
9835 ,p_line_id => p_hold_source_rec.line_id
9836 ,p_org_id => p_org_id
9837 ,p_hold_entity_where_clause => l_hold_entity_where_clause
9838 ,p_item_type => p_item_type
9839 ,p_activity_name => l_activity_name
9840 ,p_activity_status => l_act_status
9841 ,p_additional_where_clause => l_additional_where_clause
9842 ,x_is_hold_applied => x_is_hold_applied);
9843 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for I and S');
9844 --ER#7479609 end
9845
9846 /*ER#7479609 start
9847 IF p_hold_source_rec.line_id IS NOT NULL THEN
9848 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
9849 ( ORDER_HOLD_ID
9850 , LAST_UPDATE_DATE
9851 , LAST_UPDATED_BY
9852 , CREATION_DATE
9853 , CREATED_BY
9854 , LAST_UPDATE_LOGIN
9855 , HOLD_SOURCE_ID
9856 , HEADER_ID
9857 , LINE_ID
9858 , RELEASED_FLAG
9859 , ORG_ID
9860 )
9861 SELECT
9862 OE_ORDER_HOLDS_S.NEXTVAL
9863 , SYSDATE
9864 , :l_user_id
9865 , SYSDATE
9866 , :l_user_id
9867 , NULL
9868 , :hold_source_id
9869 , h.HEADER_ID
9870 , ol.line_id
9871 , ''N''
9872 , h.org_id --ER#7479609 :l_org_id
9873 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
9874 WHERE h.OPEN_FLAG = ''Y''
9875
9876 and h.header_id = ol.header_id
9877 and h.org_id = :l_org_id --ER#7479609
9878 and ol.SHIP_TO_ORG_ID = :hold_entity_id2
9879 and ol.line_id = :line_id
9880 and ol.INVENTORY_ITEM_ID = :hold_entity_id
9881 and ol.OPEN_FLAG = ''Y''
9882 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
9883 and not exists ( select ''x''
9884 from oe_order_holds_ALL oh
9885 where oh.header_id = h.header_id
9886 and oh.line_id = ol.line_id
9887 and oh.hold_source_id =:hold_source_id )';
9888 IF p_item_type is not null and p_activity_name is not null then
9889 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
9890 , wf_process_activities wpa
9891 where was.process_activity = wpa.instance_id
9892 and item_type = :p_item_type
9893 and item_key = to_char(ol.line_id)
9894 and activity_name = :l_activity_name
9895 and activity_status = :l_activity_status)';
9896 END IF;
9897 IF l_additional_where_clause = 'PICK_TRUE' THEN
9898 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
9899 where w.source_line_id = ol.line_id
9900 and w.source_code = ''OE''
9901 and w.released_status in (''Y'', ''C''))';
9902 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
9903 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
9904 where wdd.source_line_id = ol.LINE_ID
9905 and wdd.source_code = ''OE''
9906 and wda.delivery_detail_id = wdd.delivery_detail_id
9907 and wda.parent_delivery_detail_id is not null)';
9908 END IF;
9909 IF p_item_type is null and p_activity_name is null then
9910 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id,p_hold_source_rec.hold_source_id;
9911 ELSE
9912 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2,
9913 p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id,p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
9914 IF sql%rowcount = 0 THEN
9915 x_is_hold_applied := FALSE;
9916 ELSIF sql%rowcount = 1 THEN
9917 x_is_hold_applied := TRUE;
9918 END IF;
9919 END IF;
9920 ELSE
9921 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
9922 ( ORDER_HOLD_ID
9923 , LAST_UPDATE_DATE
9924 , LAST_UPDATED_BY
9925 , CREATION_DATE
9926 , CREATED_BY
9927 , LAST_UPDATE_LOGIN
9928 , HOLD_SOURCE_ID
9929 , HEADER_ID
9930 , LINE_ID
9931 , RELEASED_FLAG
9932 , ORG_ID
9933 )
9934 SELECT
9935 OE_ORDER_HOLDS_S.NEXTVAL
9936 , SYSDATE
9937 , :l_user_id
9938 , SYSDATE
9939 , :l_user_id
9940 , NULL
9941 , :hold_source_id
9942 , h.HEADER_ID
9943 , ol.line_id
9944 , ''N''
9945 , h.org_id --ER#7479609 :l_org_id
9946 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
9947 WHERE h.OPEN_FLAG = ''Y''
9948
9949 and h.header_id = ol.header_id
9950 and h.org_id = :l_org_id --ER#7479609
9951 and ol.SHIP_TO_ORG_ID = :hold_entity_id2
9952 and ol.INVENTORY_ITEM_ID = :hold_entity_id
9953 and ol.OPEN_FLAG = ''Y''
9954 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
9955 and not exists ( select ''x''
9956 from oe_order_holds_ALL oh
9957 where oh.header_id = h.header_id
9958 and oh.line_id = ol.line_id
9959 and oh.hold_source_id =:hold_source_id )';
9960 IF p_item_type is not null and p_activity_name is not null then
9961 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
9962 , wf_process_activities wpa
9963 where was.process_activity = wpa.instance_id
9964 and item_type = :p_item_type
9965 and item_key = to_char(ol.line_id)
9966 and activity_name = :l_activity_name
9967 and activity_status = :l_activity_status)';
9968 END IF;
9969 IF l_additional_where_clause = 'PICK_TRUE' THEN
9970 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
9971 where w.source_line_id = ol.line_id
9972 and w.source_code = ''OE''
9973 and w.released_status in (''Y'', ''C''))';
9974 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
9975 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
9976 where wdd.source_line_id = ol.LINE_ID
9977 and wdd.source_code = ''OE''
9978 and wda.delivery_detail_id = wdd.delivery_detail_id
9979 and wda.parent_delivery_detail_id is not null)';
9980 END IF;
9981 IF p_item_type is null and p_activity_name is null then
9982 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
9983 ELSE
9984 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2,
9985 p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
9986 l_sql_rowcount := sql%rowcount;
9987 IF l_sql_rowcount = 0 THEN
9988
9989 select meaning into l_user_activity_name
9990 from oe_lookups
9991 where lookup_type = DECODE(p_item_type,
9992 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
9993 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
9994 and lookup_code = p_activity_name;
9995
9996 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
9997 fnd_message.set_token('WF_ACT', l_user_activity_name);
9998 OE_MSG_PUB.ADD;
9999 oe_debug_pub.add(' Hold Not applied for All requested records');
10000 RAISE FND_API.G_EXC_ERROR;
10001 ELSIF l_sql_rowcount > 0 THEN
10002 SELECT count(*)
10003 into l_parent_count
10004 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
10005 WHERE h.OPEN_FLAG = 'Y'
10006 and h.header_id = ol.header_id
10007 and ol.SHIP_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
10008 and ol.INVENTORY_ITEM_ID = p_hold_source_rec.hold_entity_id
10009 and ol.OPEN_FLAG = 'Y' and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
10010 and not exists ( select 'x'
10011 from oe_order_holds_ALL oh
10012 where oh.header_id = h.header_id
10013 and oh.line_id = ol.line_id
10014 and oh.hold_source_id =
10015 p_hold_source_rec.hold_source_id );
10016
10017 -- Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables.
10018
10019 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
10020
10021 select meaning into l_user_activity_name
10022 from oe_lookups
10023 where lookup_type = DECODE(p_item_type,
10024 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
10025 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
10026 and lookup_code = p_activity_name;
10027
10028 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
10029 fnd_message.set_token('WF_ACT', l_user_activity_name);
10030 OE_MSG_PUB.ADD;
10031 oe_debug_pub.add(' Hold Not applied for FEW of the requested records');
10032 END IF;
10033 END IF;
10034 END IF;
10035 END IF;
10036 ER#7479609 end*/
10037
10038 ELSIF p_hold_source_rec.hold_entity_code = 'I' and
10039 p_hold_source_rec.hold_entity_code2 = 'W' THEN
10040
10041 --ER#7479609 start
10042 l_hold_entity_where_clause := 'and ol.INVENTORY_ITEM_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
10043 ||' and ol.SHIP_FROM_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
10044
10045
10046 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for I and W');
10047 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
10048 ,p_line_id => p_hold_source_rec.line_id
10049 ,p_org_id => p_org_id
10050 ,p_hold_entity_where_clause => l_hold_entity_where_clause
10051 ,p_item_type => p_item_type
10052 ,p_activity_name => l_activity_name
10053 ,p_activity_status => l_act_status
10054 ,p_additional_where_clause => l_additional_where_clause
10055 ,x_is_hold_applied => x_is_hold_applied);
10056 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for I and W');
10057 --ER#7479609 end
10058
10059 /*ER#7479609 start
10060 IF p_hold_source_rec.line_id IS NOT NULL THEN
10061 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
10062 ( ORDER_HOLD_ID
10063 , LAST_UPDATE_DATE
10064 , LAST_UPDATED_BY
10065 , CREATION_DATE
10066 , CREATED_BY
10067 , LAST_UPDATE_LOGIN
10068 , HOLD_SOURCE_ID
10069 , HEADER_ID
10070 , LINE_ID
10071 , RELEASED_FLAG
10072 , ORG_ID
10073 )
10074 SELECT
10075 OE_ORDER_HOLDS_S.NEXTVAL
10076 , SYSDATE
10077 , :l_user_id
10078 , SYSDATE
10079 , :l_user_id
10080 , NULL
10081 , :hold_source_id
10082 , h.HEADER_ID
10083 , ol.line_id
10084 , ''N''
10085 , h.org_id --ER#7479609 :l_org_id
10086 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
10087 WHERE h.OPEN_FLAG = ''Y''
10088
10089 and h.header_id = ol.header_id
10090 and h.org_id = :l_org_id --ER#7479609
10091 and ol.SHIP_FROM_ORG_ID = :hold_entity_id2
10092 and ol.line_id = :line_id
10093 and ol.INVENTORY_ITEM_ID = :hold_entity_id
10094 and ol.OPEN_FLAG = ''Y''
10095 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
10096 and not exists ( select ''x''
10097 from oe_order_holds_ALL oh
10098 where oh.header_id = h.header_id
10099 and oh.line_id = ol.line_id
10100 and oh.hold_source_id =:hold_source_id )';
10101 IF p_item_type is not null and p_activity_name is not null then
10102 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
10103 , wf_process_activities wpa
10104 where was.process_activity = wpa.instance_id
10105 and item_type = :p_item_type
10106 and item_key = to_char(ol.line_id)
10107 and activity_name = :l_activity_name
10108 and activity_status = :l_activity_status)';
10109 END IF;
10110 IF l_additional_where_clause = 'PICK_TRUE' THEN
10111 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
10112 where w.source_line_id = ol.line_id
10113 and w.source_code = ''OE''
10114 and w.released_status in (''Y'', ''C''))';
10115 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
10116 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
10117 where wdd.source_line_id = ol.LINE_ID
10118 and wdd.source_code = ''OE''
10119 and wda.delivery_detail_id = wdd.delivery_detail_id
10120 and wda.parent_delivery_detail_id is not null)';
10121 END IF;
10122 IF p_item_type is null and p_activity_name is null then
10123 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
10124 ELSE
10125 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2,
10126 p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
10127
10128 IF sql%rowcount = 0 THEN
10129 x_is_hold_applied := FALSE;
10130 ELSIF sql%rowcount = 1 THEN
10131 x_is_hold_applied := TRUE;
10132 END IF;
10133 END IF;
10134 ELSE
10135 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
10136 ( ORDER_HOLD_ID
10137 , LAST_UPDATE_DATE
10138 , LAST_UPDATED_BY
10139 , CREATION_DATE
10140 , CREATED_BY
10141 , LAST_UPDATE_LOGIN
10142 , HOLD_SOURCE_ID
10143 , HEADER_ID
10144 , LINE_ID
10145 , RELEASED_FLAG
10146 , ORG_ID
10147 )
10148 SELECT
10149 OE_ORDER_HOLDS_S.NEXTVAL
10150 , SYSDATE
10151 , :l_user_id
10152 , SYSDATE
10153 , :l_user_id
10154 , NULL
10155 , :hold_source_id
10156 , h.HEADER_ID
10157 , ol.line_id
10158 , ''N''
10159 , h.org_id --ER#7479609 :l_org_id
10160 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
10161 WHERE h.OPEN_FLAG = ''Y''
10162
10163 and h.header_id = ol.header_id
10164 and h.org_id = :l_org_id --ER#7479609
10165 and ol.SHIP_FROM_ORG_ID = :hold_entity_id2
10166 and ol.INVENTORY_ITEM_ID = :hold_entity_id
10167 and ol.OPEN_FLAG = ''Y''
10168 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
10169 and not exists ( select ''x''
10170 from oe_order_holds_ALL oh
10171 where oh.header_id = h.header_id
10172 and oh.line_id = ol.line_id
10173 and oh.hold_source_id =:hold_source_id )';
10174 IF p_item_type is not null and p_activity_name is not null then
10175 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
10176 , wf_process_activities wpa
10177 where was.process_activity = wpa.instance_id
10178 and item_type = :p_item_type
10179 and item_key = to_char(ol.line_id)
10180 and activity_name = :l_activity_name
10181 and activity_status = :l_activity_status)';
10182 END IF;
10183 IF l_additional_where_clause = 'PICK_TRUE' THEN
10184 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
10185 where w.source_line_id = ol.line_id
10186 and w.source_code = ''OE''
10187 and w.released_status in (''Y'', ''C''))';
10188 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
10189 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
10190 where wdd.source_line_id = ol.LINE_ID
10191 and wdd.source_code = ''OE''
10192 and wda.delivery_detail_id = wdd.delivery_detail_id
10193 and wda.parent_delivery_detail_id is not null)';
10194 END IF;
10195 IF p_item_type is null and p_activity_name is null then
10196 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
10197 ELSE
10198 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2,
10199 p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
10200 l_sql_rowcount := sql%rowcount;
10201 IF l_sql_rowcount = 0 THEN
10202
10203 select meaning into l_user_activity_name
10204 from oe_lookups
10205 where lookup_type = DECODE(p_item_type,
10206 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
10207 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
10208 and lookup_code = p_activity_name;
10209
10210 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
10211 fnd_message.set_token('WF_ACT', l_user_activity_name);
10212 OE_MSG_PUB.ADD;
10213 oe_debug_pub.add(' Hold Not applied for All requested records');
10214 RAISE FND_API.G_EXC_ERROR;
10215 ELSIF l_sql_rowcount > 0 THEN
10216 SELECT count(*)
10217 into l_parent_count
10218 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
10219 WHERE h.OPEN_FLAG = 'Y'
10220 and h.header_id = ol.header_id
10221 and ol.SHIP_FROM_ORG_ID = p_hold_source_rec.hold_entity_id2
10222 and ol.INVENTORY_ITEM_ID = p_hold_source_rec.hold_entity_id
10223 and ol.OPEN_FLAG = 'Y'
10224 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
10225 and not exists ( select 'x'
10226 from oe_order_holds_ALL oh
10227 where oh.header_id = h.header_id
10228 and oh.line_id = ol.line_id
10229 and oh.hold_source_id =
10230 p_hold_source_rec.hold_source_id );
10231
10232 -- Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables.
10233
10234 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
10235
10236 select meaning into l_user_activity_name
10237 from oe_lookups
10238 where lookup_type = DECODE(p_item_type,
10239 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
10240 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
10241 and lookup_code = p_activity_name;
10242
10243 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
10244 fnd_message.set_token('WF_ACT', l_user_activity_name);
10245 OE_MSG_PUB.ADD;
10246 oe_debug_pub.add(' Hold Not applied for FEW of the requested records');
10247 END IF;
10248 END IF;
10249 END IF;
10250 END IF;
10251 ER#7479609 end*/
10252
10253 ELSIF p_hold_source_rec.hold_entity_code = 'I' and
10254 p_hold_source_rec.hold_entity_code2 = 'H' THEN
10255
10256 --ER#7479609 start
10257 l_hold_entity_where_clause := 'and ol.INVENTORY_ITEM_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
10258 ||' and ol.BLANKET_NUMBER = '||''''||p_hold_source_rec.hold_entity_id2||'''';
10259
10260
10261 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for I and H');
10262 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
10263 ,p_line_id => p_hold_source_rec.line_id
10264 ,p_org_id => p_org_id
10265 ,p_hold_entity_where_clause => l_hold_entity_where_clause
10266 ,p_item_type => p_item_type
10267 ,p_activity_name => l_activity_name
10268 ,p_activity_status => l_act_status
10269 ,p_additional_where_clause => l_additional_where_clause
10270 ,x_is_hold_applied => x_is_hold_applied);
10271 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for I and H');
10272 --ER#7479609 end
10273
10274 -- 13990273 START
10275 -- Hold for Item and Ship To Site
10276 ELSIF p_hold_source_rec.hold_entity_code = 'I' and
10277 p_hold_source_rec.hold_entity_code2 = 'S' THEN
10278
10279 l_hold_entity_where_clause := 'and ol.INVENTORY_ITEM_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
10280 ||' and ol.SHIP_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
10281 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for I and S');
10282 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
10283 ,p_line_id => p_hold_source_rec.line_id
10284 ,p_org_id => p_org_id
10285 ,p_hold_entity_where_clause => l_hold_entity_where_clause
10286 ,p_item_type => p_item_type
10287 ,p_activity_name => l_activity_name
10288 ,p_activity_status => l_act_status
10289 ,p_additional_where_clause => l_additional_where_clause
10290 ,x_is_hold_applied => x_is_hold_applied);
10291 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for I and S');
10292
10293 -- 13990273 END
10294
10295 /*ER#7479609 start
10296 IF p_hold_source_rec.line_id IS NOT NULL THEN
10297 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
10298 ( ORDER_HOLD_ID
10299 , LAST_UPDATE_DATE
10300 , LAST_UPDATED_BY
10301 , CREATION_DATE
10302 , CREATED_BY
10303 , LAST_UPDATE_LOGIN
10304 , HOLD_SOURCE_ID
10305 , HEADER_ID
10306 , LINE_ID
10307 , RELEASED_FLAG
10308 , ORG_ID
10309 )
10310 SELECT
10311 OE_ORDER_HOLDS_S.NEXTVAL
10312 , SYSDATE
10313 , :l_user_id
10314 , SYSDATE
10315 , :l_user_id
10316 , NULL
10317 , :hold_source_id
10318 , h.HEADER_ID
10319 , ol.line_id
10320 , ''N''
10321 , h.org_id --ER#7479609 :l_org_id
10322 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
10323 WHERE h.OPEN_FLAG = ''Y''
10324
10325 and h.header_id = ol.header_id
10326 and h.org_id = :l_org_id --ER#7479609
10327 and ol.BLANKET_NUMBER = :hold_entity_id2
10328 and ol.line_id = :line_id
10329 and ol.INVENTORY_ITEM_ID = :hold_entity_id
10330 and ol.OPEN_FLAG = ''Y''
10331 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
10332 and not exists ( select ''x''
10333 from oe_order_holds_ALL oh
10334 where oh.header_id = h.header_id
10335 and oh.line_id = ol.line_id
10336 and oh.hold_source_id =:hold_source_id )';
10337 IF p_item_type is not null and p_activity_name is not null then
10338 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
10339 , wf_process_activities wpa
10340 where was.process_activity = wpa.instance_id
10341 and item_type = :p_item_type
10342 and item_key = to_char(ol.line_id)
10343 and activity_name = :l_activity_name
10344 and activity_status = :l_activity_status)';
10345 END IF;
10346 IF l_additional_where_clause = 'PICK_TRUE' THEN
10347 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
10348 where w.source_line_id = ol.line_id
10349 and w.source_code = ''OE''
10350 and w.released_status in (''Y'', ''C''))';
10351 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
10352 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
10353 where wdd.source_line_id = ol.LINE_ID
10354 and wdd.source_code = ''OE''
10355 and wda.delivery_detail_id = wdd.delivery_detail_id
10356 and wda.parent_delivery_detail_id is not null)';
10357 END IF;
10358 IF p_item_type is null and p_activity_name is null then
10359 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
10360 ELSE
10361 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2,
10362 p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
10363 IF sql%rowcount = 0 THEN
10364 x_is_hold_applied := FALSE;
10365 ELSIF sql%rowcount = 1 THEN
10366 x_is_hold_applied := TRUE;
10367 END IF;
10368 END IF;
10369 ELSE
10370 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
10371 ( ORDER_HOLD_ID
10372 , LAST_UPDATE_DATE
10373 , LAST_UPDATED_BY
10374 , CREATION_DATE
10375 , CREATED_BY
10376 , LAST_UPDATE_LOGIN
10377 , HOLD_SOURCE_ID
10378 , HEADER_ID
10379 , LINE_ID
10380 , RELEASED_FLAG
10381 , ORG_ID
10382 )
10383 SELECT
10384 OE_ORDER_HOLDS_S.NEXTVAL
10385 , SYSDATE
10386 , :l_user_id
10387 , SYSDATE
10388 , :l_user_id
10389 , NULL
10390 , :hold_source_id
10391 , h.HEADER_ID
10392 , ol.line_id
10393 , ''N''
10394 , h.org_id --ER#7479609 :l_org_id
10395 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
10396 WHERE h.OPEN_FLAG = ''Y''
10397
10398 and h.header_id = ol.header_id
10399 and h.org_id = :l_org_id --ER#7479609
10400 and ol.BLANKET_NUMBER = :hold_entity_id2
10401 and ol.INVENTORY_ITEM_ID = :hold_entity_id
10402 and ol.OPEN_FLAG = ''Y''
10403 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
10404 and not exists ( select ''x''
10405 from oe_order_holds_ALL oh
10406 where oh.header_id = h.header_id
10407 and oh.line_id = ol.line_id
10408 and oh.hold_source_id =:hold_source_id )';
10409 IF p_item_type is not null and p_activity_name is not null then
10410 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
10411 , wf_process_activities wpa
10412 where was.process_activity = wpa.instance_id
10413 and item_type = :p_item_type
10414 and item_key = to_char(ol.line_id)
10415 and activity_name = :l_activity_name
10416 and activity_status = :l_activity_status)';
10417 END IF;
10418 IF l_additional_where_clause = 'PICK_TRUE' THEN
10419 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
10420 where w.source_line_id = ol.line_id
10421 and w.source_code = ''OE''
10422 and w.released_status in (''Y'', ''C''))';
10423 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
10424 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
10425 where wdd.source_line_id = ol.LINE_ID
10426 and wdd.source_code = ''OE''
10427 and wda.delivery_detail_id = wdd.delivery_detail_id
10428 and wda.parent_delivery_detail_id is not null)';
10429 END IF;
10430 IF p_item_type is null and p_activity_name is null then
10431 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
10432 ELSE
10433 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id2,
10434 p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
10435 l_sql_rowcount := sql%rowcount;
10436 IF l_sql_rowcount = 0 THEN
10437
10438 select meaning into l_user_activity_name
10439 from oe_lookups
10440 where lookup_type = DECODE(p_item_type,
10441 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
10442 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
10443 and lookup_code = p_activity_name;
10444
10445 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
10446 fnd_message.set_token('WF_ACT', l_user_activity_name);
10447 OE_MSG_PUB.ADD;
10448 oe_debug_pub.add(' Hold Not applied for All requested records');
10449 RAISE FND_API.G_EXC_ERROR;
10450 ELSIF l_sql_rowcount > 0 THEN
10451 SELECT count(*)
10452 into l_parent_count
10453 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
10454 WHERE h.OPEN_FLAG = 'Y'
10455 and h.header_id = ol.header_id
10456 and ol.BLANKET_NUMBER = p_hold_source_rec.hold_entity_id2
10457 and ol.INVENTORY_ITEM_ID = p_hold_source_rec.hold_entity_id
10458 and ol.OPEN_FLAG = 'Y'
10459 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
10460 and not exists ( select 'x'
10461 from oe_order_holds_ALL oh
10462 where oh.header_id = h.header_id
10463 and oh.line_id = ol.line_id
10464 and oh.hold_source_id =
10465 p_hold_source_rec.hold_source_id );
10466
10467 -- Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables.
10468
10469 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
10470
10471 select meaning into l_user_activity_name
10472 from oe_lookups
10473 where lookup_type = DECODE(p_item_type,
10474 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
10475 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
10476 and lookup_code = p_activity_name;
10477
10478 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
10479 fnd_message.set_token('WF_ACT', l_user_activity_name);
10480 OE_MSG_PUB.ADD;
10481 oe_debug_pub.add(' Hold Not applied for FEW of the requested records');
10482 END IF;
10483 END IF;
10484 END IF;
10485 END IF;
10486 ER#7479609 end*/
10487
10488 --ER# 13331078 start
10489 /*********************************************************
10490 HOLD CRITERIA 1 : ITEM CATEGORY
10491 *********************************************************/
10492 ELSIF p_hold_source_rec.hold_entity_code = 'IC' and
10493 p_hold_source_rec.hold_entity_code2 IN ('C','CN') THEN --ER# 11824468
10494
10495 --13653352, used l_master_orgid below instead of ship_from_org
10496 l_hold_entity_where_clause := ' and h.SOLD_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||''''
10497 ||' and exists (Select 1
10498 from mtl_item_categories mic ,mtl_default_category_sets mdc
10499 where mdc.functional_area_id=7
10500 AND mdc.category_set_id = mic.category_set_id
10501 AND ol.INVENTORY_ITEM_ID = mic.inventory_item_id
10502 and mic.organization_id= '||''''||l_master_orgid||''''
10503 ||' and mic.category_id = '||''''||p_hold_source_rec.hold_entity_id||''''||')';
10504
10505
10506 oe_debug_pub.add('Calling InsertTable_OOH_Line for IC and C/CN');
10507 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
10508 ,p_line_id => p_hold_source_rec.line_id
10509 ,p_org_id => p_org_id
10510 ,p_hold_entity_where_clause => l_hold_entity_where_clause
10511 ,p_item_type => p_item_type
10512 ,p_activity_name => l_activity_name
10513 ,p_activity_status => l_act_status
10514 ,p_additional_where_clause => l_additional_where_clause
10515 ,x_is_hold_applied => x_is_hold_applied);
10516 oe_debug_pub.add('After Calling InsertTable_OOH_Line for IC and C/CN');
10517
10518
10519
10520
10521 ELSIF p_hold_source_rec.hold_entity_code = 'IC' and
10522 p_hold_source_rec.hold_entity_code2 = 'SM' THEN
10523 --13653352, used l_master_orgid below instead of ship_from_org
10524 l_hold_entity_where_clause := ' and ol.SHIPPING_METHOD_CODE = '||''''||p_hold_source_rec.hold_entity_id2||''''
10525 ||' and exists (Select 1
10526 from mtl_item_categories mic ,mtl_default_category_sets mdc
10527 where mdc.functional_area_id=7
10528 AND mdc.category_set_id = mic.category_set_id
10529 AND ol.INVENTORY_ITEM_ID = mic.inventory_item_id
10530 and mic.organization_id= '||''''||l_master_orgid||''''
10531 ||' and mic.category_id = '||''''||p_hold_source_rec.hold_entity_id||''''||')';
10532
10533
10534 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for IC and SM');
10535 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
10536 ,p_line_id => p_hold_source_rec.line_id
10537 ,p_org_id => p_org_id
10538 ,p_hold_entity_where_clause => l_hold_entity_where_clause
10539 ,p_item_type => p_item_type
10540 ,p_activity_name => l_activity_name
10541 ,p_activity_status => l_act_status
10542 ,p_additional_where_clause => l_additional_where_clause
10543 ,x_is_hold_applied => x_is_hold_applied);
10544 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for IC and SM');
10545
10546
10547
10548
10549 ELSIF p_hold_source_rec.hold_entity_code = 'IC' and
10550 p_hold_source_rec.hold_entity_code2 = 'D' THEN
10551
10552 --13653352, used l_master_orgid below instead of ship_from_org
10553 l_hold_entity_where_clause := ' and ol.DELIVER_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||''''
10554 ||' and exists (Select 1
10555 from mtl_item_categories mic ,mtl_default_category_sets mdc
10556 where mdc.functional_area_id=7
10557 AND mdc.category_set_id = mic.category_set_id
10558 AND ol.INVENTORY_ITEM_ID = mic.inventory_item_id
10559 and mic.organization_id= '||''''||l_master_orgid||''''
10560 ||' and mic.category_id = '||''''||p_hold_source_rec.hold_entity_id||''''||')';
10561
10562 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for IC and D');
10563 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
10564 ,p_line_id => p_hold_source_rec.line_id
10565 ,p_org_id => p_org_id
10566 ,p_hold_entity_where_clause => l_hold_entity_where_clause
10567 ,p_item_type => p_item_type
10568 ,p_activity_name => l_activity_name
10569 ,p_activity_status => l_act_status
10570 ,p_additional_where_clause => l_additional_where_clause
10571 ,x_is_hold_applied => x_is_hold_applied);
10572 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for IC and D');
10573
10574
10575
10576 ELSIF p_hold_source_rec.hold_entity_code = 'IC' and
10577 p_hold_source_rec.hold_entity_code2 = 'PL' THEN
10578
10579 --13653352, used l_master_orgid below instead of ship_from_org
10580 l_hold_entity_where_clause := ' and ol.PRICE_LIST_ID = '||''''||p_hold_source_rec.hold_entity_id2||''''
10581 ||' and exists (Select 1
10582 from mtl_item_categories mic ,mtl_default_category_sets mdc
10583 where mdc.functional_area_id=7
10584 AND mdc.category_set_id = mic.category_set_id
10585 AND ol.INVENTORY_ITEM_ID = mic.inventory_item_id
10586 and mic.organization_id= '||''''||l_master_orgid||''''
10587 ||' and mic.category_id = '||''''||p_hold_source_rec.hold_entity_id||''''||')';
10588
10589 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for IC and PL');
10590 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
10591 ,p_line_id => p_hold_source_rec.line_id
10592 ,p_org_id => p_org_id
10593 ,p_hold_entity_where_clause => l_hold_entity_where_clause
10594 ,p_item_type => p_item_type
10595 ,p_activity_name => l_activity_name
10596 ,p_activity_status => l_act_status
10597 ,p_additional_where_clause => l_additional_where_clause
10598 ,x_is_hold_applied => x_is_hold_applied);
10599 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for IC and PL');
10600
10601 ELSIF p_hold_source_rec.hold_entity_code = 'IC' and
10602 p_hold_source_rec.hold_entity_code2 = 'LT' THEN
10603
10604 --13653352, used l_master_orgid below instead of ship_from_org
10605 l_hold_entity_where_clause := ' and ol.LINE_TYPE_ID = '||''''||p_hold_source_rec.hold_entity_id2||''''
10606 ||' and exists (Select 1
10607 from mtl_item_categories mic ,mtl_default_category_sets mdc
10608 where mdc.functional_area_id=7
10609 AND mdc.category_set_id = mic.category_set_id
10610 AND ol.INVENTORY_ITEM_ID = mic.inventory_item_id
10611 and mic.organization_id= '||''''||l_master_orgid||''''
10612 ||' and mic.category_id = '||''''||p_hold_source_rec.hold_entity_id||''''||')';
10613
10614 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for IC and LT');
10615 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
10616 ,p_line_id => p_hold_source_rec.line_id
10617 ,p_org_id => p_org_id
10618 ,p_hold_entity_where_clause => l_hold_entity_where_clause
10619 ,p_item_type => p_item_type
10620 ,p_activity_name => l_activity_name
10621 ,p_activity_status => l_act_status
10622 ,p_additional_where_clause => l_additional_where_clause
10623 ,x_is_hold_applied => x_is_hold_applied);
10624 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for IC and LT');
10625
10626 ELSIF p_hold_source_rec.hold_entity_code = 'IC' and
10627 p_hold_source_rec.hold_entity_code2 = 'PR' THEN
10628
10629 --13653352, used l_master_orgid below instead of ship_from_org
10630 l_hold_entity_where_clause := ' and ol.PROJECT_ID = '||''''||p_hold_source_rec.hold_entity_id2||''''
10631 ||' and exists (Select 1
10632 from mtl_item_categories mic ,mtl_default_category_sets mdc
10633 where mdc.functional_area_id=7
10634 AND mdc.category_set_id = mic.category_set_id
10635 AND ol.INVENTORY_ITEM_ID = mic.inventory_item_id
10636 and mic.organization_id= '||''''||l_master_orgid||''''
10637 ||' and mic.category_id = '||''''||p_hold_source_rec.hold_entity_id||''''||')';
10638
10639 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for IC and PR');
10640 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
10641 ,p_line_id => p_hold_source_rec.line_id
10642 ,p_org_id => p_org_id
10643 ,p_hold_entity_where_clause => l_hold_entity_where_clause
10644 ,p_item_type => p_item_type
10645 ,p_activity_name => l_activity_name
10646 ,p_activity_status => l_act_status
10647 ,p_additional_where_clause => l_additional_where_clause
10648 ,x_is_hold_applied => x_is_hold_applied);
10649 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for IC and PR');
10650
10651 ELSIF p_hold_source_rec.hold_entity_code = 'IC' and
10652 p_hold_source_rec.hold_entity_code2 = 'B' THEN
10653
10654
10655 --13653352, used l_master_orgid below instead of ship_from_org
10656 l_hold_entity_where_clause := ' and ol.INVOICE_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||''''
10657 ||' and exists (Select 1
10658 from mtl_item_categories mic ,mtl_default_category_sets mdc
10659 where mdc.functional_area_id=7
10660 AND mdc.category_set_id = mic.category_set_id
10661 AND ol.INVENTORY_ITEM_ID = mic.inventory_item_id
10662 and mic.organization_id= '||''''||l_master_orgid||''''
10663 ||' and mic.category_id = '||''''||p_hold_source_rec.hold_entity_id||''''||')';
10664
10665 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for IC and B');
10666 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
10667 ,p_line_id => p_hold_source_rec.line_id
10668 ,p_org_id => p_org_id
10669 ,p_hold_entity_where_clause => l_hold_entity_where_clause
10670 ,p_item_type => p_item_type
10671 ,p_activity_name => l_activity_name
10672 ,p_activity_status => l_act_status
10673 ,p_additional_where_clause => l_additional_where_clause
10674 ,x_is_hold_applied => x_is_hold_applied);
10675 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for IC and B');
10676
10677 ELSIF p_hold_source_rec.hold_entity_code = 'IC' and
10678 p_hold_source_rec.hold_entity_code2 = 'W' THEN
10679
10680 --13653352, used l_master_orgid below instead of ship_from_org
10681 l_hold_entity_where_clause := ' and ol.SHIP_FROM_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||''''
10682 ||' and exists (Select 1
10683 from mtl_item_categories mic ,mtl_default_category_sets mdc
10684 where mdc.functional_area_id=7
10685 AND mdc.category_set_id = mic.category_set_id
10686 AND ol.INVENTORY_ITEM_ID = mic.inventory_item_id
10687 and mic.organization_id= '||''''||l_master_orgid||''''
10688 ||' and mic.category_id = '||''''||p_hold_source_rec.hold_entity_id||''''||')';
10689
10690 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for IC and W');
10691 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
10692 ,p_line_id => p_hold_source_rec.line_id
10693 ,p_org_id => p_org_id
10694 ,p_hold_entity_where_clause => l_hold_entity_where_clause
10695 ,p_item_type => p_item_type
10696 ,p_activity_name => l_activity_name
10697 ,p_activity_status => l_act_status
10698 ,p_additional_where_clause => l_additional_where_clause
10699 ,x_is_hold_applied => x_is_hold_applied);
10700 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for IC and W');
10701
10702
10703 ELSIF p_hold_source_rec.hold_entity_code = 'IC' and
10704 p_hold_source_rec.hold_entity_code2 = 'H' THEN
10705
10706 --13653352, used l_master_orgid below instead of ship_from_org
10707 l_hold_entity_where_clause := ' and ol.BLANKET_NUMBER = '||''''||p_hold_source_rec.hold_entity_id2||''''
10708 ||' and exists (Select 1
10709 from mtl_item_categories mic ,mtl_default_category_sets mdc
10710 where mdc.functional_area_id=7
10711 AND mdc.category_set_id = mic.category_set_id
10712 AND ol.INVENTORY_ITEM_ID = mic.inventory_item_id
10713 and mic.organization_id= '||''''||l_master_orgid||''''
10714 ||' and mic.category_id = '||''''||p_hold_source_rec.hold_entity_id||''''||')';
10715
10716 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for IC and H');
10717 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
10718 ,p_line_id => p_hold_source_rec.line_id
10719 ,p_org_id => p_org_id
10720 ,p_hold_entity_where_clause => l_hold_entity_where_clause
10721 ,p_item_type => p_item_type
10722 ,p_activity_name => l_activity_name
10723 ,p_activity_status => l_act_status
10724 ,p_additional_where_clause => l_additional_where_clause
10725 ,x_is_hold_applied => x_is_hold_applied);
10726 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for IC and H');
10727
10728 ELSIF p_hold_source_rec.hold_entity_code = 'IC'
10729 AND p_hold_source_rec.hold_entity_code2 IS NULL THEN
10730 --13653352, used l_master_orgid below instead of ship_from_org
10731 l_hold_entity_where_clause := ' and exists (Select 1
10732 from mtl_item_categories mic ,mtl_default_category_sets mdc
10733 where mdc.functional_area_id=7
10734 AND mdc.category_set_id = mic.category_set_id
10735 AND ol.INVENTORY_ITEM_ID = mic.inventory_item_id
10736 and mic.organization_id= '||''''||l_master_orgid||''''
10737 ||' and mic.category_id = '||''''||p_hold_source_rec.hold_entity_id||''''||')';
10738
10739
10740 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for IC');
10741 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
10742 ,p_line_id => p_hold_source_rec.line_id
10743 ,p_org_id => p_org_id
10744 ,p_hold_entity_where_clause => l_hold_entity_where_clause
10745 ,p_item_type => p_item_type
10746 ,p_activity_name => l_activity_name
10747 ,p_activity_status => l_act_status
10748 ,p_additional_where_clause => l_additional_where_clause
10749 ,x_is_hold_applied => x_is_hold_applied);
10750 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for IC');
10751
10752 -- 13990273 START
10753 -- Hold for Item Category and Ship To Site
10754 ELSIF p_hold_source_rec.hold_entity_code = 'IC' and
10755 p_hold_source_rec.hold_entity_code2 = 'S' THEN
10756
10757 l_hold_entity_where_clause := ' and ol.SHIP_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||''''
10758 ||' and exists (Select 1
10759 from mtl_item_categories mic ,mtl_default_category_sets mdc
10760 where mdc.functional_area_id=7
10761 AND mdc.category_set_id = mic.category_set_id
10762 AND ol.INVENTORY_ITEM_ID = mic.inventory_item_id
10763 and mic.organization_id= '||''''||l_master_orgid||''''
10764 ||' and mic.category_id = '||''''||p_hold_source_rec.hold_entity_id||''''||')';
10765
10766 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for IC and S');
10767 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
10768 ,p_line_id => p_hold_source_rec.line_id
10769 ,p_org_id => p_org_id
10770 ,p_hold_entity_where_clause => l_hold_entity_where_clause
10771 ,p_item_type => p_item_type
10772 ,p_activity_name => l_activity_name
10773 ,p_activity_status => l_act_status
10774 ,p_additional_where_clause => l_additional_where_clause
10775 ,x_is_hold_applied => x_is_hold_applied);
10776 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for IC and S');
10777
10778 -- 13990273 END
10779
10780 ---------ER# 13331078 end -------------------------------------------------
10781
10782 /*********************************************************
10783 HOLD CRITERIA 1 : WAREHOUSE
10784 *********************************************************/
10785 ELSIF p_hold_source_rec.hold_entity_code = 'W' and
10786 -- p_hold_source_rec.hold_entity_code2 = 'C' THEN --ER# 11824468
10787 p_hold_source_rec.hold_entity_code2 IN ('C','CN') THEN --ER# 11824468
10788
10789 --ER#7479609 start
10790 l_hold_entity_where_clause := 'and ol.SHIP_FROM_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
10791 ||' and ol.SOLD_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
10792
10793
10794 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for W and C/CN');
10795 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
10796 ,p_line_id => p_hold_source_rec.line_id
10797 ,p_org_id => p_org_id
10798 ,p_hold_entity_where_clause => l_hold_entity_where_clause
10799 ,p_item_type => p_item_type
10800 ,p_activity_name => l_activity_name
10801 ,p_activity_status => l_act_status
10802 ,p_additional_where_clause => l_additional_where_clause
10803 ,x_is_hold_applied => x_is_hold_applied);
10804 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for W and C/CN');
10805 --ER#7479609 end
10806
10807 /*ER#7479609 start
10808 IF p_hold_source_rec.line_id IS NOT NULL THEN
10809 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
10810 ( ORDER_HOLD_ID
10811 , LAST_UPDATE_DATE
10812 , LAST_UPDATED_BY
10813 , CREATION_DATE
10814 , CREATED_BY
10815 , LAST_UPDATE_LOGIN
10816 , HOLD_SOURCE_ID
10817 , HEADER_ID
10818 , LINE_ID
10819 , RELEASED_FLAG
10820 , ORG_ID
10821 )
10822 SELECT
10823 OE_ORDER_HOLDS_S.NEXTVAL
10824 , SYSDATE
10825 , :l_user_id
10826 , SYSDATE
10827 , :l_user_id
10828 , NULL
10829 , :hold_source_id
10830 , h.HEADER_ID
10831 , ol.line_id
10832 , ''N''
10833 , h.org_id --ER#7479609 :l_org_id
10834 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
10835 WHERE h.OPEN_FLAG = ''Y''
10836
10837 and h.header_id = ol.header_id
10838 and h.org_id = :l_org_id
10839 and ol.SHIP_FROM_ORG_ID = :hold_entity_id
10840 and ol.line_id = :line_id
10841 and h.SOLD_TO_ORG_ID = :hold_entity_id2
10842 and ol.OPEN_FLAG = ''Y''
10843 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
10844 and not exists ( select ''x''
10845 from oe_order_holds_ALL oh
10846 where oh.header_id = h.header_id
10847 and oh.line_id = ol.line_id
10848 and oh.hold_source_id =:hold_source_id )';
10849 IF p_item_type is not null and p_activity_name is not null then
10850 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
10851 , wf_process_activities wpa
10852 where was.process_activity = wpa.instance_id
10853 and item_type = :p_item_type
10854 and item_key = to_char(ol.line_id)
10855 and activity_name = :l_activity_name
10856 and activity_status = :l_activity_status)';
10857 END IF;
10858 IF l_additional_where_clause = 'PICK_TRUE' THEN
10859 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
10860 where w.source_line_id = ol.line_id
10861 and w.source_code = ''OE''
10862 and w.released_status in (''Y'', ''C''))';
10863 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
10864 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
10865 where wdd.source_line_id = ol.LINE_ID
10866 and wdd.source_code = ''OE''
10867 and wda.delivery_detail_id = wdd.delivery_detail_id
10868 and wda.parent_delivery_detail_id is not null)';
10869 END IF;
10870 IF p_item_type is null and p_activity_name is null then
10871 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id2, p_hold_source_rec.hold_source_id;
10872 ELSE
10873 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id,
10874 p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id2, p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
10875 IF sql%rowcount = 0 THEN
10876 x_is_hold_applied := FALSE;
10877 ELSIF sql%rowcount = 1 THEN
10878 x_is_hold_applied := TRUE;
10879 END IF;
10880 END IF;
10881 ELSE
10882 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
10883 ( ORDER_HOLD_ID
10884 , LAST_UPDATE_DATE
10885 , LAST_UPDATED_BY
10886 , CREATION_DATE
10887 , CREATED_BY
10888 , LAST_UPDATE_LOGIN
10889 , HOLD_SOURCE_ID
10890 , HEADER_ID
10891 , LINE_ID
10892 , RELEASED_FLAG
10893 , ORG_ID
10894 )
10895 SELECT
10896 OE_ORDER_HOLDS_S.NEXTVAL
10897 , SYSDATE
10898 , :l_user_id
10899 , SYSDATE
10900 , :l_user_id
10901 , NULL
10902 , :hold_source_id
10903 , h.HEADER_ID
10904 , ol.line_id
10905 , ''N''
10906 , p_org_id --ER#7479609 :l_org_id
10907 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
10908 WHERE h.OPEN_FLAG = ''Y''
10909
10910 and h.header_id = ol.header_id
10911 and h.org_id = :l_org_id --ER#7479609
10912 and ol.SHIP_FROM_ORG_ID = :hold_entity_id
10913 and h.SOLD_TO_ORG_ID = :hold_entity_id2
10914 and ol.OPEN_FLAG = ''Y''
10915 -- QUOTING change
10916 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
10917 and not exists ( select ''x''
10918 from oe_order_holds_ALL oh
10919 where oh.header_id = h.header_id
10920 and oh.line_id = ol.line_id
10921 and oh.hold_source_id =:hold_source_id )';
10922 IF p_item_type is not null and p_activity_name is not null then
10923 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
10924 , wf_process_activities wpa
10925 where was.process_activity = wpa.instance_id
10926 and item_type = :p_item_type
10927 and item_key = to_char(ol.line_id)
10928 and activity_name = :l_activity_name
10929 and activity_status = :l_activity_status)';
10930 END IF;
10931 IF l_additional_where_clause = 'PICK_TRUE' THEN
10932 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
10933 where w.source_line_id = ol.line_id
10934 and w.source_code = ''OE''
10935 and w.released_status in (''Y'', ''C''))';
10936 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
10937 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
10938 where wdd.source_line_id = ol.LINE_ID
10939 and wdd.source_code = ''OE''
10940 and wda.delivery_detail_id = wdd.delivery_detail_id
10941 and wda.parent_delivery_detail_id is not null)';
10942 END IF;
10943 IF p_item_type is null and p_activity_name is null then
10944 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_entity_id2, p_hold_source_rec.hold_source_id;
10945 ELSE
10946 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id,
10947 p_hold_source_rec.hold_entity_id2 , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
10948 l_sql_rowcount := sql%rowcount;
10949 IF l_sql_rowcount = 0 THEN
10950
10951 select meaning into l_user_activity_name
10952 from oe_lookups
10953 where lookup_type = DECODE(p_item_type,
10954 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
10955 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
10956 and lookup_code = p_activity_name;
10957
10958 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
10959 fnd_message.set_token('WF_ACT', l_user_activity_name);
10960 OE_MSG_PUB.ADD;
10961 oe_debug_pub.add(' Hold Not applied for All requested records');
10962 RAISE FND_API.G_EXC_ERROR;
10963 ELSIF l_sql_rowcount > 0 THEN
10964 SELECT count(*)
10965 into l_parent_count
10966 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
10967 WHERE h.OPEN_FLAG = 'Y'
10968 and h.header_id = ol.header_id
10969 and ol.SHIP_FROM_ORG_ID = p_hold_source_rec.hold_entity_id
10970 and h.SOLD_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
10971 and ol.OPEN_FLAG = 'Y'
10972 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
10973 and not exists ( select 'x'
10974 from oe_order_holds_ALL oh
10975 where oh.header_id = h.header_id
10976 and oh.line_id = ol.line_id
10977 and oh.hold_source_id =
10978 p_hold_source_rec.hold_source_id );
10979
10980 -- Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables.
10981
10982 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
10983
10984 select meaning into l_user_activity_name
10985 from oe_lookups
10986 where lookup_type = DECODE(p_item_type,
10987 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
10988 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
10989 and lookup_code = p_activity_name;
10990
10991 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
10992 fnd_message.set_token('WF_ACT', l_user_activity_name);
10993 OE_MSG_PUB.ADD;
10994 oe_debug_pub.add(' Hold Not applied for FEW of the requested records');
10995 END IF;
10996 END IF;
10997 END IF;
10998 END IF;
10999 ER#7479609 end*/
11000
11001 --ER#7479609 start
11002 ELSIF p_hold_source_rec.hold_entity_code = 'W' and
11003 p_hold_source_rec.hold_entity_code2 = 'SM' THEN
11004
11005
11006 l_hold_entity_where_clause := 'and ol.SHIP_FROM_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
11007 ||' and ol.SHIPPING_METHOD_CODE = '||''''||p_hold_source_rec.hold_entity_id2||'''';
11008
11009
11010 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for W and SM');
11011 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
11012 ,p_line_id => p_hold_source_rec.line_id
11013 ,p_org_id => p_org_id
11014 ,p_hold_entity_where_clause => l_hold_entity_where_clause
11015 ,p_item_type => p_item_type
11016 ,p_activity_name => l_activity_name
11017 ,p_activity_status => l_act_status
11018 ,p_additional_where_clause => l_additional_where_clause
11019 ,x_is_hold_applied => x_is_hold_applied);
11020 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for W and SM');
11021 --ER#7479609 end
11022
11023 --ER#7479609 start
11024 ELSIF p_hold_source_rec.hold_entity_code = 'W' and
11025 p_hold_source_rec.hold_entity_code2 = 'ST' THEN
11026
11027
11028 l_hold_entity_where_clause := 'and ol.SHIP_FROM_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
11029 ||' and ol.SOURCE_TYPE_CODE = '||''''||p_hold_source_rec.hold_entity_id2||'''';
11030
11031
11032 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for W and ST');
11033 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
11034 ,p_line_id => p_hold_source_rec.line_id
11035 ,p_org_id => p_org_id
11036 ,p_hold_entity_where_clause => l_hold_entity_where_clause
11037 ,p_item_type => p_item_type
11038 ,p_activity_name => l_activity_name
11039 ,p_activity_status => l_act_status
11040 ,p_additional_where_clause => l_additional_where_clause
11041 ,x_is_hold_applied => x_is_hold_applied);
11042 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for W and ST');
11043 --ER#7479609 end
11044
11045
11046 --ER#7479609 start
11047 ELSIF p_hold_source_rec.hold_entity_code = 'W' and
11048 p_hold_source_rec.hold_entity_code2 = 'LT' THEN
11049
11050
11051 l_hold_entity_where_clause := 'and ol.SHIP_FROM_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
11052 ||' and ol.LINE_TYPE_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
11053
11054
11055 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for W and LT');
11056 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
11057 ,p_line_id => p_hold_source_rec.line_id
11058 ,p_org_id => p_org_id
11059 ,p_hold_entity_where_clause => l_hold_entity_where_clause
11060 ,p_item_type => p_item_type
11061 ,p_activity_name => l_activity_name
11062 ,p_activity_status => l_act_status
11063 ,p_additional_where_clause => l_additional_where_clause
11064 ,x_is_hold_applied => x_is_hold_applied);
11065 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for W and LT');
11066 --ER#7479609 end
11067
11068 --ER#7479609 start
11069 ELSIF p_hold_source_rec.hold_entity_code = 'W' and
11070 p_hold_source_rec.hold_entity_code2 = 'D' THEN
11071
11072 l_hold_entity_where_clause := 'and ol.SHIP_FROM_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
11073 ||' and ol.DELIVER_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
11074
11075
11076 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for W and D');
11077 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
11078 ,p_line_id => p_hold_source_rec.line_id
11079 ,p_org_id => p_org_id
11080 ,p_hold_entity_where_clause => l_hold_entity_where_clause
11081 ,p_item_type => p_item_type
11082 ,p_activity_name => l_activity_name
11083 ,p_activity_status => l_act_status
11084 ,p_additional_where_clause => l_additional_where_clause
11085 ,x_is_hold_applied => x_is_hold_applied);
11086 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for W and D');
11087 --ER#7479609 end
11088
11089
11090 ELSIF p_hold_source_rec.hold_entity_code = 'W' and
11091 p_hold_source_rec.hold_entity_code2 = 'B' THEN
11092
11093 --ER#7479609 start
11094 l_hold_entity_where_clause := 'and ol.SHIP_FROM_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
11095 ||' and ol.INVOICE_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
11096
11097
11098 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for W and B');
11099 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
11100 ,p_line_id => p_hold_source_rec.line_id
11101 ,p_org_id => p_org_id
11102 ,p_hold_entity_where_clause => l_hold_entity_where_clause
11103 ,p_item_type => p_item_type
11104 ,p_activity_name => l_activity_name
11105 ,p_activity_status => l_act_status
11106 ,p_additional_where_clause => l_additional_where_clause
11107 ,x_is_hold_applied => x_is_hold_applied);
11108 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for W and B');
11109 --ER#7479609 end
11110
11111 /*ER#7479609 start
11112 IF p_hold_source_rec.line_id IS NOT NULL THEN
11113 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
11114 ( ORDER_HOLD_ID
11115 , LAST_UPDATE_DATE
11116 , LAST_UPDATED_BY
11117 , CREATION_DATE
11118 , CREATED_BY
11119 , LAST_UPDATE_LOGIN
11120 , HOLD_SOURCE_ID
11121 , HEADER_ID
11122 , LINE_ID
11123 , RELEASED_FLAG
11124 , ORG_ID
11125 )
11126 SELECT
11127 OE_ORDER_HOLDS_S.NEXTVAL
11128 , SYSDATE
11129 , :l_user_id
11130 , SYSDATE
11131 , :l_user_id
11132 , NULL
11133 , :hold_source_id
11134 , h.HEADER_ID
11135 , ol.line_id
11136 , ''N''
11137 , h.org_id --ER#7479609 :l_org_id
11138 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
11139 WHERE h.OPEN_FLAG = ''Y''
11140
11141 AND h.header_id = ol.header_id
11142 and h.org_id = :l_org_id --ER#7479609
11143 AND ol.SHIP_FROM_ORG_ID = :hold_entity_id
11144 and ol.line_id = :line_id
11145 AND ol.INVOICE_TO_ORG_ID = :hold_entity_id2
11146 and ol.OPEN_FLAG = ''Y''
11147 -- QUOTING change
11148 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
11149 AND NOT EXISTS ( select ''x''
11150 FROM oe_order_holds_ALL oh
11151 WHERE oh.header_id = h.header_id
11152 AND oh.line_id = ol.line_id
11153 AND oh.hold_source_id =:hold_source_id )';
11154 IF p_item_type is not null and p_activity_name is not null then
11155 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
11156 , wf_process_activities wpa
11157 where was.process_activity = wpa.instance_id
11158 and item_type = :p_item_type
11159 and item_key = to_char(ol.line_id)
11160 and activity_name = :l_activity_name
11161 and activity_status = :l_activity_status)';
11162 END IF;
11163 IF l_additional_where_clause = 'PICK_TRUE' THEN
11164 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
11165 where w.source_line_id = ol.line_id
11166 and w.source_code = ''OE''
11167 and w.released_status in (''Y'', ''C''))';
11168 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
11169 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
11170 where wdd.source_line_id = ol.LINE_ID
11171 and wdd.source_code = ''OE''
11172 and wda.delivery_detail_id = wdd.delivery_detail_id
11173 and wda.parent_delivery_detail_id is not null)';
11174 END IF;
11175 IF p_item_type is null and p_activity_name is null then
11176 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id2, p_hold_source_rec.hold_source_id;
11177 ELSE
11178 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id,
11179 p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id2 , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
11180 IF sql%rowcount = 0 THEN
11181 x_is_hold_applied := FALSE;
11182 ELSIF sql%rowcount = 1 THEN
11183 x_is_hold_applied := TRUE;
11184 END IF;
11185 END IF;
11186 ELSE
11187 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
11188 ( ORDER_HOLD_ID
11189 , LAST_UPDATE_DATE
11190 , LAST_UPDATED_BY
11191 , CREATION_DATE
11192 , CREATED_BY
11193 , LAST_UPDATE_LOGIN
11194 , HOLD_SOURCE_ID
11195 , HEADER_ID
11196 , LINE_ID
11197 , RELEASED_FLAG
11198 , ORG_ID
11199 )
11200 SELECT
11201 OE_ORDER_HOLDS_S.NEXTVAL
11202 , SYSDATE
11203 , :l_user_id
11204 , SYSDATE
11205 , :l_user_id
11206 , NULL
11207 , :hold_source_id
11208 , h.HEADER_ID
11209 , ol.line_id
11210 , ''N''
11211 , p_org_id --ER#7479609 :l_org_id
11212 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
11213 WHERE h.OPEN_FLAG = ''Y''
11214
11215 AND h.header_id = ol.header_id
11216 and h.org_id = :l_org_id --ER#7479609
11217 AND ol.SHIP_FROM_ORG_ID = :hold_entity_id
11218 AND ol.INVOICE_TO_ORG_ID = :hold_entity_id2
11219 and ol.OPEN_FLAG = ''Y''
11220 -- QUOTING change
11221 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
11222 AND NOT EXISTS ( select ''x''
11223 FROM oe_order_holds_ALL oh
11224 WHERE oh.header_id = h.header_id
11225 AND oh.line_id = ol.line_id
11226 AND oh.hold_source_id =:hold_source_id )';
11227 IF p_item_type is not null and p_activity_name is not null then
11228 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
11229 , wf_process_activities wpa
11230 where was.process_activity = wpa.instance_id
11231 and item_type = :p_item_type
11232 and item_key = to_char(ol.line_id)
11233 and activity_name = :l_activity_name
11234 and activity_status = :l_activity_status)';
11235 END IF;
11236 IF l_additional_where_clause = 'PICK_TRUE' THEN
11237 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
11238 where w.source_line_id = ol.line_id
11239 and w.source_code = ''OE''
11240 and w.released_status in (''Y'', ''C''))';
11241 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
11242 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
11243 where wdd.source_line_id = ol.LINE_ID
11244 and wdd.source_code = ''OE''
11245 and wda.delivery_detail_id = wdd.delivery_detail_id
11246 and wda.parent_delivery_detail_id is not null)';
11247 END IF;
11248 IF p_item_type is null and p_activity_name is null then
11249 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_entity_id2, p_hold_source_rec.hold_source_id;
11250 ELSE
11251 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id,
11252 p_hold_source_rec.hold_entity_id2 , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
11253 l_sql_rowcount := sql%rowcount;
11254 IF l_sql_rowcount = 0 THEN
11255
11256 select meaning into l_user_activity_name
11257 from oe_lookups
11258 where lookup_type = DECODE(p_item_type,
11259 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
11260 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
11261 and lookup_code = p_activity_name;
11262
11263 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
11264 fnd_message.set_token('WF_ACT', l_user_activity_name);
11265 OE_MSG_PUB.ADD;
11266 oe_debug_pub.add(' Hold Not applied for All requested records');
11267 RAISE FND_API.G_EXC_ERROR;
11268 ELSIF l_sql_rowcount > 0 THEN
11269 SELECT count(*)
11270 into l_parent_count
11271 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
11272 WHERE h.OPEN_FLAG = 'Y'
11273 AND h.header_id = ol.header_id
11274 AND ol.SHIP_FROM_ORG_ID = p_hold_source_rec.hold_entity_id
11275 AND ol.INVOICE_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
11276 and ol.OPEN_FLAG = 'Y'
11277 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
11278 and not exists ( select 'x'
11279 from oe_order_holds_ALL oh
11280 where oh.header_id = h.header_id
11281 and oh.line_id = ol.line_id
11282 and oh.hold_source_id =
11283 p_hold_source_rec.hold_source_id );
11284
11285 -- Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables.
11286
11287 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
11288
11289 select meaning into l_user_activity_name
11290 from oe_lookups
11291 where lookup_type = DECODE(p_item_type,
11292 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
11293 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
11294 and lookup_code = p_activity_name;
11295
11296 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
11297 fnd_message.set_token('WF_ACT', l_user_activity_name);
11298 OE_MSG_PUB.ADD;
11299 oe_debug_pub.add(' Hold Not applied for FEW of the requested records');
11300 END IF;
11301 END IF;
11302 END IF;
11303 END IF;
11304 ER#7479609 end*/
11305
11306 ELSIF p_hold_source_rec.hold_entity_code = 'W' and
11307 p_hold_source_rec.hold_entity_code2 = 'S' THEN
11308
11309 --ER#7479609 start
11310 l_hold_entity_where_clause := 'and ol.SHIP_FROM_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
11311 ||' and ol.SHIP_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
11312
11313
11314 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for W and S');
11315 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
11316 ,p_line_id => p_hold_source_rec.line_id
11317 ,p_org_id => p_org_id
11318 ,p_hold_entity_where_clause => l_hold_entity_where_clause
11319 ,p_item_type => p_item_type
11320 ,p_activity_name => l_activity_name
11321 ,p_activity_status => l_act_status
11322 ,p_additional_where_clause => l_additional_where_clause
11323 ,x_is_hold_applied => x_is_hold_applied);
11324 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for W and S');
11325 --ER#7479609 end
11326
11327 /*ER#7479609 start
11328 IF p_hold_source_rec.line_id IS NOT NULL THEN
11329 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
11330 ( ORDER_HOLD_ID
11331 , LAST_UPDATE_DATE
11332 , LAST_UPDATED_BY
11333 , CREATION_DATE
11334 , CREATED_BY
11335 , LAST_UPDATE_LOGIN
11336 , HOLD_SOURCE_ID
11337 , HEADER_ID
11338 , LINE_ID
11339 , RELEASED_FLAG
11340 , ORG_ID
11341 )
11342 SELECT
11343 OE_ORDER_HOLDS_S.NEXTVAL
11344 , SYSDATE
11345 , :l_user_id
11346 , SYSDATE
11347 , :l_user_id
11348 , NULL
11349 , :hold_source_id
11350 , h.HEADER_ID
11351 , ol.line_id
11352 , ''N''
11353 , h.org_id --ER#7479609 :l_org_id
11354 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
11355 WHERE h.OPEN_FLAG = ''Y''
11356 AND h.org_id = :l_org_id --ER#7479609
11357 AND ol.SHIP_FROM_ORG_ID = :hold_entity_id
11358 and ol.line_id = :line_id
11359 AND h.header_id = ol.header_id
11360 AND ol.SHIP_TO_ORG_ID = :hold_entity_id2
11361 and ol.OPEN_FLAG = ''Y''
11362 -- QUOTING change
11363 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
11364 AND NOT EXISTS ( select ''x''
11365 FROM oe_order_holds_ALL oh
11366 WHERE oh.header_id = h.header_id
11367 AND oh.line_id = ol.line_id
11368 AND oh.hold_source_id =:hold_source_id )';
11369 IF p_item_type is not null and p_activity_name is not null then
11370 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
11371 , wf_process_activities wpa
11372 where was.process_activity = wpa.instance_id
11373 and item_type = :p_item_type
11374 and item_key = to_char(ol.line_id)
11375 and activity_name = :l_activity_name
11376 and activity_status = :l_activity_status)';
11377 END IF;
11378 IF l_additional_where_clause = 'PICK_TRUE' THEN
11379 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
11380 where w.source_line_id = ol.line_id
11381 and w.source_code = ''OE''
11382 and w.released_status in (''Y'', ''C''))';
11383 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
11384 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
11385 where wdd.source_line_id = ol.LINE_ID
11386 and wdd.source_code = ''OE''
11387 and wda.delivery_detail_id = wdd.delivery_detail_id
11388 and wda.parent_delivery_detail_id is not null)';
11389 END IF;
11390 IF p_item_type is null and p_activity_name is null then
11391 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id2, p_hold_source_rec.hold_source_id;
11392 ELSE
11393 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id,
11394 p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id2 , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
11395 IF sql%rowcount = 0 THEN
11396 x_is_hold_applied := FALSE;
11397 ELSIF sql%rowcount = 1 THEN
11398 x_is_hold_applied := TRUE;
11399 END IF;
11400 END IF;
11401 ELSE
11402 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
11403 ( ORDER_HOLD_ID
11404 , LAST_UPDATE_DATE
11405 , LAST_UPDATED_BY
11406 , CREATION_DATE
11407 , CREATED_BY
11408 , LAST_UPDATE_LOGIN
11409 , HOLD_SOURCE_ID
11410 , HEADER_ID
11411 , LINE_ID
11412 , RELEASED_FLAG
11413 , ORG_ID
11414 )
11415 SELECT
11416 OE_ORDER_HOLDS_S.NEXTVAL
11417 , SYSDATE
11418 , :l_user_id
11419 , SYSDATE
11420 , :l_user_id
11421 , NULL
11422 , :hold_source_id
11423 , h.HEADER_ID
11424 , ol.line_id
11425 , ''N''
11426 , h.org_id --ER#7479609 :l_org_id
11427 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
11428 WHERE h.OPEN_FLAG = ''Y''
11429 AND h.org_id = :l_org_id --ER#7479609
11430 AND ol.SHIP_FROM_ORG_ID = :hold_entity_id
11431 AND h.header_id = ol.header_id
11432 AND ol.SHIP_TO_ORG_ID = :hold_entity_id2
11433 and ol.OPEN_FLAG = ''Y''
11434 -- QUOTING change
11435 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
11436 AND NOT EXISTS ( select ''x''
11437 FROM oe_order_holds_ALL oh
11438 WHERE oh.header_id = h.header_id
11439 AND oh.line_id = ol.line_id
11440 AND oh.hold_source_id =:hold_source_id )';
11441 IF p_item_type is not null and p_activity_name is not null then
11442 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
11443 , wf_process_activities wpa
11444 where was.process_activity = wpa.instance_id
11445 and item_type = :p_item_type
11446 and item_key = to_char(ol.line_id)
11447 and activity_name = :l_activity_name
11448 and activity_status = :l_activity_status)';
11449 END IF;
11450 IF l_additional_where_clause = 'PICK_TRUE' THEN
11451 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
11452 where w.source_line_id = ol.line_id
11453 and w.source_code = ''OE''
11454 and w.released_status in (''Y'', ''C''))';
11455 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
11456 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
11457 where wdd.source_line_id = ol.LINE_ID
11458 and wdd.source_code = ''OE''
11459 and wda.delivery_detail_id = wdd.delivery_detail_id
11460 and wda.parent_delivery_detail_id is not null)';
11461 END IF;
11462 IF p_item_type is null and p_activity_name is null then
11463 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_entity_id2, p_hold_source_rec.hold_source_id;
11464 ELSE
11465 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id,
11466 p_hold_source_rec.hold_entity_id2 , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
11467 l_sql_rowcount := sql%rowcount;
11468 IF l_sql_rowcount = 0 THEN
11469
11470 select meaning into l_user_activity_name
11471 from oe_lookups
11472 where lookup_type = DECODE(p_item_type,
11473 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
11474 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
11475 and lookup_code = p_activity_name;
11476
11477 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
11478 fnd_message.set_token('WF_ACT', l_user_activity_name);
11479 OE_MSG_PUB.ADD;
11480 oe_debug_pub.add(' Hold Not applied for All requested records');
11481 RAISE FND_API.G_EXC_ERROR;
11482 ELSIF l_sql_rowcount > 0 THEN
11483 SELECT count(*)
11484 into l_parent_count
11485 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
11486 WHERE h.OPEN_FLAG = 'Y'
11487 AND ol.SHIP_FROM_ORG_ID = p_hold_source_rec.hold_entity_id
11488 AND h.header_id = ol.header_id
11489 AND ol.SHIP_TO_ORG_ID = p_hold_source_rec.hold_entity_id2
11490 and ol.OPEN_FLAG = 'Y'
11491 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
11492 and not exists ( select 'x'
11493 from oe_order_holds_ALL oh
11494 where oh.header_id = h.header_id
11495 and oh.line_id = ol.line_id
11496 and oh.hold_source_id =
11497 p_hold_source_rec.hold_source_id );
11498
11499 -- Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables.
11500
11501 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
11502
11503 select meaning into l_user_activity_name
11504 from oe_lookups
11505 where lookup_type = DECODE(p_item_type,
11506 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
11507 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
11508 and lookup_code = p_activity_name;
11509
11510 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
11511 fnd_message.set_token('WF_ACT', l_user_activity_name);
11512 OE_MSG_PUB.ADD;
11513 oe_debug_pub.add(' Hold Not applied for FEW of the requested records');
11514 END IF;
11515 END IF;
11516 END IF;
11517 END IF;
11518 ER#7479609 end*/
11519 /*********************************************************
11520 HOLD CRITERIA 1 : SALES AGREEMENT
11521 *********************************************************/
11522
11523 ELSIF p_hold_source_rec.hold_entity_code = 'H' and
11524 p_hold_source_rec.hold_entity_code2 = 'B' THEN
11525
11526 --ER#7479609 start
11527 l_hold_entity_where_clause := 'and ol.BLANKET_NUMBER = '||''''||p_hold_source_rec.hold_entity_id||''''
11528 ||' and ol.INVOICE_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
11529
11530
11531 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for H and B');
11532 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
11533 ,p_line_id => p_hold_source_rec.line_id
11534 ,p_org_id => p_org_id
11535 ,p_hold_entity_where_clause => l_hold_entity_where_clause
11536 ,p_item_type => p_item_type
11537 ,p_activity_name => l_activity_name
11538 ,p_activity_status => l_act_status
11539 ,p_additional_where_clause => l_additional_where_clause
11540 ,x_is_hold_applied => x_is_hold_applied);
11541 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for H and B');
11542 --ER#7479609 end
11543
11544 /*ER#7479609 start
11545 IF p_hold_source_rec.line_id IS NOT NULL THEN
11546 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
11547 ( ORDER_HOLD_ID
11548 , LAST_UPDATE_DATE
11549 , LAST_UPDATED_BY
11550 , CREATION_DATE
11551 , CREATED_BY
11552 , LAST_UPDATE_LOGIN
11553 , HOLD_SOURCE_ID
11554 , HEADER_ID
11555 , LINE_ID
11556 , RELEASED_FLAG
11557 , ORG_ID
11558 )
11559 SELECT
11560 OE_ORDER_HOLDS_S.NEXTVAL
11561 , SYSDATE
11562 , :l_user_id
11563 , SYSDATE
11564 , :l_user_id
11565 , NULL
11566 , :hold_source_id
11567 , h.HEADER_ID
11568 , ol.line_id
11569 , ''N''
11570 , h.org_id --ER#7479609 :l_org_id
11571 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
11572 WHERE h.OPEN_FLAG = ''Y''
11573 and h.org_id = :l_org_id --ER#7479609
11574 and h.header_id = ol.header_id
11575 and ol.INVOICE_TO_ORG_ID = :hold_entity_id2
11576 and ol.line_id = :line_id
11577 and ol.BLANKET_NUMBER = :hold_entity_id
11578 and ol.OPEN_FLAG = ''Y''
11579 -- QUOTING change
11580 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
11581 and not exists ( select ''x''
11582 from oe_order_holds_ALL oh
11583 where oh.header_id = h.header_id
11584 and oh.line_id = ol.line_id
11585 and oh.hold_source_id =:hold_source_id )';
11586 IF p_item_type is not null and p_activity_name is not null then
11587 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
11588 , wf_process_activities wpa
11589 where was.process_activity = wpa.instance_id
11590 and item_type = :p_item_type
11591 and item_key = to_char(ol.line_id)
11592 and activity_name = :l_activity_name
11593 and activity_status = :l_activity_status)';
11594 END IF;
11595 IF l_additional_where_clause = 'PICK_TRUE' THEN
11596 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
11597 where w.source_line_id = ol.line_id
11598 and w.source_code = ''OE''
11599 and w.released_status in (''Y'', ''C''))';
11600 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
11601 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
11602 where wdd.source_line_id = ol.LINE_ID
11603 and wdd.source_code = ''OE''
11604 and wda.delivery_detail_id = wdd.delivery_detail_id
11605 and wda.parent_delivery_detail_id is not null)';
11606 END IF;
11607 IF p_item_type is null and p_activity_name is null then
11608 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
11609 ELSE
11610 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id2,
11611 p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
11612 IF sql%rowcount = 0 THEN
11613 x_is_hold_applied := FALSE;
11614 ELSIF sql%rowcount = 1 THEN
11615 x_is_hold_applied := TRUE;
11616 END IF;
11617 END IF;
11618 ELSE
11619 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
11620 ( ORDER_HOLD_ID
11621 , LAST_UPDATE_DATE
11622 , LAST_UPDATED_BY
11623 , CREATION_DATE
11624 , CREATED_BY
11625 , LAST_UPDATE_LOGIN
11626 , HOLD_SOURCE_ID
11627 , HEADER_ID
11628 , LINE_ID
11629 , RELEASED_FLAG
11630 , ORG_ID
11631 )
11632 SELECT
11633 OE_ORDER_HOLDS_S.NEXTVAL
11634 , SYSDATE
11635 , :l_user_id
11636 , SYSDATE
11637 , :l_user_id
11638 , NULL
11639 , :hold_source_id
11640 , h.HEADER_ID
11641 , ol.line_id
11642 , ''N''
11643 , h.org_id --ER#7479609 :l_org_id
11644 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
11645 WHERE h.OPEN_FLAG = ''Y''
11646 and h.org_id = :l_org_id --ER#7479609
11647 and h.header_id = ol.header_id
11648 and ol.INVOICE_TO_ORG_ID= :hold_entity_id2
11649 and ol.BLANKET_NUMBER = :hold_entity_id
11650 and ol.OPEN_FLAG = ''Y''
11651 -- QUOTING change
11652 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
11653 and not exists ( select ''x''
11654 from oe_order_holds_ALL oh
11655 where oh.header_id = h.header_id
11656 and oh.line_id = ol.line_id
11657 and oh.hold_source_id =:hold_source_id )';
11658 IF p_item_type is not null and p_activity_name is not null then
11659 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
11660 , wf_process_activities wpa
11661 where was.process_activity = wpa.instance_id
11662 and item_type = :p_item_type
11663 and item_key = to_char(ol.line_id)
11664 and activity_name = :l_activity_name
11665 and activity_status = :l_activity_status)';
11666 END IF;
11667 IF l_additional_where_clause = 'PICK_TRUE' THEN
11668 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
11669 where w.source_line_id = ol.line_id
11670 and w.source_code = ''OE''
11671 and w.released_status in (''Y'', ''C''))';
11672 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
11673 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
11674 where wdd.source_line_id = ol.LINE_ID
11675 and wdd.source_code = ''OE''
11676 and wda.delivery_detail_id = wdd.delivery_detail_id
11677 and wda.parent_delivery_detail_id is not null)';
11678 END IF;
11679 IF p_item_type is null and p_activity_name is null then
11680 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id2, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
11681 ELSE
11682 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id2,
11683 p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
11684 l_sql_rowcount := sql%rowcount;
11685 IF l_sql_rowcount = 0 THEN
11686
11687 select meaning into l_user_activity_name
11688 from oe_lookups
11689 where lookup_type = DECODE(p_item_type,
11690 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
11691 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
11692 and lookup_code = p_activity_name;
11693
11694 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
11695 fnd_message.set_token('WF_ACT', l_user_activity_name);
11696 OE_MSG_PUB.ADD;
11697 oe_debug_pub.add(' Hold Not applied for All requested records');
11698 RAISE FND_API.G_EXC_ERROR;
11699 ELSIF l_sql_rowcount > 0 THEN
11700 SELECT count(*)
11701 into l_parent_count
11702 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
11703 WHERE h.OPEN_FLAG = 'Y'
11704 and h.header_id = ol.header_id
11705 and ol.INVOICE_TO_ORG_ID= p_hold_source_rec.hold_entity_id2
11706 and ol.BLANKET_NUMBER = p_hold_source_rec.hold_entity_id
11707 and ol.OPEN_FLAG = 'Y'
11708 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
11709 and not exists ( select 'x'
11710 from oe_order_holds_ALL oh
11711 where oh.header_id = h.header_id
11712 and oh.line_id = ol.line_id
11713 and oh.hold_source_id =
11714 p_hold_source_rec.hold_source_id );
11715
11716 -- Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables.
11717
11718 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
11719
11720 select meaning into l_user_activity_name
11721 from oe_lookups
11722 where lookup_type = DECODE(p_item_type,
11723 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
11724 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
11725 and lookup_code = p_activity_name;
11726
11727 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
11728 fnd_message.set_token('WF_ACT', l_user_activity_name);
11729 OE_MSG_PUB.ADD;
11730 oe_debug_pub.add(' Hold Not applied for FEW of the requested records');
11731 END IF;
11732 END IF;
11733 END IF;
11734 END IF;
11735 ER#7479609 end*/
11736
11737
11738 --ER#7479609 start
11739 ELSIF p_hold_source_rec.hold_entity_code = 'H' and
11740 p_hold_source_rec.hold_entity_code2 = 'PT' THEN
11741
11742 l_hold_entity_where_clause := 'and ol.BLANKET_NUMBER = '||''''||p_hold_source_rec.hold_entity_id||''''
11743 ||' and ol.PAYMENT_TERM_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
11744
11745
11746 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for H and PT');
11747 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
11748 ,p_line_id => p_hold_source_rec.line_id
11749 ,p_org_id => p_org_id
11750 ,p_hold_entity_where_clause => l_hold_entity_where_clause
11751 ,p_item_type => p_item_type
11752 ,p_activity_name => l_activity_name
11753 ,p_activity_status => l_act_status
11754 ,p_additional_where_clause => l_additional_where_clause
11755 ,x_is_hold_applied => x_is_hold_applied);
11756 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for H and PT');
11757 --ER#7479609 end
11758
11759
11760 --ER#7479609 start
11761 ELSIF p_hold_source_rec.hold_entity_code = 'H' and
11762 p_hold_source_rec.hold_entity_code2 = 'PL' THEN
11763
11764 l_hold_entity_where_clause := 'and ol.BLANKET_NUMBER = '||''''||p_hold_source_rec.hold_entity_id||''''
11765 ||' and ol.PRICE_LIST_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
11766
11767
11768 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for H and PL');
11769 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
11770 ,p_line_id => p_hold_source_rec.line_id
11771 ,p_org_id => p_org_id
11772 ,p_hold_entity_where_clause => l_hold_entity_where_clause
11773 ,p_item_type => p_item_type
11774 ,p_activity_name => l_activity_name
11775 ,p_activity_status => l_act_status
11776 ,p_additional_where_clause => l_additional_where_clause
11777 ,x_is_hold_applied => x_is_hold_applied);
11778 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for H and PL');
11779 --ER#7479609 end
11780
11781
11782 --ER#7479609 start
11783 ELSIF p_hold_source_rec.hold_entity_code = 'H' and
11784 p_hold_source_rec.hold_entity_code2 = 'D' THEN
11785
11786 l_hold_entity_where_clause := 'and ol.BLANKET_NUMBER = '||''''||p_hold_source_rec.hold_entity_id||''''
11787 ||' and ol.DELIVER_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
11788
11789
11790 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for H and D');
11791 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
11792 ,p_line_id => p_hold_source_rec.line_id
11793 ,p_org_id => p_org_id
11794 ,p_hold_entity_where_clause => l_hold_entity_where_clause
11795 ,p_item_type => p_item_type
11796 ,p_activity_name => l_activity_name
11797 ,p_activity_status => l_act_status
11798 ,p_additional_where_clause => l_additional_where_clause
11799 ,x_is_hold_applied => x_is_hold_applied);
11800 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for H and D');
11801 --ER#7479609 end
11802
11803
11804 --ER#7479609 start
11805 ELSIF p_hold_source_rec.hold_entity_code = 'H' and
11806 p_hold_source_rec.hold_entity_code2 = 'LT' THEN
11807
11808 l_hold_entity_where_clause := 'and ol.BLANKET_NUMBER = '||''''||p_hold_source_rec.hold_entity_id||''''
11809 ||' and ol.LINE_TYPE_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
11810
11811
11812 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for H and LT');
11813 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
11814 ,p_line_id => p_hold_source_rec.line_id
11815 ,p_org_id => p_org_id
11816 ,p_hold_entity_where_clause => l_hold_entity_where_clause
11817 ,p_item_type => p_item_type
11818 ,p_activity_name => l_activity_name
11819 ,p_activity_status => l_act_status
11820 ,p_additional_where_clause => l_additional_where_clause
11821 ,x_is_hold_applied => x_is_hold_applied);
11822 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for H and LT');
11823 --ER#7479609 end
11824
11825 --ER#7479609 start
11826 ELSIF p_hold_source_rec.hold_entity_code = 'H' and
11827 p_hold_source_rec.hold_entity_code2 = 'SM' THEN
11828
11829 l_hold_entity_where_clause := 'and ol.BLANKET_NUMBER = '||''''||p_hold_source_rec.hold_entity_id||''''
11830 ||' and ol.SHIPPING_METHOD_CODE = '||''''||p_hold_source_rec.hold_entity_id2||'''';
11831
11832
11833 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for H and SM');
11834 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
11835 ,p_line_id => p_hold_source_rec.line_id
11836 ,p_org_id => p_org_id
11837 ,p_hold_entity_where_clause => l_hold_entity_where_clause
11838 ,p_item_type => p_item_type
11839 ,p_activity_name => l_activity_name
11840 ,p_activity_status => l_act_status
11841 ,p_additional_where_clause => l_additional_where_clause
11842 ,x_is_hold_applied => x_is_hold_applied);
11843 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for H and SM');
11844 --ER#7479609 end
11845
11846
11847 ELSIF p_hold_source_rec.hold_entity_code = 'H' and
11848 p_hold_source_rec.hold_entity_code2 = 'S' THEN
11849
11850 --ER#7479609 start
11851 l_hold_entity_where_clause := 'and ol.BLANKET_NUMBER = '||''''||p_hold_source_rec.hold_entity_id||''''
11852 ||' and ol.SHIP_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
11853
11854
11855 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for H and S');
11856 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
11857 ,p_line_id => p_hold_source_rec.line_id
11858 ,p_org_id => p_org_id
11859 ,p_hold_entity_where_clause => l_hold_entity_where_clause
11860 ,p_item_type => p_item_type
11861 ,p_activity_name => l_activity_name
11862 ,p_activity_status => l_act_status
11863 ,p_additional_where_clause => l_additional_where_clause
11864 ,x_is_hold_applied => x_is_hold_applied);
11865 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for H and S');
11866 --ER#7479609 end
11867
11868 /*ER#7479609 start
11869 IF p_hold_source_rec.line_id IS NOT NULL THEN
11870 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
11871 ( ORDER_HOLD_ID
11872 , LAST_UPDATE_DATE
11873 , LAST_UPDATED_BY
11874 , CREATION_DATE
11875 , CREATED_BY
11876 , LAST_UPDATE_LOGIN
11877 , HOLD_SOURCE_ID
11878 , HEADER_ID
11879 , LINE_ID
11880 , RELEASED_FLAG
11881 , ORG_ID
11882 )
11883 SELECT
11884 OE_ORDER_HOLDS_S.NEXTVAL
11885 , SYSDATE
11886 , :l_user_id
11887 , SYSDATE
11888 , :l_user_id
11889 , NULL
11890 , :hold_source_id
11891 , h.HEADER_ID
11892 , ol.line_id
11893 , ''N''
11894 , h.org_id --ER#7479609 :l_org_id
11895 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
11896 WHERE h.OPEN_FLAG = ''Y''
11897 and h.org_id = :l_org_id --ER#7479609
11898 and h.header_id = ol.header_id
11899 and ol.SHIP_TO_ORG_ID = :hold_entity_id2
11900 and ol.line_id = :line_id
11901 and ol.BLANKET_NUMBER = :hold_entity_id
11902 and ol.OPEN_FLAG = ''Y''
11903 -- QUOTING change
11904 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
11905 and not exists ( select ''x''
11906 from oe_order_holds_ALL oh
11907 where oh.header_id = h.header_id
11908 and oh.line_id = ol.line_id
11909 and oh.hold_source_id =:hold_source_id )';
11910 IF p_item_type is not null and p_activity_name is not null then
11911 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
11912 , wf_process_activities wpa
11913 where was.process_activity = wpa.instance_id
11914 and item_type = :p_item_type
11915 and item_key = to_char(ol.line_id)
11916 and activity_name = :l_activity_name
11917 and activity_status = :l_activity_status)';
11918 END IF;
11919 IF l_additional_where_clause = 'PICK_TRUE' THEN
11920 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
11921 where w.source_line_id = ol.line_id
11922 and w.source_code = ''OE''
11923 and w.released_status in (''Y'', ''C''))';
11924 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
11925 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
11926 where wdd.source_line_id = ol.LINE_ID
11927 and wdd.source_code = ''OE''
11928 and wda.delivery_detail_id = wdd.delivery_detail_id
11929 and wda.parent_delivery_detail_id is not null)';
11930 END IF;
11931 IF p_item_type is null and p_activity_name is null then
11932 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id2, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
11933 ELSE
11934 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id2,
11935 p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
11936 IF sql%rowcount = 0 THEN
11937 x_is_hold_applied := FALSE;
11938 ELSIF sql%rowcount = 1 THEN
11939 x_is_hold_applied := TRUE;
11940 END IF;
11941 END IF;
11942 ELSE
11943 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
11944 ( ORDER_HOLD_ID
11945 , LAST_UPDATE_DATE
11946 , LAST_UPDATED_BY
11947 , CREATION_DATE
11948 , CREATED_BY
11949 , LAST_UPDATE_LOGIN
11950 , HOLD_SOURCE_ID
11951 , HEADER_ID
11952 , LINE_ID
11953 , RELEASED_FLAG
11954 , ORG_ID
11955 )
11956 SELECT
11957 OE_ORDER_HOLDS_S.NEXTVAL
11958 , SYSDATE
11959 , :l_user_id
11960 , SYSDATE
11961 , :l_user_id
11962 , NULL
11963 , :hold_source_id
11964 , h.HEADER_ID
11965 , ol.line_id
11966 , ''N''
11967 , h.org_id --ER#7479609 :l_org_id
11968 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
11969 WHERE h.OPEN_FLAG = ''Y''
11970 and h.org_id = :l_org_id --ER#7479609
11971 and h.header_id = ol.header_id
11972 and ol.SHIP_TO_ORG_ID= :hold_entity_id2
11973 and ol.BLANKET_NUMBER = :hold_entity_id
11974 and ol.OPEN_FLAG = ''Y''
11975 -- QUOTING change
11976 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
11977 and not exists ( select ''x''
11978 from oe_order_holds_ALL oh
11979 where oh.header_id = h.header_id
11980 and oh.line_id = ol.line_id
11981 and oh.hold_source_id =:hold_source_id )';
11982 IF p_item_type is not null and p_activity_name is not null then
11983 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
11984 , wf_process_activities wpa
11985 where was.process_activity = wpa.instance_id
11986 and item_type = :p_item_type
11987 and item_key = to_char(ol.line_id)
11988 and activity_name = :l_activity_name
11989 and activity_status = :l_activity_status)';
11990 END IF;
11991 IF l_additional_where_clause = 'PICK_TRUE' THEN
11992 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
11993 where w.source_line_id = ol.line_id
11994 and w.source_code = ''OE''
11995 and w.released_status in (''Y'', ''C''))';
11996 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
11997 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
11998 where wdd.source_line_id = ol.LINE_ID
11999 and wdd.source_code = ''OE''
12000 and wda.delivery_detail_id = wdd.delivery_detail_id
12001 and wda.parent_delivery_detail_id is not null)';
12002 END IF;
12003 IF p_item_type is null and p_activity_name is null then
12004 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id2, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
12005 ELSE
12006 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id2,
12007 p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
12008 l_sql_rowcount := sql%rowcount;
12009
12010 IF l_sql_rowcount = 0 THEN
12011
12012 select meaning into l_user_activity_name
12013 from oe_lookups
12014 where lookup_type = DECODE(p_item_type,
12015 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
12016 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
12017 and lookup_code = p_activity_name;
12018
12019 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
12020 fnd_message.set_token('WF_ACT', l_user_activity_name);
12021 OE_MSG_PUB.ADD;
12022 oe_debug_pub.add(' Hold Not applied for All requested records');
12023 RAISE FND_API.G_EXC_ERROR;
12024 ELSIF l_sql_rowcount > 0 THEN
12025 SELECT count(*)
12026 into l_parent_count
12027 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
12028 WHERE h.OPEN_FLAG = 'Y'
12029 and h.header_id = ol.header_id
12030 and ol.SHIP_TO_ORG_ID= p_hold_source_rec.hold_entity_id2
12031 and ol.BLANKET_NUMBER = p_hold_source_rec.hold_entity_id
12032 and ol.OPEN_FLAG = 'Y'
12033 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
12034 and not exists ( select 'x'
12035 from oe_order_holds_ALL oh
12036 where oh.header_id = h.header_id
12037 and oh.line_id = ol.line_id
12038 and oh.hold_source_id =
12039 p_hold_source_rec.hold_source_id );
12040
12041 -- Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables.
12042
12043 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
12044
12045 select meaning into l_user_activity_name
12046 from oe_lookups
12047 where lookup_type = DECODE(p_item_type,
12048 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
12049 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
12050 and lookup_code = p_activity_name;
12051
12052 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
12053 fnd_message.set_token('WF_ACT', l_user_activity_name);
12054 OE_MSG_PUB.ADD;
12055 oe_debug_pub.add(' Hold Not applied for FEW of the requested records');
12056 END IF;
12057 END IF;
12058 END IF;
12059 END IF;
12060 ER#7479609 end*/
12061
12062 ELSIF p_hold_source_rec.hold_entity_code = 'H' and
12063 p_hold_source_rec.hold_entity_code2 = 'W' THEN
12064
12065 --ER#7479609 start
12066 l_hold_entity_where_clause := 'and ol.BLANKET_NUMBER = '||''''||p_hold_source_rec.hold_entity_id||''''
12067 ||' and ol.SHIP_FROM_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
12068
12069
12070 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for H and W');
12071 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
12072 ,p_line_id => p_hold_source_rec.line_id
12073 ,p_org_id => p_org_id
12074 ,p_hold_entity_where_clause => l_hold_entity_where_clause
12075 ,p_item_type => p_item_type
12076 ,p_activity_name => l_activity_name
12077 ,p_activity_status => l_act_status
12078 ,p_additional_where_clause => l_additional_where_clause
12079 ,x_is_hold_applied => x_is_hold_applied);
12080 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for H and W');
12081 --ER#7479609 end
12082
12083 /*ER#7479609 start
12084 IF p_hold_source_rec.line_id IS NOT NULL THEN
12085 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
12086 ( ORDER_HOLD_ID
12087 , LAST_UPDATE_DATE
12088 , LAST_UPDATED_BY
12089 , CREATION_DATE
12090 , CREATED_BY
12091 , LAST_UPDATE_LOGIN
12092 , HOLD_SOURCE_ID
12093 , HEADER_ID
12094 , LINE_ID
12095 , RELEASED_FLAG
12096 , ORG_ID
12097 )
12098 SELECT
12099 OE_ORDER_HOLDS_S.NEXTVAL
12100 , SYSDATE
12101 , :l_user_id
12102 , SYSDATE
12103 , :l_user_id
12104 , NULL
12105 , :hold_source_id
12106 , h.HEADER_ID
12107 , ol.line_id
12108 , ''N''
12109 , h.org_id --ER#7479609 :l_org_id
12110 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
12111 WHERE h.OPEN_FLAG = ''Y''
12112 and h.org_id = :l_org_id --ER#7479609
12113 and h.header_id = ol.header_id
12114 and ol.SHIP_FROM_ORG_ID = :hold_entity_id2
12115 and ol.line_id = :line_id
12116 and ol.BLANKET_NUMBER = :hold_entity_id
12117 and ol.OPEN_FLAG = ''Y''
12118 -- QUOTING change
12119 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
12120 and not exists ( select ''x''
12121 from oe_order_holds_ALL oh
12122 where oh.header_id = h.header_id
12123 and oh.line_id = ol.line_id
12124 and oh.hold_source_id =:hold_source_id )';
12125 IF p_item_type is not null and p_activity_name is not null then
12126 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
12127 , wf_process_activities wpa
12128 where was.process_activity = wpa.instance_id
12129 and item_type = :p_item_type
12130 and item_key = to_char(ol.line_id)
12131 and activity_name = :l_activity_name
12132 and activity_status = :l_activity_status)';
12133 END IF;
12134 IF l_additional_where_clause = 'PICK_TRUE' THEN
12135 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
12136 where w.source_line_id = ol.line_id
12137 and w.source_code = ''OE''
12138 and w.released_status in (''Y'', ''C''))';
12139 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
12140 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
12141 where wdd.source_line_id = ol.LINE_ID
12142 and wdd.source_code = ''OE''
12143 and wda.delivery_detail_id = wdd.delivery_detail_id
12144 and wda.parent_delivery_detail_id is not null)';
12145 END IF;
12146 IF p_item_type is null and p_activity_name is null then
12147 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
12148 ELSE
12149 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id2,
12150 p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
12151 IF sql%rowcount = 0 THEN
12152 x_is_hold_applied := FALSE;
12153 ELSIF sql%rowcount = 1 THEN
12154 x_is_hold_applied := TRUE;
12155 END IF;
12156 END IF;
12157 ELSE
12158 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
12159 ( ORDER_HOLD_ID
12160 , LAST_UPDATE_DATE
12161 , LAST_UPDATED_BY
12162 , CREATION_DATE
12163 , CREATED_BY
12164 , LAST_UPDATE_LOGIN
12165 , HOLD_SOURCE_ID
12166 , HEADER_ID
12167 , LINE_ID
12168 , RELEASED_FLAG
12169 , ORG_ID
12170 )
12171 SELECT
12172 OE_ORDER_HOLDS_S.NEXTVAL
12173 , SYSDATE
12174 , :l_user_id
12175 , SYSDATE
12176 , :l_user_id
12177 , NULL
12178 , :hold_source_id
12179 , h.HEADER_ID
12180 , ol.line_id
12181 , ''N''
12182 , h.org_id --ER#7479609 :l_org_id
12183 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
12184 WHERE h.OPEN_FLAG = ''Y''
12185 and h.org_id = :l_org_id --ER#7479609
12186 and h.header_id = ol.header_id
12187 and ol.SHIP_FROM_ORG_ID= :hold_entity_id2
12188 and ol.BLANKET_NUMBER = :hold_entity_id
12189 and ol.OPEN_FLAG = ''Y''
12190 -- QUOTING change
12191 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
12192 and not exists ( select ''x''
12193 from oe_order_holds_ALL oh
12194 where oh.header_id = h.header_id
12195 and oh.line_id = ol.line_id
12196 and oh.hold_source_id =:hold_source_id )';
12197 IF p_item_type is not null and p_activity_name is not null then
12198 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
12199 , wf_process_activities wpa
12200 where was.process_activity = wpa.instance_id
12201 and item_type = :p_item_type
12202 and item_key = to_char(ol.line_id)
12203 and activity_name = :l_activity_name
12204 and activity_status = :l_activity_status)';
12205 END IF;
12206 IF l_additional_where_clause = 'PICK_TRUE' THEN
12207 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
12208 where w.source_line_id = ol.line_id
12209 and w.source_code = ''OE''
12210 and w.released_status in (''Y'', ''C''))';
12211 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
12212 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
12213 where wdd.source_line_id = ol.LINE_ID
12214 and wdd.source_code = ''OE''
12215 and wda.delivery_detail_id = wdd.delivery_detail_id
12216 and wda.parent_delivery_detail_id is not null)';
12217 END IF;
12218 IF p_item_type is null and p_activity_name is null then
12219 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
12220 ELSE
12221 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2,
12222 p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
12223 l_sql_rowcount := sql%rowcount;
12224 IF l_sql_rowcount = 0 THEN
12225
12226 select meaning into l_user_activity_name
12227 from oe_lookups
12228 where lookup_type = DECODE(p_item_type,
12229 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
12230 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
12231 and lookup_code = p_activity_name;
12232
12233 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
12234 fnd_message.set_token('WF_ACT', l_user_activity_name);
12235 OE_MSG_PUB.ADD;
12236 oe_debug_pub.add(' Hold Not applied for All requested records');
12237 RAISE FND_API.G_EXC_ERROR;
12238 ELSIF l_sql_rowcount > 0 THEN
12239 SELECT count(*)
12240 into l_parent_count
12241 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
12242 WHERE h.OPEN_FLAG = 'Y'
12243 and h.header_id = ol.header_id
12244 and ol.SHIP_FROM_ORG_ID= p_hold_source_rec.hold_entity_id2
12245 and ol.BLANKET_NUMBER = p_hold_source_rec.hold_entity_id
12246 and ol.OPEN_FLAG = 'Y'
12247 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
12248 and not exists ( select 'x'
12249 from oe_order_holds_ALL oh
12250 where oh.header_id = h.header_id
12251 and oh.line_id = ol.line_id
12252 and oh.hold_source_id =
12253 p_hold_source_rec.hold_source_id );
12254
12255 -- Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables.
12256
12257 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
12258
12259 select meaning into l_user_activity_name
12260 from oe_lookups
12261 where lookup_type = DECODE(p_item_type,
12262 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
12263 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
12264 and lookup_code = p_activity_name;
12265
12266 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
12267 fnd_message.set_token('WF_ACT', l_user_activity_name);
12268 OE_MSG_PUB.ADD;
12269 oe_debug_pub.add(' Hold Not applied for FEW of the requested records');
12270 END IF;
12271 END IF;
12272 END IF;
12273 END IF;
12274 ER#7479609 end*/
12275
12276 ELSIF p_hold_source_rec.hold_entity_code = 'H' and
12277 p_hold_source_rec.hold_entity_code2 = 'L' THEN
12278
12279 --ER#7479609 start
12280 l_hold_entity_where_clause := 'and ol.BLANKET_NUMBER = '||''''||p_hold_source_rec.hold_entity_id||''''
12281 ||' and ol.BLANKET_LINE_NUMBER = '||''''||p_hold_source_rec.hold_entity_id2||'''';
12282
12283
12284 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for H and L');
12285 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
12286 ,p_line_id => p_hold_source_rec.line_id
12287 ,p_org_id => p_org_id
12288 ,p_hold_entity_where_clause => l_hold_entity_where_clause
12289 ,p_item_type => p_item_type
12290 ,p_activity_name => l_activity_name
12291 ,p_activity_status => l_act_status
12292 ,p_additional_where_clause => l_additional_where_clause
12293 ,x_is_hold_applied => x_is_hold_applied);
12294 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for H and L');
12295 --ER#7479609 end
12296
12297 /*ER#7479609 start
12298 IF p_hold_source_rec.line_id IS NOT NULL THEN
12299 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
12300 ( ORDER_HOLD_ID
12301 , LAST_UPDATE_DATE
12302 , LAST_UPDATED_BY
12303 , CREATION_DATE
12304 , CREATED_BY
12305 , LAST_UPDATE_LOGIN
12306 , HOLD_SOURCE_ID
12307 , HEADER_ID
12308 , LINE_ID
12309 , RELEASED_FLAG
12310 , ORG_ID
12311 )
12312 SELECT
12313 OE_ORDER_HOLDS_S.NEXTVAL
12314 , SYSDATE
12315 , :l_user_id
12316 , SYSDATE
12317 , :l_user_id
12318 , NULL
12319 , :hold_source_id
12320 , h.HEADER_ID
12321 , ol.line_id
12322 , ''N''
12323 , h.org_id --ER#7479609 :l_org_id
12324 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
12325 WHERE h.OPEN_FLAG = ''Y''
12326 and h.org_id = :l_org_id --ER#7479609
12327 and h.header_id = ol.header_id
12328 and ol.BLANKET_LINE_NUMBER = :hold_entity_id2
12329 and ol.line_id = :line_id
12330 and ol.BLANKET_NUMBER = :hold_entity_id
12331 and ol.OPEN_FLAG = ''Y''
12332 -- QUOTING change
12333 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
12334 and not exists ( select ''x''
12335 from oe_order_holds_ALL oh
12336 where oh.header_id = h.header_id
12337 and oh.line_id = ol.line_id
12338 and oh.hold_source_id =:hold_source_id )';
12339 IF p_item_type is not null and p_activity_name is not null then
12340 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
12341 , wf_process_activities wpa
12342 where was.process_activity = wpa.instance_id
12343 and item_type = :p_item_type
12344 and item_key = to_char(ol.line_id)
12345 and activity_name = :l_activity_name
12346 and activity_status = :l_activity_status)';
12347 END IF;
12348 IF l_additional_where_clause = 'PICK_TRUE' THEN
12349 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
12350 where w.source_line_id = ol.line_id
12351 and w.source_code = ''OE''
12352 and w.released_status in (''Y'', ''C''))';
12353 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
12354 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
12355 where wdd.source_line_id = ol.LINE_ID
12356 and wdd.source_code = ''OE''
12357 and wda.delivery_detail_id = wdd.delivery_detail_id
12358 and wda.parent_delivery_detail_id is not null)';
12359 END IF;
12360 IF p_item_type is null and p_activity_name is null then
12361 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
12362 ELSE
12363 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id2,
12364 p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
12365 IF sql%rowcount = 0 THEN
12366 x_is_hold_applied := FALSE;
12367 ELSIF sql%rowcount = 1 THEN
12368 x_is_hold_applied := TRUE;
12369 END IF;
12370 END IF;
12371 ELSE
12372 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
12373 ( ORDER_HOLD_ID
12374 , LAST_UPDATE_DATE
12375 , LAST_UPDATED_BY
12376 , CREATION_DATE
12377 , CREATED_BY
12378 , LAST_UPDATE_LOGIN
12379 , HOLD_SOURCE_ID
12380 , HEADER_ID
12381 , LINE_ID
12382 , RELEASED_FLAG
12383 , ORG_ID
12384 )
12385 SELECT
12386 OE_ORDER_HOLDS_S.NEXTVAL
12387 , SYSDATE
12388 , :l_user_id
12389 , SYSDATE
12390 , :l_user_id
12391 , NULL
12392 , :hold_source_id
12393 , h.HEADER_ID
12394 , ol.line_id
12395 , ''N''
12396 , h.org_id --ER#7479609 :l_org_id
12397 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
12398 WHERE h.OPEN_FLAG = ''Y''
12399 and h.org_id = :l_org_id --ER#7479609
12400 and h.header_id = ol.header_id
12401 and ol.BLANKET_LINE_NUMBER = :hold_entity_id2
12402 and ol.BLANKET_NUMBER = :hold_entity_id
12403 and ol.OPEN_FLAG = ''Y''
12404 -- QUOTING change
12405 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
12406 and not exists ( select ''x''
12407 from oe_order_holds_ALL oh
12408 where oh.header_id = h.header_id
12409 and oh.line_id = ol.line_id
12410 and oh.hold_source_id =:hold_source_id )';
12411 IF p_item_type is not null and p_activity_name is not null then
12412 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
12413 , wf_process_activities wpa
12414 where was.process_activity = wpa.instance_id
12415 and item_type = :p_item_type
12416 and item_key = to_char(ol.line_id)
12417 and activity_name = :l_activity_name
12418 and activity_status = :l_activity_status)';
12419 END IF;
12420 IF l_additional_where_clause = 'PICK_TRUE' THEN
12421 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
12422 where w.source_line_id = ol.line_id
12423 and w.source_code = ''OE''
12424 and w.released_status in (''Y'', ''C''))';
12425 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
12426 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
12427 where wdd.source_line_id = ol.LINE_ID
12428 and wdd.source_code = ''OE''
12429 and wda.delivery_detail_id = wdd.delivery_detail_id
12430 and wda.parent_delivery_detail_id is not null)';
12431 END IF;
12432 IF p_item_type is null and p_activity_name is null then
12433 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id2, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
12434 ELSE
12435 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id2,
12436 p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
12437 l_sql_rowcount := sql%rowcount;
12438 IF l_sql_rowcount = 0 THEN
12439
12440 select meaning into l_user_activity_name
12441 from oe_lookups
12442 where lookup_type = DECODE(p_item_type,
12443 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
12444 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
12445 and lookup_code = p_activity_name;
12446
12447 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
12448 fnd_message.set_token('WF_ACT', l_user_activity_name);
12449 OE_MSG_PUB.ADD;
12450 oe_debug_pub.add(' Hold Not applied for All requested records');
12451 RAISE FND_API.G_EXC_ERROR;
12452 ELSIF l_sql_rowcount > 0 THEN
12453 SELECT count(*)
12454 into l_parent_count
12455 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
12456 WHERE h.OPEN_FLAG = 'Y'
12457 and h.header_id = ol.header_id
12458 and ol.BLANKET_LINE_NUMBER = p_hold_source_rec.hold_entity_id2
12459 and ol.BLANKET_NUMBER = p_hold_source_rec.hold_entity_id
12460 and ol.OPEN_FLAG = 'Y'
12461 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
12462 and not exists ( select 'x'
12463 from oe_order_holds_ALL oh
12464 where oh.header_id = h.header_id
12465 and oh.line_id = ol.line_id
12466 and oh.hold_source_id =
12467 p_hold_source_rec.hold_source_id );
12468
12469 -- Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables.
12470
12471 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
12472
12473 select meaning into l_user_activity_name
12474 from oe_lookups
12475 where lookup_type = DECODE(p_item_type,
12476 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
12477 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
12478 and lookup_code = p_activity_name;
12479
12480 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
12481 fnd_message.set_token('WF_ACT', l_user_activity_name);
12482 OE_MSG_PUB.ADD;
12483 oe_debug_pub.add(' Hold Not applied for FEW of the requested records');
12484 END IF;
12485 END IF;
12486 END IF;
12487 END IF;
12488 ER#7479609 end*/
12489
12490 ELSIF p_hold_source_rec.hold_entity_code = 'H'
12491 AND p_hold_source_rec.hold_entity_code2 IS NULL THEN
12492
12493 --ER#7479609 start
12494 l_hold_entity_where_clause := 'and ol.BLANKET_NUMBER = '||''''||p_hold_source_rec.hold_entity_id||'''';
12495
12496
12497 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for H');
12498 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
12499 ,p_line_id => p_hold_source_rec.line_id
12500 ,p_org_id => p_org_id
12501 ,p_hold_entity_where_clause => l_hold_entity_where_clause
12502 ,p_item_type => p_item_type
12503 ,p_activity_name => l_activity_name
12504 ,p_activity_status => l_act_status
12505 ,p_additional_where_clause => l_additional_where_clause
12506 ,x_is_hold_applied => x_is_hold_applied);
12507 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for H');
12508 --ER#7479609 end
12509
12510 /*ER#7479609 start
12511 IF p_hold_source_rec.line_id IS NOT NULL THEN
12512 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
12513 ( ORDER_HOLD_ID
12514 , LAST_UPDATE_DATE
12515 , LAST_UPDATED_BY
12516 , CREATION_DATE
12517 , CREATED_BY
12518 , LAST_UPDATE_LOGIN
12519 , HOLD_SOURCE_ID
12520 , HEADER_ID
12521 , LINE_ID
12522 , RELEASED_FLAG
12523 , ORG_ID
12524 )
12525 SELECT
12526 OE_ORDER_HOLDS_S.NEXTVAL
12527 , SYSDATE
12528 , :l_user_id
12529 , SYSDATE
12530 , :l_user_id
12531 , NULL
12532 , :hold_source_id
12533 , h.HEADER_ID
12534 , ol.line_id
12535 , ''N''
12536 , h.org_id --ER#7479609 :l_org_id
12537 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
12538 WHERE h.OPEN_FLAG = ''Y''
12539 and h.org_id = :l_org_id --ER#7479609
12540 and h.header_id = ol.header_id
12541 and ol.line_id = :line_id
12542 and ol.BLANKET_NUMBER = :hold_entity_id
12543 and ol.OPEN_FLAG = ''Y''
12544 -- QUOTING change
12545 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
12546 and not exists ( select ''x''
12547 from oe_order_holds_ALL oh
12548 where oh.header_id = h.header_id
12549 and oh.line_id = ol.line_id
12550 and oh.hold_source_id =:hold_source_id )';
12551 IF p_item_type is not null and p_activity_name is not null then
12552 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
12553 , wf_process_activities wpa
12554 where was.process_activity = wpa.instance_id
12555 and item_type = :p_item_type
12556 and item_key = to_char(ol.line_id)
12557 and activity_name = :l_activity_name
12558 and activity_status = :l_activity_status)';
12559 END IF;
12560 IF l_additional_where_clause = 'PICK_TRUE' THEN
12561 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
12562 where w.source_line_id = ol.line_id
12563 and w.source_code = ''OE''
12564 and w.released_status in (''Y'', ''C''))';
12565 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
12566 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
12567 where wdd.source_line_id = ol.LINE_ID
12568 and wdd.source_code = ''OE''
12569 and wda.delivery_detail_id = wdd.delivery_detail_id
12570 and wda.parent_delivery_detail_id is not null)';
12571 END IF;
12572 IF p_item_type is null and p_activity_name is null then
12573 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
12574 ELSE
12575 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.line_id,
12576 p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
12577 IF sql%rowcount = 0 THEN
12578 x_is_hold_applied := FALSE;
12579 ELSIF sql%rowcount = 1 THEN
12580 x_is_hold_applied := TRUE;
12581 END IF;
12582 END IF;
12583 ELSE
12584 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
12585 ( ORDER_HOLD_ID
12586 , LAST_UPDATE_DATE
12587 , LAST_UPDATED_BY
12588 , CREATION_DATE
12589 , CREATED_BY
12590 , LAST_UPDATE_LOGIN
12591 , HOLD_SOURCE_ID
12592 , HEADER_ID
12593 , LINE_ID
12594 , RELEASED_FLAG
12595 , ORG_ID
12596 )
12597 SELECT
12598 OE_ORDER_HOLDS_S.NEXTVAL
12599 , SYSDATE
12600 , :l_user_id
12601 , SYSDATE
12602 , :l_user_id
12603 , NULL
12604 , :hold_source_id
12605 , h.HEADER_ID
12606 , ol.line_id
12607 , ''N''
12608 , h.org_id --ER#7479609 :l_org_id
12609 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
12610 WHERE h.OPEN_FLAG = ''Y''
12611 and h.org_id = :l_org_id --ER#7479609
12612 and h.header_id = ol.header_id
12613 and ol.BLANKET_NUMBER = :hold_entity_id
12614 and ol.OPEN_FLAG = ''Y''
12615 -- QUOTING change
12616 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
12617 and not exists ( select ''x''
12618 from oe_order_holds_ALL oh
12619 where oh.header_id = h.header_id
12620 and oh.line_id = ol.line_id
12621 and oh.hold_source_id =:hold_source_id )';
12622 IF p_item_type is not null and p_activity_name is not null then
12623 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
12624 , wf_process_activities wpa
12625 where was.process_activity = wpa.instance_id
12626 and item_type = :p_item_type
12627 and item_key = to_char(ol.line_id)
12628 and activity_name = :l_activity_name
12629 and activity_status = :l_activity_status)';
12630 END IF;
12631 IF l_additional_where_clause = 'PICK_TRUE' THEN
12632 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
12633 where w.source_line_id = ol.line_id
12634 and w.source_code = ''OE''
12635 and w.released_status in (''Y'', ''C''))';
12636 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
12637 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
12638 where wdd.source_line_id = ol.LINE_ID
12639 and wdd.source_code = ''OE''
12640 and wda.delivery_detail_id = wdd.delivery_detail_id
12641 and wda.parent_delivery_detail_id is not null)';
12642 END IF;
12643 IF p_item_type is null and p_activity_name is null then
12644 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
12645 ELSE
12646 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.hold_entity_id ,
12647 p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
12648 l_sql_rowcount := sql%rowcount;
12649 IF l_sql_rowcount = 0 THEN
12650
12651 select meaning into l_user_activity_name
12652 from oe_lookups
12653 where lookup_type = DECODE(p_item_type,
12654 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
12655 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
12656 and lookup_code = p_activity_name;
12657
12658 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
12659 fnd_message.set_token('WF_ACT', l_user_activity_name);
12660 OE_MSG_PUB.ADD;
12661 oe_debug_pub.add(' Hold Not applied for All requested records');
12662 RAISE FND_API.G_EXC_ERROR;
12663 ELSIF l_sql_rowcount > 0 THEN
12664 SELECT count(*)
12665 into l_parent_count
12666 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
12667 WHERE h.OPEN_FLAG = 'Y'
12668 and h.header_id = ol.header_id
12669 and ol.BLANKET_NUMBER = p_hold_source_rec.hold_entity_id
12670 and ol.OPEN_FLAG = 'Y'
12671 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
12672 and not exists ( select 'x'
12673 from oe_order_holds_ALL oh
12674 where oh.header_id = h.header_id
12675 and oh.line_id = ol.line_id
12676 and oh.hold_source_id =
12677 p_hold_source_rec.hold_source_id );
12678
12679 -- Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables.
12680
12681 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
12682
12683 select meaning into l_user_activity_name
12684 from oe_lookups
12685 where lookup_type = DECODE(p_item_type,
12686 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
12687 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
12688 and lookup_code = p_activity_name;
12689
12690 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
12691 fnd_message.set_token('WF_ACT', l_user_activity_name);
12692 OE_MSG_PUB.ADD;
12693 oe_debug_pub.add(' Hold Not applied for FEW of the requested records');
12694 END IF;
12695 END IF;
12696 END IF;
12697 END IF;
12698 ER#7479609 end*/
12699 /******************************************************************************************************
12700 HOLD CRITERIA 1 : ORDER (EVEN FOR HOLD FOR A SPECIFIC ORDER LIKE ACTION->APPLY HOLDS OR ONLINE HOLDS)
12701 ******************************************************************************************************/
12702
12703 ELSIF p_hold_source_rec.hold_entity_code = 'O' THEN
12704 IF p_hold_source_rec.line_id is NULL THEN
12705 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
12706 ( ORDER_HOLD_ID
12707 , LAST_UPDATE_DATE
12708 , LAST_UPDATED_BY
12709 , CREATION_DATE
12710 , CREATED_BY
12711 , LAST_UPDATE_LOGIN
12712 , HOLD_SOURCE_ID
12713 , HEADER_ID
12714 , LINE_ID
12715 , RELEASED_FLAG
12716 , ORG_ID
12717 )
12718 SELECT
12719 OE_ORDER_HOLDS_S.NEXTVAL
12720 , SYSDATE
12721 , :l_user_id
12722 , SYSDATE
12723 , :l_user_id
12724 , NULL
12725 , :hold_source_id
12726 , h.HEADER_ID
12727 , NULL
12728 , ''N''
12729 , h.org_id --ER#7479609 :l_org_id
12730 FROM OE_ORDER_HEADERS_ALL h
12731 WHERE h.OPEN_FLAG = ''Y''
12732 and h.org_id = :l_org_id --ER#7479609
12733 and h.header_id = :hold_entity_id
12734 -- QUOTING change
12735 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
12736 and not exists ( select ''x''
12737 from oe_order_holds_ALL oh
12738 where oh.header_id = h.header_id
12739 and oh.hold_source_id =:hold_source_id2 )';
12740 IF p_item_type is not null and p_activity_name is not null then
12741 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
12742 , wf_process_activities wpa
12743 where was.process_activity = wpa.instance_id
12744 and item_type = :p_item_type
12745 and item_key = to_char(h.header_id)
12746 and activity_name = :l_activity_name
12747 and activity_status = :l_activity_status
12748 and nvl(was.activity_result_code, :l_activity_result)
12749 NOT IN (:l_result_1, :l_result_2))'; --9538334
12750 END IF;
12751
12752 IF p_item_type is null and p_activity_name is null then
12753 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id /*ER#7479609 start l_org_id*/, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
12754 ELSE
12755 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id /*ER#7479609 start l_org_id*/, p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOH', l_activity_name,
12756 l_act_status,'XXX', 'INCOMPLETE','ON_HOLD'; --9538334
12757 IF sql%rowcount = 0 THEN
12758 x_is_hold_applied := FALSE;
12759 ELSIF sql%rowcount = 1 THEN
12760 x_is_hold_applied := TRUE;
12761 END IF;
12762 END IF;
12763 ELSE
12764 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
12765 ( ORDER_HOLD_ID
12766 , LAST_UPDATE_DATE
12767 , LAST_UPDATED_BY
12768 , CREATION_DATE
12769 , CREATED_BY
12770 , LAST_UPDATE_LOGIN
12771 , HOLD_SOURCE_ID
12772 , HEADER_ID
12773 , LINE_ID
12774 , RELEASED_FLAG
12775 , ORG_ID
12776 )
12777 SELECT
12778 OE_ORDER_HOLDS_S.NEXTVAL
12779 , SYSDATE
12780 , :l_user_id
12781 , SYSDATE
12782 , :l_user_id
12783 , NULL
12784 , :hold_source_id
12785 , h.HEADER_ID
12786 , :line_id
12787 , ''N''
12788 , h.org_id --ER#7479609 :l_org_id
12789 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
12790 WHERE h.OPEN_FLAG = ''Y''
12791 and h.org_id = :l_org_id --ER#7479609
12792 and h.header_id = :hold_entity_id
12793 and h.header_id = ol.header_id
12794 and ol.line_id = :line_id
12795 and ol.OPEN_FLAG = ''Y''
12796 -- QUOTING change
12797 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
12798 and not exists ( select ''x''
12799 from oe_order_holds_ALL oh
12800 where oh.header_id = h.header_id
12801 and oh.line_id = ol.line_id
12802 and oh.hold_source_id =:hold_source_id )';
12803 IF p_item_type is not null and p_activity_name is not null then
12804 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
12805 , wf_process_activities wpa
12806 where was.process_activity = wpa.instance_id
12807 and item_type = :p_item_type
12808 and item_key = to_char(ol.line_id)
12809 and activity_name = :l_activity_name
12810 and activity_status = :l_activity_status
12811 and nvl(activity_result_code, :l_activity_result)
12812 NOT IN (:l_result_1, :l_result_2))'; --9538334
12813 END IF;
12814 IF l_additional_where_clause = 'PICK_TRUE' THEN
12815 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
12816 where w.source_line_id = ol.line_id
12817 and w.source_code = ''OE''
12818 and w.released_status in (''Y'', ''C''))';
12819 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
12820 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
12821 where wdd.source_line_id = ol.LINE_ID
12822 and wdd.source_code = ''OE''
12823 and wda.delivery_detail_id = wdd.delivery_detail_id
12824 and wda.parent_delivery_detail_id is not null)';
12825 END IF;
12826 IF p_item_type is null and p_activity_name is null then
12827 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_hold_source_rec.line_id,
12828 p_org_id /*ER#7479609 start l_org_id*/, p_hold_source_rec.hold_entity_id,
12829 p_hold_source_rec.line_id, p_hold_source_rec.hold_source_id;
12830 ELSE
12831 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_hold_source_rec.line_id, p_org_id /*ER#7479609 start l_org_id*/,
12832 p_hold_source_rec.hold_entity_id, p_hold_source_rec.line_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status,
12833 'XXX', 'INCOMPLETE','ON_HOLD'; --9538334;
12834 l_sql_rowcount := sql%rowcount;
12835 IF l_sql_rowcount = 0 THEN
12836
12837 select meaning into l_user_activity_name
12838 from oe_lookups
12839 where lookup_type = DECODE(p_item_type,
12840 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
12841 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
12842 and lookup_code = p_activity_name;
12843
12844 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
12845 fnd_message.set_token('WF_ACT', l_user_activity_name);
12846 OE_MSG_PUB.ADD;
12847 oe_debug_pub.add(' Hold Not applied for All requested records');
12848 RAISE FND_API.G_EXC_ERROR;
12849 ELSIF l_sql_rowcount > 0 THEN
12850 x_is_hold_applied := TRUE;
12851 SELECT count(*)
12852 into l_parent_count
12853 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
12854 WHERE h.OPEN_FLAG = 'Y'
12855 and h.header_id = p_hold_source_rec.hold_entity_id
12856 and h.header_id = ol.header_id
12857 and ol.line_id = p_hold_source_rec.line_id
12858 and ol.open_flag = 'Y'
12859 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
12860 and not exists ( select 'x'
12861 from oe_order_holds_ALL oh
12862 where oh.header_id = h.header_id
12863 and oh.line_id = ol.line_id
12864 and oh.hold_source_id =
12865 p_hold_source_rec.hold_source_id );
12866
12867 /* Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables. */
12868
12869 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
12870
12871 select meaning into l_user_activity_name
12872 from oe_lookups
12873 where lookup_type = DECODE(p_item_type,
12874 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
12875 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
12876 and lookup_code = p_activity_name;
12877
12878 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
12879 fnd_message.set_token('WF_ACT', l_user_activity_name);
12880 OE_MSG_PUB.ADD;
12881 oe_debug_pub.add(' Hold Not applied for FEW of the requested records');
12882 END IF;
12883 END IF;
12884 END IF;
12885 END IF;
12886 --ER 12363706 start
12887 IF p_hold_source_rec.hold_entity_code = 'O' AND p_hold_source_rec.hold_id= 1 THEN
12888 OE_DEBUG_PUB.ADD('slagiset: calling Update_Credit_Profile_Level');
12889 OE_CREDIT_CHECK_UTIL.Update_Credit_Profile_Level(p_hold_source_rec);
12890 END IF;
12891 --ER 12363706 end
12892 /*********************************************************
12893 HOLD CRITERIA 1 : CUSTOMER
12894 *********************************************************/
12895
12896 -- ELSIF p_hold_source_rec.hold_entity_code = 'C' --ER# 11824468
12897 ELSIF p_hold_source_rec.hold_entity_code IN('C','CN') --ER# 11824468
12898 AND p_hold_source_rec.hold_entity_code2 IS NULL THEN
12899 -- Use header_id for Customer based hold source
12900 -- ER#3667551 start
12901 -- If system parameter "Apply Credit Hold Based On" is 'Bill To Customer line'
12902 -- then Line Level Hold to be applied
12903 if(p_hold_source_rec.hold_entity_code='C' AND l_credithold_cust = 'BTL' and p_hold_source_rec.hold_id =1) then
12904 OE_DEBUG_PUB.ADD('System Parameter set to Bill TO LINE, Credit Hold being applied based on BillToCustomerLine of lines');
12905
12906 --If(p_hold_source_rec.line_id is not null ) then --Bug 13565716
12907 OE_DEBUG_PUB.ADD('Not a Header based Hold');
12908
12909 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for C, BillTOLine');
12910 l_hold_entity_where_clause := ' and exists (Select 1 FROM HZ_CUST_ACCOUNTS_ALL cust ,HZ_CUST_ACCT_SITES_ALL site,hz_cust_site_uses_all siteuse WHERE cust.cust_account_id = '
12911 ||''''||p_hold_source_rec.hold_entity_id||''''||'and ol.INVOICE_TO_ORG_ID = siteuse.site_use_id'
12912 ||' AND cust.cust_account_id =site.cust_account_id AND site.cust_acct_site_id = siteuse.cust_acct_site_id AND siteuse.site_use_code ='||'''BILL_TO'''||' AND siteuse.status = '||'''A'''||')';
12913
12914
12915 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
12916 ,p_line_id => p_hold_source_rec.line_id
12917 ,p_org_id => p_org_id
12918 ,p_hold_entity_where_clause => l_hold_entity_where_clause
12919 ,p_item_type => p_item_type
12920 ,p_activity_name => l_activity_name
12921 ,p_activity_status => l_act_status
12922 ,p_additional_where_clause => l_additional_where_clause
12923 ,x_is_hold_applied => x_is_hold_applied);
12924
12925 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for C/CN');
12926 -- end if; --end if of header id null --Bug#13565716
12927
12928 else -- else of system parameter not BTL and rest all 'C' holds will have header_id not null
12929 -- ER#3667551 end
12930 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Header for C/CN');
12931 -- ER#3667551, start
12932 -- Ensure that For System Parameter "Apply Credit Hold Based On" set to 'Bill To Customer Line'
12933 -- no Header Level Hold is applied for Credit Hold
12934 if(p_hold_source_rec.hold_entity_code='C' AND l_credithold_cust = 'BTL' and p_hold_source_rec.hold_id =1 ) then
12935 -- and p_hold_source_rec.hold_id =1 and p_hold_source_rec.header_id is NOT NULL ) --then Bug 13565716
12936 OE_DEBUG_PUB.ADD('Not calling InsertTable_OOH_Header as Credit Hold System Paramter at BillTOLine');
12937 --
12938 -- If Credit Hold with System parameter as 'Bill To Customer Header'
12939 -- then Credit Hold to be applied at Order Header Level
12940 else
12941 --
12942 if(p_hold_source_rec.hold_entity_code='C' AND l_credithold_cust = 'BTH' and p_hold_source_rec.hold_id =1) then
12943 --and p_hold_source_rec.hold_id =1 and p_hold_source_rec.header_id is NOT NULL ) then --Bug 13565716
12944 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Header as Credit Hold System Paramter at BillTOCustHeader');
12945 l_hold_entity_where_clause := ' and exists (Select 1 FROM HZ_CUST_ACCOUNTS_ALL cust ,HZ_CUST_ACCT_SITES_ALL site,hz_cust_site_uses_all siteuse WHERE cust.cust_account_id = '
12946 ||''''||p_hold_source_rec.hold_entity_id||''''||'and h.INVOICE_TO_ORG_ID = siteuse.site_use_id'
12947 ||' AND cust.cust_account_id =site.cust_account_id AND site.cust_acct_site_id = siteuse.cust_acct_site_id AND siteuse.site_use_code ='||'''BILL_TO'''||' AND siteuse.status = '||'''A'''||')';
12948
12949
12950 --
12951 -- If any of the above fails then it can be a Credit Hold with System parameter as 'Sold To Customer' OR
12952 -- any user hold based on Customer which is to be applied at Order Header Level
12953 else
12954 -- ER#3667551, end
12955
12956 --ER#7479609 start
12957 l_hold_entity_where_clause := 'and h.SOLD_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||'''';
12958
12959 end if; -- -- ER#3667551 end if added for BTH and other C/CN header holds
12960 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Header for C/CN');
12961
12962 InsertTable_OOH_Header (p_hold_source_id => p_hold_source_rec.hold_source_id
12963 ,p_header_id =>p_hold_source_rec.header_id
12964 ,p_org_id => p_org_id
12965 ,p_hold_entity_where_clause => l_hold_entity_where_clause
12966 ,p_item_type => p_item_type
12967 ,p_activity_name => l_activity_name
12968 ,p_activity_status => l_act_status
12969 ,p_additional_where_clause => l_additional_where_clause
12970 ,x_is_hold_applied => x_is_hold_applied);
12971
12972 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Header for C/CN');
12973 --ER#7479609 end
12974 end if; -- ER#3667551, end if added
12975 end if; -- ER#3667551, end if added
12976
12977
12978 /*ER#7479609 start
12979 IF p_hold_source_rec.header_id IS NOT NULL THEN
12980 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
12981 ( ORDER_HOLD_ID
12982 , LAST_UPDATE_DATE
12983 , LAST_UPDATED_BY
12984 , CREATION_DATE
12985 , CREATED_BY
12986 , LAST_UPDATE_LOGIN
12987 , HOLD_SOURCE_ID
12988 , HEADER_ID
12989 , LINE_ID
12990 , RELEASED_FLAG
12991 , ORG_ID
12992 )
12993 SELECT
12994 OE_ORDER_HOLDS_S.NEXTVAL
12995 , SYSDATE
12996 , :l_user_id
12997 , SYSDATE
12998 , :l_user_id
12999 , NULL
13000 , :hold_source_id
13001 , h.HEADER_ID
13002 , NULL
13003 , ''N''
13004 , h.org_id --ER#7479609 :l_org_id
13005 FROM OE_ORDER_HEADERS_ALL h
13006 WHERE h.OPEN_FLAG = ''Y''
13007 and h.org_id = :l_org_id --ER#7479609
13008 and h.header_id = :header_id
13009 and h.SOLD_TO_ORG_ID = :hold_entity_id
13010 -- QUOTING change
13011 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
13012 and not exists ( select ''x''
13013 from oe_order_holds_ALL oh
13014 where oh.header_id = h.header_id
13015 and oh.hold_source_id =:hold_source_id )';
13016 IF p_item_type is not null and p_activity_name is not null then
13017 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
13018 , wf_process_activities wpa
13019 where was.process_activity = wpa.instance_id
13020 and item_type = :p_item_type
13021 and item_key = to_char(h.header_id)
13022 and activity_name = :l_activity_name
13023 and activity_status = :l_activity_status)';
13024 END IF;
13025
13026 IF p_item_type is null and p_activity_name is null then
13027 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.header_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
13028 ELSE
13029 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id , p_hold_source_rec.header_id,
13030 p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOH', l_activity_name, l_act_status;
13031 IF sql%rowcount = 0 THEN
13032 x_is_hold_applied := FALSE;
13033 ELSIF sql%rowcount = 1 THEN
13034 x_is_hold_applied := TRUE;
13035 END IF;
13036 END IF;
13037 ELSE
13038 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
13039 ( ORDER_HOLD_ID
13040 , LAST_UPDATE_DATE
13041 , LAST_UPDATED_BY
13042 , CREATION_DATE
13043 , CREATED_BY
13044 , LAST_UPDATE_LOGIN
13045 , HOLD_SOURCE_ID
13046 , HEADER_ID
13047 , LINE_ID
13048 , RELEASED_FLAG
13049 , ORG_ID
13050 )
13051 SELECT
13052 OE_ORDER_HOLDS_S.NEXTVAL
13053 , SYSDATE
13054 , :l_user_id
13055 , SYSDATE
13056 , :l_user_id
13057 , NULL
13058 , :hold_source_id
13059 , h.HEADER_ID
13060 , NULL
13061 , ''N''
13062 , h.org_id --ER#7479609 :l_org_id
13063 FROM OE_ORDER_HEADERS_ALL h
13064 WHERE h.OPEN_FLAG = ''Y''
13065
13066 and h.SOLD_TO_ORG_ID = :hold_entity_id
13067 and h.org_id = :l_org_id --ER#7479609
13068 -- QUOTING change
13069 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
13070 and not exists ( select ''x''
13071 from oe_order_holds_ALL oh
13072 where oh.header_id = h.header_id
13073 and oh.hold_source_id =:hold_source_id )';
13074 IF p_item_type is not null and p_activity_name is not null then
13075 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
13076 , wf_process_activities wpa
13077 where was.process_activity = wpa.instance_id
13078 and item_type = :p_item_type
13079 and item_key = to_char(h.header_id)
13080 and activity_name = :l_activity_name
13081 and activity_status = :l_activity_status)';
13082 END IF;
13083
13084 IF p_item_type is null and p_activity_name is null then
13085 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_hold_source_rec.hold_entity_id,p_org_id, p_hold_source_rec.hold_source_id;
13086 ELSE
13087
13088 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_hold_source_rec.hold_entity_id,p_org_id, p_hold_source_rec.hold_source_id, 'OEOH', l_activity_name, l_act_status;
13089
13090 l_sql_rowcount := sql%rowcount;
13091 oe_debug_pub.add('l_sql_rowcount - '||l_sql_rowcount);
13092 IF l_sql_rowcount = 0 THEN
13093
13094 select meaning into l_user_activity_name
13095 from oe_lookups
13096 where lookup_type = DECODE(p_item_type,
13097 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
13098 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
13099 and lookup_code = p_activity_name;
13100
13101 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
13102 fnd_message.set_token('WF_ACT', l_user_activity_name);
13103 OE_MSG_PUB.ADD;
13104 oe_debug_pub.add(' Hold Not applied for All requested records');
13105 RAISE FND_API.G_EXC_ERROR;
13106 ELSIF l_sql_rowcount > 0 THEN
13107 SELECT count(*)
13108 into l_parent_count
13109 FROM OE_ORDER_HEADERS_ALL h
13110 WHERE h.OPEN_FLAG = 'Y'
13111
13112 and h.SOLD_TO_ORG_ID = p_hold_source_rec.hold_entity_id
13113 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
13114 and not exists ( select 'x'
13115 from oe_order_holds_ALL oh
13116 where oh.header_id = h.header_id
13117 and oh.hold_source_id =
13118 p_hold_source_rec.hold_source_id );
13119
13120 -- Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow -- or Shipping product tables.
13121 oe_debug_pub.add('l_parent_count - '||l_parent_count);
13122 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
13123
13124 select meaning into l_user_activity_name
13125 from oe_lookups
13126 where lookup_type = DECODE(p_item_type,
13127 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
13128 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
13129 and lookup_code = p_activity_name;
13130
13131 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
13132 fnd_message.set_token('WF_ACT', l_user_activity_name);
13133 OE_MSG_PUB.ADD;
13134 oe_debug_pub.add(' Hold Not applied for FEW of the requested records');
13135 END IF;
13136 END IF;
13137 END IF;
13138 END IF;
13139 ER#7479609 end*/
13140
13141 --ER#7479609 start
13142 -- ELSIF p_hold_source_rec.hold_entity_code = 'C' and --ER# 11824468
13143 ELSIF p_hold_source_rec.hold_entity_code IN('C','CN') and --ER# 11824468
13144 p_hold_source_rec.hold_entity_code2 = 'B' THEN
13145
13146
13147 l_hold_entity_where_clause := 'and ol.SOLD_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
13148 ||' and ol.INVOICE_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
13149
13150
13151 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for C/CN and B');
13152 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
13153 ,p_line_id => p_hold_source_rec.line_id
13154 ,p_org_id => p_org_id
13155 ,p_hold_entity_where_clause => l_hold_entity_where_clause
13156 ,p_item_type => p_item_type
13157 ,p_activity_name => l_activity_name
13158 ,p_activity_status => l_act_status
13159 ,p_additional_where_clause => l_additional_where_clause
13160 ,x_is_hold_applied => x_is_hold_applied);
13161 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for C/CN and B');
13162 --ER#7479609 end
13163
13164
13165 --ER#7479609 start
13166 --ELSIF p_hold_source_rec.hold_entity_code = 'C' and --ER# 11824468
13167 ELSIF p_hold_source_rec.hold_entity_code IN('C','CN') and --ER# 11824468
13168 p_hold_source_rec.hold_entity_code2 = 'S' THEN
13169
13170
13171 l_hold_entity_where_clause := 'and ol.SOLD_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
13172 ||' and ol.SHIP_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
13173
13174
13175 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for C/CN and S');
13176 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
13177 ,p_line_id => p_hold_source_rec.line_id
13178 ,p_org_id => p_org_id
13179 ,p_hold_entity_where_clause => l_hold_entity_where_clause
13180 ,p_item_type => p_item_type
13181 ,p_activity_name => l_activity_name
13182 ,p_activity_status => l_act_status
13183 ,p_additional_where_clause => l_additional_where_clause
13184 ,x_is_hold_applied => x_is_hold_applied);
13185 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for C/CN and S');
13186 --ER#7479609 end
13187
13188
13189 --ER#7479609 start
13190 -- ELSIF p_hold_source_rec.hold_entity_code = 'C' and --ER# 11824468
13191 ELSIF p_hold_source_rec.hold_entity_code IN('C','CN') and --ER# 11824468
13192 p_hold_source_rec.hold_entity_code2 = 'D' THEN
13193
13194
13195 l_hold_entity_where_clause := 'and ol.SOLD_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
13196 ||' and ol.DELIVER_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
13197
13198
13199 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for C/CN and D');
13200 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
13201 ,p_line_id => p_hold_source_rec.line_id
13202 ,p_org_id => p_org_id
13203 ,p_hold_entity_where_clause => l_hold_entity_where_clause
13204 ,p_item_type => p_item_type
13205 ,p_activity_name => l_activity_name
13206 ,p_activity_status => l_act_status
13207 ,p_additional_where_clause => l_additional_where_clause
13208 ,x_is_hold_applied => x_is_hold_applied);
13209 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for C/CN and D');
13210 --ER#7479609 end
13211
13212
13213 --ER#7479609 start
13214 -- ELSIF p_hold_source_rec.hold_entity_code = 'C' and --ER# 11824468
13215 ELSIF p_hold_source_rec.hold_entity_code IN('C','CN') and --ER# 11824468
13216 p_hold_source_rec.hold_entity_code2 = 'PL' THEN
13217
13218
13219 l_hold_entity_where_clause := 'and ol.SOLD_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
13220 ||' and ol.PRICE_LIST_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
13221
13222
13223 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for C/CN and PL');
13224 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
13225 ,p_line_id => p_hold_source_rec.line_id
13226 ,p_org_id => p_org_id
13227 ,p_hold_entity_where_clause => l_hold_entity_where_clause
13228 ,p_item_type => p_item_type
13229 ,p_activity_name => l_activity_name
13230 ,p_activity_status => l_act_status
13231 ,p_additional_where_clause => l_additional_where_clause
13232 ,x_is_hold_applied => x_is_hold_applied);
13233 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for C/CN and PL');
13234 --ER#7479609 end
13235
13236
13237 --ER#7479609 start
13238 --ELSIF p_hold_source_rec.hold_entity_code = 'C' and --ER# 11824468
13239 ELSIF p_hold_source_rec.hold_entity_code IN('C','CN') and --ER# 11824468
13240 p_hold_source_rec.hold_entity_code2 = 'LT' THEN
13241
13242
13243 l_hold_entity_where_clause := 'and ol.SOLD_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
13244 ||' and ol.LINE_TYPE_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
13245
13246
13247 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for C/CN and LT');
13248 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
13249 ,p_line_id => p_hold_source_rec.line_id
13250 ,p_org_id => p_org_id
13251 ,p_hold_entity_where_clause => l_hold_entity_where_clause
13252 ,p_item_type => p_item_type
13253 ,p_activity_name => l_activity_name
13254 ,p_activity_status => l_act_status
13255 ,p_additional_where_clause => l_additional_where_clause
13256 ,x_is_hold_applied => x_is_hold_applied);
13257 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for C/CN and LT');
13258 --ER#7479609 end
13259
13260
13261 --ER#7479609 start
13262 -- ELSIF p_hold_source_rec.hold_entity_code = 'C' and --ER# 11824468
13263 ELSIF p_hold_source_rec.hold_entity_code IN('C','CN') and --ER# 11824468
13264 p_hold_source_rec.hold_entity_code2 = 'PT' THEN
13265
13266
13267 l_hold_entity_where_clause := 'and ol.SOLD_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
13268 ||' and ol.PAYMENT_TERM_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
13269
13270
13271 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for C/CN and PT');
13272 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
13273 ,p_line_id => p_hold_source_rec.line_id
13274 ,p_org_id => p_org_id
13275 ,p_hold_entity_where_clause => l_hold_entity_where_clause
13276 ,p_item_type => p_item_type
13277 ,p_activity_name => l_activity_name
13278 ,p_activity_status => l_act_status
13279 ,p_additional_where_clause => l_additional_where_clause
13280 ,x_is_hold_applied => x_is_hold_applied);
13281 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for C/CN and PT');
13282 --ER#7479609 end
13283
13284
13285 --ER#7479609 start
13286 -- ELSIF p_hold_source_rec.hold_entity_code = 'C' and --ER# 11824468
13287 ELSIF p_hold_source_rec.hold_entity_code IN('C','CN') and --ER# 11824468
13288 p_hold_source_rec.hold_entity_code2 = 'OT' THEN
13289
13290
13291 l_hold_entity_where_clause := 'and h.SOLD_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
13292 ||' and h.ORDER_TYPE_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
13293
13294 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Header for C/CN and OT');
13295 InsertTable_OOH_Header (p_hold_source_id => p_hold_source_rec.hold_source_id
13296 ,p_header_id =>p_hold_source_rec.header_id
13297 ,p_org_id => p_org_id
13298 ,p_hold_entity_where_clause => l_hold_entity_where_clause
13299 ,p_item_type => p_item_type
13300 ,p_activity_name => l_activity_name
13301 ,p_activity_status => l_act_status
13302 ,p_additional_where_clause => l_additional_where_clause
13303 ,x_is_hold_applied => x_is_hold_applied);
13304
13305 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Header for C/CN and OT');
13306 --ER#7479609 end
13307
13308 --ER#7479609 start
13309 -- ELSIF p_hold_source_rec.hold_entity_code = 'C' and --ER# 11824468
13310 ELSIF p_hold_source_rec.hold_entity_code IN('C','CN') and --ER# 11824468
13311 p_hold_source_rec.hold_entity_code2 = 'P' THEN
13312
13313
13314 OE_DEBUG_PUB.ADD('Calling PaymentType_Hold for C/CN and P');
13315 PaymentType_Hold (p_hold_source_rec => p_hold_source_rec
13316 ,p_org_id => p_org_id
13317 ,p_item_type => p_item_type
13318 ,p_activity_name => l_activity_name
13319 ,p_activity_status => l_act_status
13320 ,p_additional_where_clause => l_additional_where_clause
13321 ,x_is_hold_applied => x_is_hold_applied);
13322
13323 --ER#7479609 start
13324 IF NOT x_is_hold_applied THEN
13325 x_return_status := '0';
13326 END IF;
13327 --ER#7479609 end
13328
13329 OE_DEBUG_PUB.ADD('After Calling InsePaymentType_Hold for C/CN and P');
13330 --ER#7479609 end
13331
13332 --ER#7479609 start
13333 --ELSIF p_hold_source_rec.hold_entity_code = 'C' and --ER# 11824468
13334 ELSIF p_hold_source_rec.hold_entity_code IN('C','CN') and --ER# 11824468
13335 p_hold_source_rec.hold_entity_code2 = 'TC' THEN
13336
13337
13338 l_hold_entity_where_clause := 'and h.SOLD_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
13339 ||' and h.TRANSACTIONAL_CURR_CODE = '||''''||p_hold_source_rec.hold_entity_id2||'''';
13340
13341 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Header for C/CN and TC');
13342 InsertTable_OOH_Header (p_hold_source_id => p_hold_source_rec.hold_source_id
13343 ,p_header_id =>p_hold_source_rec.header_id
13344 ,p_org_id => p_org_id
13345 ,p_hold_entity_where_clause => l_hold_entity_where_clause
13346 ,p_item_type => p_item_type
13347 ,p_activity_name => l_activity_name
13348 ,p_activity_status => l_act_status
13349 ,p_additional_where_clause => l_additional_where_clause
13350 ,x_is_hold_applied => x_is_hold_applied);
13351
13352 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Header for C/CN and TC');
13353 --ER#7479609 end
13354
13355 --ER#7479609 start
13356 --ELSIF p_hold_source_rec.hold_entity_code = 'C' and --ER# 11824468
13357 ELSIF p_hold_source_rec.hold_entity_code IN('C','CN') and --ER# 11824468
13358 p_hold_source_rec.hold_entity_code2 = 'ST' THEN
13359
13360
13361 l_hold_entity_where_clause := 'and ol.SOLD_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
13362 ||' and ol.SOURCE_TYPE_CODE = '||''''||p_hold_source_rec.hold_entity_id2||'''';
13363
13364
13365 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for C/CN and ST');
13366 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
13367 ,p_line_id => p_hold_source_rec.line_id
13368 ,p_org_id => p_org_id
13369 ,p_hold_entity_where_clause => l_hold_entity_where_clause
13370 ,p_item_type => p_item_type
13371 ,p_activity_name => l_activity_name
13372 ,p_activity_status => l_act_status
13373 ,p_additional_where_clause => l_additional_where_clause
13374 ,x_is_hold_applied => x_is_hold_applied);
13375 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for C/CN and ST');
13376 --ER#7479609 end
13377
13378
13379 --ER#7479609 start
13380 -- ELSIF p_hold_source_rec.hold_entity_code = 'C' and --ER# 11824468
13381 ELSIF p_hold_source_rec.hold_entity_code IN('C','CN') and --ER# 11824468
13382 p_hold_source_rec.hold_entity_code2 = 'SC' THEN
13383
13384
13385 l_hold_entity_where_clause := 'and h.SOLD_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
13386 ||' and h.SALES_CHANNEL_CODE = '||''''||p_hold_source_rec.hold_entity_id2||'''';
13387
13388 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Header for C/CN and SC');
13389 InsertTable_OOH_Header (p_hold_source_id => p_hold_source_rec.hold_source_id
13390 ,p_header_id =>p_hold_source_rec.header_id
13391 ,p_org_id => p_org_id
13392 ,p_hold_entity_where_clause => l_hold_entity_where_clause
13393 ,p_item_type => p_item_type
13394 ,p_activity_name => l_activity_name
13395 ,p_activity_status => l_act_status
13396 ,p_additional_where_clause => l_additional_where_clause
13397 ,x_is_hold_applied => x_is_hold_applied);
13398
13399 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Header for C/CN and SC');
13400 --ER#7479609 end
13401
13402
13403 /*********************************************************
13404 HOLD CRITERIA 1 : BILL TO SITE
13405 *********************************************************/
13406
13407 ELSIF p_hold_source_rec.hold_entity_code = 'B'
13408 AND p_hold_source_rec.hold_entity_code2 IS NULL THEN
13409
13410 --ER#7479609 start
13411 l_hold_entity_where_clause := 'and ol.INVOICE_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||'''';
13412
13413
13414 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for B');
13415 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
13416 ,p_line_id => p_hold_source_rec.line_id
13417 ,p_org_id => p_org_id
13418 ,p_hold_entity_where_clause => l_hold_entity_where_clause
13419 ,p_item_type => p_item_type
13420 ,p_activity_name => l_activity_name
13421 ,p_activity_status => l_act_status
13422 ,p_additional_where_clause => l_additional_where_clause
13423 ,x_is_hold_applied => x_is_hold_applied);
13424 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for B');
13425 --ER#7479609 end
13426
13427 /*ER#7479609 start
13428 IF p_hold_source_rec.line_id IS NOT NULL THEN
13429 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
13430 ( ORDER_HOLD_ID
13431 , LAST_UPDATE_DATE
13432 , LAST_UPDATED_BY
13433 , CREATION_DATE
13434 , CREATED_BY
13435 , LAST_UPDATE_LOGIN
13436 , HOLD_SOURCE_ID
13437 , HEADER_ID
13438 , LINE_ID
13439 , RELEASED_FLAG
13440 , ORG_ID
13441 )
13442 SELECT
13443 OE_ORDER_HOLDS_S.NEXTVAL
13444 , SYSDATE
13445 , :l_user_id
13446 , SYSDATE
13447 , :l_user_id
13448 , NULL
13449 , :hold_source_id
13450 , h.HEADER_ID
13451 , ol.line_id
13452 , ''N''
13453 , h.org_id --ER#7479609 :l_org_id
13454 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
13455 WHERE h.OPEN_FLAG = ''Y''
13456 and h.org_id = :l_org_id
13457 and h.header_id = ol.header_id
13458 and ol.line_id = :line_id
13459 and ol.INVOICE_TO_ORG_ID = :hold_entity_id
13460 and ol.OPEN_FLAG = ''Y''
13461 -- QUOTING change
13462 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
13463 and not exists ( select ''x''
13464 from oe_order_holds_ALL oh
13465 where oh.header_id = h.header_id
13466 and oh.line_id = ol.line_id
13467 and oh.hold_source_id =:hold_source_id )';
13468 IF p_item_type is not null and p_activity_name is not null then
13469 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
13470 , wf_process_activities wpa
13471 where was.process_activity = wpa.instance_id
13472 and item_type = :p_item_type
13473 and item_key = to_char(ol.line_id)
13474 and activity_name = :l_activity_name
13475 and activity_status = :l_activity_status)';
13476 END IF;
13477 IF l_additional_where_clause = 'PICK_TRUE' THEN
13478 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
13479 where w.source_line_id = ol.line_id
13480 and w.source_code = ''OE''
13481 and w.released_status in (''Y'', ''C''))';
13482 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
13483 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
13484 where wdd.source_line_id = ol.LINE_ID
13485 and wdd.source_code = ''OE''
13486 and wda.delivery_detail_id = wdd.delivery_detail_id
13487 and wda.parent_delivery_detail_id is not null)';
13488 END IF;
13489 IF p_item_type is null and p_activity_name is null then
13490 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
13491 ELSE
13492 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
13493 IF sql%rowcount = 0 THEN
13494 x_is_hold_applied := FALSE;
13495 ELSIF sql%rowcount = 1 THEN
13496 x_is_hold_applied := TRUE;
13497 END IF;
13498 END IF;
13499
13500 ELSE
13501 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
13502 ( ORDER_HOLD_ID
13503 , LAST_UPDATE_DATE
13504 , LAST_UPDATED_BY
13505 , CREATION_DATE
13506 , CREATED_BY
13507 , LAST_UPDATE_LOGIN
13508 , HOLD_SOURCE_ID
13509 , HEADER_ID
13510 , LINE_ID
13511 , RELEASED_FLAG
13512 , ORG_ID
13513 )
13514 SELECT
13515 OE_ORDER_HOLDS_S.NEXTVAL
13516 , SYSDATE
13517 , :l_user_id
13518 , SYSDATE
13519 , :l_user_id
13520 , NULL
13521 , :hold_source_id
13522 , h.HEADER_ID
13523 , ol.line_id
13524 , ''N''
13525 , h.org_id --ER#7479609 :l_org_id
13526 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
13527 WHERE h.OPEN_FLAG = ''Y''
13528 and h.org_id = :l_org_id --ER#7479609
13529 and h.header_id = ol.header_id
13530 and ol.INVOICE_TO_ORG_ID = :hold_entity_id
13531 and ol.OPEN_FLAG = ''Y''
13532 -- QUOTING change
13533 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
13534 and not exists ( select ''x''
13535 from oe_order_holds_ALL oh
13536 where oh.header_id = h.header_id
13537 and oh.line_id = ol.line_id
13538 and oh.hold_source_id =:hold_source_id )';
13539 IF p_item_type is not null and p_activity_name is not null then
13540 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
13541 , wf_process_activities wpa
13542 where was.process_activity = wpa.instance_id
13543 and item_type = :p_item_type
13544 and item_key = to_char(ol.line_id)
13545 and activity_name = :l_activity_name
13546 and activity_status = :l_activity_status)';
13547 END IF;
13548 IF l_additional_where_clause = 'PICK_TRUE' THEN
13549 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
13550 where w.source_line_id = ol.line_id
13551 and w.source_code = ''OE''
13552 and w.released_status in (''Y'', ''C''))';
13553 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
13554 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
13555 where wdd.source_line_id = ol.LINE_ID
13556 and wdd.source_code = ''OE''
13557 and wda.delivery_detail_id = wdd.delivery_detail_id
13558 and wda.parent_delivery_detail_id is not null)';
13559 END IF;
13560 IF p_item_type is null and p_activity_name is null then
13561 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
13562 ELSE
13563 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
13564 l_sql_rowcount := sql%rowcount;
13565 IF l_sql_rowcount = 0 THEN
13566
13567 select meaning into l_user_activity_name
13568 from oe_lookups
13569 where lookup_type = DECODE(p_item_type,
13570 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
13571 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
13572 and lookup_code = p_activity_name;
13573
13574 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
13575 fnd_message.set_token('WF_ACT', l_user_activity_name);
13576 OE_MSG_PUB.ADD;
13577 oe_debug_pub.add(' Hold Not applied for All requested records');
13578 RAISE FND_API.G_EXC_ERROR;
13579 ELSIF l_sql_rowcount > 0 THEN
13580 SELECT count(*)
13581 into l_parent_count
13582 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
13583 WHERE h.OPEN_FLAG = 'Y'
13584 and h.header_id = ol.header_id
13585 and ol.INVOICE_TO_ORG_ID = p_hold_source_rec.hold_entity_id
13586 and ol.OPEN_FLAG = 'Y'
13587 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
13588 and not exists ( select 'x'
13589 from oe_order_holds_ALL oh
13590 where oh.header_id = h.header_id
13591 and oh.line_id = ol.line_id
13592 and oh.hold_source_id =
13593 p_hold_source_rec.hold_source_id );
13594
13595 -- Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables.
13596
13597 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
13598
13599 select meaning into l_user_activity_name
13600 from oe_lookups
13601 where lookup_type = DECODE(p_item_type,
13602 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
13603 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
13604 and lookup_code = p_activity_name;
13605
13606 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
13607 fnd_message.set_token('WF_ACT', l_user_activity_name);
13608 OE_MSG_PUB.ADD;
13609 oe_debug_pub.add(' Hold Not applied for FEW of the requested records');
13610 END IF;
13611 END IF;
13612 END IF;
13613 END IF;
13614 ER#7479609 end*/
13615
13616 /*********************************************************
13617 HOLD CRITERIA 1 : SHIP TO SITE
13618 *********************************************************/
13619
13620 ELSIF p_hold_source_rec.hold_entity_code = 'S'
13621 AND p_hold_source_rec.hold_entity_code2 IS NULL THEN
13622
13623 --ER#7479609 start
13624 l_hold_entity_where_clause := 'and ol.SHIP_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||'''';
13625
13626
13627 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for S');
13628 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
13629 ,p_line_id => p_hold_source_rec.line_id
13630 ,p_org_id => p_org_id
13631 ,p_hold_entity_where_clause => l_hold_entity_where_clause
13632 ,p_item_type => p_item_type
13633 ,p_activity_name => l_activity_name
13634 ,p_activity_status => l_act_status
13635 ,p_additional_where_clause => l_additional_where_clause
13636 ,x_is_hold_applied => x_is_hold_applied);
13637 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for S');
13638 --ER#7479609 end
13639
13640 /*ER#7479609 start
13641 IF p_hold_source_rec.line_id IS NOT NULL THEN
13642 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
13643 ( ORDER_HOLD_ID
13644 , LAST_UPDATE_DATE
13645 , LAST_UPDATED_BY
13646 , CREATION_DATE
13647 , CREATED_BY
13648 , LAST_UPDATE_LOGIN
13649 , HOLD_SOURCE_ID
13650 , HEADER_ID
13651 , LINE_ID
13652 , RELEASED_FLAG
13653 , ORG_ID
13654 )
13655 SELECT
13656 OE_ORDER_HOLDS_S.NEXTVAL
13657 , SYSDATE
13658 , :l_user_id
13659 , SYSDATE
13660 , :l_user_id
13661 , NULL
13662 , :hold_source_id
13663 , h.HEADER_ID
13664 , ol.line_id
13665 , ''N''
13666 , h.org_id --ER#7479609 :l_org_id
13667 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
13668 WHERE h.OPEN_FLAG = ''Y''
13669 and h.org_id = :l_org_id --ER#7479609
13670 and h.header_id = ol.header_id
13671 and ol.line_id = :line_id
13672 and ol.SHIP_TO_ORG_ID = :hold_entity_id
13673 and ol.OPEN_FLAG = ''Y''
13674 -- QUOTING change
13675 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
13676 and not exists ( select ''x''
13677 from oe_order_holds_ALL oh
13678 where oh.header_id = h.header_id
13679 and oh.line_id = ol.line_id
13680 and oh.hold_source_id =:hold_source_id )';
13681 IF p_item_type is not null and p_activity_name is not null then
13682 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
13683 , wf_process_activities wpa
13684 where was.process_activity = wpa.instance_id
13685 and item_type = :p_item_type
13686 and item_key = to_char(ol.line_id)
13687 and activity_name = :l_activity_name
13688 and activity_status = :l_activity_status)';
13689 END IF;
13690 IF l_additional_where_clause = 'PICK_TRUE' THEN
13691 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
13692 where w.source_line_id = ol.line_id
13693 and w.source_code = ''OE''
13694 and w.released_status in (''Y'', ''C''))';
13695 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
13696 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
13697 where wdd.source_line_id = ol.LINE_ID
13698 and wdd.source_code = ''OE''
13699 and wda.delivery_detail_id = wdd.delivery_detail_id
13700 and wda.parent_delivery_detail_id is not null)';
13701 END IF;
13702 IF p_item_type is null and p_activity_name is null then
13703 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
13704 ELSE
13705 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
13706 IF sql%rowcount = 0 THEN
13707 x_is_hold_applied := FALSE;
13708 ELSIF sql%rowcount = 1 THEN
13709 x_is_hold_applied := TRUE;
13710 END IF;
13711 END IF;
13712 ELSE
13713 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
13714 ( ORDER_HOLD_ID
13715 , LAST_UPDATE_DATE
13716 , LAST_UPDATED_BY
13717 , CREATION_DATE
13718 , CREATED_BY
13719 , LAST_UPDATE_LOGIN
13720 , HOLD_SOURCE_ID
13721 , HEADER_ID
13722 , LINE_ID
13723 , RELEASED_FLAG
13724 , ORG_ID
13725 )
13726 SELECT
13727 OE_ORDER_HOLDS_S.NEXTVAL
13728 , SYSDATE
13729 , :l_user_id
13730 , SYSDATE
13731 , :l_user_id
13732 , NULL
13733 , :hold_source_id
13734 , h.HEADER_ID
13735 , ol.line_id
13736 , ''N''
13737 , h.org_id --ER#7479609 :l_org_id
13738 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
13739 WHERE h.OPEN_FLAG = ''Y''
13740 and h.org_id = :l_org_id --ER#7479609
13741 and h.header_id = ol.header_id
13742 and ol.SHIP_TO_ORG_ID = :hold_entity_id
13743 and ol.OPEN_FLAG = ''Y''
13744 -- QUOTING change
13745 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
13746 and not exists ( select ''x''
13747 from oe_order_holds_ALL oh
13748 where oh.header_id = h.header_id
13749 and oh.line_id = ol.line_id
13750 and oh.hold_source_id =:hold_source_id )';
13751 IF p_item_type is not null and p_activity_name is not null then
13752 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
13753 , wf_process_activities wpa
13754 where was.process_activity = wpa.instance_id
13755 and item_type = :p_item_type
13756 and item_key = to_char(ol.line_id)
13757 and activity_name = :l_activity_name
13758 and activity_status = :l_activity_status)';
13759 END IF;
13760 IF l_additional_where_clause = 'PICK_TRUE' THEN
13761 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
13762 where w.source_line_id = ol.line_id
13763 and w.source_code = ''OE''
13764 and w.released_status in (''Y'', ''C''))';
13765 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
13766 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
13767 where wdd.source_line_id = ol.LINE_ID
13768 and wdd.source_code = ''OE''
13769 and wda.delivery_detail_id = wdd.delivery_detail_id
13770 and wda.parent_delivery_detail_id is not null)';
13771 END IF;
13772 IF p_item_type is null and p_activity_name is null then
13773 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
13774 ELSE
13775 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
13776 l_sql_rowcount := sql%rowcount;
13777 IF l_sql_rowcount = 0 THEN
13778
13779 select meaning into l_user_activity_name
13780 from oe_lookups
13781 where lookup_type = DECODE(p_item_type,
13782 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
13783 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
13784 and lookup_code = p_activity_name;
13785
13786 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
13787 fnd_message.set_token('WF_ACT', l_user_activity_name);
13788 OE_MSG_PUB.ADD;
13789 oe_debug_pub.add(' Hold Not applied for All requested records');
13790 RAISE FND_API.G_EXC_ERROR;
13791 ELSIF l_sql_rowcount > 0 THEN
13792 SELECT count(*)
13793 into l_parent_count
13794 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
13795 WHERE h.OPEN_FLAG = 'Y'
13796 and h.header_id = ol.header_id
13797 and ol.SHIP_TO_ORG_ID = p_hold_source_rec.hold_entity_id
13798 and ol.OPEN_FLAG = 'Y'
13799 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
13800 and not exists ( select 'x'
13801 from oe_order_holds_ALL oh
13802 where oh.header_id = h.header_id
13803 and oh.line_id = ol.line_id
13804 and oh.hold_source_id =
13805 p_hold_source_rec.hold_source_id );
13806
13807 -- Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables.
13808
13809 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
13810
13811 select meaning into l_user_activity_name
13812 from oe_lookups
13813 where lookup_type = DECODE(p_item_type,
13814 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
13815 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
13816 and lookup_code = p_activity_name;
13817
13818 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
13819 fnd_message.set_token('WF_ACT', l_user_activity_name);
13820 OE_MSG_PUB.ADD;
13821 oe_debug_pub.add(' Hold Not applied for FEW of the requested records');
13822 END IF;
13823 END IF;
13824 END IF;
13825 END IF;
13826 ER#7479609 end*/
13827 /*********************************************************
13828 HOLD CRITERIA 1 : WAREHOUSE
13829 *********************************************************/
13830
13831 ELSIF p_hold_source_rec.hold_entity_code = 'W'
13832 AND p_hold_source_rec.hold_entity_code2 IS NULL THEN
13833
13834 --ER#7479609 start
13835 l_hold_entity_where_clause := 'and ol.SHIP_FROM_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||'''';
13836
13837
13838 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for W');
13839 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
13840 ,p_line_id => p_hold_source_rec.line_id
13841 ,p_org_id => p_org_id
13842 ,p_hold_entity_where_clause => l_hold_entity_where_clause
13843 ,p_item_type => p_item_type
13844 ,p_activity_name => l_activity_name
13845 ,p_activity_status => l_act_status
13846 ,p_additional_where_clause => l_additional_where_clause
13847 ,x_is_hold_applied => x_is_hold_applied);
13848 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for W');
13849 --ER#7479609 end
13850
13851 /*ER#7479609 start
13852 IF p_hold_source_rec.line_id IS NOT NULL THEN
13853 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
13854 ( ORDER_HOLD_ID
13855 , LAST_UPDATE_DATE
13856 , LAST_UPDATED_BY
13857 , CREATION_DATE
13858 , CREATED_BY
13859 , LAST_UPDATE_LOGIN
13860 , HOLD_SOURCE_ID
13861 , HEADER_ID
13862 , LINE_ID
13863 , RELEASED_FLAG
13864 , ORG_ID
13865 )
13866 SELECT
13867 OE_ORDER_HOLDS_S.NEXTVAL
13868 , SYSDATE
13869 , :l_user_id
13870 , SYSDATE
13871 , :l_user_id
13872 , NULL
13873 , :hold_source_id
13874 , h.HEADER_ID
13875 , ol.line_id
13876 , ''N''
13877 , h.org_id --ER#7479609 :l_org_id
13878 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
13879 WHERE h.OPEN_FLAG = ''Y''
13880 and h.org_id = :l_org_id --ER#7479609
13881 and h.header_id = ol.header_id
13882 and ol.line_id = :line_id
13883 and ol.SHIP_FROM_ORG_ID = :hold_entity_id
13884 and ol.OPEN_FLAG = ''Y''
13885 -- QUOTING change
13886 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
13887 and not exists ( select ''x''
13888 from oe_order_holds_ALL oh
13889 where oh.header_id = h.header_id
13890 and oh.line_id = ol.line_id
13891 and oh.hold_source_id =:hold_source_id )';
13892 IF p_item_type is not null and p_activity_name is not null then
13893 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
13894 , wf_process_activities wpa
13895 where was.process_activity = wpa.instance_id
13896 and item_type = :p_item_type
13897 and item_key = to_char(ol.line_id)
13898 and activity_name = :l_activity_name
13899 and activity_status = :l_activity_status)';
13900 END IF;
13901 IF l_additional_where_clause = 'PICK_TRUE' THEN
13902 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
13903 where w.source_line_id = ol.line_id
13904 and w.source_code = ''OE''
13905 and w.released_status in (''Y'', ''C''))';
13906 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
13907 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
13908 where wdd.source_line_id = ol.LINE_ID
13909 and wdd.source_code = ''OE''
13910 and wda.delivery_detail_id = wdd.delivery_detail_id
13911 and wda.parent_delivery_detail_id is not null)';
13912 END IF;
13913 IF p_item_type is null and p_activity_name is null then
13914 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
13915 ELSE
13916 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
13917 IF sql%rowcount = 0 THEN
13918 x_is_hold_applied := FALSE;
13919 ELSIF sql%rowcount = 1 THEN
13920 x_is_hold_applied := TRUE;
13921 END IF;
13922 END IF;
13923 ELSE
13924 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
13925 ( ORDER_HOLD_ID
13926 , LAST_UPDATE_DATE
13927 , LAST_UPDATED_BY
13928 , CREATION_DATE
13929 , CREATED_BY
13930 , LAST_UPDATE_LOGIN
13931 , HOLD_SOURCE_ID
13932 , HEADER_ID
13933 , LINE_ID
13934 , RELEASED_FLAG
13935 , ORG_ID
13936 )
13937 SELECT
13938 OE_ORDER_HOLDS_S.NEXTVAL
13939 , SYSDATE
13940 , :l_user_id
13941 , SYSDATE
13942 , :l_user_id
13943 , NULL
13944 , :hold_source_id
13945 , h.HEADER_ID
13946 , ol.line_id
13947 , ''N''
13948 , h.org_id --ER#7479609 :l_org_id
13949 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
13950 WHERE h.OPEN_FLAG = ''Y''
13951 and h.org_id = :l_org_id --ER#7479609
13952 and h.header_id = ol.header_id
13953 and ol.SHIP_FROM_ORG_ID = :hold_entity_id
13954 and ol.OPEN_FLAG = ''Y''
13955 -- QUOTING change
13956 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
13957 and not exists ( select ''x''
13958 from oe_order_holds_ALL oh
13959 where oh.header_id = h.header_id
13960 and oh.line_id = ol.line_id
13961 and oh.hold_source_id =:hold_source_id )';
13962 IF p_item_type is not null and p_activity_name is not null then
13963 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
13964 , wf_process_activities wpa
13965 where was.process_activity = wpa.instance_id
13966 and item_type = :p_item_type
13967 and item_key = to_char(ol.line_id)
13968 and activity_name = :l_activity_name
13969 and activity_status = :l_activity_status)';
13970 END IF;
13971 IF l_additional_where_clause = 'PICK_TRUE' THEN
13972 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
13973 where w.source_line_id = ol.line_id
13974 and w.source_code = ''OE''
13975 and w.released_status in (''Y'', ''C''))';
13976 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
13977 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
13978 where wdd.source_line_id = ol.LINE_ID
13979 and wdd.source_code = ''OE''
13980 and wda.delivery_detail_id = wdd.delivery_detail_id
13981 and wda.parent_delivery_detail_id is not null)';
13982 END IF;
13983 IF p_item_type is null and p_activity_name is null then
13984 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
13985 ELSE
13986 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
13987 l_sql_rowcount := sql%rowcount;
13988 IF l_sql_rowcount = 0 THEN
13989
13990 select meaning into l_user_activity_name
13991 from oe_lookups
13992 where lookup_type = DECODE(p_item_type,
13993 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
13994 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
13995 and lookup_code = p_activity_name;
13996
13997 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
13998 fnd_message.set_token('WF_ACT', l_user_activity_name);
13999 OE_MSG_PUB.ADD;
14000 oe_debug_pub.add(' Hold Not applied for All requested records');
14001 RAISE FND_API.G_EXC_ERROR;
14002 ELSIF l_sql_rowcount > 0 THEN
14003 SELECT count(*)
14004 into l_parent_count
14005 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
14006 WHERE h.OPEN_FLAG = 'Y'
14007 and h.header_id = ol.header_id
14008 and ol.SHIP_FROM_ORG_ID = p_hold_source_rec.hold_entity_id
14009 and ol.OPEN_FLAG = 'Y'
14010 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
14011 and not exists ( select 'x'
14012 from oe_order_holds_ALL oh
14013 where oh.header_id = h.header_id
14014 and oh.line_id = ol.line_id
14015 and oh.hold_source_id =
14016 p_hold_source_rec.hold_source_id );
14017
14018 -- Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables.
14019
14020 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
14021
14022 select meaning into l_user_activity_name
14023 from oe_lookups
14024 where lookup_type = DECODE(p_item_type,
14025 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
14026 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
14027 and lookup_code = p_activity_name;
14028
14029 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
14030 fnd_message.set_token('WF_ACT', l_user_activity_name);
14031 OE_MSG_PUB.ADD;
14032 oe_debug_pub.add(' Hold Not applied for FEW of the requested records');
14033 END IF;
14034 END IF;
14035 END IF;
14036 END IF;
14037 ER#7479609 end*/
14038 /*********************************************************
14039 HOLD CRITERIA 1 : ITEM
14040 *********************************************************/
14041
14042 ELSIF p_hold_source_rec.hold_entity_code = 'I'
14043 AND p_hold_source_rec.hold_entity_code2 IS NULL THEN
14044
14045 --ER#7479609 start
14046 l_hold_entity_where_clause := 'and ol.INVENTORY_ITEM_ID = '||''''||p_hold_source_rec.hold_entity_id||'''';
14047
14048
14049 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for I');
14050 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14051 ,p_line_id => p_hold_source_rec.line_id
14052 ,p_org_id => p_org_id
14053 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14054 ,p_item_type => p_item_type
14055 ,p_activity_name => l_activity_name
14056 ,p_activity_status => l_act_status
14057 ,p_additional_where_clause => l_additional_where_clause
14058 ,x_is_hold_applied => x_is_hold_applied);
14059 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for I');
14060 --ER#7479609 end
14061
14062 /*ER#7479609 start
14063 IF p_hold_source_rec.line_id IS NOT NULL THEN
14064 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
14065 ( ORDER_HOLD_ID
14066 , LAST_UPDATE_DATE
14067 , LAST_UPDATED_BY
14068 , CREATION_DATE
14069 , CREATED_BY
14070 , LAST_UPDATE_LOGIN
14071 , HOLD_SOURCE_ID
14072 , HEADER_ID
14073 , LINE_ID
14074 , RELEASED_FLAG
14075 , ORG_ID
14076 )
14077 SELECT
14078 OE_ORDER_HOLDS_S.NEXTVAL
14079 , SYSDATE
14080 , :l_user_id
14081 , SYSDATE
14082 , :l_user_id
14083 , NULL
14084 , :hold_source_id
14085 , h.HEADER_ID
14086 , ol.line_id
14087 , ''N''
14088 , h.org_id --ER#7479609 :l_org_id
14089 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
14090 WHERE h.OPEN_FLAG = ''Y''
14091 and h.org_id = :l_org_id --ER#7479609
14092 and h.header_id = ol.header_id
14093 and ol.line_id = :line_id
14094 and ol.INVENTORY_ITEM_ID = :hold_entity_id
14095 and ol.OPEN_FLAG = ''Y''
14096 -- QUOTING change
14097 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
14098 and not exists ( select ''x''
14099 from oe_order_holds_ALL oh
14100 where oh.header_id = h.header_id
14101 and oh.line_id = ol.line_id
14102 and oh.hold_source_id =:hold_source_id )';
14103 IF p_item_type is not null and p_activity_name is not null then
14104 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
14105 , wf_process_activities wpa
14106 where was.process_activity = wpa.instance_id
14107 and item_type = :p_item_type
14108 and item_key = to_char(ol.line_id)
14109 and activity_name = :l_activity_name
14110 and activity_status = :l_activity_status)';
14111 END IF;
14112 IF l_additional_where_clause = 'PICK_TRUE' THEN
14113 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
14114 where w.source_line_id = ol.line_id
14115 and w.source_code = ''OE''
14116 and w.released_status in (''Y'', ''C''))';
14117 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
14118 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
14119 where wdd.source_line_id = ol.LINE_ID
14120 and wdd.source_code = ''OE''
14121 and wda.delivery_detail_id = wdd.delivery_detail_id
14122 and wda.parent_delivery_detail_id is not null)';
14123 END IF;
14124 IF p_item_type is null and p_activity_name is null then
14125 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
14126 ELSE
14127 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.line_id, p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
14128 IF sql%rowcount = 0 THEN
14129 x_is_hold_applied := FALSE;
14130 ELSIF sql%rowcount = 1 THEN
14131 x_is_hold_applied := TRUE;
14132 END IF;
14133 END IF;
14134
14135 ELSE
14136 l_sqlmt := 'INSERT INTO OE_ORDER_HOLDS_ALL
14137 ( ORDER_HOLD_ID
14138 , LAST_UPDATE_DATE
14139 , LAST_UPDATED_BY
14140 , CREATION_DATE
14141 , CREATED_BY
14142 , LAST_UPDATE_LOGIN
14143 , HOLD_SOURCE_ID
14144 , HEADER_ID
14145 , LINE_ID
14146 , RELEASED_FLAG
14147 , ORG_ID
14148 )
14149 SELECT
14150 OE_ORDER_HOLDS_S.NEXTVAL
14151 , SYSDATE
14152 , :l_user_id
14153 , SYSDATE
14154 , :l_user_id
14155 , NULL
14156 , :hold_source_id
14157 , h.HEADER_ID
14158 , ol.line_id
14159 , ''N''
14160 , h.org_id --ER#7479609 :l_org_id
14161 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
14162 WHERE h.OPEN_FLAG = ''Y''
14163 and h.org_id = :l_org_id --ER#7479609
14164 and h.header_id = ol.header_id
14165 and ol.INVENTORY_ITEM_ID = :hold_entity_id
14166 and ol.OPEN_FLAG = ''Y''
14167 -- QUOTING change
14168 and nvl(h.TRANSACTION_PHASE_CODE,''F'') = ''F''
14169 and not exists ( select ''x''
14170 from oe_order_holds_ALL oh
14171 where oh.header_id = h.header_id
14172 and oh.line_id = ol.line_id
14173 and oh.hold_source_id =:hold_source_id )';
14174 IF p_item_type is not null and p_activity_name is not null then
14175 l_sqlmt := l_sqlmt||' and not exists (select 1 from wf_item_activity_statuses was
14176 , wf_process_activities wpa
14177 where was.process_activity = wpa.instance_id
14178 and item_type = :p_item_type
14179 and item_key = to_char(ol.line_id)
14180 and activity_name = :l_activity_name
14181 and activity_status = :l_activity_status)';
14182 END IF;
14183 IF l_additional_where_clause = 'PICK_TRUE' THEN
14184 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details w
14185 where w.source_line_id = ol.line_id
14186 and w.source_code = ''OE''
14187 and w.released_status in (''Y'', ''C''))';
14188 ELSIF l_additional_where_clause = 'PACK_TRUE' THEN
14189 l_sqlmt := l_sqlmt||' and not exists (select 1 from wsh_delivery_details wdd, wsh_delivery_assignments wda
14190 where wdd.source_line_id = ol.LINE_ID
14191 and wdd.source_code = ''OE''
14192 and wda.delivery_detail_id = wdd.delivery_detail_id
14193 and wda.parent_delivery_detail_id is not null)';
14194 END IF;
14195 IF p_item_type is null and p_activity_name is null then
14196 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id, p_hold_source_rec.hold_source_id;
14197 ELSE
14198 execute immediate l_sqlmt using l_user_id, l_user_id, p_hold_source_rec.hold_source_id, p_org_id, p_hold_source_rec.hold_entity_id , p_hold_source_rec.hold_source_id, 'OEOL', l_activity_name, l_act_status;
14199 l_sql_rowcount := sql%rowcount;
14200 IF l_sql_rowcount = 0 THEN
14201
14202 select meaning into l_user_activity_name
14203 from oe_lookups
14204 where lookup_type = DECODE(p_item_type,
14205 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
14206 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
14207 and lookup_code = p_activity_name;
14208
14209 fnd_message.set_name('ONT', 'OE_NO_HOLD_ALL_LINES');
14210 fnd_message.set_token('WF_ACT', l_user_activity_name);
14211 OE_MSG_PUB.ADD;
14212 RAISE FND_API.G_EXC_ERROR;
14213 ELSIF l_sql_rowcount > 0 THEN
14214 SELECT count(*)
14215 into l_parent_count
14216 FROM OE_ORDER_HEADERS_ALL h, OE_ORDER_LINES_ALL ol
14217 WHERE h.OPEN_FLAG = 'Y'
14218 and h.header_id = ol.header_id
14219 and ol.INVENTORY_ITEM_ID = p_hold_source_rec.hold_entity_id
14220 and ol.OPEN_FLAG = 'Y'
14221 and nvl(h.TRANSACTION_PHASE_CODE,'F') = 'F'
14222 and not exists ( select 'x'
14223 from oe_order_holds_ALL oh
14224 where oh.header_id = h.header_id
14225 and oh.line_id = ol.line_id
14226 and oh.hold_source_id =
14227 p_hold_source_rec.hold_source_id );
14228
14229 -- Note: The above query is used based on WHERE clause of the l_sqlmt but without any query on Workflow or Shipping product tables.
14230
14231 IF l_sql_rowcount < (l_parent_count+l_sql_rowcount) THEN
14232
14233 select meaning into l_user_activity_name
14234 from oe_lookups
14235 where lookup_type = DECODE(p_item_type,
14236 OE_GLOBALS.G_WFI_HDR, 'HOLDABLE_HEADER_ACTIVITIES',
14237 OE_GLOBALS.G_WFI_LIN, 'HOLDABLE_LINE_ACTIVITIES', '-XX')
14238 and lookup_code = p_activity_name;
14239
14240 fnd_message.set_name('ONT', 'OE_NO_HOLD_FEW_LINES');
14241 fnd_message.set_token('WF_ACT', l_user_activity_name);
14242 OE_MSG_PUB.ADD;
14243
14244 END IF;
14245 END IF;
14246 END IF;
14247 END IF;
14248 ER#7479609 end*/
14249
14250 --ER#7479609 start
14251 ELSIF p_hold_source_rec.hold_entity_code = 'PR' and
14252 p_hold_source_rec.hold_entity_code2 = 'T' THEN
14253
14254 l_hold_entity_where_clause := 'and ol.PROJECT_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
14255 ||' and ol.TASK_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
14256
14257
14258 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for PR and T');
14259 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14260 ,p_line_id => p_hold_source_rec.line_id
14261 ,p_org_id => p_org_id
14262 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14263 ,p_item_type => p_item_type
14264 ,p_activity_name => l_activity_name
14265 ,p_activity_status => l_act_status
14266 ,p_additional_where_clause => l_additional_where_clause
14267 ,x_is_hold_applied => x_is_hold_applied);
14268 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for PR and T');
14269 --ER#7479609 end
14270
14271 --ER#7479609 start
14272 ELSIF p_hold_source_rec.hold_entity_code = 'PR' and
14273 p_hold_source_rec.hold_entity_code2 IS NULL THEN
14274
14275 l_hold_entity_where_clause := 'and ol.PROJECT_ID = '||''''||p_hold_source_rec.hold_entity_id||'''';
14276
14277
14278 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for PR and T');
14279 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14280 ,p_line_id => p_hold_source_rec.line_id
14281 ,p_org_id => p_org_id
14282 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14283 ,p_item_type => p_item_type
14284 ,p_activity_name => l_activity_name
14285 ,p_activity_status => l_act_status
14286 ,p_additional_where_clause => l_additional_where_clause
14287 ,x_is_hold_applied => x_is_hold_applied);
14288 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for PR and T');
14289 --ER#7479609 end
14290
14291
14292 --ER#7479609 start
14293 ELSIF p_hold_source_rec.hold_entity_code = 'PL' and
14294 p_hold_source_rec.hold_entity_code2 = 'TC' THEN
14295
14296 l_hold_entity_where_clause := 'and h.PRICE_LIST_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
14297 ||' and h.TRANSACTIONAL_CURR_CODE = '||''''||p_hold_source_rec.hold_entity_id2||'''';
14298
14299
14300 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for PL and TC');
14301 InsertTable_OOH_Header (p_hold_source_id => p_hold_source_rec.hold_source_id
14302 ,p_header_id =>p_hold_source_rec.header_id
14303 ,p_org_id => p_org_id
14304 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14305 ,p_item_type => p_item_type
14306 ,p_activity_name => l_activity_name
14307 ,p_activity_status => l_act_status
14308 ,p_additional_where_clause => l_additional_where_clause
14309 ,x_is_hold_applied => x_is_hold_applied);
14310 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for PR and T');
14311 --ER#7479609 end
14312
14313
14314 --ER#7479609 start
14315 ELSIF p_hold_source_rec.hold_entity_code = 'PL' and
14316 p_hold_source_rec.hold_entity_code2 IS NULL THEN
14317
14318 l_hold_entity_where_clause := 'and h.PRICE_LIST_ID = '||''''||p_hold_source_rec.hold_entity_id||'''';
14319
14320
14321 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for PL and TC');
14322 InsertTable_OOH_Header (p_hold_source_id => p_hold_source_rec.hold_source_id
14323 ,p_header_id =>p_hold_source_rec.header_id
14324 ,p_org_id => p_org_id
14325 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14326 ,p_item_type => p_item_type
14327 ,p_activity_name => l_activity_name
14328 ,p_activity_status => l_act_status
14329 ,p_additional_where_clause => l_additional_where_clause
14330 ,x_is_hold_applied => x_is_hold_applied);
14331 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for PR and T');
14332 --ER#7479609 end
14333
14334 --ER#7479609 start
14335 ELSIF p_hold_source_rec.hold_entity_code = 'OT' and
14336 p_hold_source_rec.hold_entity_code2 = 'LT' THEN
14337
14338 l_hold_entity_where_clause := 'and h.ORDER_TYPE_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
14339 ||' and ol.LINE_TYPE_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
14340
14341
14342 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for OT and LT');
14343 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14344 ,p_line_id => p_hold_source_rec.line_id
14345 ,p_org_id => p_org_id
14346 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14347 ,p_item_type => p_item_type
14348 ,p_activity_name => l_activity_name
14349 ,p_activity_status => l_act_status
14350 ,p_additional_where_clause => l_additional_where_clause
14351 ,x_is_hold_applied => x_is_hold_applied);
14352 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for OT and LT');
14353 --ER#7479609 end
14354
14355 --ER#7479609 start
14356 ELSIF p_hold_source_rec.hold_entity_code = 'OT' and
14357 p_hold_source_rec.hold_entity_code2 = 'TC' THEN
14358
14359 l_hold_entity_where_clause := 'and h.ORDER_TYPE_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
14360 ||' and h.TRANSACTIONAL_CURR_CODE = '||''''||p_hold_source_rec.hold_entity_id2||'''';
14361
14362
14363 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Header for OT and TC');
14364 InsertTable_OOH_Header (p_hold_source_id => p_hold_source_rec.hold_source_id
14365 ,p_header_id =>p_hold_source_rec.header_id
14366 ,p_org_id => p_org_id
14367 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14368 ,p_item_type => p_item_type
14369 ,p_activity_name => l_activity_name
14370 ,p_activity_status => l_act_status
14371 ,p_additional_where_clause => l_additional_where_clause
14372 ,x_is_hold_applied => x_is_hold_applied);
14373 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Header for OT and TC');
14374 --ER#7479609 end
14375
14376 --ER#7479609 start
14377 ELSIF p_hold_source_rec.hold_entity_code = 'OT' and
14378 p_hold_source_rec.hold_entity_code2 IS NULL THEN
14379
14380 l_hold_entity_where_clause := 'and h.ORDER_TYPE_ID = '||''''||p_hold_source_rec.hold_entity_id||'''';
14381
14382
14383 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Header for OT and TC');
14384 InsertTable_OOH_Header (p_hold_source_id => p_hold_source_rec.hold_source_id
14385 ,p_header_id =>p_hold_source_rec.header_id
14386 ,p_org_id => p_org_id
14387 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14388 ,p_item_type => p_item_type
14389 ,p_activity_name => l_activity_name
14390 ,p_activity_status => l_act_status
14391 ,p_additional_where_clause => l_additional_where_clause
14392 ,x_is_hold_applied => x_is_hold_applied);
14393 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Header for OT and TC');
14394 --ER#7479609 end
14395
14396
14397 --ER#7479609 start
14398 ELSIF p_hold_source_rec.hold_entity_code = 'CD' and
14399 p_hold_source_rec.hold_entity_code2 = 'CB' THEN
14400
14401 l_hold_entity_where_clause := 'and to_char(ol.CREATION_DATE,''DD-MON-RRRR'') = '||''''||p_hold_source_rec.hold_entity_id||''''
14402 ||' and ol.CREATED_BY = '||''''||p_hold_source_rec.hold_entity_id2||'''';
14403
14404
14405 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for CD and CB');
14406 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14407 ,p_line_id => p_hold_source_rec.line_id
14408 ,p_org_id => p_org_id
14409 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14410 ,p_item_type => p_item_type
14411 ,p_activity_name => l_activity_name
14412 ,p_activity_status => l_act_status
14413 ,p_additional_where_clause => l_additional_where_clause
14414 ,x_is_hold_applied => x_is_hold_applied);
14415 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for CD and CB');
14416 --ER#7479609 end
14417
14418 --ER#7479609 start
14419 ELSIF p_hold_source_rec.hold_entity_code = 'CD' and
14420 p_hold_source_rec.hold_entity_code2 IS NULL THEN
14421
14422 l_hold_entity_where_clause := 'and to_char(ol.CREATION_DATE,''DD-MON-RRRR'') = '||''''||p_hold_source_rec.hold_entity_id||'''';
14423
14424
14425 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for CD');
14426 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14427 ,p_line_id => p_hold_source_rec.line_id
14428 ,p_org_id => p_org_id
14429 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14430 ,p_item_type => p_item_type
14431 ,p_activity_name => l_activity_name
14432 ,p_activity_status => l_act_status
14433 ,p_additional_where_clause => l_additional_where_clause
14434 ,x_is_hold_applied => x_is_hold_applied);
14435 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for CD');
14436 --ER#7479609 end
14437
14438
14439 --ER#7479609 start
14440 ELSIF p_hold_source_rec.hold_entity_code = 'SC'
14441 AND p_hold_source_rec.hold_entity_code2 IS NULL THEN
14442
14443 l_hold_entity_where_clause := 'and h.SALES_CHANNEL_CODE = '||''''||p_hold_source_rec.hold_entity_id||'''';
14444
14445
14446 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for SC');
14447 InsertTable_OOH_Header (p_hold_source_id => p_hold_source_rec.hold_source_id
14448 ,p_header_id =>p_hold_source_rec.header_id
14449 ,p_org_id => p_org_id
14450 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14451 ,p_item_type => p_item_type
14452 ,p_activity_name => l_activity_name
14453 ,p_activity_status => l_act_status
14454 ,p_additional_where_clause => l_additional_where_clause
14455 ,x_is_hold_applied => x_is_hold_applied);
14456 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for SC');
14457 --ER#7479609 end
14458
14459 --ER#7479609 start
14460 ELSIF p_hold_source_rec.hold_entity_code = 'P'
14461 AND p_hold_source_rec.hold_entity_code2 IS NULL THEN
14462
14463
14464 OE_DEBUG_PUB.ADD('Calling PaymentType_Hold for P');
14465 PaymentType_Hold (p_hold_source_rec => p_hold_source_rec
14466 ,p_org_id => p_org_id
14467 ,p_item_type => p_item_type
14468 ,p_activity_name => l_activity_name
14469 ,p_activity_status => l_act_status
14470 ,p_additional_where_clause => l_additional_where_clause
14471 ,x_is_hold_applied => x_is_hold_applied);
14472
14473 --ER#7479609 start
14474 IF NOT x_is_hold_applied THEN
14475 x_return_status := '0';
14476 END IF;
14477 --ER#7479609 end
14478
14479 OE_DEBUG_PUB.ADD('After Calling PaymentType_Hold for P');
14480 --ER#7479609 end
14481
14482 --ER#7479609 start
14483 ELSIF p_hold_source_rec.hold_entity_code = 'SM'
14484 AND p_hold_source_rec.hold_entity_code2 IS NULL THEN
14485
14486 l_hold_entity_where_clause := 'and ol.SHIPPING_METHOD_CODE = '||''''||p_hold_source_rec.hold_entity_id||'''';
14487
14488
14489 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for SM');
14490 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14491 ,p_line_id => p_hold_source_rec.line_id
14492 ,p_org_id => p_org_id
14493 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14494 ,p_item_type => p_item_type
14495 ,p_activity_name => l_activity_name
14496 ,p_activity_status => l_act_status
14497 ,p_additional_where_clause => l_additional_where_clause
14498 ,x_is_hold_applied => x_is_hold_applied);
14499 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for SM');
14500 --ER#7479609 end
14501
14502 --ER#7479609 start
14503 ELSIF p_hold_source_rec.hold_entity_code = 'D'
14504 AND p_hold_source_rec.hold_entity_code2 IS NULL THEN
14505
14506 --ER#7479609 start
14507 l_hold_entity_where_clause := 'and ol.DELIVER_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||'''';
14508
14509
14510 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for D');
14511 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14512 ,p_line_id => p_hold_source_rec.line_id
14513 ,p_org_id => p_org_id
14514 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14515 ,p_item_type => p_item_type
14516 ,p_activity_name => l_activity_name
14517 ,p_activity_status => l_act_status
14518 ,p_additional_where_clause => l_additional_where_clause
14519 ,x_is_hold_applied => x_is_hold_applied);
14520 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for D');
14521 --ER#7479609 end
14522
14523
14524 --ER#7479609 start
14525 ELSIF p_hold_source_rec.hold_entity_code = 'TM'
14526 AND p_hold_source_rec.hold_entity_code2 IS NULL THEN
14527
14528 BEGIN
14529 l_line_id_tab.delete;
14530
14531 IF p_hold_source_rec.line_id IS NULL THEN
14532
14533 select line_id
14534 BULK COLLECT INTO l_line_id_tab
14535 from oe_order_lines_all
14536 where inventory_item_id=p_hold_source_rec.hold_entity_id
14537 and line_id=top_model_line_id
14538 and top_model_line_id IS NOT NULL;
14539
14540 ELSE
14541
14542 select line_id
14543 BULK COLLECT INTO l_line_id_tab
14544 from oe_order_lines_all
14545 where inventory_item_id=p_hold_source_rec.hold_entity_id
14546 and line_id=top_model_line_id
14547 and line_id=p_hold_source_rec.line_id
14548 and top_model_line_id IS NOT NULL;
14549
14550 END IF;
14551
14552 EXCEPTION
14553 WHEN OTHERS THEN
14554 NULL;
14555 END;
14556
14557
14558
14559 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for TM:'||l_line_id_tab.count);
14560
14561 FOR i in 1 .. l_line_id_tab.count LOOP
14562
14563 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14564 ,p_line_id => l_line_id_tab(i)
14565 ,p_org_id => p_org_id
14566 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14567 ,p_item_type => p_item_type
14568 ,p_activity_name => l_activity_name
14569 ,p_activity_status => l_act_status
14570 ,p_additional_where_clause => l_additional_where_clause
14571 ,x_is_hold_applied => x_is_hold_applied);
14572 END LOOP;
14573
14574 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for TM');
14575
14576 ELSIF p_hold_source_rec.hold_entity_code = 'TM'
14577 AND p_hold_source_rec.hold_entity_code2 = 'OI' THEN
14578
14579 BEGIN
14580 l_line_id_tab.delete;
14581
14582 IF p_hold_source_rec.line_id IS NULL THEN
14583
14584 select top_model_line_id
14585 BULK COLLECT INTO l_line_id_tab
14586 from oe_order_lines_all line_opt
14587 where line_opt.inventory_item_id=p_hold_source_rec.hold_entity_id2
14588 and line_opt.item_type_code in ('OPTION','CLASS','INCLUDED')
14589 and EXISTS (select 1 from oe_order_lines_all line_mod
14590 where line_mod.inventory_item_id=p_hold_source_rec.hold_entity_id
14591 and line_mod.line_id=line_opt.top_model_line_id);
14592 ELSE
14593
14594 select top_model_line_id
14595 BULK COLLECT INTO l_line_id_tab
14596 from oe_order_lines_all line_opt
14597 where line_opt.inventory_item_id=p_hold_source_rec.hold_entity_id2
14598 and line_opt.line_id=p_hold_source_rec.line_id
14599 and line_opt.item_type_code in ('OPTION','CLASS','INCLUDED')
14600 and EXISTS (select 1 from oe_order_lines_all line_mod
14601 where line_mod.inventory_item_id=p_hold_source_rec.hold_entity_id
14602 and line_mod.line_id=line_opt.top_model_line_id);
14603 END IF;
14604
14605 EXCEPTION
14606 WHEN OTHERS THEN
14607 NULL;
14608 END;
14609
14610
14611
14612 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for TM and OI:'||l_line_id_tab.count);
14613
14614 FOR i in 1 .. l_line_id_tab.count LOOP
14615
14616 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14617 ,p_line_id => l_line_id_tab(i)
14618 ,p_org_id => p_org_id
14619 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14620 ,p_item_type => p_item_type
14621 ,p_activity_name => l_activity_name
14622 ,p_activity_status => l_act_status
14623 ,p_additional_where_clause => l_additional_where_clause
14624 ,x_is_hold_applied => x_is_hold_applied);
14625 END LOOP;
14626
14627 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for TM and OI');
14628 --ER#7479609 end
14629
14630 --ER#12571983 start
14631 /*********************************************************
14632 HOLD CRITERIA COMBINATIONS FOR : END CUSTOMER
14633 *********************************************************/
14634 ELSIF p_hold_source_rec.hold_entity_code = 'I' and
14635 p_hold_source_rec.hold_entity_code2 IN ('EC','EN') THEN --ER# 11824468
14636
14637
14638 l_hold_entity_where_clause := 'and ol.INVENTORY_ITEM_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
14639 ||' and ol.end_customer_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
14640
14641
14642 oe_debug_pub.add('Calling InsertTable_OOH_Line for I and E/EN');
14643 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14644 ,p_line_id => p_hold_source_rec.line_id
14645 ,p_org_id => p_org_id
14646 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14647 ,p_item_type => p_item_type
14648 ,p_activity_name => l_activity_name
14649 ,p_activity_status => l_act_status
14650 ,p_additional_where_clause => l_additional_where_clause
14651 ,x_is_hold_applied => x_is_hold_applied);
14652 oe_debug_pub.add('After Calling InsertTable_OOH_Line for I and E/EN');
14653
14654
14655 ELSIF p_hold_source_rec.hold_entity_code = 'IC' and
14656 p_hold_source_rec.hold_entity_code2 IN ('EC','EN') THEN --ER# 11824468
14657 --13653352, used l_master_orgid below instead of ship_from_org
14658 l_hold_entity_where_clause := ' and ol.end_customer_ID = '||''''||p_hold_source_rec.hold_entity_id2||''''
14659 ||' and exists (Select 1
14660 from mtl_item_categories mic ,mtl_default_category_sets mdc
14661 where mdc.functional_area_id=7
14662 AND mdc.category_set_id = mic.category_set_id
14663 AND ol.INVENTORY_ITEM_ID = mic.inventory_item_id
14664 and mic.organization_id= '||''''||l_master_orgid||''''
14665 ||' and mic.category_id = '||''''||p_hold_source_rec.hold_entity_id||''''||')';
14666
14667
14668 oe_debug_pub.add('Calling InsertTable_OOH_Line for IC and EC/EN');
14669 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14670 ,p_line_id => p_hold_source_rec.line_id
14671 ,p_org_id => p_org_id
14672 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14673 ,p_item_type => p_item_type
14674 ,p_activity_name => l_activity_name
14675 ,p_activity_status => l_act_status
14676 ,p_additional_where_clause => l_additional_where_clause
14677 ,x_is_hold_applied => x_is_hold_applied);
14678 oe_debug_pub.add('After Calling InsertTable_OOH_Line for IC and EC/EN');
14679
14680
14681 ELSIF p_hold_source_rec.hold_entity_code = 'W' and
14682 p_hold_source_rec.hold_entity_code2 IN ('EC','EN') THEN --ER# 11824468
14683
14684
14685 l_hold_entity_where_clause := 'and ol.SHIP_FROM_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
14686 ||' ol.end_customer_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
14687
14688
14689 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for W and E/EN');
14690 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14691 ,p_line_id => p_hold_source_rec.line_id
14692 ,p_org_id => p_org_id
14693 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14694 ,p_item_type => p_item_type
14695 ,p_activity_name => l_activity_name
14696 ,p_activity_status => l_act_status
14697 ,p_additional_where_clause => l_additional_where_clause
14698 ,x_is_hold_applied => x_is_hold_applied);
14699 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for W and E/EN');
14700
14701 ELSIF p_hold_source_rec.hold_entity_code IN('EC','EN') --ER# 11824468
14702 AND p_hold_source_rec.hold_entity_code2 IS NULL THEN
14703 -- Use header_id for Customer based hold source
14704
14705
14706 l_hold_entity_where_clause := 'and ol.end_customer_ID = '||''''||p_hold_source_rec.hold_entity_id||'''';
14707
14708 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for EC/EN');
14709
14710 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14711 ,p_line_id => p_hold_source_rec.line_id
14712 ,p_org_id => p_org_id
14713 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14714 ,p_item_type => p_item_type
14715 ,p_activity_name => l_activity_name
14716 ,p_activity_status => l_act_status
14717 ,p_additional_where_clause => l_additional_where_clause
14718 ,x_is_hold_applied => x_is_hold_applied);
14719
14720 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for EC/EN');
14721
14722
14723
14724 ELSIF p_hold_source_rec.hold_entity_code IN('EC','EN') and --ER# 11824468
14725 p_hold_source_rec.hold_entity_code2 = 'B' THEN
14726
14727
14728 l_hold_entity_where_clause := 'and ol.end_customer_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
14729 ||' and ol.INVOICE_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
14730
14731
14732 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for EC/EN and B');
14733 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14734 ,p_line_id => p_hold_source_rec.line_id
14735 ,p_org_id => p_org_id
14736 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14737 ,p_item_type => p_item_type
14738 ,p_activity_name => l_activity_name
14739 ,p_activity_status => l_act_status
14740 ,p_additional_where_clause => l_additional_where_clause
14741 ,x_is_hold_applied => x_is_hold_applied);
14742 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for EC/EN and B');
14743
14744
14745 ELSIF p_hold_source_rec.hold_entity_code IN('EC','EN') and --ER# 11824468
14746 p_hold_source_rec.hold_entity_code2 = 'S' THEN
14747
14748
14749 l_hold_entity_where_clause := 'and ol.end_customer_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
14750 ||' and ol.SHIP_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
14751
14752
14753 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for EC/EN and S');
14754 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14755 ,p_line_id => p_hold_source_rec.line_id
14756 ,p_org_id => p_org_id
14757 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14758 ,p_item_type => p_item_type
14759 ,p_activity_name => l_activity_name
14760 ,p_activity_status => l_act_status
14761 ,p_additional_where_clause => l_additional_where_clause
14762 ,x_is_hold_applied => x_is_hold_applied);
14763 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for EC/EN and S');
14764
14765 ELSIF p_hold_source_rec.hold_entity_code IN('EC','EN') and --ER# 11824468
14766 p_hold_source_rec.hold_entity_code2 = 'D' THEN
14767
14768
14769 l_hold_entity_where_clause := 'and ol.end_customer_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
14770 ||' and ol.DELIVER_TO_ORG_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
14771
14772
14773 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for EC/EN and D');
14774 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14775 ,p_line_id => p_hold_source_rec.line_id
14776 ,p_org_id => p_org_id
14777 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14778 ,p_item_type => p_item_type
14779 ,p_activity_name => l_activity_name
14780 ,p_activity_status => l_act_status
14781 ,p_additional_where_clause => l_additional_where_clause
14782 ,x_is_hold_applied => x_is_hold_applied);
14783 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for EC/EN and D');
14784
14785 ELSIF p_hold_source_rec.hold_entity_code IN('EC','EN') and --ER# 11824468
14786 p_hold_source_rec.hold_entity_code2 = 'PL' THEN
14787
14788
14789 l_hold_entity_where_clause := 'and ol.end_customer_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
14790 ||' and ol.PRICE_LIST_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
14791
14792
14793 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for EC/EN and PL');
14794 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14795 ,p_line_id => p_hold_source_rec.line_id
14796 ,p_org_id => p_org_id
14797 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14798 ,p_item_type => p_item_type
14799 ,p_activity_name => l_activity_name
14800 ,p_activity_status => l_act_status
14801 ,p_additional_where_clause => l_additional_where_clause
14802 ,x_is_hold_applied => x_is_hold_applied);
14803 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for EC/EN and PL');
14804
14805 ELSIF p_hold_source_rec.hold_entity_code IN('EC','EN') and --ER# 11824468
14806 p_hold_source_rec.hold_entity_code2 = 'LT' THEN
14807
14808
14809 l_hold_entity_where_clause := 'and ol.end_customer_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
14810 ||' and ol.LINE_TYPE_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
14811
14812
14813 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for EC/EN and LT');
14814 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14815 ,p_line_id => p_hold_source_rec.line_id
14816 ,p_org_id => p_org_id
14817 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14818 ,p_item_type => p_item_type
14819 ,p_activity_name => l_activity_name
14820 ,p_activity_status => l_act_status
14821 ,p_additional_where_clause => l_additional_where_clause
14822 ,x_is_hold_applied => x_is_hold_applied);
14823 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for EC/EN and LT');
14824
14825 ELSIF p_hold_source_rec.hold_entity_code IN('EC','EN') and --ER# 11824468
14826 p_hold_source_rec.hold_entity_code2 = 'PT' THEN
14827
14828
14829 l_hold_entity_where_clause := 'and ol.end_customer_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
14830 ||' and ol.PAYMENT_TERM_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
14831
14832
14833 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for EC/EN and PT');
14834 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14835 ,p_line_id => p_hold_source_rec.line_id
14836 ,p_org_id => p_org_id
14837 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14838 ,p_item_type => p_item_type
14839 ,p_activity_name => l_activity_name
14840 ,p_activity_status => l_act_status
14841 ,p_additional_where_clause => l_additional_where_clause
14842 ,x_is_hold_applied => x_is_hold_applied);
14843 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for EC/EN and PT');
14844
14845 ELSIF p_hold_source_rec.hold_entity_code IN('EC','EN') and --ER# 11824468
14846 p_hold_source_rec.hold_entity_code2 = 'OT' THEN
14847
14848
14849 l_hold_entity_where_clause := 'and ol.end_customer_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
14850 ||' and h.ORDER_TYPE_ID = '||''''||p_hold_source_rec.hold_entity_id2||'''';
14851
14852 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for EC/EN and OT');
14853 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14854 ,p_line_id => p_hold_source_rec.line_id
14855 ,p_org_id => p_org_id
14856 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14857 ,p_item_type => p_item_type
14858 ,p_activity_name => l_activity_name
14859 ,p_activity_status => l_act_status
14860 ,p_additional_where_clause => l_additional_where_clause
14861 ,x_is_hold_applied => x_is_hold_applied);
14862
14863 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for EC/EN and OT');
14864
14865 ELSIF p_hold_source_rec.hold_entity_code IN('EC','EN') and --ER# 11824468
14866 p_hold_source_rec.hold_entity_code2 = 'P' THEN
14867
14868
14869 OE_DEBUG_PUB.ADD('Calling PaymentType_Hold for EC/EN and P');
14870 PaymentType_Hold (p_hold_source_rec => p_hold_source_rec
14871 ,p_org_id => p_org_id
14872 ,p_item_type => p_item_type
14873 ,p_activity_name => l_activity_name
14874 ,p_activity_status => l_act_status
14875 ,p_additional_where_clause => l_additional_where_clause
14876 ,x_is_hold_applied => x_is_hold_applied);
14877
14878
14879 IF NOT x_is_hold_applied THEN
14880 x_return_status := '0';
14881 END IF;
14882
14883
14884 OE_DEBUG_PUB.ADD('After Calling InsePaymentType_Hold for EC/EN and P');
14885
14886 ELSIF p_hold_source_rec.hold_entity_code IN('EC','EN') and --ER# 11824468
14887 p_hold_source_rec.hold_entity_code2 = 'TC' THEN
14888
14889
14890 l_hold_entity_where_clause := 'and ol.end_customer_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
14891 ||' and h.TRANSACTIONAL_CURR_CODE = '||''''||p_hold_source_rec.hold_entity_id2||'''';
14892
14893 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for EC/EN and TC');
14894 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14895 ,p_line_id => p_hold_source_rec.line_id
14896 ,p_org_id => p_org_id
14897 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14898 ,p_item_type => p_item_type
14899 ,p_activity_name => l_activity_name
14900 ,p_activity_status => l_act_status
14901 ,p_additional_where_clause => l_additional_where_clause
14902 ,x_is_hold_applied => x_is_hold_applied);
14903
14904 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for EC/EN and TC');
14905
14906 ELSIF p_hold_source_rec.hold_entity_code IN('EC','EN') and --ER# 11824468
14907 p_hold_source_rec.hold_entity_code2 = 'ST' THEN
14908
14909
14910 l_hold_entity_where_clause := 'and ol.end_customer_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
14911 ||' and ol.SOURCE_TYPE_CODE = '||''''||p_hold_source_rec.hold_entity_id2||'''';
14912
14913
14914 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for EC/EN and ST');
14915 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14916 ,p_line_id => p_hold_source_rec.line_id
14917 ,p_org_id => p_org_id
14918 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14919 ,p_item_type => p_item_type
14920 ,p_activity_name => l_activity_name
14921 ,p_activity_status => l_act_status
14922 ,p_additional_where_clause => l_additional_where_clause
14923 ,x_is_hold_applied => x_is_hold_applied);
14924 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for EC/EN and ST');
14925
14926 ELSIF p_hold_source_rec.hold_entity_code IN('EC','EN') and --ER# 11824468
14927 p_hold_source_rec.hold_entity_code2 = 'SC' THEN
14928
14929
14930 l_hold_entity_where_clause := 'and ol.end_customer_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
14931 ||' and h.SALES_CHANNEL_CODE = '||''''||p_hold_source_rec.hold_entity_id2||'''';
14932
14933 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for EC/EN and SC');
14934 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14935 ,p_line_id => p_hold_source_rec.line_id
14936 ,p_org_id => p_org_id
14937 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14938 ,p_item_type => p_item_type
14939 ,p_activity_name => l_activity_name
14940 ,p_activity_status => l_act_status
14941 ,p_additional_where_clause => l_additional_where_clause
14942 ,x_is_hold_applied => x_is_hold_applied);
14943
14944 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for EC/EN and SC');
14945
14946 ELSIF p_hold_source_rec.hold_entity_code IN('EC','EN') and
14947 p_hold_source_rec.hold_entity_code2 = 'EL' THEN
14948
14949
14950 l_hold_entity_where_clause := 'and ol.end_customer_ID = '||''''||p_hold_source_rec.hold_entity_id||''''
14951 ||' and ol.end_customer_site_use_id = '||''''
14952 ||p_hold_source_rec.hold_entity_id2||'''';
14953
14954 OE_DEBUG_PUB.ADD('Calling InsertTable_OOH_Line for EC/EN and EL');
14955 InsertTable_OOH_Line (p_hold_source_id => p_hold_source_rec.hold_source_id
14956 ,p_line_id => p_hold_source_rec.line_id
14957 ,p_org_id => p_org_id
14958 ,p_hold_entity_where_clause => l_hold_entity_where_clause
14959 ,p_item_type => p_item_type
14960 ,p_activity_name => l_activity_name
14961 ,p_activity_status => l_act_status
14962 ,p_additional_where_clause => l_additional_where_clause
14963 ,x_is_hold_applied => x_is_hold_applied);
14964
14965 OE_DEBUG_PUB.ADD('After Calling InsertTable_OOH_Line for EC/EN and EL');
14966 --ER#12571983 end
14967 -----------------------------------------------
14968
14969 END IF;
14970 -- 16053361
14971 oe_debug_pub.add( 'OE_HOLDS_PVT - Raise Integration event for Applying hold');
14972 If NVL (Fnd_Profile.Value('ONT_RAISE_STATUS_CHANGE_BUSINESS_EVENT'), 'N')='Y'
14973 THEN
14974 IF l_debug_level > 0 THEN
14975 oe_debug_pub.add( 'OE_HOLDS_PVT -Preparing paramters to pass to Integration event for Applying hold');
14976 END IF;
14977 l_count := 1;
14978 l_nameVal_tbl(l_count).name := 'CHANGE_TYPE';
14979 l_nameVal_tbl(l_count).value := 'APPLY';
14980 l_nameVal_tbl(l_count+1).name := 'HOLD_SOURCE_ID';
14981 l_nameVal_tbl(l_count+1).value := p_hold_source_rec.hold_source_id;
14982 l_nameVal_tbl(l_count+2).name := 'HOLD_RELEASE_ID';
14983 l_nameVal_tbl(l_count+2).value := null;
14984 -- Logic to derive the HEADER_ID
14985 IF p_hold_source_rec.hold_entity_code = 'O' THEN
14986 IF l_debug_level > 0 THEN
14987 oe_debug_pub.add(' p_hold_source_rec.hold_entity_code ' || p_hold_source_rec.hold_entity_code);
14988 END IF;
14989 IF p_hold_source_rec.hold_entity_id is NOT NULL THEN
14990 IF l_debug_level > 0 THEN
14991 oe_debug_pub.add(' p_hold_source_rec.hold_entity_id : ' || p_hold_source_rec.hold_entity_id);
14992 END IF;
14993 l_header_rec.header_id := p_hold_source_rec.hold_entity_id;
14994 END IF;
14995 ELSE --p_hold_source_rec.hold_entity_code != 'O'
14996 IF l_debug_level > 0 THEN
14997 oe_debug_pub.add(' p_hold_source_rec.hold_entity_code ' || p_hold_source_rec.hold_entity_code);
14998 END IF;
14999 IF p_hold_source_rec.header_id is NOT NULL THEN
15000 IF l_debug_level > 0 THEN
15001 oe_debug_pub.add(' p_hold_source_rec.header_id : ' || p_hold_source_rec.header_id);
15002 END IF;
15003 l_header_rec.header_id := p_hold_source_rec.header_id;
15004 END IF;
15005 END IF;
15006 oe_order_util.raise_business_event( p_header_id => l_header_rec.header_id,
15007 p_line_id => p_hold_source_rec.line_id,
15008 p_event_name => 'oracle.apps.ont.hold.action',
15009 p_nameVal_tbl => l_nameVal_tbl);
15010 IF l_debug_level > 0 THEN
15011 oe_debug_pub.add( 'OE_HOLDS_PVT - Done with Raising Integration event for Applying hold');
15012 END IF;
15013 END IF;
15014 oe_debug_pub.add( 'OE_HOLDS_PVT - Raise Integration event for Applying hold');
15015 -- 16053361
15016
15017
15018 -- GENESIS --
15019 IF p_hold_source_rec.line_id IS NOT NULL THEN
15020
15021 IF l_debug_level > 0 THEN
15022 oe_debug_pub.add('OE_HOLDS_PVT-CREATE ORDER HOLDS - p_hold_source_rec.line_id IS NOT NULL');
15023 END IF;
15024
15025 OPEN check_line_hold_type_cur(p_hold_source_rec.line_id);
15026 FETCH check_line_hold_type_cur INTO l_check_hold;
15027 CLOSE check_line_hold_type_cur;
15028 IF l_debug_level > 0 THEN
15029 oe_debug_pub.add('OE_HOLDS_PVT-CREATE ORDER HOLDS - l_check_hold' || l_check_hold);
15030 END IF;
15031
15032 ELSIF p_hold_source_rec.line_id IS NULL AND
15033 p_hold_source_rec.header_id IS NOT NULL THEN
15034 IF l_debug_level > 0 THEN
15035 oe_debug_pub.add('OE_HOLDS_PVT-CREATE ORDER HOLDS - p_hold_source_rec.header_id IS NOT NULL');
15036 END IF;
15037 OPEN check_hdr_hold_type_cur(p_hold_source_rec.header_id);
15038 FETCH check_hdr_hold_type_cur INTO l_check_hold;
15039 CLOSE check_hdr_hold_type_cur;
15040 IF l_debug_level > 0 THEN
15041 oe_debug_pub.add('OE_HOLDS_PVT-CREATE ORDER HOLDS - l_check_hold' || l_check_hold);
15042 END IF;
15043
15044 ELSIF p_hold_source_rec.line_id IS NULL AND
15045 p_hold_source_rec.header_id IS NULL AND
15046 p_hold_source_rec.hold_source_id IS NOT NULL THEN
15047 IF l_debug_level > 0 THEN
15048 oe_debug_pub.add('OE_HOLDS_PVT-CREATE ORDER HOLDS - p_hold_source_rec.hold_source_id IS NOT NULL');
15049 END IF;
15050 OPEN check_src_hold_type_cur(p_hold_source_rec.hold_source_id);
15051 FETCH check_src_hold_type_cur INTO l_check_hold;
15052 CLOSE check_src_hold_type_cur;
15053
15054 IF l_debug_level > 0 THEN
15055 oe_debug_pub.add('OE_HOLDS_PVT-CREATE ORDER HOLDS - l_check_hold :' || l_check_hold);
15056 END IF;
15057
15058 END IF;
15059
15060 IF l_debug_level > 0 THEN
15061 oe_debug_pub.add( 'OE_HOLDS_PVT - CREATE ORDER HOLDS - BEFORE SYNC_HEADER_LINE');
15062 END IF;
15063
15064 IF NVL(l_check_hold, 'N') = 'Y' THEN
15065 IF l_debug_level > 0 THEN
15066 oe_debug_pub.add( 'OE_HOLDS_PVT - CREATE ORDER HOLDS - l_check_hold: ' || l_check_hold);
15067 END IF;
15068
15069 IF p_hold_source_rec.hold_entity_code = 'O' THEN
15070 IF l_debug_level > 0 THEN
15071 oe_debug_pub.add(' p_hold_source_rec.hold_entity_code ' || p_hold_source_rec.hold_entity_code);
15072 END IF;
15073 IF p_hold_source_rec.hold_entity_id is NOT NULL THEN
15074 IF l_debug_level > 0 THEN
15075 oe_debug_pub.add(' p_hold_source_rec.hold_entity_id : ' || p_hold_source_rec.hold_entity_id);
15076 END IF;
15077 oe_header_util.query_row ( p_header_id => p_hold_source_rec.hold_entity_id,
15078 x_header_rec => l_header_rec);
15079 END IF; -- p_hold_source_rec.hold_entity_id is NOT NULL
15080
15081 IF p_hold_source_rec.line_id is not NULL THEN
15082 IF l_debug_level > 0 THEN
15083 oe_debug_pub.add(' p_hold_source_rec.line_id : ' || p_hold_source_rec.line_id );
15084 END IF;
15085 oe_line_util.query_row(
15086 p_line_id => p_hold_source_rec.line_id
15087 ,x_line_rec => l_line_rec
15088 );
15089 END IF;
15090
15091 -- XXXX Do we need to generate req_id here
15092 OE_SYNC_ORDER_PVT.SYNC_HEADER_LINE(p_header_rec => l_header_rec
15093 ,p_line_rec => l_line_rec
15094 ,p_hold_source_id => p_hold_source_rec.hold_source_id
15095 ,p_order_hold_id => p_hold_source_rec.hold_id -- Bug 14494236
15096 ,p_change_type => 'APPLY');
15097
15098 ELSE --p_hold_source_rec.hold_entity_code = 'O'
15099
15100 IF l_debug_level > 0 THEN
15101 oe_debug_pub.add(' p_hold_source_rec.hold_entity_code ' || p_hold_source_rec.hold_entity_code);
15102 END IF;
15103
15104 IF p_hold_source_rec.header_id is NOT NULL THEN
15105 oe_header_util.query_row ( p_header_id => p_hold_source_rec.header_id,
15106 x_header_rec => l_header_rec);
15107 END IF;
15108 IF p_hold_source_rec.line_id is not NULL THEN
15109 oe_line_util.query_row(
15110 p_line_id => p_hold_source_rec.line_id
15111 ,x_line_rec => l_line_rec
15112 );
15113 END IF;
15114
15115 -- XXXX Do we need to generate req_id here
15116 OE_SYNC_ORDER_PVT.SYNC_HEADER_LINE(p_header_rec => l_header_rec
15117 ,p_line_rec => l_line_rec
15118 ,p_hold_source_id => p_hold_source_rec.hold_source_id
15119 ,p_order_hold_id => p_hold_source_rec.hold_id -- Bug 14494236
15120 ,p_change_type => 'APPLY');
15121 END IF; --p_hold_source_rec.hold_entity_code = 'O'
15122 END IF;
15123 -- GENESIS --
15124
15125 EXCEPTION
15126 WHEN FND_API.G_EXC_ERROR THEN
15127 --ROLLBACK TO APPLY_HOLDS_PUB;
15128 x_return_status := FND_API.G_RET_STS_ERROR;
15129 OE_MSG_PUB.Count_And_Get
15130 ( p_count => x_msg_count
15131 , p_data => x_msg_data
15132 );
15133 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
15134 --ROLLBACK TO APPLY_HOLDS_PUB;
15135 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
15136 OE_MSG_PUB.Count_And_Get
15137 ( p_count => x_msg_count
15138 , p_data => x_msg_data
15139 );
15140 WHEN OTHERS THEN
15141 --ROLLBACK TO APPLY_HOLDS_PUB;
15142 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
15143 IF OE_MSG_PUB.Check_Msg_Level
15144 (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
15145 THEN
15146 OE_MSG_PUB.Add_Exc_Msg
15147 ( G_PKG_NAME
15148 , l_api_name
15149 );
15150 END IF;
15151 OE_MSG_PUB.Count_And_Get
15152 ( p_count => x_msg_count
15153 , p_data => x_msg_data
15154 );
15155
15156 END Create_Order_Holds;
15157
15158
15159 END OE_HOLDS_PVT;
15160