DBA Data[Home] [Help]

PACKAGE BODY: APPS.ONT_IMPLICITCUSTACCEPT_PVT

Source


1 PACKAGE BODY ONT_ImplicitCustAccept_PVT AS
2 /* $Header: OEXVAIPB.pls 120.12.12010000.2 2009/06/24 11:16:20 aambasth ship $ */
3 --=============================================================================
4 -- CONSTANTS
5 --=============================================================================
6 --remove, check how to get the values for debug level from atg site
7 --G_DEBUG_LEVEL VARCHAR2(1)  :=   FND_LOG.G_CURRENT_RUNTIME_LEVEL;
8 G_DEBUG       VARCHAR2(1)  := 'N';
9 G_THRESHOLD NUMBER := 50;
10 --=============================================================================
11 -- PUBLIC VARIABLES
12 --=============================================================================
13 g_action_request_tbl                OE_ORDER_PUB.Request_Tbl_Type;
14 g_cust_query                        VARCHAR2(15000) := 'SELECT  line_id  '||
15                                                               ', header_id '||
16 							      ', item_type_code '||
17 							      ', flow_status_code '||
18 							      ', actual_shipment_date '||
19 							      ', service_reference_type_code '||
20 							      ', service_reference_line_id '||
21 							      ', top_model_line_id '||
22 							      ', contingency_id '||
23 							      ', accepted_quantity '||
24 							      ', sold_to_org_id '||
25 							      ', revrec_expiration_days';
26 
27 g_query_from_clause                 VARCHAR2(1000) :=  ' FROM oe_order_lines_all ';
28 g_query_where_clause                VARCHAR2(3000) :=  ' WHERE flow_status_code = ''PRE-BILLING_ACCEPTANCE''';
29 g_customer_acceptance_enabled       BOOLEAN;
30 g_fulfillment_action                VARCHAR2(40);
31 g_return_status		            VARCHAR2(1);
32 g_msg_count		            NUMBER;
33 g_msg_data		            VARCHAR2(2000);
34 g_errbuf                            VARCHAR2(2500);
35 g_retcode                           VARCHAR2(5);
36 g_org_id			    NUMBER;
37 g_acceptance_date                   VARCHAR2(1); -- bug 8293484
38 --=============================================================================
39 -- PROCEDURES AND FUNCTIONS
40 --=============================================================================
41 --=============================================================================
42 -- PROCEDURE : implicit_acceptance
43 -- PARAMETERS: p_org_id                operating unit parameter
44 --
45 -- COMMENT   : Process order lines for implicit acceptance as well as
46 --             accepting all the lines in pre-billing and post-billing status
47 --             when the system parameter is turned off.
48 --=============================================================================
49 PROCEDURE implicit_acceptance
50 ( errbuf          OUT NOCOPY VARCHAR2
51 , retcode         OUT NOCOPY NUMBER
52 , p_org_id        IN  NUMBER
53 , p_acceptance_date IN VARCHAR2 --bug 8293484
54 )
55 IS
56 -- Section for declaring local variables
57 --
58 l_procedure_name        CONSTANT VARCHAR2(30) := ' implicit_acceptance ';
59 l_cust_sys_param        VARCHAR(1);
60 l_debug_level		CONSTANT NUMBER := oe_debug_pub.g_debug_level;
61 
62 CURSOR l_secured_ou_cur IS
63     SELECT ou.organization_id
64     FROM hr_operating_units ou
65     WHERE mo_global.check_access(ou.organization_id) = 'Y';
66 
67 BEGIN
68 
69 IF l_debug_level > 0 THEN
70     oe_debug_pub.add('Implicit_acceptance'||g_org_id);
71 END IF;
72 
73 
74 g_org_id := p_org_id;
75 
76 g_acceptance_date := NVL(p_acceptance_date,'S'); --bug 8293484
77 
78   -----------------------------------------------------------------------------
79   -- Standard Start of API savepoint
80   -----------------------------------------------------------------------------
81 
82   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
83   THEN
84     FND_LOG.string(FND_LOG.LEVEL_PROCEDURE
85                   , G_PKG_NAME || l_procedure_name || '.begin'
86                   ,'enter procedure'
87                   );
88   END IF;
89 
90 -- Get the value of system parameter,To verify whether customer acceptance is enabled.
91 -- MOAC Start
92   IF g_org_id IS NOT NULL THEN
93   IF l_debug_level  > 0 THEN
94   oe_debug_pub.add('Implicit Acceptance: g_org_id:'||g_org_id);
95   END IF;
96 
97      MO_GLOBAL.set_policy_context('S', g_org_id);
98      l_cust_sys_param := OE_SYS_PARAMETERS.VALUE('ENABLE_FULFILLMENT_ACCEPTANCE',g_org_id);
99 
100 /* myerrams, Bug: 5161878. Null value should be treated as No.*/
101     IF l_cust_sys_param = 'Y' THEN
102     IF l_debug_level  > 0 THEN
103     oe_debug_pub.add('Implicit Acceptance: Customer Acceptance System Parameter is True');
104     END IF;
105       g_customer_acceptance_enabled := true;
106     ELSE
107     IF l_debug_level  > 0 THEN
108     oe_debug_pub.add('Implicit Acceptance: Customer Acceptance System Parameter is False');
109     END IF;
110       g_customer_acceptance_enabled := false;
111     END IF;
112 /*myerrams, Bug: 5161878. End.*/
113 
114   IF g_customer_acceptance_enabled THEN
115       IF l_debug_level > 0 THEN
116           oe_debug_pub.add('g_customer_acceptance_enabled is TRUE calling process_expired_lines');
117       END IF;
118       process_expired_lines;
119   ELSE
120         IF l_debug_level > 0 THEN
121             oe_debug_pub.add('AAMBASTH: g_customer_acceptance_enabled is FALSE calling process_all_lines');
122       END IF;
123       process_all_lines;
124   END IF;
125 
126   ELSE
127      MO_GLOBAL.set_policy_context('M', '');
128 
129   OPEN l_secured_ou_cur;
130   loop
131      FETCH l_secured_ou_cur
132      into g_org_id;
133      EXIT WHEN l_secured_ou_cur%NOTFOUND;
134 
135      MO_GLOBAL.set_policy_context('S', g_org_id);
136      l_cust_sys_param := OE_SYS_PARAMETERS.VALUE('ENABLE_FULFILLMENT_ACCEPTANCE',g_org_id);
137 
138 /* myerrams, Bug: 5161878. Null value should be treated as No.*/
139     IF l_cust_sys_param = 'Y' THEN
140     IF l_debug_level  > 0 THEN
141       oe_debug_pub.add('Implicit Acceptance: Customer Acceptance System Parameter is True for Org:'||g_org_id );
142     END IF;
143       g_customer_acceptance_enabled := true;
144     ELSE
145     IF l_debug_level  > 0 THEN
146       oe_debug_pub.add('Implicit Acceptance: Customer Acceptance System Parameter is False for Org:'||g_org_id);
147     END IF;
148       g_customer_acceptance_enabled := false;
149     END IF;
150 /* myerrams, Bug: 5161878. End.*/
151 
152   IF g_customer_acceptance_enabled THEN
153       process_expired_lines;
154   ELSE
155       process_all_lines;
156   END IF;
157 
158  END LOOP;
159 CLOSE l_secured_ou_cur;
160 
161 END IF;
162 -- MOAC End
163 
164   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
165   THEN
166     FND_LOG.string(FND_LOG.LEVEL_PROCEDURE
167                   , G_PKG_NAME || l_procedure_name || '.end'
168                   ,'exit procedure'
169                   );
170   END IF;
171 
172 EXCEPTION
173   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
174     FND_MESSAGE.SET_NAME(application=>'FND',name=>'FND_AS_UNEXPECTED_ERROR');
175     FND_MESSAGE.SET_TOKEN('error_text', SQLERRM(sqlcode));
176     FND_MESSAGE.SET_TOKEN('pkg_name' , G_PKG_NAME);
177     FND_MESSAGE.SET_TOKEN('procedure_name' , l_procedure_name );
178     FND_MSG_PUB.Add;
179     errbuf := g_errbuf;
180     retcode := g_retcode;
181   WHEN OTHERS THEN
182     IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
183     THEN
184       FND_LOG.string(FND_LOG.LEVEL_PROCEDURE
185                     , G_PKG_NAME || l_procedure_name || 'Inside the WHEN OTHERS EXCEPTION'
186                     ,substr(SQLERRM(sqlcode), 1, 2000)
187                     );
188     END IF;
189     errbuf := g_errbuf;
190     retcode := g_retcode;
191 
192 END implicit_acceptance;
193 
194 --=============================================================================
195 -- PROCEDURE : process_all_lines
196 -- PARAMETERS: None
197 --
198 -- COMMENT   : TODO
199 --=============================================================================
200 PROCEDURE process_all_lines
201 IS
202 l_line_id                         NUMBER;
203 l_header_id                       NUMBER;
204 l_item_type_code                  VARCHAR(30);
205 l_flow_status_code                VARCHAR(30);
206 l_actual_shipment_date            DATE;
207 l_service_reference_type_code     VARCHAR(30);
208 l_service_reference_line_id       NUMBER;
209 l_top_model_line_id               NUMBER;
210 l_contingency_id                  NUMBER;
211 l_accepted_quantity               NUMBER;
212 l_sold_to_org_id		  NUMBER;	--myerrams
213 l_revrec_expiration_days	  NUMBER;	--myerrams
214 l_table_loop_index                NUMBER := 1;
215 l_query_where_clause              VARCHAR2(3000);			--myerrams, Bug:5161878
216 l_cust_query			  VARCHAR2(15000);			--myerrams, Bug:5161878
217 l_action_request_tbl              OE_ORDER_PUB.Request_Tbl_Type;	--myerrams, Bug:5161878
218 l_expiry_date DATE := SYSDATE; -- bug 8293484
219 l_fulfillment_date DATE; -- bug 8293484
220 
221 -- ======================
222 -- Dynamic Cursor Variable
223 -- =======================
224 TYPE g_cust_lines_type              IS REF CURSOR;
225 g_cust_lines                        g_cust_lines_type;
226 l_debug_level			    CONSTANT NUMBER := oe_debug_pub.g_debug_level;
227 
228 BEGIN
229 
230 /*myerrams, Bug:5161878. This method is executed more than once.
231 value of g_query_where_clause is getting modified for each run in that case. It should be same.
232   g_query_where_clause := g_query_where_clause || ' OR FLOW_STATUS_CODE = ''POST-BILLING_ACCEPTANCE''';
233   g_cust_query := g_cust_query || g_query_from_clause || g_query_where_clause;
234 myerrams, Bug:5161878. end*/
235 --myerrams, Bug: 5235959. Added the org_id condition.
236 --myerrams, Bug: 5297684  l_query_where_clause := ' WHERE flow_status_code in (''PRE-BILLING_ACCEPTANCE'' , ''POST-BILLING_ACCEPTANCE'') AND org_id =' || g_org_id ||' ';
237   l_query_where_clause := ' WHERE flow_status_code in (:1 , :2) AND org_id = :3  and open_flag = :4 ';
238   l_cust_query := g_cust_query || g_query_from_clause || l_query_where_clause;
239 
240 IF l_debug_level  > 0 THEN
241   oe_debug_pub.add('Implicit Acceptance: l_query_where_clause:'||l_query_where_clause);
242   oe_debug_pub.add('Implicit Acceptance: l_cust_query:'||l_cust_query);
243 END IF;
244 
245   OPEN g_cust_lines FOR l_cust_query
246   USING 'PRE-BILLING_ACCEPTANCE','POST-BILLING_ACCEPTANCE',g_org_id,'Y';  --myerrams, Bug: 5297684
247   LOOP
248     FETCH g_cust_lines
249     INTO  l_line_id,
250 	  l_header_id,
251 	  l_item_type_code,
252 	  l_flow_status_code,
253 	  l_actual_shipment_date,
254 	  l_service_reference_type_code,
255 	  l_service_reference_line_id,
256 	  l_top_model_line_id,
257 	  l_contingency_id,
258 	  l_accepted_quantity,
259 	  l_sold_to_org_id,
260 	  l_revrec_expiration_days;
261     EXIT WHEN g_cust_lines%NOTFOUND;
262 
263 
264     -- bug 8293484
265     IF g_acceptance_date = 'E' THEN
266 
267         IF l_actual_shipment_date IS NOT NULL THEN
268 
269             l_expiry_date := l_actual_shipment_date + NVL(l_revrec_expiration_days,0);
270 
271         ELSIF l_actual_shipment_date IS NULL THEN
272 
273             BEGIN
274                 SELECT fulfillment_date
275                 INTO l_fulfillment_date
276                 FROM oe_order_lines_all
277                 WHERE line_id = l_line_id;
278             EXCEPTION
279 
280                 WHEN OTHERS THEN
281                     oe_debug_pub.add('Exception in getting the fulfillment date');
282 
283             END;
284 
285             l_expiry_date := l_fulfillment_date + NVL(l_revrec_expiration_days,0);
286 
287         END IF;
288     END IF;
289     -- bug 8293484
290 
291 /*myerrams, Bug:5161878
292     g_action_request_tbl(l_table_loop_index).entity_code  := OE_GLOBALS.G_ENTITY_LINE;
293     g_action_request_tbl(l_table_loop_index).request_type := OE_GLOBALS.G_ACCEPT_FULFILLMENT;
294     g_action_request_tbl(l_table_loop_index).entity_id    := l_line_id;
295     g_action_request_tbl(l_table_loop_index).param4       := 'Y';
296     g_action_request_tbl(l_table_loop_index).param5       := l_header_id;
297     g_action_request_tbl(l_table_loop_index).date_param1  := SYSDATE;
298 myerrams, Bug:5161878 end*/
299     l_action_request_tbl(l_table_loop_index).entity_code  := OE_GLOBALS.G_ENTITY_LINE;
300     l_action_request_tbl(l_table_loop_index).request_type := OE_GLOBALS.G_ACCEPT_FULFILLMENT;
301     l_action_request_tbl(l_table_loop_index).entity_id    := l_line_id;
302     l_action_request_tbl(l_table_loop_index).param4       := 'Y';
303     l_action_request_tbl(l_table_loop_index).param5       := l_header_id;
304     --l_action_request_tbl(l_table_loop_index).date_param1  := SYSDATE; --bug 8293484
305     l_action_request_tbl(l_table_loop_index).date_param1  := l_expiry_date; -- bug 8293484
306     l_table_loop_index := l_table_loop_index + 1;
307 
308 IF l_debug_level  > 0 THEN
309       oe_debug_pub.add('Implicit Acceptance: inside l_status condition');
310       oe_debug_pub.add('Implicit Acceptance: entity_code:'||OE_GLOBALS.G_ENTITY_LINE);
311       oe_debug_pub.add('Implicit Acceptance: request_type:'||OE_GLOBALS.G_ACCEPT_FULFILLMENT);
312       oe_debug_pub.add('Implicit Acceptance: entity_id:'||l_line_id);
313       oe_debug_pub.add('Implicit Acceptance: param5:'||l_header_id);
314       oe_debug_pub.add('Implicit Acceptance: date_param1:'||l_expiry_date); --bug 8293484
315 END IF;
316   END LOOP;
317   g_action_request_tbl := l_action_request_tbl;		--myerrams,  Bug:5161878
318   CLOSE g_cust_lines;
319 
320 --Call Process Order API for further processing
321   call_process_order_api;
322 
323 END process_all_lines;
324 --=============================================================================
325 -- PROCEDURE : process_expired_lines
326 -- PARAMETERS: p_org_id
327 --
328 -- COMMENT   : TODO
329 --=============================================================================
330 PROCEDURE process_expired_lines
331 IS
332 l_cust_query                        VARCHAR2(15000) := 'SELECT  oel.line_id  '||
333                                                               ', oel.header_id '||
334 							      ', oel.item_type_code '||
335 							      ', oel.flow_status_code '||
336 							      ', oel.actual_shipment_date '||
337 							      ', oel.service_reference_type_code '||
338 							      ', oel.service_reference_line_id '||
339 							      ', oel.top_model_line_id '||
340 							      ', oel.contingency_id '||
341 							      ', oel.accepted_quantity '||
342 							      ', oel.sold_to_org_id '||
343 							      ', oel.revrec_expiration_days ';
344 l_line_id                         NUMBER;
345 l_header_id                       NUMBER;
346 l_item_type_code                  VARCHAR(30);
347 l_flow_status_code                VARCHAR(30);
348 l_actual_shipment_date            DATE;
349 l_service_reference_type_code     VARCHAR(30);
350 l_service_reference_line_id       NUMBER;
351 l_top_model_line_id               NUMBER;
352 l_contingency_id                  NUMBER;
353 l_accepted_quantity               NUMBER;
354 l_sold_to_org_id                  NUMBER;
355 l_revrec_expiration_days	  NUMBER;
356 l_table_loop_index                NUMBER := 1;
357 l_status                          BOOLEAN;
358 l_action_request_tbl              OE_ORDER_PUB.Request_Tbl_Type;	--myerrams, Bug:5161878
359 l_query_where_clause              VARCHAR2(3000);			--myerrams, Bug: 5235959
360 l_max_actual_shipment_date	  DATE;					--myerrams, Bug: 5212583
361 l_count				  NUMBER;				--myerrams, Bug: 5212583
362 l_debug_level		CONSTANT NUMBER := oe_debug_pub.g_debug_level;
363 l_query_from_clause		  VARCHAR2(100);
364 
365 l_expiry_date DATE := SYSDATE; -- bug 8293484
366 l_fulfillment_date DATE; -- bug 8293484
367 
368 -- ======================
369 -- Dynamic Cursor Variable
370 -- =======================
371 TYPE g_cust_lines_type              IS REF CURSOR;
372 g_cust_lines                        g_cust_lines_type;
373 
374 BEGIN
375 
376 IF l_debug_level  > 0 THEN
377     oe_debug_pub.add('Implicit Acceptance: Inside Process_expired_lines');
378 END IF;
379 
380 /* myerrams, Bug: 5531056. Modified the l_cust_query to restrict records with Acceptance Expire Event as Ship Confirm Date and REVREC_EVENT_CODE as Invoicing (Pre-Billing Acceptance) */
381 l_query_where_clause := ' WHERE oel.contingency_id = arc.contingency_id AND oel.flow_status_code = :1 AND oel.org_id = :2 and oel.open_flag = :3 AND arc.expiration_event_code = :4 AND oel.REVREC_EVENT_CODE = :5 ';
382 l_query_from_clause := ' FROM oe_order_lines_all oel, ar_deferral_reasons arc ';
383 l_cust_query := l_cust_query || l_query_from_clause || l_query_where_clause;
384 IF l_debug_level  > 0 THEN
385   oe_debug_pub.add('Implicit Acceptance: the query that is being executed is:'||l_cust_query);
386 END IF;
387 
388   OPEN g_cust_lines FOR l_cust_query
389   USING 'PRE-BILLING_ACCEPTANCE',g_org_id,'Y', 'SHIP_CONFIRM_DATE', 'INVOICING' ;  --myerrams, Bug: 5297684
390   LOOP
391     FETCH g_cust_lines
392     INTO  l_line_id
393 	, l_header_id
394 	, l_item_type_code
395 	, l_flow_status_code
396 	, l_actual_shipment_date
397 	, l_service_reference_type_code
398 	, l_service_reference_line_id
399 	, l_top_model_line_id
400 	, l_contingency_id
401 	, l_accepted_quantity
402 	, l_sold_to_org_id
403 	, l_revrec_expiration_days;
404     EXIT WHEN g_cust_lines%NOTFOUND;
405 
406     IF l_item_type_code = 'SERVICE'
407        AND l_service_reference_type_code ='CUSTOMER_PRODUCT'
408        AND l_service_reference_line_id IS NOT NULL
409     THEN
410       l_status := validate_service_lines
411                     ( l_service_reference_line_id
412 		    , l_sold_to_org_id
413 		    );
414 /*myerrams, Bug: 5212583. Modified the Logic for Non Shippable Lines. */
415     ELSE
416         g_fulfillment_action := OE_GLOBALS.G_ACCEPT_FULFILLMENT;
417 	IF l_actual_shipment_date IS NULL THEN
418 	  IF l_debug_level  > 0 THEN
419 	    oe_debug_pub.add('Inside Non Shippable line Logic');
420 	  END IF;
421 	  IF (l_item_type_code = 'KIT' or l_item_type_code = 'MODEL') and l_top_model_line_id = l_line_id THEN
422 	    IF l_debug_level  > 0 THEN
423 	      oe_debug_pub.add('Inside KIT or MODEL Item Logic, Line_id:'||l_line_id);
424 	    END IF;
425                   SELECT count(*)
426                   INTO l_count
427                   FROM oe_order_lines_all
428                   WHERE header_id = l_header_id
429                   AND top_model_line_id = l_line_id
430                   AND flow_status_code NOT IN ('PRE-BILLING_ACCEPTANCE')	--myerrams, Bug: 5290313
431 		  AND nvl(open_flag, 'Y') = 'Y';
432 		/* If all the Child/Included lines are either Pending Pre-Billing_Acceptance or Closed */
433 		IF l_count = 0 THEN
434                   SELECT max(actual_shipment_date)
435                   INTO l_max_actual_shipment_date
436                   FROM oe_order_lines_all
437                   WHERE header_id = l_header_id
438                   AND top_model_line_id = l_line_id;
439 
440 		  IF l_max_actual_shipment_date IS NULL THEN
441 			l_status := TRUE;
442 		  ELSE
443 			l_status := validate_expiration
444 				 ( l_max_actual_shipment_date
445 				 , l_revrec_expiration_days
446 				 );
447 			l_actual_shipment_date := l_max_actual_shipment_date;	  -- bug 8293484
448 		  END IF;
449 		ELSE
450 	  		l_status := FALSE;
451 		END IF;
452 	   ELSE
453 	   l_status := TRUE;
454 	   END IF;
455 	ELSE
456 	      l_status := validate_expiration
457                    ( l_actual_shipment_date
458 		   , l_revrec_expiration_days
459 		   );
460 	END IF;
461     END IF;
462 
463     -- bug 8293484
464     IF g_acceptance_date = 'E' THEN
465 
466         IF l_actual_shipment_date IS NOT NULL THEN
467 
468             l_expiry_date := l_actual_shipment_date + NVL(l_revrec_expiration_days,0);
469 
470         ELSIF l_actual_shipment_date IS NULL THEN
471 
472             BEGIN
473                 SELECT fulfillment_date
474                 INTO l_fulfillment_date
475                 FROM oe_order_lines_all
476                 WHERE line_id = l_line_id;
477             EXCEPTION
478 
479                 WHEN OTHERS THEN
480                     oe_debug_pub.add('Exception in getting the fulfillment date'); -- exception should be raised
481 
482             END;
483 
484             l_expiry_date := l_fulfillment_date + NVL(l_revrec_expiration_days,0);
485 
486         END IF;
487     END IF;
488     --bug 8293484
489 
490     IF l_status
491     THEN
492 --      g_action_request_tbl(l_table_loop_index).request_type := OE_GLOBALS.G_BOOK_ORDER;
493 /*myerrams,  Bug:5161878
494       g_action_request_tbl(l_table_loop_index).entity_code  := OE_GLOBALS.G_ENTITY_LINE;
495       g_action_request_tbl(l_table_loop_index).request_type := OE_GLOBALS.G_ACCEPT_FULFILLMENT;
496       g_action_request_tbl(l_table_loop_index).entity_id    := l_line_id;
497 --myerrams, Bug:4751568      g_action_request_tbl(l_table_loop_index).param4       := 'N';
498       g_action_request_tbl(l_table_loop_index).param4       := 'Y';
499       g_action_request_tbl(l_table_loop_index).param5       := l_header_id;
500       g_action_request_tbl(l_table_loop_index).date_param1  := SYSDATE;
501 myerrams,  Bug:5161878. end.*/
502 
503       l_action_request_tbl(l_table_loop_index).entity_code  := OE_GLOBALS.G_ENTITY_LINE;
504       l_action_request_tbl(l_table_loop_index).request_type := g_fulfillment_action;--OE_GLOBALS.G_ACCEPT_FULFILLMENT;  --myerrams
505       l_action_request_tbl(l_table_loop_index).entity_id    := l_line_id;
506       l_action_request_tbl(l_table_loop_index).param4       := 'Y';
507       l_action_request_tbl(l_table_loop_index).param5       := l_header_id;
508       --l_action_request_tbl(l_table_loop_index).date_param1  := SYSDATE; --bug 8293484
509       l_action_request_tbl(l_table_loop_index).date_param1  := l_expiry_date; --bug 8293484
510       l_table_loop_index := l_table_loop_index + 1;
511 
512 IF l_debug_level  > 0 THEN
513       oe_debug_pub.add('Implicit Acceptance: inside l_status condition');
514       oe_debug_pub.add('Implicit Acceptance: entity_code:'||OE_GLOBALS.G_ENTITY_LINE);
515       oe_debug_pub.add('Implicit Acceptance: request_type:'||g_fulfillment_action);	--myerrams, Bug: 5212583
516       oe_debug_pub.add('Implicit Acceptance: entity_id:'||l_line_id);
517       oe_debug_pub.add('Implicit Acceptance: param5:'||l_header_id);
518       oe_debug_pub.add('Implicit Acceptance: date_param1:'||l_expiry_date); -- bug 8293484
519 END IF;
520     END IF;
521   END LOOP;
522   g_action_request_tbl := l_action_request_tbl; --myerrams, Bug:5161878
523   call_process_order_api;
524 END process_expired_lines;
525 
526 --=============================================================================
527 -- PROCEDURE : call_process_order_api
528 -- PARAMETERS: None
529 --
530 -- COMMENT   : TODO
531 --=============================================================================
532 PROCEDURE call_process_order_api
533 IS
534 l_header_out_rec            OE_ORDER_PUB.Header_Rec_Type;
535 l_header_adj_out_tbl        OE_Order_PUB.Header_Adj_Tbl_Type;
536 l_header_price_att_out_tbl  OE_ORDER_PUB.Header_Price_Att_Tbl_Type;
537 l_header_adj_att_out_tbl    OE_ORDER_PUB.Header_Adj_Att_Tbl_Type;
538 l_header_adj_assoc_out_tbl  OE_ORDER_PUB.Header_Adj_Assoc_Tbl_Type;
539 l_header_scredit_out_tbl    OE_Order_PUB.Header_Scredit_Tbl_Type;
540 l_line_out_tbl              OE_ORDER_PUB.Line_Tbl_Type;
541 l_line_adj_out_tbl          OE_ORDER_PUB.Line_Adj_Tbl_Type;
542 l_line_price_att_out_tbl    OE_ORDER_PUB.Line_Price_Att_Tbl_Type;
543 l_line_adj_att_out_tbl	    OE_ORDER_PUB.Line_Adj_Att_Tbl_Type;
544 l_line_adj_assoc_out_tbl    OE_ORDER_PUB.Line_Adj_Assoc_Tbl_Type;
545 l_line_scredit_out_tbl      OE_Order_PUB.Line_Scredit_Tbl_Type;
546 l_lot_serial_out_tbl        OE_Order_PUB.Lot_Serial_Tbl_Type;
547 l_action_request_out_tbl    OE_Order_PUB.Request_Tbl_Type;
548 l_debug_level		CONSTANT NUMBER := oe_debug_pub.g_debug_level;
549 BEGIN
550 IF l_debug_level  > 0 THEN
551 oe_debug_pub.add('Implicit Acceptance: Before call to Process Order API');
552 END IF;
553   OE_Order_PVT.Process_Order( p_api_version_number       => 1.0
554                             , x_return_status	         => g_return_status
555 			    , x_msg_count                => g_msg_count
556 			    , x_msg_data	         => g_msg_data
557 			    , p_x_header_rec	         => l_header_out_rec
558 			    , p_x_header_adj_tbl         => l_header_adj_out_tbl
559 			    , p_x_header_price_att_tbl	 => l_header_price_att_out_tbl
560 			    , p_x_header_adj_att_tbl	 => l_header_adj_att_out_tbl
561 			    , p_x_header_adj_assoc_tbl   => l_header_adj_assoc_out_tbl
562 			    , p_x_header_scredit_tbl	 => l_header_scredit_out_tbl
563 			    , p_x_line_tbl		 => l_line_out_tbl
564 			    , p_x_line_adj_tbl           => l_line_adj_out_tbl
565 			    , p_x_line_price_att_tbl     => l_line_price_att_out_tbl
566 			    , p_x_line_adj_att_tbl	 => l_line_adj_att_out_tbl
567 			    , p_x_line_adj_assoc_tbl	 => l_line_adj_assoc_out_tbl
568 			    , p_x_line_scredit_tbl       => l_line_scredit_out_tbl
569 			    , p_x_lot_serial_tbl         => l_lot_serial_out_tbl
570 			    , p_x_action_request_tbl	 => g_action_request_tbl
571                             );
572 IF l_debug_level  > 0 THEN
573 oe_debug_pub.add('Implicit Acceptance: After call to Process Order API');
574 END IF;
575 --myerrams, decode the message
576 if g_msg_count > 0 then
577 	for k in 1 .. g_msg_count loop
578 		g_msg_data := oe_msg_pub.get( p_msg_index => k,
579 					      p_encoded => 'F'
580 					    );
581 		g_msg_data := g_msg_data || k || '.' ||  g_msg_data || '  ' ;
582 	end loop;
583 end if;
584 IF l_debug_level  > 0 THEN
585 oe_debug_pub.add('Implicit Acceptance: Process Order Error Msgs -> g_msg_data:'||g_msg_data);
586 END IF;
587 EXCEPTION
588   WHEN FND_API.G_EXC_UNEXPECTED_ERROR
589   THEN
590 --  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
591   g_errbuf := 'Unexpected Error while calling process order API: '||g_msg_data;
592   g_retcode := 2;
593   g_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;	--myerrams
594 
595  WHEN FND_API.G_EXC_ERROR
596   THEN
597 --  RAISE FND_API.G_RET_STS_ERROR;
598   g_errbuf := 'Error while calling process order API: '||g_msg_data;
599   g_retcode := 2;
600   g_return_status := FND_API.G_RET_STS_ERROR;
601 
602   WHEN OTHERS
603   THEN
604   g_errbuf := 'Others Exception while calling process order API: '||g_msg_data;
605   g_retcode := 2;
606   g_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
607 --  RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
608 -- Do the status processing
609 
610 END call_process_order_api;
611 --=============================================================================
612 -- PROC NAME     : validate_service_lines
613 -- DESCRIPTION   : Validates whether parent line associted with the service line
614 --                 is accepted or not.
615 -- PARAMETERS    : None.
616 -- EXCEPTIONS    : None.
617 --=============================================================================
618 FUNCTION validate_service_lines
619 ( p_service_ref_line_id	      IN NUMBER
620 , p_sold_to_org_id            IN NUMBER
621 )
622 RETURN BOOLEAN
623 IS
624 l_return_status		VARCHAR2(100);
625 l_product_line_id	NUMBER;
626 l_line_id		NUMBER;
627 l_contingency_id	NUMBER;
628 l_revrec_event_code	VARCHAR2(30);
629 l_accepted_quantity	NUMBER;
630 l_debug_level		CONSTANT NUMBER := oe_debug_pub.g_debug_level;
631 BEGIN
632   OE_SERVICE_UTIL.Get_Cust_Product_Line_Id( x_return_status        => l_return_status
633                                           , p_reference_line_id    => p_service_ref_line_id
634                                           , p_customer_id          => p_sold_to_org_id
635 					  , x_cust_product_line_id => l_product_line_id
636 					  );
637   SELECT line_id
638        , contingency_id
639        , revrec_event_code
640        , accepted_quantity
641   INTO   l_line_id
642        , l_contingency_id
643        , l_revrec_event_code
644        , l_accepted_quantity
645   FROM   oe_order_lines_all
646   WHERE  line_id = l_product_line_id;
647 
648   IF l_contingency_id IS NOT NULL
649      AND l_accepted_quantity IS NOT NULL
650      AND l_revrec_event_code = 'INVOICING'
651   THEN
652     IF l_accepted_quantity = 0
653     THEN
654       g_fulfillment_action := OE_GLOBALS.G_REJECT_FULFILLMENT;
655     ELSE
656       g_fulfillment_action := OE_GLOBALS.G_ACCEPT_FULFILLMENT;
657     END IF;
658 IF l_debug_level  > 0 THEN
659     oe_debug_pub.add('Implicit Acceptance: validate_service_lines returns true');
660 END IF;
661     RETURN TRUE;
662   ELSE
663 IF l_debug_level  > 0 THEN
664     oe_debug_pub.add('Implicit Acceptance: validate_service_lines returns false');
665 END IF;
666     RETURN FALSE;
667   END IF;
668 
669 END validate_service_lines;
670 --=============================================================================
671 -- PROC NAME     : validate_expiration
672 -- DESCRIPTION   : Validates whether order line is expired or not.
673 -- PARAMETERS    : None.
674 -- EXCEPTIONS    : None.
675 --=============================================================================
676 FUNCTION validate_expiration
677 (  p_actual_shipment_date	IN DATE
678  , p_revrec_expiration_days	IN NUMBER
679 )
680 RETURN BOOLEAN
681 IS
682 l_reference_date                DATE;
683 l_revrec_expiration_days	NUMBER;
684 l_debug_level			CONSTANT NUMBER := oe_debug_pub.g_debug_level;
685 BEGIN
686   l_reference_date := p_actual_shipment_date;
687 
688 /* myerrams, Bug: 5531056; If Exipration Days is null, then its explicit acceptance.
689    This SO line will never expire. So, Returning False. */
690   IF p_revrec_expiration_days IS NULL THEN
691     RETURN FALSE;
692   ELSE
693     l_revrec_expiration_days := p_revrec_expiration_days;
694   END IF;
695   IF l_reference_date + l_revrec_expiration_days < SYSDATE
696   THEN
697    RETURN TRUE;
698   ELSE
699    RETURN FALSE;
700   END IF;
701 END validate_expiration;
702 
703 END ONT_ImplicitCustAccept_PVT;