10: -- Function :
11: -- Pre-reqs : None.
12: -- Parameters :
13: -- IN p_api_version IN NUMBER Required
14: -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API.G_FALSE
15: -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
16: -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
17: -- parameter1
18: -- parameter2
11: -- Pre-reqs : None.
12: -- Parameters :
13: -- IN p_api_version IN NUMBER Required
14: -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API.G_FALSE
15: -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
16: -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
17: -- parameter1
18: -- parameter2
19: -- .
12: -- Parameters :
13: -- IN p_api_version IN NUMBER Required
14: -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API.G_FALSE
15: -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
16: -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
17: -- parameter1
18: -- parameter2
19: -- .
20: -- .
41:
42: PROCEDURE create_maint_attributes
43: (
44: p_api_version IN NUMBER
45: ,p_init_msg_list IN VARCHAR2 := fnd_api.g_false
46: ,p_commit IN VARCHAR2 := fnd_api.g_false
47: ,p_validation_level IN NUMBER := fnd_api.g_valid_level_full
48: ,p_instance_id IN NUMBER
49: ,p_owning_department_id IN NUMBER
42: PROCEDURE create_maint_attributes
43: (
44: p_api_version IN NUMBER
45: ,p_init_msg_list IN VARCHAR2 := fnd_api.g_false
46: ,p_commit IN VARCHAR2 := fnd_api.g_false
47: ,p_validation_level IN NUMBER := fnd_api.g_valid_level_full
48: ,p_instance_id IN NUMBER
49: ,p_owning_department_id IN NUMBER
50: ,p_accounting_class_code IN VARCHAR2
43: (
44: p_api_version IN NUMBER
45: ,p_init_msg_list IN VARCHAR2 := fnd_api.g_false
46: ,p_commit IN VARCHAR2 := fnd_api.g_false
47: ,p_validation_level IN NUMBER := fnd_api.g_valid_level_full
48: ,p_instance_id IN NUMBER
49: ,p_owning_department_id IN NUMBER
50: ,p_accounting_class_code IN VARCHAR2
51: ,p_area_id IN NUMBER
72: -- Standard Start of API savepoint
73: SAVEPOINT eam_maint_attributes_pub;
74:
75: -- Standard call to check for call compatibility.
76: IF NOT fnd_api.compatible_api_call(
77: l_api_version
78: ,p_api_version
79: ,l_api_name
80: ,g_pkg_name) THEN
77: l_api_version
78: ,p_api_version
79: ,l_api_name
80: ,g_pkg_name) THEN
81: RAISE fnd_api.g_exc_unexpected_error;
82: END IF;
83:
84: -- Initialize message list if p_init_msg_list is set to TRUE.
85: IF fnd_api.to_boolean(p_init_msg_list) THEN
81: RAISE fnd_api.g_exc_unexpected_error;
82: END IF;
83:
84: -- Initialize message list if p_init_msg_list is set to TRUE.
85: IF fnd_api.to_boolean(p_init_msg_list) THEN
86: fnd_msg_pub.initialize;
87: END IF;
88:
89: -- Initialize API return status to success
86: fnd_msg_pub.initialize;
87: END IF;
88:
89: -- Initialize API return status to success
90: x_return_status := fnd_api.g_ret_sts_success;
91:
92: -- API body
93:
94: -- Call validate procedure for validating the maint attributes
106: ,x_msg_count => x_msg_count
107: ,x_msg_data => x_msg_data
108: );
109:
110: IF x_return_status <> fnd_api.g_ret_sts_success THEN
111: RAISE fnd_api.g_exc_error;
112: END IF;
113:
114: eam_org_maint_defaults_pvt.insert_row
107: ,x_msg_data => x_msg_data
108: );
109:
110: IF x_return_status <> fnd_api.g_ret_sts_success THEN
111: RAISE fnd_api.g_exc_error;
112: END IF;
113:
114: eam_org_maint_defaults_pvt.insert_row
115: (
124: ,x_msg_count => x_msg_count
125: ,x_msg_data => x_msg_data
126: );
127:
128: IF x_return_status <> fnd_api.g_ret_sts_success THEN
129: RAISE fnd_api.g_exc_error;
130: END IF;
131:
132: -- Find serial number and inventory_item_id to be passed to the geneloagy API
125: ,x_msg_data => x_msg_data
126: );
127:
128: IF x_return_status <> fnd_api.g_ret_sts_success THEN
129: RAISE fnd_api.g_exc_error;
130: END IF;
131:
132: -- Find serial number and inventory_item_id to be passed to the geneloagy API
133: IF p_parent_instance_id IS NOT NULL THEN
141: EXCEPTION
142: WHEN NO_DATA_FOUND THEN
143: fnd_message.set_name('EAM', 'EAM_INVALID_INSTANCE_ID');
144: fnd_msg_pub.add;
145: RAISE fnd_api.g_exc_error;
146: END;
147: BEGIN
148: SELECT cii.serial_number, cii.inventory_item_id, cii.last_vld_organization_id
149: INTO l_sn_2, l_inv_id_2, l_org_id_2
155: EXCEPTION
156: WHEN NO_DATA_FOUND THEN
157: fnd_message.set_name('EAM', 'EAM_INVLD_PARENT_INST_ID');
158: fnd_msg_pub.add;
159: RAISE fnd_api.g_exc_error;
160: END;
161:
162: wip_eam_genealogy_pvt.create_eam_genealogy
163: (
167: p_inventory_item_id => l_inv_id_1,
168: p_parent_serial_number => l_sn_2,
169: p_parent_inventory_item_id => l_inv_id_2,
170: p_parent_organization_id => l_org_id_2,
171: p_from_eam => FND_API.G_TRUE,
172: x_return_status => x_return_status,
173: x_msg_count => x_msg_count,
174: x_msg_data => x_msg_data
175: );
173: x_msg_count => x_msg_count,
174: x_msg_data => x_msg_data
175: );
176:
177: IF x_return_status <> fnd_api.g_ret_sts_success THEN
178: RAISE fnd_api.g_exc_error;
179: END IF;
180:
181: END IF;
174: x_msg_data => x_msg_data
175: );
176:
177: IF x_return_status <> fnd_api.g_ret_sts_success THEN
178: RAISE fnd_api.g_exc_error;
179: END IF;
180:
181: END IF;
182:
182:
183: -- End of API body.
184:
185: -- Standard check of p_commit.
186: IF fnd_api.to_boolean(p_commit) THEN
187: COMMIT WORK;
188: END IF;
189:
190: -- Standard call to get message count and if count is 1, get message info.
190: -- Standard call to get message count and if count is 1, get message info.
191: fnd_msg_pub.count_and_get(p_count => x_msg_count
192: ,p_data => x_msg_data);
193: EXCEPTION
194: WHEN fnd_api.g_exc_error THEN
195: ROLLBACK TO eam_maint_attributes_pub;
196: x_return_status := fnd_api.g_ret_sts_error;
197: fnd_msg_pub.count_and_get(p_count => x_msg_count
198: ,p_data => x_msg_data);
192: ,p_data => x_msg_data);
193: EXCEPTION
194: WHEN fnd_api.g_exc_error THEN
195: ROLLBACK TO eam_maint_attributes_pub;
196: x_return_status := fnd_api.g_ret_sts_error;
197: fnd_msg_pub.count_and_get(p_count => x_msg_count
198: ,p_data => x_msg_data);
199: WHEN fnd_api.g_exc_unexpected_error THEN
200: ROLLBACK TO eam_maint_attributes_pub;
195: ROLLBACK TO eam_maint_attributes_pub;
196: x_return_status := fnd_api.g_ret_sts_error;
197: fnd_msg_pub.count_and_get(p_count => x_msg_count
198: ,p_data => x_msg_data);
199: WHEN fnd_api.g_exc_unexpected_error THEN
200: ROLLBACK TO eam_maint_attributes_pub;
201: x_return_status := fnd_api.g_ret_sts_unexp_error;
202: fnd_msg_pub.count_and_get(p_count => x_msg_count
203: ,p_data => x_msg_data);
197: fnd_msg_pub.count_and_get(p_count => x_msg_count
198: ,p_data => x_msg_data);
199: WHEN fnd_api.g_exc_unexpected_error THEN
200: ROLLBACK TO eam_maint_attributes_pub;
201: x_return_status := fnd_api.g_ret_sts_unexp_error;
202: fnd_msg_pub.count_and_get(p_count => x_msg_count
203: ,p_data => x_msg_data);
204: WHEN OTHERS THEN
205: ROLLBACK TO eam_maint_attributes_pub;
202: fnd_msg_pub.count_and_get(p_count => x_msg_count
203: ,p_data => x_msg_data);
204: WHEN OTHERS THEN
205: ROLLBACK TO eam_maint_attributes_pub;
206: x_return_status := fnd_api.g_ret_sts_unexp_error;
207: IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error) THEN
208: fnd_msg_pub.add_exc_msg(g_pkg_name, l_api_name);
209: END IF;
210: fnd_msg_pub.count_and_get(p_count => x_msg_count
214:
215: PROCEDURE update_maint_attributes
216: (
217: p_api_version IN NUMBER
218: ,p_init_msg_list IN VARCHAR2 := fnd_api.g_false
219: ,p_commit IN VARCHAR2 := fnd_api.g_false
220: ,p_validation_level IN NUMBER := fnd_api.g_valid_level_full
221: ,p_instance_id IN NUMBER
222: ,p_owning_department_id IN NUMBER
215: PROCEDURE update_maint_attributes
216: (
217: p_api_version IN NUMBER
218: ,p_init_msg_list IN VARCHAR2 := fnd_api.g_false
219: ,p_commit IN VARCHAR2 := fnd_api.g_false
220: ,p_validation_level IN NUMBER := fnd_api.g_valid_level_full
221: ,p_instance_id IN NUMBER
222: ,p_owning_department_id IN NUMBER
223: ,p_accounting_class_code IN VARCHAR2
216: (
217: p_api_version IN NUMBER
218: ,p_init_msg_list IN VARCHAR2 := fnd_api.g_false
219: ,p_commit IN VARCHAR2 := fnd_api.g_false
220: ,p_validation_level IN NUMBER := fnd_api.g_valid_level_full
221: ,p_instance_id IN NUMBER
222: ,p_owning_department_id IN NUMBER
223: ,p_accounting_class_code IN VARCHAR2
224: ,p_area_id IN NUMBER
244: -- Standard Start of API savepoint
245: SAVEPOINT eam_maint_attributes_pub;
246:
247: -- Standard call to check for call compatibility.
248: IF NOT fnd_api.compatible_api_call(
249: l_api_version
250: ,p_api_version
251: ,l_api_name
252: ,g_pkg_name) THEN
249: l_api_version
250: ,p_api_version
251: ,l_api_name
252: ,g_pkg_name) THEN
253: RAISE fnd_api.g_exc_unexpected_error;
254: END IF;
255:
256: -- Initialize message list if p_init_msg_list is set to TRUE.
257: IF fnd_api.to_boolean(p_init_msg_list) THEN
253: RAISE fnd_api.g_exc_unexpected_error;
254: END IF;
255:
256: -- Initialize message list if p_init_msg_list is set to TRUE.
257: IF fnd_api.to_boolean(p_init_msg_list) THEN
258: fnd_msg_pub.initialize;
259: END IF;
260:
261: -- Initialize API return status to success
258: fnd_msg_pub.initialize;
259: END IF;
260:
261: -- Initialize API return status to success
262: x_return_status := fnd_api.g_ret_sts_success;
263:
264: -- API body
265:
266: -- Call validate procedure for validating the maint attributes
278: ,x_msg_count => x_msg_count
279: ,x_msg_data => x_msg_data
280: );
281:
282: IF x_return_status <> fnd_api.g_ret_sts_success THEN
283: RAISE fnd_api.g_exc_error;
284: END IF;
285:
286: eam_org_maint_defaults_pvt.update_insert_row
279: ,x_msg_data => x_msg_data
280: );
281:
282: IF x_return_status <> fnd_api.g_ret_sts_success THEN
283: RAISE fnd_api.g_exc_error;
284: END IF;
285:
286: eam_org_maint_defaults_pvt.update_insert_row
287: (
296: ,x_msg_count => x_msg_count
297: ,x_msg_data => x_msg_data
298: );
299:
300: IF x_return_status <> fnd_api.g_ret_sts_success THEN
301: RAISE fnd_api.g_exc_error;
302: END IF;
303:
304: -- End of API body.
297: ,x_msg_data => x_msg_data
298: );
299:
300: IF x_return_status <> fnd_api.g_ret_sts_success THEN
301: RAISE fnd_api.g_exc_error;
302: END IF;
303:
304: -- End of API body.
305:
303:
304: -- End of API body.
305:
306: -- Standard check of p_commit.
307: IF fnd_api.to_boolean(p_commit) THEN
308: COMMIT WORK;
309: END IF;
310:
311: -- Standard call to get message count and if count is 1, get message info.
311: -- Standard call to get message count and if count is 1, get message info.
312: fnd_msg_pub.count_and_get(p_count => x_msg_count
313: ,p_data => x_msg_data);
314: EXCEPTION
315: WHEN fnd_api.g_exc_error THEN
316: ROLLBACK TO eam_maint_attributes_pub;
317: x_return_status := fnd_api.g_ret_sts_error;
318: fnd_msg_pub.count_and_get(p_count => x_msg_count
319: ,p_data => x_msg_data);
313: ,p_data => x_msg_data);
314: EXCEPTION
315: WHEN fnd_api.g_exc_error THEN
316: ROLLBACK TO eam_maint_attributes_pub;
317: x_return_status := fnd_api.g_ret_sts_error;
318: fnd_msg_pub.count_and_get(p_count => x_msg_count
319: ,p_data => x_msg_data);
320: WHEN fnd_api.g_exc_unexpected_error THEN
321: ROLLBACK TO eam_maint_attributes_pub;
316: ROLLBACK TO eam_maint_attributes_pub;
317: x_return_status := fnd_api.g_ret_sts_error;
318: fnd_msg_pub.count_and_get(p_count => x_msg_count
319: ,p_data => x_msg_data);
320: WHEN fnd_api.g_exc_unexpected_error THEN
321: ROLLBACK TO eam_maint_attributes_pub;
322: x_return_status := fnd_api.g_ret_sts_unexp_error;
323: fnd_msg_pub.count_and_get(p_count => x_msg_count
324: ,p_data => x_msg_data);
318: fnd_msg_pub.count_and_get(p_count => x_msg_count
319: ,p_data => x_msg_data);
320: WHEN fnd_api.g_exc_unexpected_error THEN
321: ROLLBACK TO eam_maint_attributes_pub;
322: x_return_status := fnd_api.g_ret_sts_unexp_error;
323: fnd_msg_pub.count_and_get(p_count => x_msg_count
324: ,p_data => x_msg_data);
325: WHEN OTHERS THEN
326: ROLLBACK TO eam_maint_attributes_pub;
323: fnd_msg_pub.count_and_get(p_count => x_msg_count
324: ,p_data => x_msg_data);
325: WHEN OTHERS THEN
326: ROLLBACK TO eam_maint_attributes_pub;
327: x_return_status := fnd_api.g_ret_sts_unexp_error;
328: IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error) THEN
329: fnd_msg_pub.add_exc_msg(g_pkg_name, l_api_name);
330: END IF;
331: fnd_msg_pub.count_and_get(p_count => x_msg_count
336:
337: PROCEDURE validate_maint_defaults
338: (
339: p_api_version IN NUMBER
340: ,p_init_msg_list IN VARCHAR2 := fnd_api.g_false
341: ,p_commit IN VARCHAR2 := fnd_api.g_false
342: ,p_validation_level IN NUMBER := fnd_api.g_valid_level_full
343: ,p_instance_id IN NUMBER
344: ,p_owning_department_id IN NUMBER := NULL
337: PROCEDURE validate_maint_defaults
338: (
339: p_api_version IN NUMBER
340: ,p_init_msg_list IN VARCHAR2 := fnd_api.g_false
341: ,p_commit IN VARCHAR2 := fnd_api.g_false
342: ,p_validation_level IN NUMBER := fnd_api.g_valid_level_full
343: ,p_instance_id IN NUMBER
344: ,p_owning_department_id IN NUMBER := NULL
345: ,p_accounting_class_code IN VARCHAR2 := NULL
338: (
339: p_api_version IN NUMBER
340: ,p_init_msg_list IN VARCHAR2 := fnd_api.g_false
341: ,p_commit IN VARCHAR2 := fnd_api.g_false
342: ,p_validation_level IN NUMBER := fnd_api.g_valid_level_full
343: ,p_instance_id IN NUMBER
344: ,p_owning_department_id IN NUMBER := NULL
345: ,p_accounting_class_code IN VARCHAR2 := NULL
346: ,p_area_id IN NUMBER := NULL
360: -- Standard Start of API savepoint
361: SAVEPOINT eam_maint_attributes_pub;
362:
363: -- Standard call to check for call compatibility.
364: IF NOT fnd_api.compatible_api_call(
365: l_api_version
366: ,p_api_version
367: ,l_api_name
368: ,g_pkg_name) THEN
365: l_api_version
366: ,p_api_version
367: ,l_api_name
368: ,g_pkg_name) THEN
369: RAISE fnd_api.g_exc_unexpected_error;
370: END IF;
371:
372: -- Initialize message list if p_init_msg_list is set to TRUE.
373: IF fnd_api.to_boolean(p_init_msg_list) THEN
369: RAISE fnd_api.g_exc_unexpected_error;
370: END IF;
371:
372: -- Initialize message list if p_init_msg_list is set to TRUE.
373: IF fnd_api.to_boolean(p_init_msg_list) THEN
374: fnd_msg_pub.initialize;
375: END IF;
376:
377: -- Initialize API return status to success
374: fnd_msg_pub.initialize;
375: END IF;
376:
377: -- Initialize API return status to success
378: x_return_status := fnd_api.g_ret_sts_success;
379:
380: -- API body
381:
382: -- Validate instance id
386: AND msi.serial_number_control_code <> 1;
387: IF l_count = 0 THEN
388: fnd_message.set_name('EAM', 'EAM_INVALID_INSTANCE_ID');
389: fnd_msg_pub.add;
390: RAISE fnd_api.g_exc_error;
391: END IF;
392:
393: -- Select the maintenance organization id
394: SELECT mp.maint_organization_id INTO x_org_id FROM csi_item_instances cii, mtl_parameters mp
396:
397: IF x_org_id is NULL THEN
398: fnd_message.set_name('EAM', 'EAM_MAINT_ORG_MISSING');
399: fnd_msg_pub.add;
400: RAISE fnd_api.g_exc_error;
401: END IF;
402:
403: -- Validate dept id
404: IF p_owning_department_id IS NOT NULL THEN
401: END IF;
402:
403: -- Validate dept id
404: IF p_owning_department_id IS NOT NULL THEN
405: IF ( NOT(p_mode = 2 AND p_owning_department_id = fnd_api.g_miss_num)) THEN
406: SELECT count(department_id) INTO l_count FROM bom_departments
407: WHERE department_id = p_owning_department_id AND organization_id = x_org_id
408: AND nvl(disable_date, sysdate+1) >= sysdate;
409:
409:
410: IF l_count = 0 THEN
411: fnd_message.set_name('EAM', 'EAM_ABO_INVALID_OWN_DEPT_ID');
412: fnd_msg_pub.add;
413: RAISE fnd_api.g_exc_error;
414: END IF;
415: END IF;
416: END IF;
417:
416: END IF;
417:
418: -- Validate WIP Accounting class
419: IF p_accounting_class_code IS NOT NULL THEN
420: IF ( NOT(p_mode = 2 AND p_accounting_class_code = fnd_api.g_miss_char)) THEN
421: SELECT count(*) INTO l_count FROM wip_accounting_classes
422: WHERE class_code = p_accounting_class_code AND class_type = 6
423: AND organization_id = x_org_id;
424:
424:
425: IF l_count = 0 THEN
426: fnd_message.set_name('EAM', 'EAM_ABO_INVALID_CLASS_CODE');
427: fnd_msg_pub.add;
428: RAISE fnd_api.g_exc_error;
429: END IF;
430: END IF;
431: END IF;
432:
431: END IF;
432:
433: -- Validate Area
434: IF p_area_id IS NOT NULL THEN
435: IF ( NOT(p_mode = 2 AND p_area_id = fnd_api.g_miss_num)) THEN
436: SELECT count(*) INTO l_count FROM mtl_eam_locations
437: WHERE location_id = p_area_id AND organization_id = x_org_id
438: AND sysdate BETWEEN nvl(start_date, sysdate-1) AND nvl(end_date, sysdate+1);
439:
439:
440: IF l_count = 0 THEN
441: fnd_message.set_name('EAM', 'EAM_LOCATION_ID_INVALID');
442: fnd_msg_pub.add;
443: RAISE fnd_api.g_exc_error;
444: END IF;
445: END IF;
446: END IF;
447:
447:
448: -- End of API body.
449:
450: -- Standard check of p_commit.
451: IF fnd_api.to_boolean(p_commit) THEN
452: COMMIT WORK;
453: END IF;
454:
455: -- Standard call to get message count and if count is 1, get message info.
455: -- Standard call to get message count and if count is 1, get message info.
456: fnd_msg_pub.count_and_get(p_count => x_msg_count
457: ,p_data => x_msg_data);
458: EXCEPTION
459: WHEN fnd_api.g_exc_error THEN
460: ROLLBACK TO eam_maint_attributes_pub;
461: x_return_status := fnd_api.g_ret_sts_error;
462: fnd_msg_pub.count_and_get(p_count => x_msg_count
463: ,p_data => x_msg_data);
457: ,p_data => x_msg_data);
458: EXCEPTION
459: WHEN fnd_api.g_exc_error THEN
460: ROLLBACK TO eam_maint_attributes_pub;
461: x_return_status := fnd_api.g_ret_sts_error;
462: fnd_msg_pub.count_and_get(p_count => x_msg_count
463: ,p_data => x_msg_data);
464: WHEN fnd_api.g_exc_unexpected_error THEN
465: ROLLBACK TO eam_maint_attributes_pub;
460: ROLLBACK TO eam_maint_attributes_pub;
461: x_return_status := fnd_api.g_ret_sts_error;
462: fnd_msg_pub.count_and_get(p_count => x_msg_count
463: ,p_data => x_msg_data);
464: WHEN fnd_api.g_exc_unexpected_error THEN
465: ROLLBACK TO eam_maint_attributes_pub;
466: x_return_status := fnd_api.g_ret_sts_unexp_error;
467: fnd_msg_pub.count_and_get(p_count => x_msg_count
468: ,p_data => x_msg_data);
462: fnd_msg_pub.count_and_get(p_count => x_msg_count
463: ,p_data => x_msg_data);
464: WHEN fnd_api.g_exc_unexpected_error THEN
465: ROLLBACK TO eam_maint_attributes_pub;
466: x_return_status := fnd_api.g_ret_sts_unexp_error;
467: fnd_msg_pub.count_and_get(p_count => x_msg_count
468: ,p_data => x_msg_data);
469: WHEN OTHERS THEN
470: ROLLBACK TO eam_maint_attributes_pub;
467: fnd_msg_pub.count_and_get(p_count => x_msg_count
468: ,p_data => x_msg_data);
469: WHEN OTHERS THEN
470: ROLLBACK TO eam_maint_attributes_pub;
471: x_return_status := fnd_api.g_ret_sts_unexp_error;
472: IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error) THEN
473: fnd_msg_pub.add_exc_msg(g_pkg_name, l_api_name);
474: END IF;
475: fnd_msg_pub.count_and_get(p_count => x_msg_count