1 PACKAGE BODY AHL_WARRANTY_ENTL_PVT AS
2 /* $Header: AHLVENTB.pls 120.2.12020000.2 2012/12/14 08:49:53 shnatu ship $ */
3
4 G_PKG_NAME CONSTANT VARCHAR2(30) := 'AHL_WARRANTY_ENTL_PVT';
5 G_APP_NAME CONSTANT VARCHAR2(3) := 'AHL';
6
7 ------------------------------------------------------------------------------------
8 -- Common constants and variables
9 ------------------------------------------------------------------------------------
10 l_log_current_level NUMBER := FND_LOG.g_current_runtime_level;
11 l_log_statement NUMBER := FND_LOG.level_statement;
12 l_log_procedure NUMBER := FND_LOG.level_procedure;
13 l_log_error NUMBER := FND_LOG.level_error;
14 l_log_exception NUMBER := FND_LOG.level_exception;
15 l_log_unexpected NUMBER := FND_LOG.level_unexpected;
16 ------------------------------------------------------------------------------------
17
18 ------------------------------------------------------------------------------------
19 -- Private procedure prototypes
20 ------------------------------------------------------------------------------------
21 -- Procedure to create Warranty Entitlement record
22 PROCEDURE Create_Warranty_Entitlement (
23 p_module_type IN VARCHAR2 := NULL,
24 p_user_role IN VARCHAR2,
25 p_x_warranty_entl_rec IN OUT NOCOPY Warranty_Entl_Rec_Type
26 );
27
28 -- Procedure to update Warranty Entitlement record
29 PROCEDURE Update_Warranty_Entitlement (
30 p_module_type IN VARCHAR2 := NULL,
31 p_user_role IN VARCHAR2,
32 p_x_warranty_entl_rec IN OUT NOCOPY Warranty_Entl_Rec_Type
33 );
34
35 -- Procedure to delete Warranty Entitlement record
36 PROCEDURE Delete_Warranty_Entitlement (
37 p_module_type IN VARCHAR2 := NULL,
38 p_user_role IN VARCHAR2,
39 p_x_warranty_entl_rec IN OUT NOCOPY Warranty_Entl_Rec_Type
40 );
41
42 -- Procedure to approve Warranty Entitlement record
43 PROCEDURE Approve_Warranty_Entitlement (
44 p_module_type IN VARCHAR2 := NULL,
45 p_user_role IN VARCHAR2,
46 p_appr_action IN VARCHAR2,
47 p_x_warranty_entl_rec IN OUT NOCOPY Warranty_Entl_Rec_Type
48 );
49
50 -- Procedure to validate the Warranty Entitlement record
51 PROCEDURE Validate_Warranty_Entitlement (
52 p_user_role IN VARCHAR2,
53 p_warranty_entl_rec IN Warranty_Entl_Rec_Type
54 );
55 ------------------------------------------------------------------------------------
56
57 ------------------------------------------------------------------------------------
58 -- Start of Comments
59 -- Procedure name : Process_Warranty_Entitlements
60 -- Type : Public
61 -- Function : Create, Update, Delete or Approve the Warranty Entitlements records.
62 -- Pre-reqs :
63 -- Parameters :
64 --
65 -- Process_Item_Group Parameters:
66 -- p_user_role IN Either of G_USER_PLANNER or G_USER_NONPLANNER Required
67 -- p_appr_action IN Either of G_APPR_ACCEPT or G_APPR_REJECT Required
68 -- p_x_warranty_entl_tbl IN OUT Warranty_Entl_Tbl_Type Required
69 --
70 -- End of Comments
71
72 PROCEDURE Process_Warranty_Entitlements (
73 p_api_version IN NUMBER := 1.0,
74 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
75 p_commit IN VARCHAR2 := FND_API.G_FALSE,
76 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
77 p_module_type IN VARCHAR2 := NULL,
78 p_user_role IN VARCHAR2,
79 p_appr_action IN VARCHAR2 := NULL,
80 p_x_warranty_entl_tbl IN OUT NOCOPY Warranty_Entl_Tbl_Type,
81 x_return_status OUT NOCOPY VARCHAR2,
82 x_msg_count OUT NOCOPY NUMBER,
83 x_msg_data OUT NOCOPY VARCHAR2
84 ) IS
85
86 --
87 l_api_version CONSTANT NUMBER := 1.0;
88 l_api_name CONSTANT VARCHAR2(30) := 'Process_Warranty_Entitlements';
89 l_full_name CONSTANT VARCHAR2(100) := 'ahl.plsql.'||G_PKG_NAME||'.'||l_api_name;
90
91 l_msg_count NUMBER;
92 l_warranty_entl_tbl Warranty_Entl_Tbl_Type DEFAULT p_x_warranty_entl_tbl;
93 --
94
95 BEGIN
96 IF (l_log_procedure >= l_log_current_level) THEN
97 FND_LOG.string(l_log_procedure, l_full_name || '.begin', 'At the start of the API');
98 END IF;
99
100 -- Standard start of API savepoint
101 SAVEPOINT Process_Warranty_Entl_Pub;
102
103 -- Standard call to check for call compatibility
104 IF NOT FND_API.Compatible_API_Call(l_api_version, p_api_version,
105 l_api_name, G_PKG_NAME) THEN
106 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
107 END IF;
108
109 -- Initialize message list if p_init_msg_list is set to TRUE
110 IF FND_API.To_Boolean( p_init_msg_list) THEN
111 FND_MSG_PUB.Initialize;
112 END IF;
113
114 -- Initialize Procedure return status to success
115 x_return_status := FND_API.G_RET_STS_SUCCESS;
116
117 IF (l_log_statement >= l_log_current_level) THEN
118 FND_LOG.string(l_log_statement, l_full_name, 'l_warranty_entl_tbl.COUNT = '|| l_warranty_entl_tbl.COUNT);
119 END IF;
120
121 -- Get the error message count till this point
122 l_msg_count := FND_MSG_PUB.count_msg;
123
124 -- Check for the availability of records in the table type.
125 IF (l_warranty_entl_tbl.COUNT >= 1) THEN
126 FOR i IN l_warranty_entl_tbl.FIRST..l_warranty_entl_tbl.LAST LOOP
127
128 IF (l_log_statement >= l_log_current_level) THEN
129 FND_LOG.string(l_log_statement, l_full_name, 'operation '||l_warranty_entl_tbl(i).operation_flag||
130 ' for record# '||i);
131 END IF;
132
133 -- Check for the operation associated to the record.
134 IF (l_warranty_entl_tbl(i).operation_flag = G_OP_CREATE) THEN
135 -- Procedure call to insert the record into the table
136 Create_Warranty_Entitlement (
137 p_module_type => p_module_type,
138 p_user_role => p_user_role,
139 p_x_warranty_entl_rec => l_warranty_entl_tbl(i)
140 );
141 ELSIF (l_warranty_entl_tbl(i).operation_flag = G_OP_UPDATE) THEN
142 -- Procedure call to update the record in the table
143 Update_Warranty_Entitlement (
144 p_module_type => p_module_type,
145 p_user_role => p_user_role,
146 p_x_warranty_entl_rec => l_warranty_entl_tbl(i)
147 );
148 ELSIF (l_warranty_entl_tbl(i).operation_flag = G_OP_DELETE) THEN
149 -- Procedure call to delete the record from the table
150 Delete_Warranty_Entitlement (
151 p_module_type => p_module_type,
152 p_user_role => p_user_role,
153 p_x_warranty_entl_rec => l_warranty_entl_tbl(i)
154 );
155 ELSIF (l_warranty_entl_tbl(i).operation_flag = G_OP_APPROVE) THEN
156 -- Procedure call to approve the record in the table
157 Approve_Warranty_Entitlement (
158 p_module_type => p_module_type,
159 p_user_role => p_user_role,
160 p_appr_action => p_appr_action,
161 p_x_warranty_entl_rec => l_warranty_entl_tbl(i)
162 );
163 END IF;
164 END LOOP;
165 END IF;
166
167 -- If any errors occured, then raise them
168 IF (l_msg_count < FND_MSG_PUB.count_msg) THEN
169 IF (l_log_statement >= l_log_current_level) THEN
170 FND_LOG.string(l_log_statement, l_full_name, 'Process_Warranty_Entitlements errored out');
171 END IF;
172 RAISE FND_API.G_EXC_ERROR;
173 END IF;
174
175 -- Standard check of p_commit
176 IF FND_API.TO_BOOLEAN(p_commit) THEN
177 COMMIT WORK;
178 END IF;
179
180 IF (l_log_procedure >= l_log_current_level) THEN
181 FND_LOG.string(l_log_procedure, l_full_name || '.end', 'At the end of the API');
182 END IF;
183
184 EXCEPTION
185 WHEN FND_API.G_EXC_ERROR THEN
186 ROLLBACK TO Process_Warranty_Entl_Pub;
187 x_return_status := FND_API.G_RET_STS_ERROR;
188 FND_MSG_PUB.count_and_get( p_count => x_msg_count,
189 p_data => x_msg_data,
190 p_encoded => FND_API.G_FALSE);
191 IF (l_log_exception >= l_log_current_level) THEN
192 FND_LOG.string(l_log_exception, l_full_name, 'Execution Error: ' || x_msg_data);
193 END IF;
194
195 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
196 ROLLBACK TO Process_Warranty_Entl_Pub;
197 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
198 FND_MSG_PUB.count_and_get( p_count => x_msg_count,
199 p_data => x_msg_data,
200 p_encoded => FND_API.G_FALSE);
201 IF (l_log_unexpected >= l_log_current_level) THEN
202 FND_LOG.string(l_log_unexpected, l_full_name, 'Unexpected Exception: ' || x_msg_data);
203 END IF;
204
205 WHEN OTHERS THEN
206 ROLLBACK TO Process_Warranty_Entl_Pub;
207 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
208 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
209 FND_MSG_PUB.add_exc_msg(p_pkg_name => G_PKG_NAME,
210 p_procedure_name => l_api_name,
211 p_error_text => SUBSTR(SQLERRM,1,500));
212 END IF;
213 FND_MSG_PUB.count_and_get(p_count => x_msg_count,
214 p_data => x_msg_data,
215 p_encoded => fnd_api.G_FALSE);
216 IF (l_log_unexpected >= l_log_current_level) THEN
217 FND_LOG.string(l_log_unexpected, l_full_name, 'Other Exception: ' || x_msg_data);
218 END IF;
219
220 END Process_Warranty_Entitlements;
221 ------------------------------------------------------------------------------------
222
223 ------------------------------------------------------------------------------------
224 -- Start of Comments
225 -- Function name : Is_Task_Warranty_Available
226 -- Type : Public
227 -- Function : To Check whether the visit task is warranty enabled
228 -- Return 'Y' for the following cases:
229 -- 1. If the originating MR or Route had a Warranty Template assigned.
230 -- This will just identify that there could be the possibility of an applicable warranty.
231 -- Return 'N' otherwise
232 -- 1. If the originating MR or Route did not have a Warranty Template assigned.
233 -- Pre-reqs :
234 -- Parameters : p_task_id IN NUMBER Required : Visit Task id
235 --
236 -- End of Comments
237
238 FUNCTION Is_Task_Warranty_Available(
239 p_task_id IN NUMBER
240 ) RETURN VARCHAR2 IS
241
242 -- cursor to check for warranty template at MR header
243 CURSOR chk_wrrnty_tmpl_mr_csr (c_task_id NUMBER) IS
244 SELECT 'X'
245 FROM AHL_VISIT_TASKS_B TSK,
246 AHL_MR_HEADERS_B MRH
247 WHERE MRH.warranty_template_id IS NOT NULL
248 AND MRH.mr_header_id = TSK.mr_id
249 AND TSK.visit_task_id = c_task_id;
250
251 -- cursor to check for warranty template at Route
252 CURSOR chk_wrrnty_tmpl_route_csr (c_task_id NUMBER) IS
253 SELECT 'X'
254 FROM AHL_VISIT_TASKS_B TSK,
255 AHL_MR_ROUTES MRR,
256 AHL_ROUTES_B ROUTE
257 WHERE ROUTE.warranty_template_id IS NOT NULL
258 AND ROUTE.route_id = MRR.route_id
259 AND MRR.mr_route_id = TSK.mr_route_id
260 AND TSK.visit_task_id = c_task_id;
261
262 --
263 l_ret_val VARCHAR2(1) := 'N';
264 l_dummy VARCHAR2(1);
265 --
266
267 BEGIN
268 -- check for the warranty template at the MR header level
269 OPEN chk_wrrnty_tmpl_mr_csr (p_task_id);
270 FETCH chk_wrrnty_tmpl_mr_csr INTO l_dummy;
271 IF (chk_wrrnty_tmpl_mr_csr%FOUND) THEN
272 l_ret_val := 'Y';
273 END IF;
274 CLOSE chk_wrrnty_tmpl_mr_csr;
275
276 -- if not set at the MR header level, check at the Route level
277 IF (l_ret_val = 'N') THEN
278 OPEN chk_wrrnty_tmpl_route_csr (p_task_id);
279 FETCH chk_wrrnty_tmpl_route_csr INTO l_dummy;
280 IF (chk_wrrnty_tmpl_route_csr%FOUND) THEN
281 l_ret_val := 'Y';
282 END IF;
283 CLOSE chk_wrrnty_tmpl_route_csr;
284 END IF;
285
286 -- return the set value
287 RETURN l_ret_val;
288
289 END Is_Task_Warranty_Available;
290 ------------------------------------------------------------------------------------
291
292 ------------------------------------------------------------------------------------
293 -- Start of Comments
294 -- Procedure name : Launch_Entl_Notification
295 -- Type : Public
296 -- Function : Launches a Workflow notification for an entitlement for review
297 -- Pre-reqs :
298 -- Parameters :
299 --
300 -- Launch_Entl_Notification Parameters:
301 -- p_entitlement_id IN Entitlement id Required
302 -- p_commit IN Commit flag. Workflow won't launch if this is Required
303 -- passed as FND_API.G_FALSE
304 -- x_item_key OUT Item key of the launched notification Required
305 -- x_return_status OUT Return status. Item key to be used only if Required
306 -- this status is FND_API.G_RET_STS_SUCCESS.
307 --
308 -- End of Comments
309
310 PROCEDURE Launch_Entl_Notification (
311 p_entitlement_id IN NUMBER,
312 p_commit IN VARCHAR2 := FND_API.G_FALSE,
313 x_item_key OUT NOCOPY VARCHAR2,
314 x_return_status OUT NOCOPY VARCHAR2
315 ) IS
316
317 --
318 l_api_name CONSTANT VARCHAR2(30) := 'Launch_Entl_Notification';
319 l_full_name CONSTANT VARCHAR2(100) := 'ahl.plsql.'||G_PKG_NAME||'.'||l_api_name;
320
321 l_msg_count NUMBER;
322 l_msg_data VARCHAR2(4000);
323 l_active_flag VARCHAR2(1);
324 l_process_name VARCHAR2(30);
325 l_item_type VARCHAR2(8);
326 l_subject FND_NEW_MESSAGES.message_text%TYPE;
327 --
328
329 BEGIN
330 IF (l_log_procedure >= l_log_current_level) THEN
331 FND_LOG.string(l_log_procedure, l_full_name || '.begin', 'At the start of the API');
332 END IF;
333
334 -- initialize procedure return status to success
335 x_return_status := FND_API.G_RET_STS_SUCCESS;
336
337 IF (l_log_statement >= l_log_current_level) THEN
338 FND_LOG.string(l_log_statement, l_full_name, 'the arguments: '||
339 ' p_entitlement_id > '||p_entitlement_id||
340 ', p_commit > '||p_commit);
341 END IF;
342
343 -- check for the entitlement id
344 IF (p_entitlement_id IS NULL) THEN
345 x_return_status := FND_API.G_RET_STS_ERROR;
346 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_WARRANTY_ENTL_ID_INVLD'); -- Warranty entitlement id ENTL_ID is invalid.
347 FND_MESSAGE.Set_Token('ENTL_ID', p_entitlement_id);
348 FND_MSG_PUB.ADD;
349 RETURN;
350 END IF;
351
352 -- get the details of the Workflow process mapped to the object G_WF_ENTL_OBJ
353 AHL_UTILITY_PVT.Get_WF_Process_Name(
354 p_object => G_WF_ENTL_OBJ,
355 x_active => l_active_flag,
356 x_process_name => l_process_name ,
357 x_item_type => l_item_type,
358 x_msg_count => l_msg_count,
359 x_msg_data => l_msg_data,
360 x_return_status => x_return_status);
361
362 IF (l_log_statement >= l_log_current_level) THEN
363 FND_LOG.string(l_log_statement, l_full_name, 'the returned values from AHL_UTILITY_PVT.Get_WF_Process_Name : '||
364 ' l_active_flag > '||l_active_flag||
365 ', l_process_name > '||l_process_name||
366 ', l_item_type > '||l_item_type||
367 ', x_return_status > '||x_return_status);
368 END IF;
369
370 -- if returned with error, don't proceed any further
371 IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
372 RETURN;
373 END IF;
374
375 -- if the mapping is active, call the notification API
376 If (l_active_flag = 'Y') THEN
377 -- get the subject text
378 l_subject := FND_MESSAGE.GET_STRING(G_APP_NAME, G_WARRANTY_ENTL_SBJ);
379
380 IF (l_log_statement >= l_log_current_level) THEN
381 FND_LOG.string(l_log_statement, l_full_name,
382 'before calling AHL_WF_NOTIFICATION_PVT.Launch_OA_Notification with arguments: '||
383 ' p_object > '||G_WF_ENTL_OBJ||
384 ', p_process_name > '||l_process_name||
385 ', p_item_type > '||l_item_type||
386 ', p_subject > '||l_subject||
387 ', p_oa_function > '||G_WARRANTY_ENTL_FN||
388 ', p_param1_name > '||G_ENTL_FN_PARAM1||
389 ', p_param1_value > '||p_entitlement_id);
390 END IF;
391
392 -- call AHL_WF_NOTIFICATION_PVT.Launch_OA_Notification
393 AHL_WF_NOTIFICATION_PVT.Launch_OA_Notification(
394 p_object => G_WF_ENTL_OBJ,
395 p_process_name => l_process_name,
396 p_item_type => l_item_type,
397 p_subject => l_subject,
398 p_oa_function => G_WARRANTY_ENTL_FN,
399 p_param1_name => G_ENTL_FN_PARAM1,
400 p_param1_value => TO_CHAR(p_entitlement_id),
401 x_item_key => x_item_key,
402 x_return_status => x_return_status);
403
404 IF (l_log_statement >= l_log_current_level) THEN
405 FND_LOG.string(l_log_statement, l_full_name,
406 'after calling AHL_WF_NOTIFICATION_PVT.Launch_OA_Notification, '||
407 ' x_item_key > '||x_item_key||
408 ', x_return_status > '||x_return_status);
409 END IF;
410
411 -- if returned with error, don't proceed any further
412 IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
413 RETURN;
414 END IF;
415 END IF;
416
417 -- Standard check of p_commit
418 IF FND_API.TO_BOOLEAN(p_commit) THEN
419 COMMIT WORK;
420 END IF;
421
422 IF (l_log_procedure >= l_log_current_level) THEN
423 FND_LOG.string(l_log_procedure, l_full_name || '.end', 'At the end of the API');
424 END IF;
425
426 END Launch_Entl_Notification;
427 ------------------------------------------------------------------------------------
428
429 ------------------------------------------------------------------------------------
430 -- Start of Comments
431 -- Procedure name : Launch_Expr_Notification
432 -- Type : Public
433 -- Function : Launches a Workflow notification for warranty expiration. Will be configured
434 -- as a concurrent program
435 -- Pre-reqs :
436 -- Parameters :
437 --
438 -- End of Comments
439
440 PROCEDURE Launch_Expr_Notification (
441 errbuf OUT NOCOPY VARCHAR2,
442 retcode OUT NOCOPY NUMBER
443 ) IS
444
445 --
446 l_api_name CONSTANT VARCHAR2(30) := 'Launch_Expr_Notification';
447 l_full_name CONSTANT VARCHAR2(100) := 'ahl.plsql.'||G_PKG_NAME||'.'||l_api_name;
448
449 l_msg_count NUMBER;
450 l_msg_data VARCHAR2(4000);
451 l_return_status VARCHAR2(1);
452 l_active_flag VARCHAR2(1);
453 l_process_name VARCHAR2(30);
454 l_item_type VARCHAR2(8);
455 l_item_key VARCHAR2(60);
456 l_subject FND_NEW_MESSAGES.message_text%TYPE;
457 l_dummy NUMBER;
458 --
459
460 BEGIN
461 FND_FILE.PUT_LINE(FND_FILE.LOG, l_full_name||', start');
462 FND_FILE.NEW_LINE(FND_FILE.LOG, 1);
463 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Start time: '||TO_CHAR(SYSDATE, 'Month DD, YYYY HH24:MI:SS'));
464 FND_FILE.NEW_LINE(FND_FILE.LOG, 1);
465
466 -- initialize return status to success
467 retcode := 0;
468 l_return_status := FND_API.G_RET_STS_SUCCESS;
469
470 -- initialize error message stack
471 FND_MSG_PUB.Initialize;
472
473 -- get the details of the Workflow process mapped to the object G_WF_EXPR_OBJ
474 AHL_UTILITY_PVT.Get_WF_Process_Name(
475 p_object => G_WF_EXPR_OBJ,
476 x_active => l_active_flag,
477 x_process_name => l_process_name ,
478 x_item_type => l_item_type,
479 x_msg_count => l_msg_count,
480 x_msg_data => l_msg_data,
481 x_return_status => l_return_status);
482
483 FND_FILE.PUT_LINE(FND_FILE.LOG, 'the returned values: '||
484 ' l_active_flag > '||l_active_flag||
485 ', l_process_name > '||l_process_name||
486 ', l_item_type > '||l_item_type||
487 ', l_return_status > '||l_return_status);
488 FND_FILE.NEW_LINE(FND_FILE.LOG, 1);
489
490 -- if returned with error, don't proceed any further
491 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
492 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Error occurred > '||l_msg_data);
493 FND_FILE.NEW_LINE(FND_FILE.LOG, 2);
494 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
495 END IF;
496
497 -- if returned without any errors and if the mapping is active, call the notification API
498 IF (l_return_status = FND_API.G_RET_STS_SUCCESS AND l_active_flag = 'Y') THEN
499 -- get the subject text
500 l_subject := FND_MESSAGE.GET_STRING(G_APP_NAME, G_WARRANTY_EXPR_SBJ);
501
502 FND_FILE.PUT_LINE(FND_FILE.LOG, 'before calling AHL_WF_NOTIFICATION_PVT.Launch_OA_Notification with arguments: '||
503 ' p_object > '||G_WF_EXPR_OBJ||
504 ', p_process_name > '||l_process_name||
505 ', p_item_type > '||l_item_type||
506 ', p_subject > '||l_subject||
507 ', p_oa_function > '||G_WARRANTY_EXPR_FN);
508 FND_FILE.NEW_LINE(FND_FILE.LOG, 1);
509
510 -- call AHL_WF_NOTIFICATION_PVT.Launch_OA_Notification
511 AHL_WF_NOTIFICATION_PVT.Launch_OA_Notification(
512 p_object => G_WF_EXPR_OBJ,
513 p_process_name => l_process_name,
514 p_item_type => l_item_type,
515 p_subject => l_subject,
516 p_oa_function => G_WARRANTY_EXPR_FN,
517 x_item_key => l_item_key,
518 x_return_status => l_return_status);
519
520 FND_FILE.PUT_LINE(FND_FILE.LOG, 'after calling AHL_WF_NOTIFICATION_PVT.Launch_OA_Notification, '||
521 ' l_item_key > '||l_item_key||
522 ', l_return_status > '||l_return_status);
523 FND_FILE.NEW_LINE(FND_FILE.LOG, 1);
524
525 -- if returned with error, don't proceed any further
526 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
527 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Errors occurred, as given below: ');
528 FND_FILE.NEW_LINE(FND_FILE.LOG, 2);
529
530 -- put all the errors in the log file
531 l_msg_count := FND_MSG_PUB.count_msg;
532 FOR i IN 1..l_msg_count LOOP
533 FND_MSG_PUB.get(
534 p_msg_index => i,
535 p_encoded => FND_API.G_FALSE,
536 p_data => l_msg_data,
537 p_msg_index_out => l_dummy);
538
539 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Error '||i||': > '||l_msg_data);
540 FND_FILE.NEW_LINE(FND_FILE.LOG, 1);
541 END LOOP;
542
543 -- raise the exception
544 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
545 END IF;
546
547 -- set the output
548 FND_FILE.PUT_LINE(FND_FILE.OUTPUT, 'Workflow notification launched with item key > '||l_item_key);
549 ELSE
550 -- set the output
551 FND_FILE.PUT_LINE(FND_FILE.OUTPUT, 'Workflow notification could not be launched. Check the Workflow mapping.');
552 END IF;
553
554 -- commit required to launch the Workflow
555 COMMIT;
556
557 FND_FILE.PUT_LINE(FND_FILE.LOG, l_full_name||', end');
558 FND_FILE.NEW_LINE(FND_FILE.LOG, 1);
559 FND_FILE.PUT_LINE(FND_FILE.LOG, 'End time: '||TO_CHAR(SYSDATE, 'Month DD, YYYY HH24:MI:SS'));
560
561 EXCEPTION
562 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
563 retcode := 2;
564 errbuf := FND_MSG_PUB.Get;
565 FND_FILE.PUT_LINE(FND_FILE.OUTPUT, 'Process failed. View program logs for details.');
566
567 WHEN OTHERS THEN
568 retcode := 2;
569 errbuf := l_full_name||': '||SUBSTRB(SQLERRM, 1, 200);
570 FND_FILE.PUT_LINE(FND_FILE.LOG, l_full_name||', exception occurred: '||SUBSTRB(SQLERRM, 1, 200));
571 FND_FILE.PUT_LINE(FND_FILE.OUTPUT, 'Process failed. View program logs for details.');
572
573 END Launch_Expr_Notification;
574 ------------------------------------------------------------------------------------
575
576 ------------------------------------------------------------------------------------
577 -- Start of Comments
578 -- Procedure name : Launch_WOCl_Notification
579 -- Type : Public
580 -- Function : Launches a Workflow notification for completed Workorders. Will be configured
581 -- as a concurrent program
582 -- Pre-reqs :
583 -- Parameters :
584 --
585 -- End of Comments
586
587 PROCEDURE Launch_WOCl_Notification (
588 errbuf OUT NOCOPY VARCHAR2,
589 retcode OUT NOCOPY NUMBER
590 ) IS
591
592 --
593 l_api_name CONSTANT VARCHAR2(30) := 'Launch_WOCl_Notification';
594 l_full_name CONSTANT VARCHAR2(100) := 'ahl.plsql.'||G_PKG_NAME||'.'||l_api_name;
595
596 l_msg_count NUMBER;
597 l_msg_data VARCHAR2(4000);
598 l_return_status VARCHAR2(1);
599 l_active_flag VARCHAR2(1);
600 l_process_name VARCHAR2(30);
601 l_item_type VARCHAR2(8);
602 l_item_key VARCHAR2(60);
603 l_subject FND_NEW_MESSAGES.message_text%TYPE;
604 l_dummy NUMBER;
605 --
606
607 BEGIN
608 FND_FILE.PUT_LINE(FND_FILE.LOG, l_full_name||', start');
609 FND_FILE.NEW_LINE(FND_FILE.LOG, 1);
610 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Start time: '||TO_CHAR(SYSDATE, 'Month DD, YYYY HH24:MI:SS'));
611 FND_FILE.NEW_LINE(FND_FILE.LOG, 1);
612
613 -- initialize return status to success
614 retcode := 0;
615 l_return_status := FND_API.G_RET_STS_SUCCESS;
616
617 -- initialize error message stack
618 FND_MSG_PUB.Initialize;
619
620 -- get the details of the Workflow process mapped to the object G_WF_WOCL_OBJ
621 AHL_UTILITY_PVT.Get_WF_Process_Name(
622 p_object => G_WF_WOCL_OBJ,
623 x_active => l_active_flag,
624 x_process_name => l_process_name ,
625 x_item_type => l_item_type,
626 x_msg_count => l_msg_count,
627 x_msg_data => l_msg_data,
628 x_return_status => l_return_status);
629
630 FND_FILE.PUT_LINE(FND_FILE.LOG, 'the returned values: '||
631 ' l_active_flag > '||l_active_flag||
632 ', l_process_name > '||l_process_name||
633 ', l_item_type > '||l_item_type||
634 ', l_return_status > '||l_return_status);
635 FND_FILE.NEW_LINE(FND_FILE.LOG, 1);
636
637 -- if returned with error, don't proceed any further
638 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
639 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Error occurred > '||l_msg_data);
640 FND_FILE.NEW_LINE(FND_FILE.LOG, 2);
641 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
642 END IF;
643
644 -- if returned without any errors and if the mapping is active, call the notification API
645 IF (l_return_status = FND_API.G_RET_STS_SUCCESS AND l_active_flag = 'Y') THEN
646 -- get the subject text
647 l_subject := FND_MESSAGE.GET_STRING(G_APP_NAME, G_WARRANTY_WOCL_SBJ);
648
649 FND_FILE.PUT_LINE(FND_FILE.LOG, 'before calling AHL_WF_NOTIFICATION_PVT.Launch_OA_Notification with arguments: '||
650 ' p_object > '||G_WF_WOCL_OBJ||
651 ', p_process_name > '||l_process_name||
652 ', p_item_type > '||l_item_type||
653 ', p_subject > '||l_subject||
654 ', p_oa_function > '||G_WARRANTY_WOCL_FN);
655 FND_FILE.NEW_LINE(FND_FILE.LOG, 1);
656
657 -- call AHL_WF_NOTIFICATION_PVT.Launch_OA_Notification
658 AHL_WF_NOTIFICATION_PVT.Launch_OA_Notification(
659 p_object => G_WF_WOCL_OBJ,
660 p_process_name => l_process_name,
661 p_item_type => l_item_type,
662 p_subject => l_subject,
663 p_oa_function => G_WARRANTY_WOCL_FN,
664 x_item_key => l_item_key,
665 x_return_status => l_return_status);
666
667 FND_FILE.PUT_LINE(FND_FILE.LOG, 'after calling AHL_WF_NOTIFICATION_PVT.Launch_OA_Notification, '||
668 ' l_item_key > '||l_item_key||
669 ', l_return_status > '||l_return_status);
670 FND_FILE.NEW_LINE(FND_FILE.LOG, 1);
671
672 -- if returned with error, don't proceed any further
673 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
674 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Errors occurred, as given below: ');
675 FND_FILE.NEW_LINE(FND_FILE.LOG, 2);
676
677 -- put all the errors in the log file
678 l_msg_count := FND_MSG_PUB.count_msg;
679 FOR i IN 1..l_msg_count LOOP
680 FND_MSG_PUB.get(
681 p_msg_index => i,
682 p_encoded => FND_API.G_FALSE,
683 p_data => l_msg_data,
684 p_msg_index_out => l_dummy);
685
686 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Error '||i||': > '||l_msg_data);
687 FND_FILE.NEW_LINE(FND_FILE.LOG, 1);
688 END LOOP;
689
690 -- raise the exception
691 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
692 END IF;
693
694 -- set the output
695 FND_FILE.PUT_LINE(FND_FILE.OUTPUT, 'Workflow notification launched with item key > '||l_item_key);
696 ELSE
697 -- set the output
698 FND_FILE.PUT_LINE(FND_FILE.OUTPUT, 'Workflow notification could not be launched. Check the Workflow mapping.');
699 END IF;
700
701 -- commit required to launch the Workflow
702 COMMIT;
703
704 FND_FILE.PUT_LINE(FND_FILE.LOG, l_full_name||', end');
705 FND_FILE.NEW_LINE(FND_FILE.LOG, 1);
706 FND_FILE.PUT_LINE(FND_FILE.LOG, 'End time: '||TO_CHAR(SYSDATE, 'Month DD, YYYY HH24:MI:SS'));
707
708 EXCEPTION
709 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
710 retcode := 2;
711 errbuf := FND_MSG_PUB.Get;
712 FND_FILE.PUT_LINE(FND_FILE.OUTPUT, 'Process failed. View program logs for details.');
713
714 WHEN OTHERS THEN
715 retcode := 2;
716 errbuf := l_full_name||': '||SUBSTRB(SQLERRM, 1, 200);
717 FND_FILE.PUT_LINE(FND_FILE.LOG, l_full_name||', exception occurred: '||SUBSTRB(SQLERRM, 1, 200));
718 FND_FILE.PUT_LINE(FND_FILE.OUTPUT, 'Process failed. View program logs for details.');
719
720 END Launch_WOCl_Notification;
721 ------------------------------------------------------------------------------------
722
723 ------------------------------------------------------------------------------------
724 -- Start of Comments
725 -- Function name : Get_Entitlement_Instance
726 -- Type : Public
727 -- Function : Gets the instance id for the given warranty entitlement id.
728 -- Returns NULL if not found.
729 --
730 -- Pre-reqs :
731 -- Parameters :
732 --
733 -- Get_Entitlement_Instance Parameters:
734 -- p_entitlement_id IN Entitlement id Required
735 --
736 -- End of Comments
737
738 FUNCTION Get_Entitlement_Instance(
739 p_entitlement_id IN NUMBER
740 ) RETURN NUMBER IS
741
742 CURSOR get_visit_task_inst_csr (c_entl_id NUMBER) IS
743 SELECT VTK.instance_id
744 FROM AHL_VISIT_TASKS_B VTK, AHL_WARRANTY_ENTITLEMENTS ENT
745 WHERE VTK.visit_task_id = ENT.visit_task_id
746 AND ENT.warranty_entitlement_id = c_entl_id;
747
748 CURSOR get_osp_line_inst_csr (c_entl_id NUMBER) IS
749 SELECT VTK.instance_id
750 FROM AHL_VISIT_TASKS_B VTK, AHL_WORKORDERS WO,
751 AHL_OSP_ORDER_LINES OSP, AHL_WARRANTY_ENTITLEMENTS ENT
752 WHERE VTK.visit_task_id = WO.visit_task_id
753 AND WO.workorder_id = OSP.workorder_id
754 AND OSP.workorder_id IS NOT NULL
755 AND OSP.osp_order_line_id = ENT.osp_order_line_id
756 AND ENT.warranty_entitlement_id = c_entl_id
757 UNION ALL
758 SELECT CSI.instance_id
759 FROM AHL_OSP_ORDER_LINES OSP, CSI_ITEM_INSTANCES CSI,
760 AHL_WARRANTY_ENTITLEMENTS ENT
761 WHERE CSI.last_vld_organization_id = OSP.inventory_org_id
762 AND CSI.inventory_item_id = OSP.inventory_item_id
763 AND CSI.serial_number = OSP.serial_number
764 AND OSP.workorder_id IS NULL
765 AND OSP.osp_order_line_id = ENT.osp_order_line_id
766 AND ENT.warranty_entitlement_id = c_entl_id;
767
768 --
769 l_api_name CONSTANT VARCHAR2(30) := 'Get_Entitlement_Instance';
770 l_full_name CONSTANT VARCHAR2(100) := 'ahl.plsql.'||G_PKG_NAME||'.'||l_api_name;
771
772 l_ret_val NUMBER := NULL;
773 --
774
775 BEGIN
776 IF (l_log_procedure >= l_log_current_level) THEN
777 FND_LOG.string(l_log_procedure, l_full_name || '.begin', 'Entering Procedure');
778 END IF;
779
780 IF (l_log_statement >= l_log_current_level) THEN
781 FND_LOG.string(l_log_statement, l_full_name, 'p_entitlement_id > '||p_entitlement_id);
782 END IF;
783
784 -- get the instance id from the visit task id
785 OPEN get_visit_task_inst_csr(p_entitlement_id);
786 FETCH get_visit_task_inst_csr INTO l_ret_val;
787 CLOSE get_visit_task_inst_csr;
788
789 IF (l_log_statement >= l_log_current_level) THEN
790 FND_LOG.string(l_log_statement, l_full_name, 'l_ret_val > '||l_ret_val);
791 END IF;
792
793 -- if not found, then get the instance id from the OSP order line id
794 IF (l_ret_val IS NULL) THEN
795 OPEN get_osp_line_inst_csr(p_entitlement_id);
796 FETCH get_osp_line_inst_csr INTO l_ret_val;
797 CLOSE get_osp_line_inst_csr;
798 END IF;
799
800 IF (l_log_statement >= l_log_current_level) THEN
801 FND_LOG.string(l_log_statement, l_full_name, 'l_ret_val > '||l_ret_val);
802 END IF;
803
804 IF (l_log_procedure >= l_log_current_level) THEN
805 FND_LOG.string(l_log_procedure, l_full_name || '.end', 'Exiting Procedure');
806 END IF;
807
808 RETURN l_ret_val;
809
810 END Get_Entitlement_Instance;
811 ------------------------------------------------------------------------------------
812
813 ------------------------------------------------------------------------------------
814 -- Start of Comments
815 -- Function name : Get_OSP_Order_Number
816 -- Type : Public
817 -- Function : Gets the OSP order number for the given OSP line id.
818 -- Returns NULL if not found.
819 --
820 -- Pre-reqs :
821 -- Parameters :
822 --
823 -- Get_OSP_Order_Number Parameters:
824 -- p_osp_line_id IN OSP line id Required
825 --
826 -- End of Comments
827
828 FUNCTION Get_OSP_Order_Number(
829 p_osp_line_id IN NUMBER
830 ) RETURN NUMBER IS
831
832 -- cursor to get the OSP order number for the given OSP line id
833 CURSOR get_osp_order_number_csr (c_osp_line_id NUMBER) IS
834 SELECT OSPO.osp_order_number
835 FROM AHL_OSP_ORDERS_B OSPO, AHL_OSP_ORDER_LINES OSPL
836 WHERE OSPO.osp_order_id = OSPL.osp_order_id
837 AND OSPL.osp_order_line_id = c_osp_line_id;
838
839 --
840 l_api_name CONSTANT VARCHAR2(30) := 'Get_OSP_Order_Number';
841 l_full_name CONSTANT VARCHAR2(100) := 'ahl.plsql.'||G_PKG_NAME||'.'||l_api_name;
842
843 l_ret_val NUMBER := NULL;
844 --
845
846 BEGIN
847 IF (l_log_procedure >= l_log_current_level) THEN
848 FND_LOG.string(l_log_procedure, l_full_name || '.begin', 'Entering Procedure');
849 END IF;
850
851 IF (l_log_statement >= l_log_current_level) THEN
852 FND_LOG.string(l_log_statement, l_full_name, 'p_osp_line_id > '||p_osp_line_id);
853 END IF;
854
855 -- get the OSP order number for the given OSP line id
856 OPEN get_osp_order_number_csr(p_osp_line_id);
857 FETCH get_osp_order_number_csr INTO l_ret_val;
858 CLOSE get_osp_order_number_csr;
859
860 IF (l_log_statement >= l_log_current_level) THEN
861 FND_LOG.string(l_log_statement, l_full_name, 'l_ret_val > '||l_ret_val);
862 END IF;
863
864 IF (l_log_procedure >= l_log_current_level) THEN
865 FND_LOG.string(l_log_procedure, l_full_name || '.end', 'Exiting Procedure');
866 END IF;
867
868 RETURN l_ret_val;
869
870 END Get_OSP_Order_Number;
871 ------------------------------------------------------------------------------------
872
873 ------------------------------------------------------------------------------------
874 -- Start of Comments
875 -- Function name : Get_OSP_Line_Number
876 -- Type : Public
877 -- Function : Gets the OSP line number for the given OSP line id.
878 -- Returns NULL if not found.
879 --
880 -- Pre-reqs :
881 -- Parameters :
882 --
883 -- Get_OSP_Line_Number Parameters:
884 -- p_osp_line_id IN OSP line id Required
885 --
886 -- End of Comments
887
888 FUNCTION Get_OSP_Line_Number(
889 p_osp_line_id IN NUMBER
890 ) RETURN NUMBER IS
891
892 -- cursor to get the OSP line number for the given OSP line id
893 CURSOR get_osp_line_number_csr (c_osp_line_id NUMBER) IS
894 SELECT osp_line_number
895 FROM AHL_OSP_ORDER_LINES
896 WHERE osp_order_line_id = c_osp_line_id;
897
898 --
899 l_api_name CONSTANT VARCHAR2(30) := 'Get_OSP_Line_Number';
900 l_full_name CONSTANT VARCHAR2(100) := 'ahl.plsql.'||G_PKG_NAME||'.'||l_api_name;
901
902 l_ret_val NUMBER := NULL;
903 --
904
905 BEGIN
906 IF (l_log_procedure >= l_log_current_level) THEN
907 FND_LOG.string(l_log_procedure, l_full_name || '.begin', 'Entering Procedure');
908 END IF;
909
910 IF (l_log_statement >= l_log_current_level) THEN
911 FND_LOG.string(l_log_statement, l_full_name, 'p_osp_line_id > '||p_osp_line_id);
912 END IF;
913
914 -- get the OSP line number for the given OSP line id
915 OPEN get_osp_line_number_csr(p_osp_line_id);
916 FETCH get_osp_line_number_csr INTO l_ret_val;
917 CLOSE get_osp_line_number_csr;
918
919 IF (l_log_statement >= l_log_current_level) THEN
920 FND_LOG.string(l_log_statement, l_full_name, 'l_ret_val > '||l_ret_val);
921 END IF;
922
923 IF (l_log_procedure >= l_log_current_level) THEN
924 FND_LOG.string(l_log_procedure, l_full_name || '.end', 'Exiting Procedure');
925 END IF;
926
927 RETURN l_ret_val;
928
929 END Get_OSP_Line_Number;
930 ------------------------------------------------------------------------------------
931
932 ------------------------------------------------------------------------------------
933 -- Start of Comments
934 -- Function name : Get_OSP_Line_Status
935 -- Type : Public
936 -- Function : Gets the OSP line status for the given OSP line id.
937 -- Returns NULL if not found.
938 --
939 -- Pre-reqs :
940 -- Parameters :
941 --
942 -- Get_OSP_Line_Status Parameters:
943 -- p_osp_line_id IN OSP line id Required
944 --
945 -- End of Comments
946
947 FUNCTION Get_OSP_Line_Status(
948 p_osp_line_id IN NUMBER
949 ) RETURN VARCHAR2 IS
950
951 -- cursor to get the OSP line status for the given OSP line id
952 CURSOR get_osp_line_status_csr (c_osp_line_id NUMBER) IS
953 SELECT FOS.meaning
954 FROM AHL_OSP_ORDER_LINES OSPL, FND_LOOKUP_VALUES_VL FOS
955 WHERE FOS.lookup_code = OSPL.status_code
956 AND FOS.lookup_type = 'AHL_OSP_LINE_STATUS_TYPE'
957 AND OSPL.osp_order_line_id = c_osp_line_id;
958
959 --
960 l_api_name CONSTANT VARCHAR2(30) := 'Get_OSP_Line_Status';
961 l_full_name CONSTANT VARCHAR2(100) := 'ahl.plsql.'||G_PKG_NAME||'.'||l_api_name;
962
963 l_ret_val VARCHAR2(80) := NULL;
964 --
965
966 BEGIN
967 IF (l_log_procedure >= l_log_current_level) THEN
968 FND_LOG.string(l_log_procedure, l_full_name || '.begin', 'Entering Procedure');
969 END IF;
970
971 IF (l_log_statement >= l_log_current_level) THEN
972 FND_LOG.string(l_log_statement, l_full_name, 'p_osp_line_id > '||p_osp_line_id);
973 END IF;
974
975 -- get the OSP line status for the given OSP line id
976 OPEN get_osp_line_status_csr(p_osp_line_id);
977 FETCH get_osp_line_status_csr INTO l_ret_val;
978 CLOSE get_osp_line_status_csr;
979
980 IF (l_log_statement >= l_log_current_level) THEN
981 FND_LOG.string(l_log_statement, l_full_name, 'l_ret_val > '||l_ret_val);
982 END IF;
983
984 IF (l_log_procedure >= l_log_current_level) THEN
985 FND_LOG.string(l_log_procedure, l_full_name || '.end', 'Exiting Procedure');
986 END IF;
987
988 RETURN l_ret_val;
989
990 END Get_OSP_Line_Status;
991 ------------------------------------------------------------------------------------
992
993
994 ------------------------------------------------------------------------------------
995 -- Private procedure definitions
996 ------------------------------------------------------------------------------------
997 -- Procedure to create Warranty Entitlement record
998 PROCEDURE Create_Warranty_Entitlement (
999 p_module_type IN VARCHAR2 := NULL,
1000 p_user_role IN VARCHAR2,
1001 p_x_warranty_entl_rec IN OUT NOCOPY Warranty_Entl_Rec_Type
1002 ) IS
1003
1004 --
1005 l_api_name CONSTANT VARCHAR2(30) := 'Create_Warranty_Entitlement';
1006 l_full_name CONSTANT VARCHAR2(100) := 'ahl.plsql.'||G_PKG_NAME||'.'||l_api_name;
1007
1008 l_dummy_char VARCHAR2(30);
1009 l_msg_count NUMBER;
1010 l_contract_id NUMBER;
1011 l_item_key VARCHAR2(60);
1012 l_return_status VARCHAR2(1);
1013 --
1014
1015 BEGIN
1016 IF (l_log_procedure >= l_log_current_level) THEN
1017 FND_LOG.string(l_log_procedure, l_full_name || '.begin', 'Entering Procedure');
1018 END IF;
1019
1020 -- module type check commented for present requirements. can be used in future
1021 -- IF (p_module_type = 'JSP') THEN
1022 IF (p_x_warranty_entl_rec.warranty_contract_id = FND_API.G_MISS_NUM) THEN
1023 p_x_warranty_entl_rec.warranty_contract_id := NULL;
1024 END IF;
1025 IF (p_x_warranty_entl_rec.entitlement_status_code = FND_API.G_MISS_CHAR) THEN
1026 p_x_warranty_entl_rec.entitlement_status_code := NULL;
1027 END IF;
1028 IF (p_x_warranty_entl_rec.warranty_claim_id = FND_API.G_MISS_NUM) THEN
1029 p_x_warranty_entl_rec.warranty_claim_id := NULL;
1030 END IF;
1031 IF (p_x_warranty_entl_rec.po_header_id = FND_API.G_MISS_NUM) THEN
1032 p_x_warranty_entl_rec.po_header_id := NULL;
1033 END IF;
1034 IF (p_x_warranty_entl_rec.sr_incident_id = FND_API.G_MISS_NUM) THEN
1035 p_x_warranty_entl_rec.sr_incident_id := NULL;
1036 END IF;
1037 IF (p_x_warranty_entl_rec.visit_task_id = FND_API.G_MISS_NUM) THEN
1038 p_x_warranty_entl_rec.visit_task_id := NULL;
1039 END IF;
1040 IF (p_x_warranty_entl_rec.workorder_id = FND_API.G_MISS_NUM) THEN
1041 p_x_warranty_entl_rec.workorder_id := NULL;
1042 END IF;
1043 IF (p_x_warranty_entl_rec.osp_order_line_id = FND_API.G_MISS_NUM) THEN
1044 p_x_warranty_entl_rec.osp_order_line_id := NULL;
1045 END IF;
1046 IF (p_x_warranty_entl_rec.warranty_labour_capture = FND_API.G_MISS_CHAR) THEN
1047 p_x_warranty_entl_rec.warranty_labour_capture := NULL;
1048 END IF;
1049 IF (p_x_warranty_entl_rec.warranty_mtl_capture = FND_API.G_MISS_CHAR) THEN
1050 p_x_warranty_entl_rec.warranty_mtl_capture := NULL;
1051 END IF;
1052 IF (p_x_warranty_entl_rec.order_claim_amount = FND_API.G_MISS_NUM) THEN
1053 p_x_warranty_entl_rec.order_claim_amount := NULL;
1054 END IF;
1055 IF (p_x_warranty_entl_rec.attribute_category = FND_API.G_MISS_CHAR) THEN
1056 p_x_warranty_entl_rec.attribute_category := NULL;
1057 END IF;
1058 IF (p_x_warranty_entl_rec.attribute1 = FND_API.G_MISS_CHAR) THEN
1059 p_x_warranty_entl_rec.attribute1 := NULL;
1060 END IF;
1061 IF (p_x_warranty_entl_rec.attribute2 = FND_API.G_MISS_CHAR) THEN
1062 p_x_warranty_entl_rec.attribute2 := NULL;
1063 END IF;
1064 IF (p_x_warranty_entl_rec.attribute3 = FND_API.G_MISS_CHAR) THEN
1065 p_x_warranty_entl_rec.attribute3 := NULL;
1066 END IF;
1067 IF (p_x_warranty_entl_rec.attribute4 = FND_API.G_MISS_CHAR) THEN
1068 p_x_warranty_entl_rec.attribute4 := NULL;
1069 END IF;
1070 IF (p_x_warranty_entl_rec.attribute5 = FND_API.G_MISS_CHAR) THEN
1071 p_x_warranty_entl_rec.attribute5 := NULL;
1072 END IF;
1073 IF (p_x_warranty_entl_rec.attribute6 = FND_API.G_MISS_CHAR) THEN
1074 p_x_warranty_entl_rec.attribute6 := NULL;
1075 END IF;
1076 IF (p_x_warranty_entl_rec.attribute7 = FND_API.G_MISS_CHAR) THEN
1077 p_x_warranty_entl_rec.attribute7 := NULL;
1078 END IF;
1079 IF (p_x_warranty_entl_rec.attribute8 = FND_API.G_MISS_CHAR) THEN
1080 p_x_warranty_entl_rec.attribute8 := NULL;
1081 END IF;
1082 IF (p_x_warranty_entl_rec.attribute9 = FND_API.G_MISS_CHAR) THEN
1083 p_x_warranty_entl_rec.attribute9 := NULL;
1084 END IF;
1085 IF (p_x_warranty_entl_rec.attribute10 = FND_API.G_MISS_CHAR) THEN
1086 p_x_warranty_entl_rec.attribute10 := NULL;
1087 END IF;
1088 IF (p_x_warranty_entl_rec.attribute11 = FND_API.G_MISS_CHAR) THEN
1089 p_x_warranty_entl_rec.attribute11 := NULL;
1090 END IF;
1091 IF (p_x_warranty_entl_rec.attribute12 = FND_API.G_MISS_CHAR) THEN
1092 p_x_warranty_entl_rec.attribute12 := NULL;
1093 END IF;
1094 IF (p_x_warranty_entl_rec.attribute13 = FND_API.G_MISS_CHAR) THEN
1095 p_x_warranty_entl_rec.attribute13 := NULL;
1096 END IF;
1097 IF (p_x_warranty_entl_rec.attribute14 = FND_API.G_MISS_CHAR) THEN
1098 p_x_warranty_entl_rec.attribute14 := NULL;
1099 END IF;
1100 IF (p_x_warranty_entl_rec.attribute15 = FND_API.G_MISS_CHAR) THEN
1101 p_x_warranty_entl_rec.attribute15 := NULL;
1102 END IF;
1103 -- END IF; -- module type check
1104
1105 -- get the error message count till this point
1106 l_msg_count := FND_MSG_PUB.count_msg;
1107
1108 -- validate the record for create
1109 Validate_Warranty_Entitlement (
1110 p_user_role => p_user_role,
1111 p_warranty_entl_rec => p_x_warranty_entl_rec
1112 );
1113
1114 -- if any errors occured, then don't proceed any further
1115 IF (l_msg_count < FND_MSG_PUB.count_msg) THEN
1116 IF (l_log_statement >= l_log_current_level) THEN
1117 FND_LOG.string(l_log_statement, l_full_name, 'Validate_Warranty_Entitlement for create had errors');
1118 END IF;
1119 RETURN;
1120 END IF;
1121
1122 -- prepare for insert
1123 SELECT AHL_WARRANTY_ENTITLEMENTS_S.NEXTVAL INTO p_x_warranty_entl_rec.warranty_entitlement_id FROM DUAL;
1124 -- setting object version number for create
1125 p_x_warranty_entl_rec.object_version_number := 1;
1126 -- setting up user/create/update information
1127 p_x_warranty_entl_rec.created_by := FND_GLOBAL.USER_ID;
1128 p_x_warranty_entl_rec.creation_date := SYSDATE;
1129 p_x_warranty_entl_rec.last_updated_by := FND_GLOBAL.USER_ID;
1130 p_x_warranty_entl_rec.last_update_date := SYSDATE;
1131 p_x_warranty_entl_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
1132
1133 -- setting the old contract id
1134 IF (NVL(p_user_role, 'X') = G_USER_PLANNER) THEN
1135 l_contract_id := p_x_warranty_entl_rec.warranty_contract_id;
1136 ELSE
1137 l_contract_id := NULL;
1138 END IF;
1139
1140 IF (l_log_statement >= l_log_current_level) THEN
1141 FND_LOG.string(l_log_statement, l_full_name, 'Before Insert_Row');
1142 END IF;
1143
1144 AHL_WARRANTY_ENTITLEMENTS_PKG.Insert_Row(
1145 x_row_id => l_dummy_char,
1146 x_warranty_entitlement_id => p_x_warranty_entl_rec.warranty_entitlement_id,
1147 x_object_version_number => p_x_warranty_entl_rec.object_version_number,
1148 x_warranty_contract_id => p_x_warranty_entl_rec.warranty_contract_id,
1149 x_old_warranty_contract_id => l_contract_id,
1150 x_entitlement_status_code => p_x_warranty_entl_rec.entitlement_status_code,
1151 x_warranty_claim_id => p_x_warranty_entl_rec.warranty_claim_id,
1152 x_po_header_id => p_x_warranty_entl_rec.po_header_id,
1153 x_sr_incident_id => p_x_warranty_entl_rec.sr_incident_id,
1154 x_visit_task_id => p_x_warranty_entl_rec.visit_task_id,
1155 x_workorder_id => p_x_warranty_entl_rec.workorder_id,
1156 x_osp_order_line_id => p_x_warranty_entl_rec.osp_order_line_id,
1157 x_warranty_labour_capture => p_x_warranty_entl_rec.warranty_labour_capture,
1158 x_warranty_mtl_capture => p_x_warranty_entl_rec.warranty_mtl_capture ,
1159 x_order_claim_amount => p_x_warranty_entl_rec.order_claim_amount,
1160 x_attribute_category => p_x_warranty_entl_rec.attribute_category,
1161 x_attribute1 => p_x_warranty_entl_rec.attribute1,
1162 x_attribute2 => p_x_warranty_entl_rec.attribute2,
1163 x_attribute3 => p_x_warranty_entl_rec.attribute3,
1164 x_attribute4 => p_x_warranty_entl_rec.attribute4,
1165 x_attribute5 => p_x_warranty_entl_rec.attribute5,
1166 x_attribute6 => p_x_warranty_entl_rec.attribute6,
1167 x_attribute7 => p_x_warranty_entl_rec.attribute7,
1168 x_attribute8 => p_x_warranty_entl_rec.attribute8,
1169 x_attribute9 => p_x_warranty_entl_rec.attribute9,
1170 x_attribute10 => p_x_warranty_entl_rec.attribute10,
1171 x_attribute11 => p_x_warranty_entl_rec.attribute11,
1172 x_attribute12 => p_x_warranty_entl_rec.attribute12,
1173 x_attribute13 => p_x_warranty_entl_rec.attribute13,
1174 x_attribute14 => p_x_warranty_entl_rec.attribute14,
1175 x_attribute15 => p_x_warranty_entl_rec.attribute15,
1176 x_creation_date => p_x_warranty_entl_rec.creation_date ,
1177 x_created_by => p_x_warranty_entl_rec.created_by,
1178 x_last_update_date => p_x_warranty_entl_rec.last_update_date,
1179 x_last_updated_by => p_x_warranty_entl_rec.last_updated_by,
1180 x_last_update_login => p_x_warranty_entl_rec.last_update_login
1181 );
1182
1183 IF (l_log_statement >= l_log_current_level) THEN
1184 FND_LOG.string(l_log_statement, l_full_name, 'After Insert_Row');
1185 END IF;
1186
1187 -- for non-planner user and Approval Pending status creation, launch the notification
1188 IF (NVL(p_user_role, 'X') = G_USER_NONPLANNER AND
1189 NVL(p_x_warranty_entl_rec.entitlement_status_code, 'X') = 'APPROVAL_PENDING') THEN
1190 IF (l_log_statement >= l_log_current_level) THEN
1191 FND_LOG.string(l_log_statement, l_full_name,
1192 'before calling Launch_Entl_Notification with arguments: '||
1193 ' p_entitlement_id > '||p_x_warranty_entl_rec.warranty_entitlement_id);
1194 END IF;
1195
1196 -- call Launch_Entl_Notification
1197 -- NOTE: the OUT parameters are not used in this flow as the notification is sent as part of a create
1198 Launch_Entl_Notification(
1199 p_entitlement_id => p_x_warranty_entl_rec.warranty_entitlement_id,
1200 p_commit => FND_API.G_FALSE,
1201 x_item_key => l_item_key,
1202 x_return_status => l_return_status);
1203
1204 IF (l_log_statement >= l_log_current_level) THEN
1205 FND_LOG.string(l_log_statement, l_full_name,
1206 'after calling Launch_Entl_Notification, '||
1207 ' l_item_key > '||l_item_key||
1208 ', l_return_status'||l_return_status);
1209 END IF;
1210 END IF;
1211
1212 IF (l_log_procedure >= l_log_current_level) THEN
1213 FND_LOG.string(l_log_procedure, l_full_name || '.end', 'Exiting Procedure');
1214 END IF;
1215 END Create_Warranty_Entitlement;
1216 ------------------------------------------------------------------------------------
1217
1218 -- Procedure to update Warranty Entitlement record
1219 PROCEDURE Update_Warranty_Entitlement (
1220 p_module_type IN VARCHAR2 := NULL,
1221 p_user_role IN VARCHAR2,
1222 p_x_warranty_entl_rec IN OUT NOCOPY Warranty_Entl_Rec_Type
1223 ) IS
1224
1225 CURSOR warranty_entl_csr(c_warranty_entl_id NUMBER) IS
1226 SELECT *
1227 FROM AHL_WARRANTY_ENTITLEMENTS
1228 WHERE warranty_entitlement_id = c_warranty_entl_id;
1229
1230 --
1231 l_api_name CONSTANT VARCHAR2(30) := 'Update_Warranty_Entitlement';
1232 l_full_name CONSTANT VARCHAR2(100) := 'ahl.plsql.'||G_PKG_NAME||'.'||l_api_name;
1233
1234 l_msg_count NUMBER;
1235 l_warranty_entl_rec warranty_entl_csr%ROWTYPE;
1236 l_contract_id NUMBER;
1237 l_item_key VARCHAR2(60);
1238 l_return_status VARCHAR2(1);
1239 --
1240
1241 BEGIN
1242 IF (l_log_procedure >= l_log_current_level) THEN
1243 FND_LOG.string(l_log_procedure, l_full_name || '.begin', 'Entering Procedure');
1244 END IF;
1245
1246 OPEN warranty_entl_csr(p_x_warranty_entl_rec.warranty_entitlement_id);
1247 FETCH warranty_entl_csr INTO l_warranty_entl_rec;
1248 IF (warranty_entl_csr%NOTFOUND) THEN
1249 -- invalid entitlement id
1250 IF (l_log_statement >= l_log_current_level) THEN
1251 FND_LOG.string(l_log_statement, l_full_name, 'invalid entitlement id for update');
1252 END IF;
1253 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_WARRANTY_ENTL_ID_INVLD'); -- Warranty entitlement id ENTL_ID is invalid.
1254 FND_MESSAGE.Set_Token('ENTL_ID', p_x_warranty_entl_rec.warranty_entitlement_id);
1255 FND_MSG_PUB.ADD;
1256 RETURN;
1257 END IF;
1258 CLOSE warranty_entl_csr;
1259
1260 -- check for object_version_number
1261 IF (p_x_warranty_entl_rec.object_version_number <> l_warranty_entl_rec.object_version_number) THEN
1262 IF (l_log_statement >= l_log_current_level) THEN
1263 FND_LOG.string(l_log_statement, l_full_name, 'object_version_number mismatch');
1264 END IF;
1265 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_COM_RECORD_CHANGED'); -- Record has been modified by another user.
1266 FND_MSG_PUB.ADD;
1267 RETURN;
1268 END IF;
1269
1270 -- module type check commented for present requirements. can be used in future
1271 -- IF (p_module_type = 'JSP') THEN
1272 IF (p_x_warranty_entl_rec.warranty_contract_id IS NULL) THEN
1273 p_x_warranty_entl_rec.warranty_contract_id := l_warranty_entl_rec.warranty_contract_id;
1274 ELSIF (p_x_warranty_entl_rec.warranty_contract_id = FND_API.G_MISS_NUM) THEN
1275 p_x_warranty_entl_rec.warranty_contract_id := NULL;
1276 END IF;
1277 IF (p_x_warranty_entl_rec.entitlement_status_code IS NULL) THEN
1278 p_x_warranty_entl_rec.entitlement_status_code := l_warranty_entl_rec.entitlement_status_code;
1279 ELSIF (p_x_warranty_entl_rec.entitlement_status_code = FND_API.G_MISS_CHAR) THEN
1280 p_x_warranty_entl_rec.entitlement_status_code := NULL;
1281 END IF;
1282 IF (p_x_warranty_entl_rec.warranty_claim_id IS NULL) THEN
1283 p_x_warranty_entl_rec.warranty_claim_id := l_warranty_entl_rec.warranty_claim_id;
1284 ELSIF (p_x_warranty_entl_rec.warranty_claim_id = FND_API.G_MISS_NUM) THEN
1285 p_x_warranty_entl_rec.warranty_claim_id := NULL;
1286 END IF;
1287 IF (p_x_warranty_entl_rec.po_header_id IS NULL) THEN
1288 p_x_warranty_entl_rec.po_header_id := l_warranty_entl_rec.po_header_id;
1289 ELSIF (p_x_warranty_entl_rec.po_header_id = FND_API.G_MISS_NUM) THEN
1290 p_x_warranty_entl_rec.po_header_id := NULL;
1291 END IF;
1292 IF (p_x_warranty_entl_rec.sr_incident_id IS NULL) THEN
1293 p_x_warranty_entl_rec.sr_incident_id := l_warranty_entl_rec.sr_incident_id;
1294 ELSIF (p_x_warranty_entl_rec.sr_incident_id = FND_API.G_MISS_NUM) THEN
1295 p_x_warranty_entl_rec.sr_incident_id := NULL;
1296 END IF;
1297 IF (p_x_warranty_entl_rec.visit_task_id IS NULL) THEN
1298 p_x_warranty_entl_rec.visit_task_id := l_warranty_entl_rec.visit_task_id;
1299 ELSIF (p_x_warranty_entl_rec.visit_task_id = FND_API.G_MISS_NUM) THEN
1300 p_x_warranty_entl_rec.visit_task_id := NULL;
1301 END IF;
1302 IF (p_x_warranty_entl_rec.workorder_id IS NULL) THEN
1303 p_x_warranty_entl_rec.workorder_id := l_warranty_entl_rec.workorder_id;
1304 ELSIF (p_x_warranty_entl_rec.workorder_id = FND_API.G_MISS_NUM) THEN
1305 p_x_warranty_entl_rec.workorder_id := NULL;
1306 END IF;
1307 IF (p_x_warranty_entl_rec.osp_order_line_id IS NULL) THEN
1308 p_x_warranty_entl_rec.osp_order_line_id := l_warranty_entl_rec.osp_order_line_id;
1309 ELSIF (p_x_warranty_entl_rec.osp_order_line_id = FND_API.G_MISS_NUM) THEN
1310 p_x_warranty_entl_rec.osp_order_line_id := NULL;
1311 END IF;
1312 IF (p_x_warranty_entl_rec.warranty_labour_capture IS NULL) THEN
1313 p_x_warranty_entl_rec.warranty_labour_capture := l_warranty_entl_rec.warranty_labour_capture;
1314 ELSIF (p_x_warranty_entl_rec.warranty_labour_capture = FND_API.G_MISS_CHAR) THEN
1315 p_x_warranty_entl_rec.warranty_labour_capture := NULL;
1316 END IF;
1317 IF (p_x_warranty_entl_rec.warranty_mtl_capture IS NULL) THEN
1318 p_x_warranty_entl_rec.warranty_mtl_capture := l_warranty_entl_rec.warranty_mtl_capture;
1319 ELSIF (p_x_warranty_entl_rec.warranty_mtl_capture = FND_API.G_MISS_CHAR) THEN
1320 p_x_warranty_entl_rec.warranty_mtl_capture := NULL;
1321 END IF;
1322 IF (p_x_warranty_entl_rec.order_claim_amount IS NULL) THEN
1323 p_x_warranty_entl_rec.order_claim_amount := l_warranty_entl_rec.order_claim_amount;
1324 ELSIF (p_x_warranty_entl_rec.order_claim_amount = FND_API.G_MISS_NUM) THEN
1325 p_x_warranty_entl_rec.order_claim_amount := NULL;
1326 END IF;
1327 IF (p_x_warranty_entl_rec.attribute_category IS NULL) THEN
1328 p_x_warranty_entl_rec.attribute_category := l_warranty_entl_rec.attribute_category;
1329 ELSIF (p_x_warranty_entl_rec.attribute_category = FND_API.G_MISS_CHAR) THEN
1330 p_x_warranty_entl_rec.attribute_category := NULL;
1331 END IF;
1332 IF (p_x_warranty_entl_rec.attribute1 IS NULL) THEN
1333 p_x_warranty_entl_rec.attribute1 := l_warranty_entl_rec.attribute1;
1334 ELSIF (p_x_warranty_entl_rec.attribute1 = FND_API.G_MISS_CHAR) THEN
1335 p_x_warranty_entl_rec.attribute1 := NULL;
1336 END IF;
1337 IF (p_x_warranty_entl_rec.attribute2 IS NULL) THEN
1338 p_x_warranty_entl_rec.attribute2 := l_warranty_entl_rec.attribute2;
1339 ELSIF (p_x_warranty_entl_rec.attribute2 = FND_API.G_MISS_CHAR) THEN
1340 p_x_warranty_entl_rec.attribute2 := NULL;
1341 END IF;
1342 IF (p_x_warranty_entl_rec.attribute3 IS NULL) THEN
1343 p_x_warranty_entl_rec.attribute3 := l_warranty_entl_rec.attribute3;
1344 ELSIF (p_x_warranty_entl_rec.attribute3 = FND_API.G_MISS_CHAR) THEN
1345 p_x_warranty_entl_rec.attribute3 := NULL;
1346 END IF;
1347 IF (p_x_warranty_entl_rec.attribute4 IS NULL) THEN
1348 p_x_warranty_entl_rec.attribute4 := l_warranty_entl_rec.attribute4;
1349 ELSIF (p_x_warranty_entl_rec.attribute4 = FND_API.G_MISS_CHAR) THEN
1350 p_x_warranty_entl_rec.attribute4 := NULL;
1351 END IF;
1352 IF (p_x_warranty_entl_rec.attribute5 IS NULL) THEN
1353 p_x_warranty_entl_rec.attribute5 := l_warranty_entl_rec.attribute5;
1354 ELSIF (p_x_warranty_entl_rec.attribute5 = FND_API.G_MISS_CHAR) THEN
1355 p_x_warranty_entl_rec.attribute5 := NULL;
1356 END IF;
1357 IF (p_x_warranty_entl_rec.attribute6 IS NULL) THEN
1358 p_x_warranty_entl_rec.attribute6 := l_warranty_entl_rec.attribute6;
1359 ELSIF (p_x_warranty_entl_rec.attribute6 = FND_API.G_MISS_CHAR) THEN
1360 p_x_warranty_entl_rec.attribute6 := NULL;
1361 END IF;
1362 IF (p_x_warranty_entl_rec.attribute7 IS NULL) THEN
1363 p_x_warranty_entl_rec.attribute7 := l_warranty_entl_rec.attribute7;
1364 ELSIF (p_x_warranty_entl_rec.attribute7 = FND_API.G_MISS_CHAR) THEN
1365 p_x_warranty_entl_rec.attribute7 := NULL;
1366 END IF;
1367 IF (p_x_warranty_entl_rec.attribute8 IS NULL) THEN
1368 p_x_warranty_entl_rec.attribute8 := l_warranty_entl_rec.attribute8;
1369 ELSIF (p_x_warranty_entl_rec.attribute8 = FND_API.G_MISS_CHAR) THEN
1370 p_x_warranty_entl_rec.attribute8 := NULL;
1371 END IF;
1372 IF (p_x_warranty_entl_rec.attribute9 IS NULL) THEN
1373 p_x_warranty_entl_rec.attribute9 := l_warranty_entl_rec.attribute9;
1374 ELSIF (p_x_warranty_entl_rec.attribute9 = FND_API.G_MISS_CHAR) THEN
1375 p_x_warranty_entl_rec.attribute9 := NULL;
1376 END IF;
1377 IF (p_x_warranty_entl_rec.attribute10 IS NULL) THEN
1378 p_x_warranty_entl_rec.attribute10 := l_warranty_entl_rec.attribute10;
1379 ELSIF (p_x_warranty_entl_rec.attribute10 = FND_API.G_MISS_CHAR) THEN
1380 p_x_warranty_entl_rec.attribute10 := NULL;
1381 END IF;
1382 IF (p_x_warranty_entl_rec.attribute11 IS NULL) THEN
1383 p_x_warranty_entl_rec.attribute11 := l_warranty_entl_rec.attribute11;
1384 ELSIF (p_x_warranty_entl_rec.attribute11 = FND_API.G_MISS_CHAR) THEN
1385 p_x_warranty_entl_rec.attribute11 := NULL;
1386 END IF;
1387 IF (p_x_warranty_entl_rec.attribute12 IS NULL) THEN
1388 p_x_warranty_entl_rec.attribute12 := l_warranty_entl_rec.attribute12;
1389 ELSIF (p_x_warranty_entl_rec.attribute12 = FND_API.G_MISS_CHAR) THEN
1390 p_x_warranty_entl_rec.attribute12 := NULL;
1391 END IF;
1392 IF (p_x_warranty_entl_rec.attribute13 IS NULL) THEN
1393 p_x_warranty_entl_rec.attribute13 := l_warranty_entl_rec.attribute13;
1394 ELSIF (p_x_warranty_entl_rec.attribute13 = FND_API.G_MISS_CHAR) THEN
1395 p_x_warranty_entl_rec.attribute13 := NULL;
1396 END IF;
1397 IF (p_x_warranty_entl_rec.attribute14 IS NULL) THEN
1398 p_x_warranty_entl_rec.attribute14 := l_warranty_entl_rec.attribute14;
1399 ELSIF (p_x_warranty_entl_rec.attribute14 = FND_API.G_MISS_CHAR) THEN
1400 p_x_warranty_entl_rec.attribute14 := NULL;
1401 END IF;
1402 IF (p_x_warranty_entl_rec.attribute15 IS NULL) THEN
1403 p_x_warranty_entl_rec.attribute15 := l_warranty_entl_rec.attribute15;
1404 ELSIF (p_x_warranty_entl_rec.attribute15 = FND_API.G_MISS_CHAR) THEN
1405 p_x_warranty_entl_rec.attribute15 := NULL;
1406 END IF;
1407 -- END IF; -- module type check
1408
1409 -- get the error message count till this point
1410 l_msg_count := FND_MSG_PUB.count_msg;
1411
1412 -- validate the record for update
1413 Validate_Warranty_Entitlement (
1414 p_user_role => p_user_role,
1415 p_warranty_entl_rec => p_x_warranty_entl_rec
1416 );
1417
1418 -- if any errors occured, then don't proceed any further
1419 IF (l_msg_count < FND_MSG_PUB.count_msg) THEN
1420 IF (l_log_statement >= l_log_current_level) THEN
1421 FND_LOG.string(l_log_statement, l_full_name, 'Validate_Warranty_Entitlement for update had errors');
1422 END IF;
1423 RETURN;
1424 END IF;
1425
1426 -- setting up object version number
1427 p_x_warranty_entl_rec.object_version_number := p_x_warranty_entl_rec.object_version_number + 1;
1428 -- setting up user/create/update information
1429 p_x_warranty_entl_rec.last_updated_by := FND_GLOBAL.USER_ID;
1430 p_x_warranty_entl_rec.last_update_date := SYSDATE;
1431 p_x_warranty_entl_rec.last_update_login := FND_GLOBAL.LOGIN_ID;
1432
1433 -- setting the old contract id
1434 IF (NVL(p_user_role, 'X') = G_USER_PLANNER) THEN
1435 l_contract_id := p_x_warranty_entl_rec.warranty_contract_id;
1436 ELSE
1437 l_contract_id := l_warranty_entl_rec.old_warranty_contract_id;
1438 END IF;
1439
1440 IF (l_log_statement >= l_log_current_level) THEN
1441 FND_LOG.string(l_log_statement, l_full_name, 'Before Update_Row');
1442 END IF;
1443
1444 AHL_WARRANTY_ENTITLEMENTS_PKG.Update_Row(
1445 x_warranty_entitlement_id => p_x_warranty_entl_rec.warranty_entitlement_id,
1446 x_object_version_number => p_x_warranty_entl_rec.object_version_number,
1447 x_warranty_contract_id => p_x_warranty_entl_rec.warranty_contract_id,
1448 x_old_warranty_contract_id => l_contract_id,
1449 x_entitlement_status_code => p_x_warranty_entl_rec.entitlement_status_code,
1450 x_warranty_claim_id => p_x_warranty_entl_rec.warranty_claim_id,
1451 x_po_header_id => p_x_warranty_entl_rec.po_header_id,
1452 x_sr_incident_id => p_x_warranty_entl_rec.sr_incident_id,
1453 x_visit_task_id => p_x_warranty_entl_rec.visit_task_id,
1454 x_workorder_id => p_x_warranty_entl_rec.workorder_id,
1455 x_osp_order_line_id => p_x_warranty_entl_rec.osp_order_line_id,
1456 x_warranty_labour_capture => p_x_warranty_entl_rec.warranty_labour_capture,
1457 x_warranty_mtl_capture => p_x_warranty_entl_rec.warranty_mtl_capture ,
1458 x_order_claim_amount => p_x_warranty_entl_rec.order_claim_amount,
1459 x_attribute_category => p_x_warranty_entl_rec.attribute_category,
1460 x_attribute1 => p_x_warranty_entl_rec.attribute1,
1461 x_attribute2 => p_x_warranty_entl_rec.attribute2,
1462 x_attribute3 => p_x_warranty_entl_rec.attribute3,
1463 x_attribute4 => p_x_warranty_entl_rec.attribute4,
1464 x_attribute5 => p_x_warranty_entl_rec.attribute5,
1465 x_attribute6 => p_x_warranty_entl_rec.attribute6,
1466 x_attribute7 => p_x_warranty_entl_rec.attribute7,
1467 x_attribute8 => p_x_warranty_entl_rec.attribute8,
1468 x_attribute9 => p_x_warranty_entl_rec.attribute9,
1469 x_attribute10 => p_x_warranty_entl_rec.attribute10,
1470 x_attribute11 => p_x_warranty_entl_rec.attribute11,
1471 x_attribute12 => p_x_warranty_entl_rec.attribute12,
1472 x_attribute13 => p_x_warranty_entl_rec.attribute13,
1473 x_attribute14 => p_x_warranty_entl_rec.attribute14,
1474 x_attribute15 => p_x_warranty_entl_rec.attribute15,
1475 x_last_update_date => p_x_warranty_entl_rec.last_update_date,
1476 x_last_updated_by => p_x_warranty_entl_rec.last_updated_by,
1477 x_last_update_login => p_x_warranty_entl_rec.last_update_login
1478 );
1479
1480 IF (l_log_statement >= l_log_current_level) THEN
1481 FND_LOG.string(l_log_statement, l_full_name, 'After Update_Row');
1482 END IF;
1483
1484 -- for non-planner user and Approval Pending status update, launch the notification
1485 IF (NVL(p_user_role, 'X') = G_USER_NONPLANNER AND
1486 NVL(p_x_warranty_entl_rec.entitlement_status_code, 'X') = 'APPROVAL_PENDING') THEN
1487 IF (l_log_statement >= l_log_current_level) THEN
1488 FND_LOG.string(l_log_statement, l_full_name,
1489 'before calling Launch_Entl_Notification with arguments: '||
1490 ' p_entitlement_id > '||p_x_warranty_entl_rec.warranty_entitlement_id);
1491 END IF;
1492
1493 -- call Launch_Entl_Notification
1494 -- NOTE: the OUT parameters are not used in this flow as the notification is sent as part of an update
1495 Launch_Entl_Notification(
1496 p_entitlement_id => p_x_warranty_entl_rec.warranty_entitlement_id,
1497 p_commit => FND_API.G_FALSE,
1498 x_item_key => l_item_key,
1499 x_return_status => l_return_status);
1500
1501 IF (l_log_statement >= l_log_current_level) THEN
1502 FND_LOG.string(l_log_statement, l_full_name,
1503 'after calling Launch_Entl_Notification, '||
1504 ' l_item_key > '||l_item_key||
1505 ', l_return_status'||l_return_status);
1506 END IF;
1507 END IF;
1508
1509 IF (l_log_procedure >= l_log_current_level) THEN
1510 FND_LOG.string(l_log_procedure, l_full_name || '.end', 'Exiting Procedure');
1511 END IF;
1512 END Update_Warranty_Entitlement;
1513 ------------------------------------------------------------------------------------
1514
1515 -- Procedure to delete Warranty Entitlement record
1516 PROCEDURE Delete_Warranty_Entitlement (
1517 p_module_type IN VARCHAR2 := NULL,
1518 p_user_role IN VARCHAR2,
1519 p_x_warranty_entl_rec IN OUT NOCOPY Warranty_Entl_Rec_Type
1520 ) IS
1521
1522 --
1523 l_api_name CONSTANT VARCHAR2(30) := 'Delete_Warranty_Entitlement';
1524 l_full_name CONSTANT VARCHAR2(100) := 'ahl.plsql.'||G_PKG_NAME||'.'||l_api_name;
1525 --
1526
1527 BEGIN
1528 IF (l_log_procedure >= l_log_current_level) THEN
1529 FND_LOG.string(l_log_procedure, l_full_name || '.begin', 'Entering Procedure');
1530 END IF;
1531
1532 -- check if the user is planner or not
1533 IF (NVL(p_user_role, 'X') <> G_USER_PLANNER) THEN
1534 IF (l_log_statement >= l_log_current_level) THEN
1535 FND_LOG.string(l_log_statement, l_full_name, 'deletion permitted only to planner user');
1536 END IF;
1537 -- Warranty entitlement deletion is allowed only to the planner or the administrator.
1538 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_WARRANTY_DEL_NOT_ALWD');
1539 FND_MSG_PUB.ADD;
1540 RETURN;
1541 END IF;
1542
1543 IF (l_log_statement >= l_log_current_level) THEN
1544 FND_LOG.string(l_log_statement, l_full_name, 'Before Delete_Row');
1545 END IF;
1546
1547 -- delete row
1548 AHL_WARRANTY_ENTITLEMENTS_PKG.Delete_Row(
1549 x_warranty_entitlement_id => p_x_warranty_entl_rec.warranty_entitlement_id
1550 );
1551
1552 IF (l_log_statement >= l_log_current_level) THEN
1553 FND_LOG.string(l_log_statement, l_full_name, 'After Delete_Row');
1554 END IF;
1555
1556 IF (l_log_procedure >= l_log_current_level) THEN
1557 FND_LOG.string(l_log_procedure, l_full_name || '.end', 'Exiting Procedure');
1558 END IF;
1559 END Delete_Warranty_Entitlement;
1560 ------------------------------------------------------------------------------------
1561
1562 -- Procedure to approve Warranty Entitlement record
1563 PROCEDURE Approve_Warranty_Entitlement (
1564 p_module_type IN VARCHAR2 := NULL,
1565 p_user_role IN VARCHAR2,
1566 p_appr_action IN VARCHAR2,
1567 p_x_warranty_entl_rec IN OUT NOCOPY Warranty_Entl_Rec_Type
1568 ) IS
1569
1570 CURSOR warranty_entl_csr(c_warranty_entl_id NUMBER) IS
1571 SELECT *
1572 FROM AHL_WARRANTY_ENTITLEMENTS
1573 WHERE warranty_entitlement_id = c_warranty_entl_id;
1574
1575 CURSOR chk_war_cont_id_csr (c_contract_id NUMBER) IS
1576 SELECT 'X'
1577 FROM AHL_WARRANTY_CONTRACTS_B
1578 WHERE warranty_contract_id = c_contract_id
1579 AND contract_status_code = 'ACTIVE';
1580
1581 --
1582 l_api_name CONSTANT VARCHAR2(30) := 'Approve_Warranty_Entitlement';
1583 l_full_name CONSTANT VARCHAR2(100) := 'ahl.plsql.'||G_PKG_NAME||'.'||l_api_name;
1584
1585 l_dummy VARCHAR2(1);
1586 l_msg_count NUMBER;
1587 l_contract_id NUMBER;
1588 l_entl_status VARCHAR2(30) := 'APPROVED';
1589 l_warranty_entl_rec warranty_entl_csr%ROWTYPE;
1590 --
1591
1592 BEGIN
1593 IF (l_log_procedure >= l_log_current_level) THEN
1594 FND_LOG.string(l_log_procedure, l_full_name || '.begin', 'Entering Procedure');
1595 END IF;
1596
1597 -- get the error message count till this point
1598 l_msg_count := FND_MSG_PUB.count_msg;
1599
1600 -- check for the entitlement id
1601 OPEN warranty_entl_csr(p_x_warranty_entl_rec.warranty_entitlement_id);
1602 FETCH warranty_entl_csr INTO l_warranty_entl_rec;
1603 IF (warranty_entl_csr%NOTFOUND) THEN
1604 -- invalid entitlement id
1605 IF (l_log_statement >= l_log_current_level) THEN
1606 FND_LOG.string(l_log_statement, l_full_name,
1607 'invalid entitlement id for approve '||p_x_warranty_entl_rec.warranty_entitlement_id);
1608 END IF;
1609 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_WARRANTY_ENTL_ID_INVLD'); -- Warranty entitlement id ENTL_ID is invalid.
1610 FND_MESSAGE.Set_Token('ENTL_ID', p_x_warranty_entl_rec.warranty_entitlement_id);
1611 FND_MSG_PUB.ADD;
1612 END IF;
1613 CLOSE warranty_entl_csr;
1614
1615 -- check for the user
1616 IF (NVL(p_user_role, 'X') <> G_USER_PLANNER) THEN
1617 -- invalid user
1618 IF (l_log_statement >= l_log_current_level) THEN
1619 FND_LOG.string(l_log_statement, l_full_name,
1620 'invalid user for approve '||p_user_role);
1621 END IF;
1622 -- Warranty entitlement approval is allowed only to the administrator.
1623 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_WARRANTY_APPR_USER_INVLD');
1624 FND_MSG_PUB.ADD;
1625 END IF;
1626
1627 -- check for the approval action
1628 IF (NVL(p_appr_action, 'X') NOT IN (G_APPR_ACCEPT, G_APPR_REJECT)) THEN
1629 -- invalid approval action
1630 IF (l_log_statement >= l_log_current_level) THEN
1631 FND_LOG.string(l_log_statement, l_full_name,
1632 'invalid approval action '||p_appr_action);
1633 END IF;
1634 -- Warranty entitlement approval action can only be Accept or Reject.
1635 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_WARRANTY_APPR_ACTION_INVLD');
1636 FND_MSG_PUB.ADD;
1637 END IF;
1638
1639 -- check for the entitlement status
1640 IF (NVL(p_x_warranty_entl_rec.entitlement_status_code, 'X') <> 'APPROVAL_PENDING') THEN
1641 -- invalid entitlement status
1642 IF (l_log_statement >= l_log_current_level) THEN
1643 FND_LOG.string(l_log_statement, l_full_name,
1644 'invalid entitlement status for approve '||p_x_warranty_entl_rec.entitlement_status_code);
1645 END IF;
1646 -- For approval operation, the warranty entitlement status can only be Approval Pending.
1647 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_WARRANTY_APPR_STS_INVLD');
1648 FND_MSG_PUB.ADD;
1649 END IF;
1650
1651 -- run all the status transition checks
1652 -- ************************************
1653 -- the correct way to perform the following two actions is by clicking Not Applicable button
1654 -- 1) Accpet to new NULL contract
1655 -- 2) Reject to old NULL contract
1656 IF ((NVL(p_appr_action, 'X') = G_APPR_ACCEPT AND p_x_warranty_entl_rec.warranty_contract_id IS NULL) OR
1657 (NVL(p_appr_action, 'X') = G_APPR_REJECT AND l_warranty_entl_rec.old_warranty_contract_id IS NULL)) THEN
1658 -- use Not Applicable button instead
1659 IF (l_log_statement >= l_log_current_level) THEN
1660 FND_LOG.string(l_log_statement, l_full_name,
1661 'Not Applicable button should be used instead');
1662 END IF;
1663 -- For dis-associating the warranty entitlement from a contract, use the Not Applicable action.
1664 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_WARRANTY_APPR_USE_NA');
1665 FND_MSG_PUB.ADD;
1666 END IF;
1667
1668 -- validate the contract to be updated (only if there weren't any errors till now)
1669 -- 1) for Accept, validate the new contract
1670 -- 2) for Reject, validate the old contract
1671 -- NOTE: point 2 above is not needed, but retaining it for code consistency
1672 IF (l_msg_count < FND_MSG_PUB.count_msg) THEN
1673 IF (l_log_statement >= l_log_current_level) THEN
1674 FND_LOG.string(l_log_statement, l_full_name, 'approval errored out, no need to validate contract id');
1675 END IF;
1676 RETURN;
1677 END IF;
1678 IF (p_appr_action = G_APPR_ACCEPT) THEN
1679 l_contract_id := p_x_warranty_entl_rec.warranty_contract_id;
1680 ELSIF (p_appr_action = G_APPR_REJECT) THEN
1681 l_contract_id := l_warranty_entl_rec.old_warranty_contract_id;
1682 END IF;
1683 OPEN chk_war_cont_id_csr (l_contract_id);
1684 FETCH chk_war_cont_id_csr INTO l_dummy;
1685 IF (chk_war_cont_id_csr%NOTFOUND) THEN
1686 IF (l_log_statement >= l_log_current_level) THEN
1687 FND_LOG.string(l_log_statement, l_full_name,
1688 'invalid contract id '||l_contract_id);
1689 END IF;
1690 -- Warranty contract id CONT_ID is invalid.
1691 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_WARRANTY_CONT_ID_INVLD');
1692 FND_MESSAGE.Set_Token('CONT_ID', l_contract_id);
1693 FND_MSG_PUB.ADD;
1694 END IF;
1695 CLOSE chk_war_cont_id_csr;
1696 -- ************************************
1697
1698 -- if any errors occured, then don't proceed any further
1699 IF (l_msg_count < FND_MSG_PUB.count_msg) THEN
1700 IF (l_log_statement >= l_log_current_level) THEN
1701 FND_LOG.string(l_log_statement, l_full_name, 'approval status transition errored out');
1702 END IF;
1703 RETURN;
1704 END IF;
1705
1706 IF (l_log_statement >= l_log_current_level) THEN
1707 FND_LOG.string(l_log_statement, l_full_name, 'Before approval update');
1708 END IF;
1709
1710 -- update the warranty contract id, old contract id and the status
1711 UPDATE AHL_WARRANTY_ENTITLEMENTS SET
1712 warranty_contract_id = l_contract_id,
1713 old_warranty_contract_id = l_contract_id,
1714 entitlement_status_code = l_entl_status
1715 WHERE warranty_entitlement_id = p_x_warranty_entl_rec.warranty_entitlement_id;
1716
1717 IF (l_log_statement >= l_log_current_level) THEN
1718 FND_LOG.string(l_log_statement, l_full_name, 'After approval update');
1719 END IF;
1720
1721 IF (l_log_procedure >= l_log_current_level) THEN
1722 FND_LOG.string(l_log_procedure, l_full_name || '.end', 'Exiting Procedure');
1723 END IF;
1724 END Approve_Warranty_Entitlement;
1725 ------------------------------------------------------------------------------------
1726
1727 -- Procedure to validate the Warranty Entitlement record
1728 PROCEDURE Validate_Warranty_Entitlement (
1729 p_user_role IN VARCHAR2,
1730 p_warranty_entl_rec IN Warranty_Entl_Rec_Type
1731 ) IS
1732
1733 CURSOR chk_war_cont_id_csr (c_contract_id NUMBER) IS
1734 SELECT 'X'
1735 FROM AHL_WARRANTY_CONTRACTS_B
1736 WHERE warranty_contract_id = c_contract_id
1737 AND contract_status_code = 'ACTIVE';
1738
1739 CURSOR chk_entl_sts_code_csr (c_entl_sts_code VARCHAR2) IS
1740 SELECT 'X'
1741 FROM FND_LOOKUPS
1742 WHERE lookup_code = NVL(c_entl_sts_code, 'X')
1743 AND lookup_type = 'AHL_WARRANTY_ENTLMNT_STATUS'
1744 AND NVL(end_date_active, SYSDATE + 1) > SYSDATE;
1745
1746 CURSOR chk_claim_id_csr (c_claim_id NUMBER) IS
1747 SELECT 'X'
1748 FROM AHL_WARRANTY_CLAIMS_B
1749 WHERE warranty_claim_id = c_claim_id
1750 AND claim_status_code <> 'CANCELLED';
1751
1752 CURSOR chk_incident_id_csr (c_incident_id NUMBER) IS
1753 SELECT 'X'
1754 FROM CS_INCIDENTS_ALL_B
1755 WHERE incident_id = c_incident_id
1756 AND incident_status_id <> 2; -- Closed status
1757
1758 CURSOR chk_visit_tsk_id_csr (c_task_id NUMBER) IS
1759 SELECT 'X'
1760 FROM AHL_VISIT_TASKS_B
1761 WHERE visit_task_id = c_task_id
1762 AND status_code NOT IN ('CANCELLED', 'DELETED');
1763
1764 CURSOR chk_workorder_id_csr (c_wo_id NUMBER) IS
1765 SELECT 'X'
1766 FROM AHL_WORKORDERS
1767 WHERE workorder_id = c_wo_id;
1768
1769 CURSOR chk_osp_line_id_csr (c_line_id NUMBER) IS
1770 SELECT 'X'
1771 FROM AHL_OSP_ORDER_LINES
1772 WHERE osp_order_line_id = c_line_id;
1773
1774 --
1775 l_api_name CONSTANT VARCHAR2(30) := 'Validate_Warranty_Entitlement';
1776 l_full_name CONSTANT VARCHAR2(100) := 'ahl.plsql.'||G_PKG_NAME||'.'||l_api_name;
1777
1778 l_dummy VARCHAR2(1);
1779 --
1780
1781 BEGIN
1782 IF (l_log_procedure >= l_log_current_level) THEN
1783 FND_LOG.string(l_log_procedure, l_full_name || '.begin', 'Entering Procedure');
1784 END IF;
1785
1786 -- Check: Non-planner user can create or update entitlement only in Approval Pending status
1787 IF (NVL(p_user_role, 'X') = G_USER_NONPLANNER AND
1788 NVL(p_warranty_entl_rec.entitlement_status_code, 'X') <> 'APPROVAL_PENDING') THEN
1789 IF (l_log_statement >= l_log_current_level) THEN
1790 FND_LOG.string(l_log_statement, l_full_name,
1791 'non-planner with incorrect status '||p_warranty_entl_rec.entitlement_status_code);
1792 END IF;
1793 -- Non-planner or non-administrator can create or update warranty entitlement only in Approval Pending status.
1794 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_WARRANTY_NP_STS_INVLD');
1795 FND_MSG_PUB.ADD;
1796 END IF;
1797
1798 -- Check: Not Applicable or Review status is allowed only for NULL contract id
1799 IF (NVL(p_warranty_entl_rec.entitlement_status_code, 'X') IN ('NOT_APPLICABLE', 'REVIEW') AND
1800 p_warranty_entl_rec.warranty_contract_id IS NOT NULL) THEN
1801 IF (l_log_statement >= l_log_current_level) THEN
1802 FND_LOG.string(l_log_statement, l_full_name,
1803 'Not Applicable or Review status is allowed only for NULL contract id');
1804 END IF;
1805 -- Warranty entitlement can have status Not Applicable or Review only if it has no contract associated to it.
1806 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_WARRANTY_NAR_STS_INVLD');
1807 FND_MSG_PUB.ADD;
1808 END IF;
1809
1810 -- Check: Approved status is allowed only for non-NULL contract id
1811 IF (NVL(p_warranty_entl_rec.entitlement_status_code, 'X') = 'APPROVED' AND
1812 p_warranty_entl_rec.warranty_contract_id IS NULL) THEN
1813 IF (l_log_statement >= l_log_current_level) THEN
1814 FND_LOG.string(l_log_statement, l_full_name,
1815 'Approved status is allowed only for non-NULL contract id');
1816 END IF;
1817 -- Warranty entitlement can have status Approved only if it has a valid contract associated to it.
1818 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_WARRANTY_APRD_STS_INVLD');
1819 FND_MSG_PUB.ADD;
1820 END IF;
1821
1822 -- Check: Ids, if present, should be valid
1823 -- ***************************************
1824 -- Warranty contract id
1825 IF (p_warranty_entl_rec.warranty_contract_id IS NOT NULL) THEN
1826 OPEN chk_war_cont_id_csr (p_warranty_entl_rec.warranty_contract_id);
1827 FETCH chk_war_cont_id_csr INTO l_dummy;
1828 IF (chk_war_cont_id_csr%NOTFOUND) THEN
1829 IF (l_log_statement >= l_log_current_level) THEN
1830 FND_LOG.string(l_log_statement, l_full_name,
1831 'invalid contract id '||p_warranty_entl_rec.warranty_contract_id);
1832 END IF;
1833 -- Warranty contract id CONT_ID is invalid.
1834 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_WARRANTY_CONT_ID_INVLD');
1835 FND_MESSAGE.Set_Token('CONT_ID', p_warranty_entl_rec.warranty_contract_id);
1836 FND_MSG_PUB.ADD;
1837 END IF;
1838 CLOSE chk_war_cont_id_csr;
1839 END IF;
1840
1841 -- Entitlement status code
1842 IF (p_warranty_entl_rec.entitlement_status_code IS NOT NULL) THEN
1843 OPEN chk_entl_sts_code_csr (p_warranty_entl_rec.entitlement_status_code);
1844 FETCH chk_entl_sts_code_csr INTO l_dummy;
1845 IF (chk_entl_sts_code_csr%NOTFOUND) THEN
1846 IF (l_log_statement >= l_log_current_level) THEN
1847 FND_LOG.string(l_log_statement, l_full_name,
1848 'invalid entitlement status code '||p_warranty_entl_rec.entitlement_status_code);
1849 END IF;
1850 -- Warranty entitlement status code ENTL_STS is invalid.
1851 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_WARRANTY_ENTL_STS_INVLD');
1852 FND_MESSAGE.Set_Token('ENTL_STS', p_warranty_entl_rec.entitlement_status_code);
1853 FND_MSG_PUB.ADD;
1854 END IF;
1855 CLOSE chk_entl_sts_code_csr;
1856 END IF;
1857
1858 -- Claim id
1859 IF (p_warranty_entl_rec.warranty_claim_id IS NOT NULL) THEN
1860 OPEN chk_claim_id_csr (p_warranty_entl_rec.warranty_claim_id);
1861 FETCH chk_claim_id_csr INTO l_dummy;
1862 IF (chk_claim_id_csr%NOTFOUND) THEN
1863 IF (l_log_statement >= l_log_current_level) THEN
1864 FND_LOG.string(l_log_statement, l_full_name,
1865 'invalid claim id '||p_warranty_entl_rec.warranty_claim_id);
1866 END IF;
1867 -- Warranty entitlement claim id CLAIM_ID is invalid.
1868 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_WARRANTY_CLAIM_ID_INVLD');
1869 FND_MESSAGE.Set_Token('CLAIM_ID', p_warranty_entl_rec.warranty_claim_id);
1870 FND_MSG_PUB.ADD;
1871 END IF;
1872 CLOSE chk_claim_id_csr;
1873 END IF;
1874
1875 -- SR/Incident id
1876 IF (p_warranty_entl_rec.sr_incident_id IS NOT NULL) THEN
1877 OPEN chk_incident_id_csr (p_warranty_entl_rec.sr_incident_id);
1878 FETCH chk_incident_id_csr INTO l_dummy;
1879 IF (chk_incident_id_csr%NOTFOUND) THEN
1880 IF (l_log_statement >= l_log_current_level) THEN
1881 FND_LOG.string(l_log_statement, l_full_name,
1882 'invalid SR id '||p_warranty_entl_rec.sr_incident_id);
1883 END IF;
1884 -- The incident id 'INCIDENT_ID' is not valid.
1885 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_UMP_INVALID_INCIDENT_ID');
1886 FND_MESSAGE.Set_Token('INCIDENT_ID', p_warranty_entl_rec.sr_incident_id);
1887 FND_MSG_PUB.ADD;
1888 END IF;
1889 CLOSE chk_incident_id_csr;
1890 END IF;
1891
1892 -- Visit task id
1893 IF (p_warranty_entl_rec.visit_task_id IS NOT NULL) THEN
1894 OPEN chk_visit_tsk_id_csr (p_warranty_entl_rec.visit_task_id);
1895 FETCH chk_visit_tsk_id_csr INTO l_dummy;
1896 IF (chk_visit_tsk_id_csr%NOTFOUND) THEN
1897 IF (l_log_statement >= l_log_current_level) THEN
1898 FND_LOG.string(l_log_statement, l_full_name,
1899 'invalid visit task id '||p_warranty_entl_rec.visit_task_id);
1900 END IF;
1901 -- Visit task TASK_ID is invalid.
1902 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_LTP_TASK_ID_INVALID');
1903 FND_MESSAGE.Set_Token('TASK_ID', p_warranty_entl_rec.visit_task_id);
1904 FND_MSG_PUB.ADD;
1905 END IF;
1906 CLOSE chk_visit_tsk_id_csr;
1907 END IF;
1908
1909 -- Workorder id
1910 IF (p_warranty_entl_rec.workorder_id IS NOT NULL) THEN
1911 OPEN chk_workorder_id_csr (p_warranty_entl_rec.workorder_id);
1912 FETCH chk_workorder_id_csr INTO l_dummy;
1913 IF (chk_workorder_id_csr%NOTFOUND) THEN
1914 IF (l_log_statement >= l_log_current_level) THEN
1915 FND_LOG.string(l_log_statement, l_full_name,
1916 'invalid workorder id '||p_warranty_entl_rec.workorder_id);
1917 END IF;
1918 -- Workorder id FIELD1 invalid.
1919 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_PRD_WORKORDER_ID_INVALID');
1920 FND_MESSAGE.Set_Token('FIELD1', p_warranty_entl_rec.workorder_id);
1921 FND_MSG_PUB.ADD;
1922 END IF;
1923 CLOSE chk_workorder_id_csr;
1924 END IF;
1925
1926 -- OSP line id
1927 IF (p_warranty_entl_rec.osp_order_line_id IS NOT NULL) THEN
1928 OPEN chk_osp_line_id_csr (p_warranty_entl_rec.osp_order_line_id);
1929 FETCH chk_osp_line_id_csr INTO l_dummy;
1930 IF (chk_osp_line_id_csr%NOTFOUND) THEN
1931 IF (l_log_statement >= l_log_current_level) THEN
1932 FND_LOG.string(l_log_statement, l_full_name,
1933 'invalid OSP order line id '||p_warranty_entl_rec.osp_order_line_id);
1934 END IF;
1935 -- OSP order line id OLINE_ID is invalid.
1936 FND_MESSAGE.Set_Name(G_APP_NAME, 'AHL_WARRANTY_OLINE_ID_INVLD');
1937 FND_MESSAGE.Set_Token('OLINE_ID', p_warranty_entl_rec.osp_order_line_id);
1938 FND_MSG_PUB.ADD;
1939 END IF;
1940 CLOSE chk_osp_line_id_csr;
1941 END IF;
1942 -- ***************************************
1943
1944 IF (l_log_procedure >= l_log_current_level) THEN
1945 FND_LOG.string(l_log_procedure, l_full_name || '.end', 'Exiting Procedure');
1946 END IF;
1947 END Validate_Warranty_Entitlement;
1948 ------------------------------------------------------------------------------------
1949
1950 END AHL_WARRANTY_ENTL_PVT;