DBA Data[Home] [Help]

PACKAGE BODY: APPS.ONT_IMPLICITCUSTACCEPT_PVT

Source


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