[Home] [Help]
PACKAGE BODY: APPS.CSI_ITEM_INSTANCE_PUB
Source
1 PACKAGE BODY CSI_ITEM_INSTANCE_PUB AS
2 /* $Header: csipiib.pls 120.18 2007/10/20 00:26:49 fli ship $ */
3
4 -- --------------------------------------------------------
5 -- Define global variables
6 -- --------------------------------------------------------
7
8 G_PKG_NAME CONSTANT VARCHAR2(30):= 'CSI_ITEM_INSTANCE_PUB';
9 G_FILE_NAME CONSTANT VARCHAR2(12) := 'csipiib.pls';
10
11 /*----------------------------------------------------*/
12 /* procedure name: create_item_instance */
13 /* description : procedure used to */
14 /* create item instances */
15 /*----------------------------------------------------*/
16
17 PROCEDURE create_item_instance
18 (
19 p_api_version IN NUMBER
20 ,p_commit IN VARCHAR2
21 ,p_init_msg_list IN VARCHAR2
22 ,p_validation_level IN NUMBER
23 ,p_instance_rec IN OUT NOCOPY csi_datastructures_pub.instance_rec
24 ,p_ext_attrib_values_tbl IN OUT NOCOPY csi_datastructures_pub.extend_attrib_values_tbl
25 ,p_party_tbl IN OUT NOCOPY csi_datastructures_pub.party_tbl
26 ,p_account_tbl IN OUT NOCOPY csi_datastructures_pub.party_account_tbl
27 ,p_pricing_attrib_tbl IN OUT NOCOPY csi_datastructures_pub.pricing_attribs_tbl
28 ,p_org_assignments_tbl IN OUT NOCOPY csi_datastructures_pub.organization_units_tbl
29 ,p_asset_assignment_tbl IN OUT NOCOPY csi_datastructures_pub.instance_asset_tbl
30 ,p_txn_rec IN OUT NOCOPY csi_datastructures_pub.transaction_rec
31 ,x_return_status OUT NOCOPY VARCHAR2
32 ,x_msg_count OUT NOCOPY NUMBER
33 ,x_msg_data OUT NOCOPY VARCHAR2
34 )
35 IS
36 l_api_name CONSTANT VARCHAR2(30) := 'CREATE_ITEM_INSTANCE';
37 l_api_version CONSTANT NUMBER := 1.0;
38 l_debug_level NUMBER;
39 l_flag VARCHAR2(1) := 'N';
40 l_msg_data VARCHAR2(2000);
41 l_msg_index NUMBER;
42 l_msg_count NUMBER;
43 l_transaction_type VARCHAR2(10);
44 l_old_oks_cp_rec oks_ibint_pub.cp_rec_type;
45 l_new_oks_cp_rec oks_ibint_pub.cp_rec_type;
46 l_contracts_status VARCHAR2(3);
47 l_account_id NUMBER;
48 l_internal_party_id NUMBER;
49 l_party_id NUMBER;
50 l_version_label VARCHAR2(30);
51 l_version_label_rec csi_datastructures_pub.version_label_rec;
52 l_item_attribute_tbl csi_item_instance_pvt.item_attribute_tbl;
53 l_location_tbl csi_item_instance_pvt.location_tbl;
54 l_generic_id_tbl csi_item_instance_pvt.generic_id_tbl;
55 l_lookup_tbl csi_item_instance_pvt.lookup_tbl;
56 l_ins_count_rec csi_item_instance_pvt.ins_count_rec;
57 l_asset_lookup_tbl csi_asset_pvt.lookup_tbl;
58 l_asset_count_rec csi_asset_pvt.asset_count_rec;
59 l_asset_id_tbl csi_asset_pvt.asset_id_tbl;
60 l_asset_loc_tbl csi_asset_pvt.asset_loc_tbl;
61 l_party NUMBER;
62 l_contact NUMBER;
63 l_account NUMBER;
64 l_party_tbl csi_datastructures_pub.party_tbl;
65 lc_party_tbl csi_datastructures_pub.party_tbl;
66 l_temp_party_tbl csi_datastructures_pub.party_tbl;
67 l_account_tbl csi_datastructures_pub.party_account_tbl;
68 l_temp_account_tbl csi_datastructures_pub.party_account_tbl;
69 l_count NUMBER;
70 l_t_party_tbl csi_datastructures_pub.party_tbl;
71 -- following were added for att enhancements.
72 l_component_ins_type VARCHAR2(1):=NULL ;
73 l_config_hdr_id NUMBER;
74 l_config_rev_nbr NUMBER;
75 l_config_key csi_utility_grp.config_instance_key;
76 l_config_valid_status VARCHAR2(10);
77 l_return_message VARCHAR2(100);
78 -- Begin Add Code for Siebel Genesis Project
79 l_raise_bes_event VARCHAR2(1) := nvl(fnd_profile.value('CSI_RAISE_BES_CUST_OWNED_INSTANCES'),'N');
80 l_link_to_line_id NUMBER;
81 l_item_type_code VARCHAR2(30);
82 -- End Add Code for Siebel Genesis Project
83 -- end addition
84 CURSOR instance_csr (p_ins_id IN NUMBER) IS
85 SELECT *
86 FROM csi_item_instances
87 WHERE instance_id = p_ins_id;
88 l_instance_csr instance_csr%ROWTYPE;
89
90
91 CURSOR config_ins_key (p_config_hdr_id NUMBER, p_config_rev_nbr NUMBER) is
92 SELECT instance_hdr_id
93 ,config_item_id
94 ,has_failures
95 FROM cz_config_details_v d
96 ,cz_config_hdrs_v h
97 WHERE d.instance_hdr_id = h.config_hdr_id
98 AND d.instance_rev_nbr = h.config_rev_nbr
99 AND d.component_instance_type = 'I'
100 AND d.config_hdr_id = p_config_hdr_id
101 AND d.config_rev_nbr = p_config_rev_nbr;
102
103 CURSOR instance_key (p_config_inst_hdr_id NUMBER, p_config_inst_item_id NUMBER)is
104 SELECT instance_id
105 ,object_version_number
106 ,config_valid_status
107 FROM csi_item_instances
108 WHERE config_inst_hdr_id=p_config_inst_hdr_id
109 AND config_inst_item_id=p_config_inst_item_id;
110
111 CURSOR new_config_ins_key (p_config_ins_hdr_id NUMBER, p_config_ins_rev_nbr NUMBER) is
112 SELECT has_failures
113 ,config_status
114 FROM cz_config_details_v d
115 ,cz_config_hdrs h
116 WHERE d.instance_hdr_id = p_config_ins_hdr_id
117 AND d.instance_rev_nbr = p_config_ins_rev_nbr
118 -- AND d.component_instance_type = 'I'
119 AND d.config_hdr_id = h.config_hdr_id
120 AND d.config_rev_nbr = h.config_rev_nbr;
121
122 CURSOR new_instance_key (p_config_inst_hdr_id NUMBER, p_config_inst_item_id NUMBER)is
123 SELECT instance_id
124 ,object_version_number
125 ,config_valid_status
126 FROM csi_item_instances
127 WHERE config_inst_hdr_id=p_config_inst_hdr_id
128 AND config_inst_item_id=p_config_inst_item_id;
129
130 l_config_instance_rec csi_datastructures_pub.instance_rec ;
131 l_config_temp_rec csi_datastructures_pub.instance_rec ;
132 l_batch_hdr_id NUMBER;
133 l_batch_rev_nbr NUMBER;
134 l_instance_id_lst csi_datastructures_pub.id_tbl;
135 l_config_ins_rec csi_datastructures_pub.instance_rec;
136 l_config_tmp_rec csi_datastructures_pub.instance_rec;
137 --
138 px_oks_txn_inst_tbl OKS_IBINT_PUB.TXN_INSTANCE_TBL;
139 px_child_inst_tbl csi_item_instance_grp.child_inst_tbl;
140 l_batch_id NUMBER;
141 l_batch_type VARCHAR2(50);
142 BEGIN
143
144 -- Standard Start of API savepoint
145 SAVEPOINT create_item_instance;
146
147 -- Check for freeze_flag in csi_install_parameters is set to 'Y'
148
149 csi_utility_grp.check_ib_active;
150
151 -- Standard call to check for call compatibility.
152 IF NOT FND_API.Compatible_API_Call (l_api_version,
153 p_api_version,
154 l_api_name ,
155 G_PKG_NAME )
156 THEN
157 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
158 END IF;
159
160 -- Initialize message list if p_init_msg_list is set to TRUE.
161 IF FND_API.to_Boolean( p_init_msg_list ) THEN
162 FND_MSG_PUB.initialize;
163 END IF;
164
165 -- Initialize API return status to success
166 x_return_status := FND_API.G_RET_STS_SUCCESS;
167
168 -- Check the profile option debug_level for debug message reporting
169 l_debug_level:=fnd_profile.value('CSI_DEBUG_LEVEL');
170
171 -- If debug_level = 1 then dump the procedure name
172 IF (l_debug_level > 0) THEN
173 csi_gen_utility_pvt.put_line( 'create_item_instance');
174 END IF;
175
176 -- If the debug level = 2 then dump all the parameters values.
177 IF (l_debug_level > 1) THEN
178
179 csi_gen_utility_pvt.put_line( 'create_item_instance' ||
180 p_api_version ||'-'||
181 p_commit ||'-'||
182 p_init_msg_list ||'-'||
183 p_validation_level );
184 csi_gen_utility_pvt.dump_instance_rec(p_instance_rec);
185 csi_gen_utility_pvt.dump_party_tbl(p_party_tbl);
186 csi_gen_utility_pvt.dump_txn_rec(p_txn_rec);
187 csi_gen_utility_pvt.dump_organization_unit_tbl(p_org_assignments_tbl);
188 csi_gen_utility_pvt.dump_pricing_attribs_tbl(p_pricing_attrib_tbl);
189 csi_gen_utility_pvt.dump_party_account_tbl(p_account_tbl);
190 csi_gen_utility_pvt.dump_ext_attrib_values_tbl(p_ext_attrib_values_tbl);
191 END IF;
192 /***** srramakr commented for bug # 3304439
193 -- Check for the profile option and enable trace
194 l_flag:=CSI_GEN_UTILITY_PVT.enable_trace(l_trace_flag => l_flag);
195 -- End enable trace
196 ****/
197 -- Start API body
198 --
199 -- Calling Pre Customer User Hook
200 BEGIN
201
202 IF JTF_USR_HKS.Ok_to_execute(G_PKG_NAME, l_api_name, 'B', 'C' ) THEN
203 csi_gen_utility_pvt.put_line('Calling CSI_ITEM_INSTANCE_CUHK.Create_Item_Instance_Pre ..');
204 CSI_ITEM_INSTANCE_CUHK.Create_Item_Instance_Pre
205 (
206 p_api_version => 1.0
207 ,p_commit => fnd_api.g_false
208 ,p_init_msg_list => fnd_api.g_false
209 ,p_validation_level => fnd_api.g_valid_level_full
210 ,p_instance_rec => p_instance_rec
211 ,p_ext_attrib_values_tbl => p_ext_attrib_values_tbl
212 ,p_party_tbl => p_party_tbl
213 ,p_account_tbl => p_account_tbl
214 ,p_pricing_attrib_tbl => p_pricing_attrib_tbl
215 ,p_org_assignments_tbl => p_org_assignments_tbl
216 ,p_asset_assignment_tbl => p_asset_assignment_tbl
217 ,p_txn_rec => p_txn_rec
218 ,x_return_status => x_return_status
219 ,x_msg_count => x_msg_count
220 ,x_msg_data => x_msg_data
221 );
222 --
223 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
224 l_msg_index := 1;
225 l_msg_count := x_msg_count;
226 WHILE l_msg_count > 0 LOOP
227 x_msg_data := FND_MSG_PUB.GET
228 ( l_msg_index,
229 FND_API.G_FALSE );
230 csi_gen_utility_pvt.put_line('ERROR FROM CSI_ITEM_INSTANCE_CUHK.Create_Item_Instance_Pre API ');
231 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
232 l_msg_index := l_msg_index + 1;
233 l_msg_count := l_msg_count - 1;
234 END LOOP;
235 RAISE FND_API.G_EXC_ERROR;
236 END IF;
237 --
238 END IF;
239 EXCEPTION
240 WHEN OTHERS THEN
241 csi_gen_utility_pvt.put_line('ERROR FROM JTF_USR_HKS.Ok_to_execute API Create Pre Customer');
242 RAISE FND_API.G_EXC_ERROR;
243 END;
244 --
245 -- Calling Pre Vertical User Hook
246 BEGIN
247
248 IF JTF_USR_HKS.Ok_to_execute( G_PKG_NAME, l_api_name, 'B', 'V' ) THEN
249 csi_gen_utility_pvt.put_line('Calling CSI_ITEM_INSTANCE_VUHK.Create_Item_Instance_Pre ..');
250 CSI_ITEM_INSTANCE_VUHK.Create_Item_Instance_Pre
251 (
252 p_api_version => 1.0
253 ,p_commit => fnd_api.g_false
254 ,p_init_msg_list => fnd_api.g_false
255 ,p_validation_level => fnd_api.g_valid_level_full
256 ,p_instance_rec => p_instance_rec
257 ,p_ext_attrib_values_tbl => p_ext_attrib_values_tbl
258 ,p_party_tbl => p_party_tbl
259 ,p_account_tbl => p_account_tbl
260 ,p_pricing_attrib_tbl => p_pricing_attrib_tbl
261 ,p_org_assignments_tbl => p_org_assignments_tbl
262 ,p_asset_assignment_tbl => p_asset_assignment_tbl
263 ,p_txn_rec => p_txn_rec
264 ,x_return_status => x_return_status
265 ,x_msg_count => x_msg_count
266 ,x_msg_data => x_msg_data
267 );
268 --
269 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
270 l_msg_index := 1;
271 l_msg_count := x_msg_count;
272 WHILE l_msg_count > 0 LOOP
273 x_msg_data := FND_MSG_PUB.GET
274 ( l_msg_index,
275 FND_API.G_FALSE );
276 csi_gen_utility_pvt.put_line('ERROR FROM CSI_ITEM_INSTANCE_VUHK.Create_Item_Instance_Pre API ');
277 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
278 l_msg_index := l_msg_index + 1;
279 l_msg_count := l_msg_count - 1;
280 END LOOP;
281 RAISE FND_API.G_EXC_ERROR;
282 END IF;
283 --
284 END IF;
285
286 EXCEPTION
287 WHEN OTHERS THEN
288 csi_gen_utility_pvt.put_line('ERROR FROM JTF_USR_HKS.Ok_to_execute API Create Pre Vertical');
289 RAISE FND_API.G_EXC_ERROR;
290 END;
291
292 -- End of PRE User Hooks
293 --
294 -- Create an item instance after validating all the instance attributes.
295 -- API also validates that exactly one owner is being created for the
296 -- item instance
297 -- The following code has been added to assign call_contracts
298 -- false so that contracts call can be made only once.
299 IF (p_account_tbl.count > 0) THEN
300 FOR tab_row IN p_account_tbl.FIRST .. p_account_tbl.LAST
301 LOOP
302 IF p_account_tbl.EXISTS(tab_row) THEN
303 p_account_tbl(tab_row).call_contracts := fnd_api.g_false;
304 p_account_tbl(tab_row).vld_organization_id := p_instance_rec.vld_organization_id;
305 END IF;
306 END LOOP;
307 END IF;
308
309
310 csi_item_instance_pvt.create_item_instance
311 (
312 p_api_version => p_api_version
313 ,p_commit => fnd_api.g_false
314 ,p_init_msg_list => p_init_msg_list
315 ,p_validation_level => p_validation_level
316 ,p_instance_rec => p_instance_rec
317 ,p_txn_rec => p_txn_rec
318 ,p_party_tbl => p_party_tbl
319 ,p_asset_tbl => p_asset_assignment_tbl
320 ,x_return_status => x_return_status
321 ,x_msg_count => x_msg_count
322 ,x_msg_data => x_msg_data
323 ,p_item_attribute_tbl => l_item_attribute_tbl
324 ,p_location_tbl => l_location_tbl
325 ,p_generic_id_tbl => l_generic_id_tbl
326 ,p_lookup_tbl => l_lookup_tbl
327 ,p_ins_count_rec => l_ins_count_rec
328 );
329 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
330 l_msg_index := 1;
331 l_msg_count := x_msg_count;
332 WHILE l_msg_count > 0 LOOP
333 x_msg_data := FND_MSG_PUB.GET
334 ( l_msg_index,
335 FND_API.G_FALSE );
336 csi_gen_utility_pvt.put_line( ' Error from CSI_ITEM_INSTANCE_PVT.. ');
337 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
338 l_msg_index := l_msg_index + 1;
339 l_msg_count := l_msg_count - 1;
340 END LOOP;
341 RAISE FND_API.G_EXC_ERROR;
342 END IF;
343 --
344 -- Calling Post Customer User Hook
345 BEGIN
346
347 IF JTF_USR_HKS.Ok_to_execute(G_PKG_NAME, l_api_name, 'A', 'C' ) THEN
348 csi_gen_utility_pvt.put_line('Calling CSI_ITEM_INSTANCE_CUHK.Create_Item_Instance_Post ..');
349 CSI_ITEM_INSTANCE_CUHK.Create_Item_Instance_Post
350 (
351 p_api_version => 1.0
352 ,p_commit => fnd_api.g_false
353 ,p_init_msg_list => fnd_api.g_false
354 ,p_validation_level => fnd_api.g_valid_level_full
355 ,p_instance_rec => p_instance_rec
356 ,p_ext_attrib_values_tbl => p_ext_attrib_values_tbl
357 ,p_party_tbl => p_party_tbl
358 ,p_account_tbl => p_account_tbl
359 ,p_pricing_attrib_tbl => p_pricing_attrib_tbl
360 ,p_org_assignments_tbl => p_org_assignments_tbl
361 ,p_asset_assignment_tbl => p_asset_assignment_tbl
362 ,p_txn_rec => p_txn_rec
363 ,x_return_status => x_return_status
364 ,x_msg_count => x_msg_count
365 ,x_msg_data => x_msg_data
366 );
367 --
368 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
369 l_msg_index := 1;
370 l_msg_count := x_msg_count;
371 WHILE l_msg_count > 0 LOOP
372 x_msg_data := FND_MSG_PUB.GET
373 ( l_msg_index,
374 FND_API.G_FALSE );
375 csi_gen_utility_pvt.put_line('ERROR FROM CSI_ITEM_INSTANCE_CUHK.Create_Item_Instance_Post API ');
376 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
377 l_msg_index := l_msg_index + 1;
378 l_msg_count := l_msg_count - 1;
379 END LOOP;
380 RAISE FND_API.G_EXC_ERROR;
381 END IF;
382 --
383 END IF;
384 EXCEPTION
385 WHEN OTHERS THEN
386 csi_gen_utility_pvt.put_line('ERROR FROM JTF_USR_HKS.Ok_to_execute API Create Post Customer');
387 RAISE FND_API.G_EXC_ERROR;
388 END;
389
390
391 -- Call the create_party_relationship API to create instance-to-party
392 -- relationships.
393
394 IF (p_party_tbl.count > 0) THEN
395 FOR tab_row IN p_party_tbl.FIRST .. p_party_tbl.LAST
396 LOOP
397 IF p_party_tbl.EXISTS(tab_row) THEN
398 p_party_tbl(tab_row).instance_id := p_instance_rec.instance_id;
399 IF ((p_party_tbl(tab_row).active_start_date IS NULL) OR
400 (p_party_tbl(tab_row).active_start_date = FND_API.G_MISS_DATE)) THEN
401 p_party_tbl(tab_row).active_start_date := p_instance_rec.active_start_date;
402 END IF;
403 END IF;
404 END LOOP;
405 -- Added by sguthiva for att enhancements
406 -- The following code has been written to allow the flexibility
407 -- to pass a party and its contacts.
408 l_party:=1;
409 l_contact:=1;
410 l_account:=1;
411 -- The following code is written for parties
412 FOR tab_row IN p_party_tbl.FIRST .. p_party_tbl.LAST
413 LOOP
414 IF nvl(p_party_tbl(tab_row).contact_flag,'N') <> 'Y'
415 THEN
416 l_party_tbl(l_party):=p_party_tbl(tab_row);
417 IF p_account_tbl.count > 0
418 THEN
419 FOR acct_row IN p_account_tbl.FIRST..p_account_tbl.last
420 LOOP
421 IF p_account_tbl(acct_row).parent_tbl_index =tab_row
422 THEN
423 l_account_tbl(l_account):=p_account_tbl(acct_row);
424 l_account_tbl(l_account).parent_tbl_index:=l_party;
425 l_account:=l_account+1;
426 END IF;
427 END LOOP;
428 END IF;
429
430 l_t_party_tbl(l_party).parent_tbl_index:=tab_row;
431 l_t_party_tbl(l_party).contact_parent_tbl_index:=l_party;
432 l_party:=l_party+1;
433 END IF;
434 END LOOP;
435 -- The following code is written for contacts
436 FOR cont_row IN p_party_tbl.FIRST .. p_party_tbl.LAST
437 LOOP
438 IF p_party_tbl(cont_row).contact_flag='Y'
439 AND (p_party_tbl(cont_row).contact_ip_id IS NULL
440 OR p_party_tbl(cont_row).contact_ip_id=fnd_api.g_miss_num
441 )
442 AND (p_party_tbl(cont_row).contact_parent_tbl_index IS NOT NULL
443 AND p_party_tbl(cont_row).contact_parent_tbl_index <> fnd_api.g_miss_num
444 )
445 THEN
446 lc_party_tbl(l_contact):=p_party_tbl(cont_row);
447 FOR k in l_t_party_tbl.first..l_t_party_tbl.last
448 LOOP
449 IF l_t_party_tbl(k).parent_tbl_index=lc_party_tbl(l_contact).contact_parent_tbl_index
450 THEN
451 lc_party_tbl(l_contact).contact_parent_tbl_index:=l_t_party_tbl(k).contact_parent_tbl_index;
452 END IF;
453 END LOOP;
454 l_contact:=l_contact+1;
455 END IF;
456 END LOOP;
457
458 p_account_tbl:=l_temp_account_tbl;
459 p_account_tbl:=l_account_tbl;
460 l_count:=l_party_tbl.count;
461 p_party_tbl:=l_temp_party_tbl;
462 p_party_tbl:=l_party_tbl;
463
464 IF lc_party_tbl.COUNT > 0
465 THEN
466 FOR cont_row IN lc_party_tbl.FIRST..lc_party_tbl.LAST
467 LOOP
468 l_count:=l_count+1;
469 p_party_tbl(l_count):=lc_party_tbl(cont_row);
470 END LOOP;
471 END IF;
472
473 csi_party_relationships_pub.create_inst_party_relationship
474 (
475 p_api_version => p_api_version
476 ,p_commit => fnd_api.g_false
477 ,p_init_msg_list => p_init_msg_list
478 ,p_validation_level => p_validation_level
479 ,p_party_tbl => p_party_tbl
480 ,p_party_account_tbl => p_account_tbl
481 ,p_txn_rec => p_txn_rec
482 ,p_oks_txn_inst_tbl => px_oks_txn_inst_tbl
483 ,x_return_status => x_return_status
484 ,x_msg_count => x_msg_count
485 ,x_msg_data => x_msg_data
486 );
487 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
488 l_msg_index := 1;
489 l_msg_count := x_msg_count;
490 WHILE l_msg_count > 0 LOOP
491 x_msg_data := FND_MSG_PUB.GET
492 ( l_msg_index,
493 FND_API.G_FALSE );
494 csi_gen_utility_pvt.put_line( ' Error from CSI_PARTY_RELATIONSHIPS_PUB.. ');
495 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
496 l_msg_index := l_msg_index + 1;
497 l_msg_count := l_msg_count - 1;
498 END LOOP;
499 RAISE FND_API.G_EXC_ERROR;
500 END IF;
501 END IF;
502
503 -- Call create_organization_unit API to create instance-
504 -- to-organization units associations
505
506 IF (p_org_assignments_tbl.count > 0) THEN
507 FOR tab_row IN p_org_assignments_tbl.FIRST .. p_org_assignments_tbl.LAST
508 LOOP
509 IF p_org_assignments_tbl.EXISTS(tab_row) THEN
510 p_org_assignments_tbl(tab_row).instance_id := p_instance_rec.instance_id;
511 END IF;
512 END LOOP;
513
514 csi_organization_unit_pub.create_organization_unit
515 (
516 p_api_version => p_api_version
517 ,p_commit => fnd_api.g_false
518 ,p_init_msg_list => p_init_msg_list
519 ,p_validation_level => p_validation_level
520 ,p_org_unit_tbl => p_org_assignments_tbl
521 ,p_txn_rec => p_txn_rec
522 ,x_return_status => x_return_status
523 ,x_msg_count => x_msg_count
524 ,x_msg_data => x_msg_data
525 );
526
527 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
528 l_msg_index := 1;
529 l_msg_count := x_msg_count;
530 WHILE l_msg_count > 0 LOOP
531 x_msg_data := FND_MSG_PUB.GET
532 ( l_msg_index,
533 FND_API.G_FALSE );
534 csi_gen_utility_pvt.put_line( ' Error from CSI_ORGANIZATION_UNIT_PUB..');
535 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
536 l_msg_index := l_msg_index + 1;
537 l_msg_count := l_msg_count - 1;
538 END LOOP;
539 RAISE FND_API.G_EXC_ERROR;
540 END IF;
541
542 END IF;
543
544 -- Call create_pricing_attribs to associate any pricing attributes
545 -- to the item instance
546
547 IF (p_pricing_attrib_tbl.count > 0) THEN
548 FOR tab_row IN p_pricing_attrib_tbl.FIRST .. p_pricing_attrib_tbl.LAST
549 LOOP
550 IF p_pricing_attrib_tbl.EXISTS(tab_row) THEN
551 p_pricing_attrib_tbl(tab_row).instance_id := p_instance_rec.instance_id;
552 END IF;
553 END LOOP;
554
555 csi_pricing_attribs_pub.create_pricing_attribs
556 (
557 p_api_version => p_api_version
558 ,p_commit => fnd_api.g_false
559 ,p_init_msg_list => p_init_msg_list
560 ,p_validation_level => p_validation_level
561 ,p_pricing_attribs_tbl => p_pricing_attrib_tbl
562 ,p_txn_rec => p_txn_rec
563 ,x_return_status => x_return_status
564 ,x_msg_count => x_msg_count
565 ,x_msg_data => x_msg_data
566 );
567
568 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
569 l_msg_index := 1;
570 l_msg_count := x_msg_count;
571 WHILE l_msg_count > 0 LOOP
572 x_msg_data := FND_MSG_PUB.GET
573 ( l_msg_index,
574 FND_API.G_FALSE );
575
576 csi_gen_utility_pvt.put_line( ' Error from CSI_PRICING_ATTRIBS_PUB..');
577 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
578 l_msg_index := l_msg_index + 1;
579 l_msg_count := l_msg_count - 1;
580 END LOOP;
581 RAISE FND_API.G_EXC_ERROR;
582 END IF;
583 END IF;
584
585 -- Call create_extended_attribs to associate any extended attributes
586 -- to the item instance
587
588 IF (p_ext_attrib_values_tbl.count > 0) THEN
589 FOR tab_row IN p_ext_attrib_values_tbl.FIRST .. p_ext_attrib_values_tbl.LAST
590 LOOP
591 IF p_ext_attrib_values_tbl.EXISTS(tab_row) THEN
592 p_ext_attrib_values_tbl(tab_row).instance_id := p_instance_rec.instance_id;
593 END IF;
594 END LOOP;
595
596 create_extended_attrib_values
597 (
598 p_api_version => p_api_version
599 ,p_commit => fnd_api.g_false
600 ,p_init_msg_list => p_init_msg_list
601 ,p_validation_level => p_validation_level
602 ,p_ext_attrib_tbl => p_ext_attrib_values_tbl
603 ,p_txn_rec => p_txn_rec
604 ,x_return_status => x_return_status
605 ,x_msg_count => x_msg_count
606 ,x_msg_data => x_msg_data
607 );
608
609 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
610 l_msg_index := 1;
611 l_msg_count := x_msg_count;
612 WHILE l_msg_count > 0 LOOP
613 x_msg_data := FND_MSG_PUB.GET
614 ( l_msg_index,
615 FND_API.G_FALSE );
616
617 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
618 l_msg_index := l_msg_index + 1;
619 l_msg_count := l_msg_count - 1;
620 END LOOP;
621 RAISE FND_API.G_EXC_ERROR;
622 END IF;
623 END IF;
624
625 -- Call create_asset_assignments to associate any assets associated
626 -- to the item instance
627
628 IF (p_asset_assignment_tbl.count > 0) THEN
629 FOR tab_row IN p_asset_assignment_tbl.FIRST .. p_asset_assignment_tbl.LAST
630 LOOP
631 IF p_asset_assignment_tbl.EXISTS(tab_row) THEN
632 p_asset_assignment_tbl(tab_row).instance_id := p_instance_rec.instance_id;
633 csi_asset_pvt.create_instance_asset
634 (
635 p_api_version => p_api_version
636 ,p_commit => fnd_api.g_false
637 ,p_init_msg_list => p_init_msg_list
638 ,p_instance_asset_rec => p_asset_assignment_tbl(tab_row)
639 ,p_txn_rec => p_txn_rec
640 ,x_return_status => x_return_status
641 ,x_msg_count => x_msg_count
642 ,x_msg_data => x_msg_data
643 ,p_lookup_tbl => l_asset_lookup_tbl
644 ,p_asset_count_rec => l_asset_count_rec
645 ,p_asset_id_tbl => l_asset_id_tbl
646 ,p_asset_loc_tbl => l_asset_loc_tbl
647 );
648
649 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
650 l_msg_index := 1;
651 l_msg_count := x_msg_count;
652 WHILE l_msg_count > 0 LOOP
653 x_msg_data := FND_MSG_PUB.GET
654 ( l_msg_index,
655 FND_API.G_FALSE );
656 csi_gen_utility_pvt.put_line( ' Error from CSI_ASSET_PVT..');
657 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
658 l_msg_index := l_msg_index + 1;
659 l_msg_count := l_msg_count - 1;
660 END LOOP;
661 RAISE FND_API.G_EXC_ERROR;
662 END IF;
663 END IF;
664 END LOOP;
665 END IF;
666
667 -- Added by rtalluri for Bug 2256588 on 03/26/02
668
669 -- If version label is null, then we need read the the default value from the profile option
670
671 IF ((p_instance_rec.version_label IS NULL) OR
672 (p_instance_rec.version_label = FND_API.G_MISS_CHAR)) THEN
673 l_version_label := FND_PROFILE.VALUE('CSI_DEFAULT_VERSION_LABEL');
674 IF l_version_label IS NULL THEN
675 FND_MESSAGE.SET_NAME('CSI','CSI_API_INVALID_VERSION_LABEL');
676 FND_MSG_PUB.ADD;
677 RAISE FND_API.G_EXC_ERROR;
678 ELSE
679 p_instance_rec.version_label := l_version_label;
680 END IF;
681 END IF;
682
683 --Calling the Create Version Label API to associate a version label for an instance created
684
685 l_version_label_rec.instance_id := p_instance_rec.instance_id;
686 l_version_label_rec.version_label := p_instance_rec.version_label;
687 l_version_label_rec.date_time_stamp := SYSDATE;
688 l_version_label_rec.active_start_date := p_instance_rec.active_start_date;
689
690
691 csi_item_instance_pvt.create_version_label
692 (
693 p_api_version => p_api_version
694 ,p_commit => fnd_api.g_false
695 ,p_init_msg_list => p_init_msg_list
696 ,p_validation_level => p_validation_level
697 ,p_version_label_rec => l_version_label_rec
698 ,p_txn_rec => p_txn_rec
699 ,x_return_status => x_return_status
700 ,x_msg_count => x_msg_count
701 ,x_msg_data => x_msg_data
702 );
703
704 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
705 csi_gen_utility_pvt.put_line( ' Error from CSI_ITEM_INSTANCE_PVT.CREATE_VERSION_LABEL..');
706 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
707 FND_MESSAGE.SET_NAME('CSI','CSI_FAILED_TO_CREATE_VERSION');
708 FND_MESSAGE.SET_TOKEN('API_ERROR', 'CREATE_VERSION_LABEL');
709 FND_MSG_PUB.Add;
710 RAISE FND_API.G_EXC_ERROR;
711 END IF;
712
713 -- End of addition by rtalluri for Bug 2256588 on 03/26/02
714
715 -- Here we call update_version_time to update date_time_stamp of
716 -- version labels created with this transaction_id to sysdate.
717 -- Commented the following code, which is causing the prformance
718 -- issue. -- bug 3558082 (reported in 11.5.8)
719 -- Calling Contracts
720 -- Added on 02-OCT-01
721 -- Added by sk for fixing bug 2245976
722 IF csi_datastructures_pub.g_install_param_rec.fetch_flag IS NULL THEN
723 csi_gen_utility_pvt.populate_install_param_rec;
724 END IF;
725 --
726 l_internal_party_id := csi_datastructures_pub.g_install_param_rec.internal_party_id;
727 --
728 BEGIN
729 SELECT cip.party_id
730 INTO l_party_id
731 FROM csi_i_parties cip
732 WHERE cip.instance_id = p_instance_rec.instance_id
733 AND cip.relationship_type_code = 'OWNER';
734 EXCEPTION
735 WHEN OTHERS THEN
736 l_party_id := NULL;
737 END;
738
739 IF l_party_id IS NOT NULL AND
740 l_internal_party_id IS NOT NULL AND
741 l_party_id <> l_internal_party_id
742 THEN
743 -- End addition by sk for fixing bug 2245976
744 l_transaction_type:= 'NEW';
745 IF (p_instance_rec.call_contracts <> fnd_api.g_false) --added by radha on 04/04/02
746 THEN
747 csi_item_instance_pvt.Call_to_Contracts(
748 p_transaction_type => l_transaction_type
749 ,p_instance_id => p_instance_rec.instance_id
750 ,p_new_instance_id => NULL
751 ,p_vld_org_id => p_instance_rec.vld_organization_id
752 ,p_quantity => NULL
753 ,p_party_account_id1 => NULL
754 ,p_party_account_id2 => NULL
755 ,p_transaction_date => p_txn_rec.transaction_date -- Refer 3483763
756 ,p_source_transaction_date => p_txn_rec.source_transaction_date -- Added jpwilson
757 ,p_oks_txn_inst_tbl => px_oks_txn_inst_tbl
758 ,x_return_status => x_return_status
759 ,x_msg_count => x_msg_count
760 ,x_msg_data => x_msg_data
761 );
762
763 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS)
764 THEN
765 l_msg_index := 1;
766 l_msg_count := x_msg_count;
767 WHILE l_msg_count > 0 LOOP
768 x_msg_data := FND_MSG_PUB.GET
769 ( l_msg_index,
770 FND_API.G_FALSE
771 );
772 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
773 l_msg_index := l_msg_index + 1;
774 l_msg_count := l_msg_count - 1;
775 END LOOP;
776 RAISE FND_API.G_EXC_ERROR;
777 END IF;
778 END IF;
779 END IF;
780
781 -- Start att enhancements
782 IF p_instance_rec.call_batch_validation<>fnd_api.g_false
783 THEN
784 IF (p_instance_rec.config_inst_hdr_id IS NOT NULL AND p_instance_rec.config_inst_hdr_id <> fnd_api.g_miss_num)
785 AND (p_instance_rec.config_inst_item_id IS NOT NULL AND p_instance_rec.config_inst_item_id <> fnd_api.g_miss_num)
786 AND (p_instance_rec.config_inst_rev_num IS NOT NULL AND p_instance_rec.config_inst_rev_num <> fnd_api.g_miss_num)
787 THEN
788
789 IF NOT csi_item_instance_vld_pvt.is_unique_config_key ( p_config_inst_hdr_id => p_instance_rec.config_inst_hdr_id
790 ,p_config_inst_item_id => p_instance_rec.config_inst_item_id
791 ,p_instance_id => p_instance_rec.instance_id
792 ,p_validation_mode => 'CREATE'
793 )
794 THEN
795 FND_MESSAGE.SET_NAME('CSI','CSI_CONFIG_KEY_EXISTS');
796 FND_MSG_PUB.Add;
797 RAISE fnd_api.g_exc_error;
798 END IF;
799
800 BEGIN
801 SELECT component_instance_type
802 ,config_hdr_id
803 ,config_rev_nbr
804 INTO l_component_ins_type
805 ,l_config_hdr_id
806 ,l_config_rev_nbr
807 FROM cz_config_items_v
808 WHERE instance_hdr_id = p_instance_rec.config_inst_hdr_id
809 AND instance_rev_nbr = p_instance_rec.config_inst_rev_num
810 AND config_item_id = p_instance_rec.config_inst_item_id;
811 EXCEPTION
812 WHEN OTHERS THEN
813 FND_MESSAGE.SET_NAME('CSI','CSI_CONFIG_NOT_IN_CZ');
814 FND_MESSAGE.SET_TOKEN('INSTANCE_HDR_ID',p_instance_rec.config_inst_hdr_id);
815 FND_MESSAGE.SET_TOKEN('INSTANCE_REV_NBR',p_instance_rec.config_inst_rev_num);
816 FND_MESSAGE.SET_TOKEN('CONFIG_ITEM_ID',p_instance_rec.config_inst_item_id);
817 FND_MSG_PUB.Add;
818 RAISE FND_API.G_EXC_ERROR;
819 END;
820
821 IF l_component_ins_type='I'
822 THEN
823 Csi_item_instance_vld_pvt.Call_batch_validate
824 ( p_instance_rec => p_instance_rec
825 ,p_config_hdr_id => l_config_hdr_id
826 ,p_config_rev_nbr => l_config_rev_nbr
827 ,x_config_hdr_id => l_batch_hdr_id
828 ,x_config_rev_nbr => l_batch_rev_nbr
829 ,x_return_status => x_return_status);
830
831 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
832 FND_MESSAGE.SET_NAME('CSI','CSI_CONFIG_ERROR');
833 FND_MSG_PUB.Add;
834 csi_gen_utility_pvt.put_line('Call to batch validation has errored ');
835 RAISE FND_API.G_EXC_ERROR;
836 END IF;
837 END IF;
838 ELSIF ( (p_instance_rec.config_inst_hdr_id IS NULL OR p_instance_rec.config_inst_hdr_id = fnd_api.g_miss_num)
839 AND (p_instance_rec.config_inst_item_id IS NOT NULL AND p_instance_rec.config_inst_item_id <> fnd_api.g_miss_num))
840 OR ( (p_instance_rec.config_inst_hdr_id IS NOT NULL AND p_instance_rec.config_inst_hdr_id <> fnd_api.g_miss_num)
841 AND (p_instance_rec.config_inst_item_id IS NULL OR p_instance_rec.config_inst_item_id = fnd_api.g_miss_num))
842 OR ( (p_instance_rec.config_inst_hdr_id IS NOT NULL AND p_instance_rec.config_inst_hdr_id <> fnd_api.g_miss_num)
843 AND (p_instance_rec.config_inst_item_id IS NOT NULL AND p_instance_rec.config_inst_item_id <> fnd_api.g_miss_num)
844 AND (p_instance_rec.config_inst_rev_num IS NULL OR p_instance_rec.config_inst_rev_num = fnd_api.g_miss_num))
845 THEN
846 FND_MESSAGE.SET_NAME('CSI','CSI_INVALID_CONFIG_COMB');
847 FND_MSG_PUB.Add;
848 RAISE fnd_api.g_exc_error;
849 END IF;
850 END IF;
851 -- End att enhancements
852 -- Adding new changes for bug 3799694
853 IF (p_instance_rec.config_inst_hdr_id IS NOT NULL AND p_instance_rec.config_inst_hdr_id <> fnd_api.g_miss_num)
854 AND (p_instance_rec.config_inst_item_id IS NOT NULL AND p_instance_rec.config_inst_item_id <> fnd_api.g_miss_num)
855 AND (p_instance_rec.config_inst_rev_num IS NOT NULL AND p_instance_rec.config_inst_rev_num <> fnd_api.g_miss_num)
856 THEN
857 FOR l_config_ins_key IN new_config_ins_key(p_instance_rec.config_inst_hdr_id,p_instance_rec.config_inst_rev_num)
858 LOOP
859
860 IF l_config_ins_key.has_failures ='1'
861 OR nvl(l_config_ins_key.config_status,'0') <> '2'
862 THEN
863 FOR l_instance_key IN new_instance_key(p_instance_rec.config_inst_hdr_id,p_instance_rec.config_inst_item_id)
864 LOOP
865
866 l_config_instance_rec:=l_config_temp_rec;
867 IF (l_instance_key.instance_id IS NOT NULL AND
868 l_instance_key.instance_id <> fnd_api.g_miss_num) AND
869 ( l_instance_key.config_valid_status IS NULL OR
870 (l_instance_key.config_valid_status IS NOT NULL AND
871 l_instance_key.config_valid_status <> '1'))
872 THEN
873 l_config_instance_rec.instance_id:=l_instance_key.instance_id;
874 l_config_instance_rec.object_version_number:=l_instance_key.object_version_number;
875 l_config_instance_rec.config_valid_status:='1'; --INVALID
876 csi_item_instance_pvt.update_item_instance
877 (
878 p_api_version => p_api_version
879 ,p_commit => fnd_api.g_false
880 ,p_init_msg_list => p_init_msg_list
881 ,p_validation_level => p_validation_level
882 ,p_instance_rec => l_config_instance_rec
883 ,p_txn_rec => p_txn_rec
884 ,x_instance_id_lst => l_instance_id_lst
885 ,x_return_status => x_return_status
886 ,x_msg_count => x_msg_count
887 ,x_msg_data => x_msg_data
888 ,p_item_attribute_tbl => l_item_attribute_tbl
889 ,p_location_tbl => l_location_tbl
890 ,p_generic_id_tbl => l_generic_id_tbl
891 ,p_lookup_tbl => l_lookup_tbl
892 ,p_ins_count_rec => l_ins_count_rec
893 ,p_oks_txn_inst_tbl => px_oks_txn_inst_tbl
894 ,p_child_inst_tbl => px_child_inst_tbl
895 );
896
897 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
898 l_msg_index := 1;
899 l_msg_count := x_msg_count;
900 WHILE l_msg_count > 0 LOOP
901 x_msg_data := FND_MSG_PUB.GET
902 ( l_msg_index,
903 FND_API.G_FALSE );
904 csi_gen_utility_pvt.put_line( 'Error from UPDATE_ITEM_INSTANCE_PVT..');
905 csi_gen_utility_pvt.put_line( 'while updating config status');
906 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
907 l_msg_index := l_msg_index + 1;
908 l_msg_count := l_msg_count - 1;
909 END LOOP;
910 RAISE FND_API.G_EXC_ERROR;
911 END IF;
912 END IF;
913 END LOOP;
914 ELSE
915 FOR l_instance_key IN new_instance_key(p_instance_rec.config_inst_hdr_id,p_instance_rec.config_inst_item_id)
916 LOOP
917
918 l_config_instance_rec:=l_config_temp_rec;
919 IF (l_instance_key.instance_id IS NOT NULL AND
920 l_instance_key.instance_id <> fnd_api.g_miss_num) AND
921 ( l_instance_key.config_valid_status IS NULL OR
922 (l_instance_key.config_valid_status IS NOT NULL AND
923 l_instance_key.config_valid_status <> '0'))
924 THEN
925 l_config_instance_rec.instance_id:=l_instance_key.instance_id;
926 l_config_instance_rec.object_version_number:=l_instance_key.object_version_number;
927 l_config_instance_rec.config_valid_status:='0'; --VALID
928 csi_item_instance_pvt.update_item_instance
929 (
930 p_api_version => p_api_version
931 ,p_commit => fnd_api.g_false
932 ,p_init_msg_list => p_init_msg_list
933 ,p_validation_level => p_validation_level
934 ,p_instance_rec => l_config_instance_rec
935 ,p_txn_rec => p_txn_rec
936 ,x_instance_id_lst => l_instance_id_lst
937 ,x_return_status => x_return_status
938 ,x_msg_count => x_msg_count
939 ,x_msg_data => x_msg_data
940 ,p_item_attribute_tbl => l_item_attribute_tbl
941 ,p_location_tbl => l_location_tbl
942 ,p_generic_id_tbl => l_generic_id_tbl
943 ,p_lookup_tbl => l_lookup_tbl
944 ,p_ins_count_rec => l_ins_count_rec
945 ,p_oks_txn_inst_tbl => px_oks_txn_inst_tbl
946 ,p_child_inst_tbl => px_child_inst_tbl
947 );
948
949 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
950 l_msg_index := 1;
951 l_msg_count := x_msg_count;
952 WHILE l_msg_count > 0 LOOP
953 x_msg_data := FND_MSG_PUB.GET
954 ( l_msg_index,
955 FND_API.G_FALSE );
956 csi_gen_utility_pvt.put_line( 'Error from UPDATE_ITEM_INSTANCE_PVT..');
957 csi_gen_utility_pvt.put_line( 'while updating config status');
958 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
959 l_msg_index := l_msg_index + 1;
960 l_msg_count := l_msg_count - 1;
961 END LOOP;
962 RAISE FND_API.G_EXC_ERROR;
963 END IF;
964 END IF;
965 END LOOP;
966 END IF;
967 END LOOP;
968 END IF;
969 --
970 IF px_oks_txn_inst_tbl.count > 0 THEN
971 csi_gen_utility_pvt.dump_oks_txn_inst_tbl(px_oks_txn_inst_tbl);
972 csi_gen_utility_pvt.put_line('Calling OKS Core API...');
973 --
974 IF p_txn_rec.transaction_type_id = 3 THEN
975 l_batch_id := p_txn_rec.source_header_ref_id;
976 l_batch_type := p_txn_rec.source_group_ref;
977 ELSE
978 l_batch_id := NULL;
979 l_batch_type := NULL;
980 END IF;
981 --
982 UPDATE CSI_TRANSACTIONS
983 set contracts_invoked = 'Y'
984 where transaction_id = p_txn_rec.transaction_id;
985 --
986 OKS_IBINT_PUB.IB_interface
987 (
988 P_Api_Version => 1.0,
989 P_init_msg_list => p_init_msg_list,
990 P_single_txn_date_flag => 'Y',
991 P_Batch_type => l_batch_type,
992 P_Batch_ID => l_batch_id,
993 P_OKS_Txn_Inst_tbl => px_oks_txn_inst_tbl,
994 x_return_status => x_return_status,
995 x_msg_count => x_msg_count,
996 x_msg_data => x_msg_data
997 );
998 --
999 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1000 l_msg_index := 1;
1001 l_msg_count := x_msg_count;
1002 WHILE l_msg_count > 0 LOOP
1003 x_msg_data := FND_MSG_PUB.GET
1004 ( l_msg_index,
1005 FND_API.G_FALSE );
1006 csi_gen_utility_pvt.put_line( 'Error from OKS_IBINT_PUB.IB_interface..');
1007 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
1008 l_msg_index := l_msg_index + 1;
1009 l_msg_count := l_msg_count - 1;
1010 END LOOP;
1011 RAISE FND_API.G_EXC_ERROR;
1012 END IF;
1013 END IF;
1014
1015 -- End addition of changes for bug 3799694
1016 -- End of API body
1017
1018 -- Begin Add Code for Siebel Genesis Project - Call the Business Event
1019 IF l_raise_bes_event = 'Y' THEN
1020 csi_gen_utility_pvt.put_line('l_internal_party_Id = '||to_char(l_internal_party_id));
1021 csi_gen_utility_pvt.put_line('l_party_Id = '||to_char(l_party_id));
1022 csi_gen_utility_pvt.put_line('fnd_api.g_miss_num = '||to_char(fnd_api.g_miss_num));
1023 IF l_internal_party_id <> l_party_id THEN
1024 IF (p_instance_rec.last_oe_order_line_id IS NULL OR p_instance_rec.last_oe_order_line_id = fnd_api.g_miss_num) THEN
1025 csi_gen_utility_pvt.put_line('Firing the CREATE INSTANCE EVENT ');
1026 CSI_BUSINESS_EVENT_PVT.CREATE_INSTANCE_EVENT
1027 (p_api_version => p_api_version
1028 ,p_commit => fnd_api.g_false
1029 ,p_init_msg_list => p_init_msg_list
1030 ,p_validation_level => p_validation_level
1031 ,p_instance_id => p_instance_rec.instance_id
1032 ,p_subject_instance_id => null
1033 ,x_return_status => x_return_status
1034 ,x_msg_count => x_msg_count
1035 ,x_msg_data => x_msg_data
1036 );
1037
1038 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1039 l_msg_index := 1;
1040 l_msg_count := x_msg_count;
1041
1042 WHILE l_msg_count > 0 LOOP
1043 x_msg_data := FND_MSG_PUB.GET
1044 (l_msg_index,
1045 FND_API.G_FALSE );
1046 csi_gen_utility_pvt.put_line('Error from CSI_BUSINESS_EVENT.CREATE_INSTANCE_EVENT');
1047 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
1048 l_msg_index := l_msg_index + 1;
1049 l_msg_count := l_msg_count - 1;
1050 END LOOP;
1051 RAISE FND_API.G_EXC_ERROR;
1052 END IF;
1053 ELSIF (p_instance_rec.last_oe_order_line_id IS NOT NULL OR p_instance_rec.last_oe_order_line_id <> fnd_api.g_miss_num) THEN
1054 csi_gen_utility_pvt.put_line('Before link to line id ');
1055 BEGIN
1056 SELECT link_to_line_id, item_type_code
1057 INTO l_link_to_line_id, l_item_type_code
1058 FROM oe_order_lines_all
1059 WHERE line_id = p_instance_rec.last_oe_order_line_id;
1060 EXCEPTION
1061 WHEN OTHERS THEN
1062 l_link_to_line_id := null;
1063 l_item_type_code := null;
1064 END;
1065
1066 IF l_link_to_line_id is null and l_item_type_code = 'STANDARD' THEN
1067 CSI_BUSINESS_EVENT_PVT.CREATE_INSTANCE_EVENT
1068 (p_api_version => p_api_version
1069 ,p_commit => fnd_api.g_false
1070 ,p_init_msg_list => p_init_msg_list
1071 ,p_validation_level => p_validation_level
1072 ,p_instance_id => p_instance_rec.instance_id
1073 ,p_subject_instance_id => null
1074 ,x_return_status => x_return_status
1075 ,x_msg_count => x_msg_count
1076 ,x_msg_data => x_msg_data
1077 );
1078
1079 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1080 l_msg_index := 1;
1081 l_msg_count := x_msg_count;
1082
1083 WHILE l_msg_count > 0 LOOP
1084 x_msg_data := FND_MSG_PUB.GET
1085 (l_msg_index,
1086 FND_API.G_FALSE );
1087 csi_gen_utility_pvt.put_line('Error from CSI_BUSINESS_EVENT.CREATE_INSTANCE_EVENT');
1088 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
1089 l_msg_index := l_msg_index + 1;
1090 l_msg_count := l_msg_count - 1;
1091 END LOOP;
1092 RAISE FND_API.G_EXC_ERROR;
1093 END IF;
1094 END IF;
1095 END IF;
1096 END IF;
1097 END IF;
1098 -- End Add Code for Siebel Genesis Project - Call the Business Event
1099
1100 -- Standard check of p_commit.
1101 IF FND_API.To_Boolean( p_commit ) THEN
1102 COMMIT WORK;
1103 END IF;
1104 /***** srramakr commented for bug # 3304439
1105 -- Check for the profile option and disable the trace
1106 IF (l_flag = 'Y') THEN
1107 dbms_session.set_sql_trace(FALSE);
1108 END IF;
1109 ****/
1110 -- End disable trace
1111
1112 -- Standard call to get message count and if count is get message info.
1113 FND_MSG_PUB.Count_And_Get
1114 (p_count => x_msg_count ,
1115 p_data => x_msg_data
1116 );
1117
1118
1119 -- Calling Post Vertical User Hook
1120 BEGIN
1121
1122 IF JTF_USR_HKS.Ok_to_execute( G_PKG_NAME, l_api_name, 'A', 'V' ) THEN
1123 csi_gen_utility_pvt.put_line('Calling CSI_ITEM_INSTANCE_VUHK.Create_Item_Instance_Post ..');
1124 CSI_ITEM_INSTANCE_VUHK.Create_Item_Instance_Post
1125 (
1126 p_api_version => 1.0
1127 ,p_commit => fnd_api.g_false
1128 ,p_init_msg_list => fnd_api.g_false
1129 ,p_validation_level => fnd_api.g_valid_level_full
1130 ,p_instance_rec => p_instance_rec
1131 ,p_ext_attrib_values_tbl => p_ext_attrib_values_tbl
1132 ,p_party_tbl => p_party_tbl
1133 ,p_account_tbl => p_account_tbl
1134 ,p_pricing_attrib_tbl => p_pricing_attrib_tbl
1135 ,p_org_assignments_tbl => p_org_assignments_tbl
1136 ,p_asset_assignment_tbl => p_asset_assignment_tbl
1137 ,p_txn_rec => p_txn_rec
1138 ,x_return_status => x_return_status
1139 ,x_msg_count => x_msg_count
1140 ,x_msg_data => x_msg_data
1141 );
1142
1143 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1144 l_msg_index := 1;
1145 l_msg_count := x_msg_count;
1146 WHILE l_msg_count > 0 LOOP
1147 x_msg_data := FND_MSG_PUB.GET
1148 ( l_msg_index,
1149 FND_API.G_FALSE );
1150 csi_gen_utility_pvt.put_line('ERROR FROM CSI_ITEM_INSTANCE_VUHK.Create_Item_Instance_Post API ');
1151 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
1152 l_msg_index := l_msg_index + 1;
1153 l_msg_count := l_msg_count - 1;
1154 END LOOP;
1155 RAISE FND_API.G_EXC_ERROR;
1156 END IF;
1157 --
1158 END IF;
1159 EXCEPTION
1160 WHEN OTHERS THEN
1161 csi_gen_utility_pvt.put_line('ERROR FROM JTF_USR_HKS.Ok_to_execute API Create Post Vertical');
1162 RAISE FND_API.G_EXC_ERROR;
1163 END;
1164 -- End of POST User Hooks
1165
1166
1167
1168 EXCEPTION
1169
1170 WHEN FND_API.G_EXC_ERROR THEN
1171 x_return_status := FND_API.G_RET_STS_ERROR ;
1172 ROLLBACK TO create_item_instance;
1173 FND_MSG_PUB.Count_And_Get
1174 ( p_count => x_msg_count,
1175 p_data => x_msg_data
1176 );
1177
1178 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1179 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1180 ROLLBACK TO create_item_instance;
1181 FND_MSG_PUB.Count_And_Get
1182 ( p_count => x_msg_count,
1183 p_data => x_msg_data
1184 );
1185
1186 WHEN OTHERS THEN
1187 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1188 ROLLBACK TO create_item_instance;
1189 IF FND_MSG_PUB.Check_Msg_Level
1190 (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1191 THEN
1192 FND_MSG_PUB.Add_Exc_Msg
1193 (G_PKG_NAME,
1194 l_api_name
1195 );
1196 END IF;
1197 FND_MSG_PUB.Count_And_Get
1198 ( p_count => x_msg_count,
1199 p_data => x_msg_data
1200 );
1201
1202 END create_item_instance;
1203
1204 /*----------------------------------------------------*/
1205 /* Procedure name: update_item_instance */
1206 /* Description : procedure used to update an Item */
1207 /* Instance */
1208 /*----------------------------------------------------*/
1209
1210 PROCEDURE update_item_instance
1211 (
1212 p_api_version IN NUMBER
1213 ,p_commit IN VARCHAR2
1214 ,p_init_msg_list IN VARCHAR2
1215 ,p_validation_level IN NUMBER
1216 ,p_instance_rec IN csi_datastructures_pub.instance_rec
1217 ,p_ext_attrib_values_tbl IN OUT NOCOPY csi_datastructures_pub.extend_attrib_values_tbl
1218 ,p_party_tbl IN OUT NOCOPY csi_datastructures_pub.party_tbl
1219 ,p_account_tbl IN OUT NOCOPY csi_datastructures_pub.party_account_tbl
1220 ,p_pricing_attrib_tbl IN OUT NOCOPY csi_datastructures_pub.pricing_attribs_tbl
1221 ,p_org_assignments_tbl IN OUT NOCOPY csi_datastructures_pub.organization_units_tbl
1222 ,p_asset_assignment_tbl IN OUT NOCOPY csi_datastructures_pub.instance_asset_tbl
1223 ,p_txn_rec IN OUT NOCOPY csi_datastructures_pub.transaction_rec
1224 ,x_instance_id_lst OUT NOCOPY csi_datastructures_pub.id_tbl
1225 ,x_return_status OUT NOCOPY VARCHAR2
1226 ,x_msg_count OUT NOCOPY NUMBER
1227 ,x_msg_data OUT NOCOPY VARCHAR2
1228 )
1229
1230 IS
1231 l_api_name CONSTANT VARCHAR2(30) := 'UPDATE_ITEM_INSTANCE';
1232 l_api_version CONSTANT NUMBER := 1.0;
1233 l_debug_level NUMBER;
1234 l_instance_rec csi_datastructures_pub.instance_rec;
1235 l_temp_instance_rec csi_datastructures_pub.instance_rec;
1236 l_new_instance_rec csi_datastructures_pub.instance_rec := p_instance_rec;
1237 l_config_instance_rec csi_datastructures_pub.instance_rec ;
1238 l_config_temp_rec csi_datastructures_pub.instance_rec ;
1239 l_party_tbl csi_datastructures_pub.party_tbl;
1240 l_account_tbl csi_datastructures_pub.party_account_tbl;
1241 l_party_row NUMBER := 1;
1242 l_acct_row NUMBER := 1;
1243 l_msg_count NUMBER;
1244 l_msg_data VARCHAR2(2000);
1245 l_msg_index NUMBER;
1246 l_line_count NUMBER;
1247 l_flag VARCHAR2(1):='N';
1248 l_transaction_type VARCHAR2(10) := NULL;
1249 l_old_oks_cp_rec oks_ibint_pub.cp_rec_type;
1250 l_new_oks_cp_rec oks_ibint_pub.cp_rec_type;
1251 l_contracts_status VARCHAR2(3);
1252 l_account_id NUMBER;
1253 l_owner_party_id NUMBER;
1254 l_transaction_date DATE ;
1255 l_internal_party_id NUMBER;
1256 l_party_id NUMBER;
1257 l_active_end_date DATE;
1258 l_dummy VARCHAR2(1);
1259 l_version_label_rec csi_datastructures_pub.version_label_rec;
1260 l_item_attribute_tbl csi_item_instance_pvt.item_attribute_tbl;
1261 l_location_tbl csi_item_instance_pvt.location_tbl;
1262 l_generic_id_tbl csi_item_instance_pvt.generic_id_tbl;
1263 l_lookup_tbl csi_item_instance_pvt.lookup_tbl;
1264 l_ins_count_rec csi_item_instance_pvt.ins_count_rec;
1265 l_ou_lookup_tbl csi_organization_unit_pvt.lookup_tbl;
1266 l_ou_count_rec csi_organization_unit_pvt.ou_count_rec;
1267 l_ou_id_tbl csi_organization_unit_pvt.ou_id_tbl;
1268 l_ext_id_tbl csi_item_instance_pvt.ext_id_tbl;
1269 l_ext_count_rec csi_item_instance_pvt.ext_count_rec;
1270 l_ext_attr_tbl csi_item_instance_pvt.ext_attr_tbl;
1271 l_ext_cat_tbl csi_item_instance_pvt.ext_cat_tbl;
1272 l_asset_lookup_tbl csi_asset_pvt.lookup_tbl;
1273 l_asset_count_rec csi_asset_pvt.asset_count_rec;
1274 l_asset_id_tbl csi_asset_pvt.asset_id_tbl;
1275 l_asset_loc_tbl csi_asset_pvt.asset_loc_tbl;
1276 l_updated BOOLEAN := FALSE;
1277 l_date BOOLEAN := FALSE;
1278 l_curr_party_id NUMBER; -- Added for 2972082
1279 l_cascade_party_tbl csi_datastructures_pub.party_tbl; -- Added for 2972082
1280 l_cascade_account_tbl csi_datastructures_pub.party_account_tbl; -- Added for 2972082
1281 l_found BOOLEAN := FALSE; -- Added for 2972082
1282 -- The following were added for att
1283 l_component_ins_type VARCHAR2(1):=NULL;
1284 l_config_hdr_id NUMBER;
1285 l_config_rev_nbr NUMBER;
1286 l_config_key csi_utility_grp.config_instance_key;
1287 l_config_valid_status VARCHAR2(10);
1288 l_no_config_keys BOOLEAN := FALSE;
1289 l_return_message VARCHAR2(100);
1290 l_order_line_id NUMBER;
1291 l_party_slot NUMBER;
1292 l_tmp_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
1293 l_bump_date DATE;
1294 -- Begin Add Code for Siebel Genesis Project
1295 l_source_code VARCHAR2(30);
1296 l_raise_bes_event VARCHAR2(1) := nvl(fnd_profile.value('CSI_RAISE_BES_CUST_OWNED_INSTANCES'),'N');
1297 l_link_to_line_Id NUMBER;
1298 l_item_type_code VARCHAR2(30);
1299 l_root_asset_id NUMBER;
1300 l_subject_id NUMBER;
1301 l_object_id NUMBER;
1302 l_relationship_type_code VARCHAR2(30);
1303 l_relationship_exists VARCHAR2(1);
1304 l_instance_id NUMBER; -- Bug #5912182
1305 -- End Add Code for Siebel Genesis Project
1306 -- end addition
1307 CURSOR instance_csr (p_ins_id IN NUMBER) IS
1308 SELECT *
1309 FROM csi_item_instances
1310 WHERE instance_id = p_ins_id;
1311 l_instance_csr instance_csr%ROWTYPE;
1312
1313 CURSOR old_ins_csr (p_ins_id IN NUMBER) IS
1314 SELECT *
1315 FROM csi_item_instances
1316 WHERE instance_id=p_ins_id;
1317
1318 l_old_ins_csr old_ins_csr%ROWTYPE;
1319 -- Start of defining variables for bug 2172968
1320
1321 l_create NUMBER;
1322 l_update NUMBER;
1323 l_p_id NUMBER;
1324 l_t_party_tbl csi_datastructures_pub.party_tbl;
1325 l_t_account_tbl csi_datastructures_pub.party_account_tbl;
1326 l_new_party_tbl csi_datastructures_pub.party_tbl;
1327 l_new_account_tbl csi_datastructures_pub.party_account_tbl;
1328 lb_party_tbl csi_datastructures_pub.party_tbl;
1329 lc_party_tbl csi_datastructures_pub.party_tbl;
1330 l_temp_party_tbl csi_datastructures_pub.party_tbl;
1331 la_account_tbl csi_datastructures_pub.party_account_tbl;
1332 l_temp_acct_tbl csi_datastructures_pub.party_account_tbl;
1333
1334 -- End of defining variables for bug 2172968
1335
1336 CURSOR config_ins_key (p_config_hdr_id NUMBER, p_config_rev_nbr NUMBER) is
1337 SELECT instance_hdr_id
1338 ,config_item_id
1339 ,has_failures
1340 FROM cz_config_details_v d
1341 ,cz_config_hdrs_v h
1342 WHERE d.instance_hdr_id = h.config_hdr_id
1343 AND d.instance_rev_nbr = h.config_rev_nbr
1344 AND d.component_instance_type = 'I'
1345 AND d.config_hdr_id = p_config_hdr_id
1346 AND d.config_rev_nbr = p_config_rev_nbr;
1347
1348 CURSOR instance_key (p_config_inst_hdr_id NUMBER, p_config_inst_item_id NUMBER)is
1349 SELECT instance_id
1350 ,object_version_number
1351 ,config_valid_status
1352 FROM csi_item_instances
1353 WHERE config_inst_hdr_id=p_config_inst_hdr_id
1354 AND config_inst_item_id=p_config_inst_item_id;
1355
1356 CURSOR new_config_ins_key (p_config_ins_hdr_id NUMBER, p_config_ins_rev_nbr NUMBER) is
1357 SELECT has_failures
1358 ,config_status
1359 FROM cz_config_details_v d
1360 ,cz_config_hdrs h
1361 WHERE d.instance_hdr_id = p_config_ins_hdr_id
1362 AND d.instance_rev_nbr = p_config_ins_rev_nbr
1363 -- AND d.component_instance_type = 'I'
1364 AND d.config_hdr_id = h.config_hdr_id
1365 AND d.config_rev_nbr = h.config_rev_nbr;
1366
1367 CURSOR new_instance_key (p_config_inst_hdr_id NUMBER, p_config_inst_item_id NUMBER)is
1368 SELECT instance_id
1369 ,object_version_number
1370 ,config_valid_status
1371 FROM csi_item_instances
1372 WHERE config_inst_hdr_id=p_config_inst_hdr_id
1373 AND config_inst_item_id=p_config_inst_item_id;
1374 ------------------------------------------added-----------
1375 CURSOR non_owner_csr (p_ins_pty_id NUMBER) IS
1376 SELECT ip_account_id
1377 ,active_end_date
1378 ,object_version_number
1379 from csi_ip_accounts
1380 where instance_party_id=p_ins_pty_id
1381 and relationship_type_code<>'OWNER';
1382 l_tem_acct_tbl csi_datastructures_pub.party_account_tbl;
1383 l_tem_party_id NUMBER:=NULL;
1384 l_temp_var NUMBER:=1;
1385 l_bacct_row NUMBER;
1386 ------------------------------------------end addition ---
1387 l_batch_hdr_id NUMBER;
1388 l_batch_rev_nbr NUMBER;
1389 l_instance_id_lst csi_datastructures_pub.id_tbl;
1390 l_config_ins_rec csi_datastructures_pub.instance_rec;
1391 l_config_tmp_rec csi_datastructures_pub.instance_rec;
1392 l_lock_status NUMBER;
1393 --
1394 px_oks_txn_inst_tbl OKS_IBINT_PUB.TXN_INSTANCE_TBL;
1395 px_child_inst_tbl csi_item_instance_grp.child_inst_tbl;
1396 l_batch_type VARCHAR2(50);
1397 l_batch_id NUMBER;
1398
1399 BEGIN
1400 -- Standard Start of API savepoint
1401 SAVEPOINT update_item_instance;
1402
1403 -- srramakr fix for Bug # 2909878
1404 -- Bug 3804960 commented the following as we are not going to use l_date.
1405 -- We need to honor the end_date passed to instance_rec
1406 /**** IF p_ext_attrib_values_tbl.count > 0 OR
1407 p_party_tbl.count > 0 OR
1408 p_account_tbl.count > 0 OR
1409 p_pricing_attrib_tbl.count > 0 OR
1410 p_org_assignments_tbl.count > 0 OR
1411 p_asset_assignment_tbl.count > 0 THEN
1412 IF p_instance_rec.active_end_date <= sysdate -- srramakr changed to <=
1413 THEN
1414 l_date:=TRUE;
1415 END IF;
1416 END IF; ***/
1417 --
1418 IF p_instance_rec.active_end_date IS NOT NULL AND
1419 p_instance_rec.active_end_date <> FND_API.G_MISS_DATE THEN
1420 p_txn_rec.src_txn_creation_date := p_instance_rec.active_end_date;
1421 END IF;
1422 --
1423 -- End of 3804960
1424 -- Check for freeze_flag in csi_install_parameters is set to 'Y'
1425 csi_utility_grp.check_ib_active;
1426
1427 -- Standard call to check for call compatibility.
1428 IF NOT FND_API.Compatible_API_Call (l_api_version,
1429 p_api_version,
1430 l_api_name ,
1431 G_PKG_NAME )
1432 THEN
1433 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1434 END IF;
1435
1436 -- Initialize message list if p_init_msg_list is set to TRUE.
1437 IF FND_API.to_Boolean( p_init_msg_list ) THEN
1438 FND_MSG_PUB.initialize;
1439 END IF;
1440
1441 -- Initialize API return status to success
1442 x_return_status := FND_API.G_RET_STS_SUCCESS;
1443
1444 -- Check the profile option debug_level for debug message reporting
1445 l_debug_level:=fnd_profile.value('CSI_DEBUG_LEVEL');
1446
1447 -- If debug_level = 1 then dump the procedure name
1448 IF (l_debug_level > 0) THEN
1449 csi_gen_utility_pvt.put_line( 'update_item_instance');
1450 END IF;
1451
1452 -- If the debug level = 2 then dump all the parameters values.
1453 IF (l_debug_level > 1) THEN
1454 csi_gen_utility_pvt.put_line( 'update_item_instance' ||
1455 p_api_version ||'-'||
1456 p_commit ||'-'||
1457 p_init_msg_list ||'-'||
1458 p_validation_level );
1459 csi_gen_utility_pvt.dump_instance_rec(p_instance_rec);
1460 csi_gen_utility_pvt.dump_party_tbl(p_party_tbl);
1461 csi_gen_utility_pvt.dump_txn_rec(p_txn_rec);
1462 csi_gen_utility_pvt.dump_organization_unit_tbl(p_org_assignments_tbl);
1463 csi_gen_utility_pvt.dump_pricing_attribs_tbl(p_pricing_attrib_tbl);
1464 csi_gen_utility_pvt.dump_party_account_tbl(p_account_tbl);
1465 csi_gen_utility_pvt.dump_ext_attrib_values_tbl(p_ext_attrib_values_tbl);
1466 END IF;
1467
1468 /***** srramakr commented for bug # 3304439
1469 -- Check for the profile option and enable trace
1470 l_flag:=CSI_GEN_UTILITY_PVT.enable_trace(l_trace_flag => l_flag);
1471 -- End enable trace
1472 ****/
1473 -- Start API body
1474 IF csi_datastructures_pub.g_install_param_rec.fetch_flag IS NULL THEN
1475 csi_gen_utility_pvt.populate_install_param_rec;
1476 END IF;
1477 --
1478 l_internal_party_id := csi_datastructures_pub.g_install_param_rec.internal_party_id;
1479 --
1480 IF l_internal_party_id IS NULL THEN
1481 FND_MESSAGE.SET_NAME('CSI','CSI_API_UNINSTALLED_PARAMETER');
1482 FND_MSG_PUB.ADD;
1483 RAISE FND_API.G_EXC_ERROR;
1484 END IF;
1485
1486 -- Begin Add Code for Siebel Genesis Project
1487 csi_gen_utility_pvt.put_line('Inside CSI_ITEM_INSTANCE_PUB.Update_Item_Instance');
1488 csi_gen_utility_pvt.put_line('p_instance_rec = '||to_char(p_instance_rec.instance_id));
1489 -- End Add Code for Siebel Genesis Project
1490
1491 --Added for MACD lock functionality
1492 IF NOT (csi_Item_Instance_Pvt.Anything_To_Update(p_instance_rec => p_instance_rec ))
1493 THEN
1494 -- If Anything is getting updated then lock check will be made in pvt.
1495 IF p_instance_rec.instance_id IS NOT NULL AND
1496 p_instance_rec.instance_id <> fnd_api.g_miss_num
1497 THEN
1498 csi_item_instance_pvt.get_instance_lock_status
1499 ( p_instance_id => p_instance_rec.instance_id ,
1500 p_lock_status => l_lock_status
1501 );
1502 IF (p_txn_rec.transaction_type_id = 401 AND
1503 l_lock_status = 1) OR
1504 (l_lock_status = 0)
1505 THEN
1506 NULL;
1507 ELSE
1508 FND_MESSAGE.SET_NAME('CSI','CSI_INSTANCE_LOCKED');
1509 FND_MESSAGE.SET_TOKEN('INSTANCE_ID',p_instance_rec.instance_id);
1510 FND_MSG_PUB.ADD;
1511 RAISE FND_API.G_EXC_ERROR;
1512 END IF;
1513 END IF;
1514 END IF;
1515 -- End addition for MACD lock functionality
1516 -- Call Pre Customer User Hook
1517 BEGIN
1518 IF JTF_USR_HKS.Ok_to_execute(G_PKG_NAME, l_api_name, 'B', 'C' ) THEN
1519 csi_gen_utility_pvt.put_line('Calling CSI_ITEM_INSTANCE_CUHK.Update_Item_Instance_Pre ..');
1520 CSI_ITEM_INSTANCE_CUHK.Update_Item_Instance_Pre
1521 (
1522 p_api_version => 1.0
1523 ,p_commit => fnd_api.g_false
1524 ,p_init_msg_list => fnd_api.g_false
1525 ,p_validation_level => fnd_api.g_valid_level_full
1526 ,p_instance_rec => p_instance_rec
1527 ,p_ext_attrib_values_tbl => p_ext_attrib_values_tbl
1528 ,p_party_tbl => p_party_tbl
1529 ,p_account_tbl => p_account_tbl
1530 ,p_pricing_attrib_tbl => p_pricing_attrib_tbl
1531 ,p_org_assignments_tbl => p_org_assignments_tbl
1532 ,p_asset_assignment_tbl => p_asset_assignment_tbl
1533 ,p_txn_rec => p_txn_rec
1534 ,x_instance_id_lst => x_instance_id_lst
1535 ,x_return_status => x_return_status
1536 ,x_msg_count => x_msg_count
1537 ,x_msg_data => x_msg_data
1538 );
1539 --
1540 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1541 l_msg_index := 1;
1542 l_msg_count := x_msg_count;
1543 WHILE l_msg_count > 0 LOOP
1544 x_msg_data := FND_MSG_PUB.GET
1545 ( l_msg_index,
1546 FND_API.G_FALSE );
1547 csi_gen_utility_pvt.put_line('ERROR FROM CSI_ITEM_INSTANCE_CUHK.Update_Item_Instance_Pre API ');
1548 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
1549 l_msg_index := l_msg_index + 1;
1550 l_msg_count := l_msg_count - 1;
1551 END LOOP;
1552 RAISE FND_API.G_EXC_ERROR;
1553 END IF;
1554 --
1555 END IF;
1556
1557 EXCEPTION
1558 WHEN OTHERS THEN
1559 csi_gen_utility_pvt.put_line('ERROR FROM JTF_USR_HKS.Ok_to_execute API Update Pre Customer');
1560 RAISE FND_API.G_EXC_ERROR;
1561 END;
1562 --
1563 -- Call Pre Vertical user Hook
1564 BEGIN
1565 IF JTF_USR_HKS.Ok_to_execute(G_PKG_NAME, l_api_name, 'B', 'V' ) THEN
1566 csi_gen_utility_pvt.put_line('Calling CSI_ITEM_INSTANCE_VUHK.Update_Item_Instance_Pre ..');
1567 CSI_ITEM_INSTANCE_VUHK.Update_Item_Instance_Pre
1568 (
1569 p_api_version => 1.0
1570 ,p_commit => fnd_api.g_false
1571 ,p_init_msg_list => fnd_api.g_false
1572 ,p_validation_level => fnd_api.g_valid_level_full
1573 ,p_instance_rec => p_instance_rec
1574 ,p_ext_attrib_values_tbl => p_ext_attrib_values_tbl
1575 ,p_party_tbl => p_party_tbl
1576 ,p_account_tbl => p_account_tbl
1577 ,p_pricing_attrib_tbl => p_pricing_attrib_tbl
1578 ,p_org_assignments_tbl => p_org_assignments_tbl
1579 ,p_asset_assignment_tbl => p_asset_assignment_tbl
1580 ,p_txn_rec => p_txn_rec
1581 ,x_instance_id_lst => x_instance_id_lst
1582 ,x_return_status => x_return_status
1583 ,x_msg_count => x_msg_count
1584 ,x_msg_data => x_msg_data
1585 );
1586 --
1587 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1588 l_msg_index := 1;
1589 l_msg_count := x_msg_count;
1590 WHILE l_msg_count > 0 LOOP
1591 x_msg_data := FND_MSG_PUB.GET
1592 ( l_msg_index,
1593 FND_API.G_FALSE );
1594 csi_gen_utility_pvt.put_line('ERROR FROM CSI_ITEM_INSTANCE_VUHK.Update_Item_Instance_Pre API ');
1595 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
1596 l_msg_index := l_msg_index + 1;
1597 l_msg_count := l_msg_count - 1;
1598 END LOOP;
1599 RAISE FND_API.G_EXC_ERROR;
1600 END IF;
1601 END IF;
1602 EXCEPTION
1603 WHEN OTHERS THEN
1604 csi_gen_utility_pvt.put_line('ERROR FROM JTF_USR_HKS.Ok_to_execute API Update Pre Vertical');
1605 RAISE FND_API.G_EXC_ERROR;
1606 END;
1607 -- End of PRE User Hooks
1608 --
1609 -- This will fetch old instance data for the purpose of contracts
1610 BEGIN
1611 OPEN old_ins_csr (p_instance_rec.instance_id);
1612 FETCH old_ins_csr INTO l_old_ins_csr;
1613 CLOSE old_ins_csr;
1614 EXCEPTION
1615 WHEN OTHERS THEN
1616 NULL;
1617 END;
1618
1619 BEGIN
1620 SELECT cip.party_id
1621 INTO l_owner_party_id
1622 FROM csi_i_parties cip
1623 WHERE cip.instance_id = p_instance_rec.instance_id
1624 AND cip.relationship_type_code = 'OWNER';
1625 EXCEPTION
1626 WHEN OTHERS THEN
1627 NULL;
1628 END;
1629
1630 -- Following are the cascade ownership changes for
1631 -- bug 2972082
1632 IF p_instance_rec.cascade_ownership_flag IS NOT NULL AND
1633 p_instance_rec.cascade_ownership_flag='Y'
1634 THEN
1635 csi_gen_utility_pvt.put_line('Cascade_ownership_flag :'||p_instance_rec.cascade_ownership_flag);
1636 IF p_party_tbl.count > 0
1637 THEN
1638 FOR l_party_rec IN p_party_tbl.FIRST .. p_party_tbl.LAST
1639 LOOP
1640 IF p_party_tbl.EXISTS(l_party_rec)
1641 THEN
1642 IF p_party_tbl(l_party_rec).instance_id = p_instance_rec.instance_id AND
1643 p_party_tbl(l_party_rec).relationship_type_code = 'OWNER'
1644 THEN
1645 -- Assigning cascade_ownership_flag with a value true
1646 p_party_tbl(l_party_rec).cascade_ownership_flag:='Y';
1647
1648 IF p_party_tbl(l_party_rec).party_id<>l_internal_party_id
1649 THEN
1650 IF p_account_tbl.count>0
1651 THEN
1652 FOR l_acct_rec IN p_account_tbl.FIRST .. p_account_tbl.LAST
1653 LOOP
1654 IF p_account_tbl.EXISTS(l_acct_rec)
1655 THEN
1656 IF p_account_tbl(l_acct_rec).instance_party_id=
1657 p_party_tbl(l_party_rec).instance_party_id AND
1658 p_account_tbl(l_acct_rec).relationship_type_code='OWNER'
1659 THEN
1660 l_found:=TRUE;
1661 END IF;
1662 END IF;
1663 END LOOP;
1664 END IF;
1665 ELSE
1666 l_found:= TRUE;
1667 END IF;
1668 END IF;
1669 END IF;
1670 END LOOP;
1671 IF NOT(l_found)
1672 THEN
1673 csi_gen_utility_pvt.put_line('Owner party or account information is not passed for the instance');
1674 csi_gen_utility_pvt.put_line(',which you are trying to cascade the ownership.');
1675 RAISE FND_API.G_EXC_ERROR;
1676 END IF;
1677 ELSE
1678 -- Since party information is not passed so I need to build the party and account
1679 -- information.
1680 -- In the party record assign cascade_ownership_flag with a value fnd_api.g_true.
1681 BEGIN
1682 SELECT instance_party_id,
1683 instance_id,
1684 party_source_table,
1685 party_id,
1686 relationship_type_code,
1687 contact_flag,
1688 object_version_number,
1689 'Y'
1690 INTO l_cascade_party_tbl(1).instance_party_id,
1691 l_cascade_party_tbl(1).instance_id,
1692 l_cascade_party_tbl(1).party_source_table,
1693 l_cascade_party_tbl(1).party_id,
1694 l_cascade_party_tbl(1).relationship_type_code,
1695 l_cascade_party_tbl(1).contact_flag,
1696 l_cascade_party_tbl(1).object_version_number,
1697 l_cascade_party_tbl(1).cascade_ownership_flag
1698 FROM csi_i_parties
1699 WHERE instance_id=p_instance_rec.instance_id
1700 AND relationship_type_code='OWNER'
1701 AND (active_end_date IS NULL OR active_end_date>sysdate);
1702
1703 p_party_tbl:=l_cascade_party_tbl;
1704
1705 EXCEPTION
1706 WHEN OTHERS
1707 THEN
1708 csi_gen_utility_pvt.put_line('Owner party information not found for the instance');
1709 csi_gen_utility_pvt.put_line(',which you are trying to cascade the ownership.');
1710 RAISE FND_API.G_EXC_ERROR;
1711 END;
1712
1713
1714 IF l_cascade_party_tbl(1).party_id <> l_internal_party_id
1715 THEN
1716 -- Here I need to build account record
1717 BEGIN
1718 SELECT ip_account_id,
1719 instance_party_id,
1720 party_account_id,
1721 relationship_type_code,
1722 1,
1723 object_version_number
1724 INTO l_cascade_account_tbl(1).ip_account_id,
1725 l_cascade_account_tbl(1).instance_party_id,
1726 l_cascade_account_tbl(1).party_account_id,
1727 l_cascade_account_tbl(1).relationship_type_code,
1728 l_cascade_account_tbl(1).parent_tbl_index,
1729 l_cascade_account_tbl(1).object_version_number
1730 FROM csi_ip_accounts
1731 WHERE instance_party_id=l_cascade_party_tbl(1).instance_party_id
1732 AND relationship_type_code='OWNER'
1733 AND (active_end_date IS NULL OR active_end_date>sysdate);
1734 IF p_account_tbl.count>0
1735 THEN
1736 p_account_tbl(p_account_tbl.count+1):=l_cascade_account_tbl(1);
1737 ELSE
1738 p_account_tbl:=l_cascade_account_tbl;
1739 END IF;
1740 EXCEPTION
1741 WHEN OTHERS THEN
1742 csi_gen_utility_pvt.put_line('Owner account information not found for the instance');
1743 csi_gen_utility_pvt.put_line(',which you are trying to cascade the ownership');
1744 RAISE FND_API.G_EXC_ERROR;
1745 END;
1746 END IF; -- End of building account record.
1747 END IF; -- End of party building party record.
1748 END IF; -- End of cascade ownership check.
1749
1750 -- End of cascade ownership changes for
1751 -- bug 2972082
1752
1753 --
1754 --
1755 -- The following code has been added to assign call_contracts
1756 -- false so that contracts call can be made only once.
1757 /* -- Commented by sguthiva for bug 2307804
1758 IF (p_account_tbl.count > 0) THEN
1759 FOR tab_row IN p_account_tbl.FIRST .. p_account_tbl.LAST
1760 LOOP
1761 IF p_account_tbl.EXISTS(tab_row)
1762 THEN
1763 IF p_account_tbl(tab_row).instance_party_id = l_owner_party_id
1764 AND p_account_tbl(tab_row).instance_party_id IS NOT NULL
1765 AND p_account_tbl(tab_row).instance_party_id <> fnd_api.g_miss_num
1766 AND l_owner_party_id IS NOT NULL
1767 THEN
1768 p_account_tbl(tab_row).call_contracts := fnd_api.g_false;
1769 p_account_tbl(tab_row).vld_organization_id := p_instance_rec.vld_organization_id;
1770 END IF;
1771 END IF;
1772 END LOOP;
1773 END IF;
1774 -- End fetching old instance data for the purpose of contracts
1775 */ -- End commentation by sguthiva for bug 2307804
1776 -- IF any of the instance columns are changing then call the update_item_instance private api
1777 IF (csi_Item_Instance_Pvt.Anything_To_Update(p_instance_rec => p_instance_rec ))
1778 THEN
1779
1780 l_new_instance_rec := p_instance_rec;
1781
1782 IF (p_party_tbl.count > 0) THEN
1783 FOR tab_row IN p_party_tbl.FIRST .. p_party_tbl.LAST
1784 LOOP
1785 IF p_party_tbl.EXISTS(tab_row) THEN
1786 IF ((p_party_tbl(tab_row).instance_party_id IS NOT NULL) AND
1787 (p_party_tbl(tab_row).instance_party_id <> FND_API.G_MISS_NUM))THEN
1788 l_new_instance_rec.accounting_class_code := NULL;
1789 END IF;
1790 END IF;
1791 END LOOP;
1792 END IF;
1793
1794 -- If Ownership is changing from Internal to External then OKS call should be made only at Account update level.
1795 -- The call should be suppressed at instance level. This is true for child instances also.
1796 -- Hence instance_rec.call_contracts is set to FLASE which eventually gets passed to child instances where the
1797 -- check is made.
1798 --
1799 l_party_slot := NULL;
1800 IF l_owner_party_id = l_internal_party_id THEN
1801 IF p_party_tbl.count > 0 THEN
1802 FOR party_rec in p_party_tbl.FIRST .. p_party_tbl.LAST LOOP
1803 IF p_party_tbl.EXISTS(party_rec) THEN
1804 IF p_party_tbl(party_rec).instance_id = p_instance_rec.instance_id AND
1805 p_party_tbl(party_rec).relationship_type_code = 'OWNER' AND
1806 p_party_tbl(party_rec).party_id IS NOT NULL AND
1807 p_party_tbl(party_rec).party_id <> FND_API.G_MISS_NUM AND
1808 p_party_tbl(party_rec).party_id <> l_internal_party_id THEN
1809 l_party_slot := party_rec;
1810 -- Added
1811 l_new_instance_rec.owner_party_id:=p_party_tbl(party_rec).party_id;
1812 exit;
1813 END IF;
1814 END IF;
1815 END LOOP;
1816 IF l_party_slot IS NOT NULL AND
1817 p_account_tbl.count > 0 THEN
1818 FOR acct_rec in p_account_tbl.FIRST .. p_account_tbl.LAST LOOP
1819 IF p_account_tbl.EXISTS(acct_rec) THEN
1820 IF p_account_tbl(acct_rec).parent_tbl_index = l_party_slot AND
1821 p_account_tbl(acct_rec).relationship_type_code = 'OWNER' THEN
1822 l_new_instance_rec.call_contracts := FND_API.G_FALSE; -- since p_instance_rec is IN parameter
1823 csi_gen_utility_pvt.put_line('Instance Rec Call contracts set to FALSE');
1824 exit;
1825 END IF;
1826 END IF;
1827 END LOOP;
1828 END IF;
1829 END IF;
1830 END IF;
1831 --
1832 -- Similarly if the ownership is transferred from external to internal then
1833 -- make the call to contracts during party update and supress it at instance level.
1834 -- If this instance has a configuration then for the child instance, contracts call will be supressed
1835 -- for TRM txn type in Update_Child_Instance_Location by looking at the instance_rec.call_contracts.
1836 IF l_owner_party_id <> l_internal_party_id AND
1837 p_party_tbl.count > 0 THEN
1838 FOR party_rec in p_party_tbl.FIRST .. p_party_tbl.LAST LOOP
1839 IF p_party_tbl.EXISTS(party_rec) THEN
1840 IF p_party_tbl(party_rec).instance_id = p_instance_rec.instance_id AND
1841 p_party_tbl(party_rec).relationship_type_code = 'OWNER' AND
1842 p_party_tbl(party_rec).party_id = l_internal_party_id THEN
1843 l_new_instance_rec.call_contracts := FND_API.G_FALSE; -- since p_instance_rec is IN parameter
1844 -- Added
1845 l_new_instance_rec.owner_party_id:=p_party_tbl(party_rec).party_id;
1846 csi_gen_utility_pvt.put_line('Instance Rec Call contracts set to FALSE');
1847 exit;
1848 END IF;
1849 END IF;
1850 END LOOP;
1851 END IF;
1852 --
1853 IF (p_asset_assignment_tbl.count > 0) THEN
1854 l_new_instance_rec.accounting_class_code := NULL;
1855 END IF;
1856 --
1857 --
1858 -- srramakr fix for Bug # 2909878
1859 IF p_ext_attrib_values_tbl.count > 0 OR
1860 p_party_tbl.count > 0 OR
1861 p_account_tbl.count > 0 OR
1862 p_pricing_attrib_tbl.count > 0 OR
1863 p_org_assignments_tbl.count > 0 OR
1864 p_asset_assignment_tbl.count > 0 OR
1865 -- Added the following code for bug 4350017
1866 ((p_instance_rec.config_inst_hdr_id IS NOT NULL AND
1867 p_instance_rec.config_inst_hdr_id <> fnd_api.g_miss_num) AND
1868 (p_instance_rec.config_inst_item_id IS NOT NULL AND
1869 p_instance_rec.config_inst_item_id <> fnd_api.g_miss_num) AND
1870 (p_instance_rec.config_inst_rev_num IS NOT NULL AND
1871 p_instance_rec.config_inst_rev_num <> fnd_api.g_miss_num)
1872 )
1873 -- End code addition for bug 4350017
1874 THEN
1875 IF l_new_instance_rec.active_end_date IS NOT NULL
1876 AND l_new_instance_rec.active_end_date <> fnd_api.g_miss_date
1877 AND l_new_instance_rec.active_end_date <= SYSDATE
1878 THEN
1879 l_new_instance_rec.active_end_date:=fnd_api.g_miss_date;
1880 l_new_instance_rec.instance_status_id:=fnd_api.g_miss_num; -- srramakr Fix for Bug # 2766216
1881 l_updated:=TRUE;
1882 END IF;
1883 END IF;
1884 -- Call the update_item_instance private API to update the instances
1885 csi_item_instance_pvt.update_item_instance
1886 (
1887 p_api_version => p_api_version
1888 ,p_commit => fnd_api.g_false
1889 ,p_init_msg_list => p_init_msg_list
1890 ,p_validation_level => p_validation_level
1891 ,p_instance_rec => l_new_instance_rec
1892 ,p_txn_rec => p_txn_rec
1893 ,x_instance_id_lst => x_instance_id_lst
1894 ,x_return_status => x_return_status
1895 ,x_msg_count => x_msg_count
1896 ,x_msg_data => x_msg_data
1897 ,p_item_attribute_tbl => l_item_attribute_tbl
1898 ,p_location_tbl => l_location_tbl
1899 ,p_generic_id_tbl => l_generic_id_tbl
1900 ,p_lookup_tbl => l_lookup_tbl
1901 ,p_ins_count_rec => l_ins_count_rec
1902 ,p_oks_txn_inst_tbl => px_oks_txn_inst_tbl
1903 ,p_child_inst_tbl => px_child_inst_tbl
1904 );
1905
1906 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1907 l_msg_index := 1;
1908 l_msg_count := x_msg_count;
1909 WHILE l_msg_count > 0 LOOP
1910 x_msg_data := FND_MSG_PUB.GET
1911 ( l_msg_index,
1912 FND_API.G_FALSE );
1913 csi_gen_utility_pvt.put_line( 'Error from UPDATE_ITEM_INSTANCE_PVT..');
1914 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
1915 l_msg_index := l_msg_index + 1;
1916 l_msg_count := l_msg_count - 1;
1917 END LOOP;
1918 RAISE FND_API.G_EXC_ERROR;
1919 END IF;
1920 -- Calling Contracts for Quantity Change
1921 IF p_instance_rec.quantity IS NOT NULL AND
1922 p_instance_rec.quantity <> FND_API.G_MISS_NUM AND
1923 p_instance_rec.quantity <> 0 AND -- Supress 'UPD' call if Qty drops to 0
1924 l_old_ins_csr.quantity <> p_instance_rec.quantity THEN
1925 IF l_owner_party_id IS NOT NULL AND
1926 l_owner_party_id <> l_internal_party_id THEN
1927 IF p_txn_rec.transaction_type_id <> 7 -- Added for bug 3973706
1928 THEN
1929 CSI_Item_Instance_Pvt.Call_to_Contracts
1930 ( p_transaction_type => 'UPD'
1931 ,p_instance_id => p_instance_rec.instance_id
1932 ,p_new_instance_id => NULL
1933 ,p_vld_org_id => p_instance_rec.vld_organization_id
1934 ,p_quantity => l_old_ins_csr.quantity -- Passing the Old qty
1935 ,p_party_account_id1 => NULL
1936 ,p_party_account_id2 => NULL
1937 ,p_transaction_date => p_txn_rec.transaction_date -- Refer 3483763
1938 ,p_source_transaction_date => p_txn_rec.source_transaction_date -- Added jpwilson
1939 ,p_txn_type_id => p_txn_rec.transaction_type_id
1940 ,p_oks_txn_inst_tbl => px_oks_txn_inst_tbl
1941 ,x_return_status => x_return_status
1942 ,x_msg_count => x_msg_count
1943 ,x_msg_data => x_msg_data
1944 );
1945 --
1946 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1947 l_msg_index := 1;
1948 l_msg_count := x_msg_count;
1949 WHILE l_msg_count > 0 LOOP
1950 x_msg_data := FND_MSG_PUB.GET
1951 ( l_msg_index,
1952 FND_API.G_FALSE
1953 );
1954 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
1955 l_msg_index := l_msg_index + 1;
1956 l_msg_count := l_msg_count - 1;
1957 END LOOP;
1958 RAISE FND_API.G_EXC_ERROR;
1959 END IF;
1960 END IF; -- Added for bug 3973706
1961
1962 END IF;
1963 END IF;
1964 --
1965 -- Caliing Contracts for Install Date Change
1966 IF ( (p_instance_rec.install_date IS NULL AND
1967 l_old_ins_csr.install_date IS NOT NULL) OR
1968 (p_instance_rec.install_date IS NOT NULL AND
1969 p_instance_rec.install_date <> FND_API.G_MISS_DATE AND
1970 nvl(l_old_ins_csr.install_date,FND_API.G_MISS_DATE) <> p_instance_rec.install_date) ) THEN
1971 IF l_owner_party_id IS NOT NULL AND
1972 l_owner_party_id <> l_internal_party_id THEN
1973 CSI_Item_Instance_Pvt.Call_to_Contracts
1974 ( p_transaction_type => 'IDC'
1975 ,p_instance_id => p_instance_rec.instance_id
1976 ,p_new_instance_id => NULL
1977 ,p_vld_org_id => p_instance_rec.vld_organization_id
1978 ,p_quantity => p_instance_rec.quantity
1979 ,p_party_account_id1 => NULL
1980 ,p_party_account_id2 => NULL
1981 ,p_transaction_date => p_txn_rec.transaction_date -- Refer 3483763
1982 ,p_source_transaction_date => p_txn_rec.source_transaction_date -- Added jpwilson
1983 ,p_oks_txn_inst_tbl => px_oks_txn_inst_tbl
1984 ,x_return_status => x_return_status
1985 ,x_msg_count => x_msg_count
1986 ,x_msg_data => x_msg_data
1987 );
1988 --
1989 IF x_return_status = 'W' THEN -- Warning from OKS
1990 l_tmp_return_status := 'W';
1991 l_msg_index := 1;
1992 l_msg_count := x_msg_count;
1993 WHILE l_msg_count > 0 LOOP
1994 x_msg_data := FND_MSG_PUB.GET
1995 ( l_msg_index,
1996 FND_API.G_FALSE
1997 );
1998 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
1999 l_msg_index := l_msg_index + 1;
2000 l_msg_count := l_msg_count - 1;
2001 END LOOP;
2002 FND_MSG_PUB.Count_And_Get
2003 ( p_count => x_msg_count,
2004 p_data => x_msg_data
2005 );
2006 ELSIF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2007 l_msg_index := 1;
2008 l_msg_count := x_msg_count;
2009 WHILE l_msg_count > 0 LOOP
2010 x_msg_data := FND_MSG_PUB.GET
2011 ( l_msg_index,
2012 FND_API.G_FALSE
2013 );
2014 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
2015 l_msg_index := l_msg_index + 1;
2016 l_msg_count := l_msg_count - 1;
2017 END LOOP;
2018 RAISE FND_API.G_EXC_ERROR;
2019 END IF;
2020 END IF;
2021 END IF;
2022 END IF;
2023 --
2024 x_return_status := l_tmp_return_status;
2025 -- Call Post Customer User Hook
2026 BEGIN
2027
2028 IF JTF_USR_HKS.Ok_to_execute(G_PKG_NAME, l_api_name, 'A', 'C' ) THEN
2029 csi_gen_utility_pvt.put_line('Calling CSI_ITEM_INSTANCE_CUHK.Update_Item_Instance_Post ..');
2030 CSI_ITEM_INSTANCE_CUHK.Update_Item_Instance_Post
2031 (
2032 p_api_version => 1.0
2033 ,p_commit => fnd_api.g_false
2034 ,p_init_msg_list => fnd_api.g_false
2035 ,p_validation_level => fnd_api.g_valid_level_full
2036 ,p_instance_rec => p_instance_rec
2037 ,p_ext_attrib_values_tbl => p_ext_attrib_values_tbl
2038 ,p_party_tbl => p_party_tbl
2039 ,p_account_tbl => p_account_tbl
2040 ,p_pricing_attrib_tbl => p_pricing_attrib_tbl
2041 ,p_org_assignments_tbl => p_org_assignments_tbl
2042 ,p_asset_assignment_tbl => p_asset_assignment_tbl
2043 ,p_txn_rec => p_txn_rec
2044 ,x_instance_id_lst => x_instance_id_lst
2045 ,x_return_status => x_return_status
2046 ,x_msg_count => x_msg_count
2047 ,x_msg_data => x_msg_data
2048 );
2049 --
2050 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2051 l_msg_index := 1;
2052 l_msg_count := x_msg_count;
2053 WHILE l_msg_count > 0 LOOP
2054 x_msg_data := FND_MSG_PUB.GET
2055 ( l_msg_index,
2056 FND_API.G_FALSE );
2057 csi_gen_utility_pvt.put_line('ERROR FROM CSI_ITEM_INSTANCE_CUHK.Update_Item_Instance_Post API ');
2058 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
2059 l_msg_index := l_msg_index + 1;
2060 l_msg_count := l_msg_count - 1;
2061 END LOOP;
2062 RAISE FND_API.G_EXC_ERROR;
2063 END IF;
2064 END IF;
2065
2066 EXCEPTION
2067 WHEN OTHERS THEN
2068 csi_gen_utility_pvt.put_line('ERROR FROM JTF_USR_HKS.Ok_to_execute API Update Post Customer');
2069 RAISE FND_API.G_EXC_ERROR;
2070 END;
2071 --
2072 x_return_status := l_tmp_return_status;
2073
2074 -- Call the update_party_relationship API to update instance-to-party
2075 -- relationships.
2076 -- START MODIFICATION BY SK for bug 2172968
2077 l_t_party_tbl := p_party_tbl;
2078 l_t_account_tbl := p_account_tbl;
2079
2080 -- p_party_tbl has been replaced by l_t_party_tbl
2081 -- p_account_tbl has been replaced by l_t_account_tbl
2082 -- l_party_tbl has been replaced by l_new_party_tbl
2083 -- l_account_tbl has been replaced by l_new_account_tbl
2084 -- Above changes were made so as not to break the existing code.
2085 l_party_row := 1;
2086 l_acct_row := 1;
2087 l_bacct_row := 1;
2088 l_create:=1;
2089 l_update:=1;
2090 IF (l_t_party_tbl.count > 0) THEN
2091 FOR party_row IN l_t_party_tbl.FIRST .. l_t_party_tbl.LAST
2092 LOOP
2093 IF l_t_party_tbl.EXISTS(party_row) THEN
2094 IF ((l_t_party_tbl(party_row).instance_party_id IS NULL)
2095 OR
2096 (l_t_party_tbl(party_row).instance_party_id = FND_API.G_MISS_NUM))
2097 THEN
2098 -- The following code has been written to take of creating the contacts
2099 -- no matter the order which they are passed. So I'm grabbing the contacts
2100 -- into another temp table lb_party_tbl which I will make use in the seperate
2101 -- call during create_inst_party_relationship.
2102 IF l_t_party_tbl(party_row).contact_ip_id IS NOT NULL AND
2103 l_t_party_tbl(party_row).contact_ip_id <> FND_API.G_MISS_NUM
2104 THEN
2105 lb_party_tbl(l_create):= l_t_party_tbl(party_row);
2106 l_t_party_tbl.DELETE(party_row);
2107 l_create:=l_create+1;
2108 ELSE
2109 l_new_party_tbl(l_party_row) := l_t_party_tbl(party_row);
2110 l_t_party_tbl.DELETE(party_row);
2111 END IF;
2112 -- Grab all its accounts in a temprorary account table
2113 -- The following code has been written to take care the accounts for
2114 -- other than OWNER party.
2115
2116 IF l_t_account_tbl.COUNT > 0 THEN
2117 FOR acct_row IN l_t_account_tbl.FIRST .. l_t_account_tbl.LAST
2118 LOOP
2119 IF l_t_account_tbl.EXISTS(acct_row) THEN
2120 IF (l_t_account_tbl(acct_row).parent_tbl_index = l_party_row ) THEN --changed
2121 la_account_tbl(l_bacct_row) := l_t_account_tbl(acct_row);
2122 la_account_tbl(l_bacct_row).parent_tbl_index := l_party_row;
2123 l_t_account_tbl.DELETE(acct_row);
2124 l_bacct_row := l_bacct_row + 1;
2125 END IF;
2126 END IF;
2127 END LOOP;
2128 END IF;
2129
2130 ELSE
2131 -- The following code has been written to take care the accounts for the
2132 -- OWNER party.
2133 lc_party_tbl(l_update) := l_t_party_tbl(party_row);
2134 l_t_party_tbl.DELETE(party_row);
2135
2136 IF l_t_account_tbl.COUNT > 0 THEN
2137 FOR acct_row IN l_t_account_tbl.FIRST .. l_t_account_tbl.LAST
2138 LOOP
2139 IF l_t_account_tbl.EXISTS(acct_row) THEN
2140 IF (l_t_account_tbl(acct_row).parent_tbl_index = l_party_row ) THEN --change
2141 l_new_account_tbl(l_acct_row) := l_t_account_tbl(acct_row);
2142 l_new_account_tbl(l_acct_row).parent_tbl_index := l_update;
2143 l_t_account_tbl.DELETE(acct_row);
2144 l_acct_row := l_acct_row + 1;
2145 END IF;
2146 END IF;
2147 END LOOP;
2148 END IF;
2149 l_update:=l_update+1;
2150 END IF;
2151 l_party_row := l_party_row + 1;
2152 END IF;
2153 END LOOP;
2154 END IF;
2155
2156 -- Update the parties,contacts and its accounts
2157 IF (lc_party_tbl.count > 0) THEN
2158
2159 -- The following changes were made to make sure to associate
2160 -- accounts belonging to owner party to a newly created
2161 -- non owner parties.
2162 IF lc_party_tbl.COUNT > 0
2163 THEN
2164 FOR i IN 1..lc_party_tbl.COUNT
2165 LOOP
2166 IF lc_party_tbl.EXISTS(i)
2167 THEN
2168 BEGIN
2169 l_tem_party_id:=NULL;
2170 SELECT party_id
2171 INTO l_tem_party_id
2172 FROM csi_i_parties
2173 WHERE instance_party_id=lc_party_tbl(i).instance_party_id
2174 AND relationship_type_code='OWNER';
2175 EXCEPTION
2176 WHEN OTHERS THEN
2177 l_tem_party_id:=NULL;
2178 END;
2179 IF l_tem_party_id IS NOT NULL AND
2180 lc_party_tbl(i).party_id <> l_tem_party_id AND
2181 lc_party_tbl(i).relationship_type_code='OWNER'
2182 THEN
2183 FOR j IN non_owner_csr(lc_party_tbl(i).instance_party_id)
2184 LOOP
2185 l_tem_acct_tbl(l_temp_var).ip_account_id:=j.ip_account_id;
2186 l_tem_acct_tbl(l_temp_var).object_version_number:=j.object_version_number;
2187 l_tem_acct_tbl(l_temp_var).active_end_date:=j.active_end_date;
2188 l_temp_var:=l_temp_var+1;
2189 END LOOP;
2190
2191 -- This loop has been written to take care of contacts issue.
2192 -- When ever there is a transfer ownership then all the contacts
2193 -- will get expired.
2194 -- Contact object_version_numbers need to be bumped up
2195 -- bug 2933430
2196
2197 FOR k IN i..lc_party_tbl.COUNT
2198 LOOP
2199 IF lc_party_tbl(k).contact_ip_id=lc_party_tbl(i).instance_party_id
2200 AND lc_party_tbl(k).contact_flag='Y'
2201 THEN
2202 -- Commented for bug 3376233
2203 -- lc_party_tbl(k).object_version_number:=lc_party_tbl(k).object_version_number+1;
2204 l_bump_date:=null;
2205 -- IF lc_party_tbl(k).active_end_date = fnd_api.g_miss_date
2206 -- THEN
2207 BEGIN
2208 SELECT active_end_date
2209 INTO l_bump_date --lc_party_tbl(k).active_end_date
2210 FROM csi_i_parties
2211 WHERE instance_party_id=lc_party_tbl(k).instance_party_id;
2212
2213 -- Added the following if condition for bug 3376233.
2214 IF l_bump_date IS NULL OR
2215 l_bump_date > SYSDATE
2216 THEN
2217 -- We need to bump up this record as it is active and will
2218 -- get expired during transfer of ownership.
2219 -- For those records which were already expired, there is no
2220 -- need to bump up the version number.
2221 IF lc_party_tbl(k).active_end_date = fnd_api.g_miss_date
2222 THEN
2223 lc_party_tbl(k).active_end_date:=l_bump_date;
2224 END IF;
2225 lc_party_tbl(k).object_version_number:=lc_party_tbl(k).object_version_number+1;
2226 END IF;
2227
2228
2229
2230 EXCEPTION
2231 WHEN NO_DATA_FOUND THEN
2232 NULL;
2233 END;
2234 -- END IF;
2235 END IF;
2236 END LOOP;
2237
2238 -- End addition for contacts bug 2933430
2239
2240 END IF;
2241 END IF;
2242 END LOOP;
2243 END IF;
2244 --
2245 csi_party_relationships_pub.update_inst_party_relationship
2246 (p_api_version => p_api_version
2247 ,p_commit => fnd_api.g_false
2248 ,p_init_msg_list => p_init_msg_list
2249 ,p_validation_level => p_validation_level
2250 ,p_party_tbl => lc_party_tbl
2251 ,p_party_account_tbl=> l_new_account_tbl
2252 ,p_txn_rec => p_txn_rec
2253 ,p_oks_txn_inst_tbl => px_oks_txn_inst_tbl
2254 ,x_return_status => x_return_status
2255 ,x_msg_count => x_msg_count
2256 ,x_msg_data => x_msg_data
2257 );
2258
2259 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2260 l_msg_index := 1;
2261 l_msg_count := x_msg_count;
2262 WHILE l_msg_count > 0
2263 LOOP
2264 x_msg_data := FND_MSG_PUB.GET
2265 ( l_msg_index,
2266 FND_API.G_FALSE );
2267 csi_gen_utility_pvt.put_line('Error from CSI_PARTY_RELATIONSHIPS_PUB.. ');
2268 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
2269 l_msg_index := l_msg_index + 1;
2270 l_msg_count := l_msg_count - 1;
2271 END LOOP;
2272 RAISE FND_API.G_EXC_ERROR;
2273 END IF;
2274 END IF;
2275 --
2276 x_return_status := l_tmp_return_status;
2277 -- Create the parties and its accounts
2278 IF l_new_party_tbl.COUNT > 0 THEN
2279 -- The following changes were made to make sure to associate
2280 -- accounts belonging to owner party to a newly created
2281 -- non owner parties.
2282 IF la_account_tbl.COUNT > 0
2283 THEN
2284 FOR i IN 1..la_account_tbl.COUNT
2285 LOOP
2286 IF la_account_tbl.EXISTS(i)
2287 THEN
2288 IF l_tem_acct_tbl.COUNT>0
2289 THEN
2290 FOR j IN 1..l_tem_acct_tbl.COUNT
2291 LOOP
2292 IF la_account_tbl.EXISTS(i) AND
2293 la_account_tbl(i).ip_account_id=l_tem_acct_tbl(j).ip_account_id
2294 THEN
2295 /*
2296 la_account_tbl(i).object_version_number:=l_tem_acct_tbl(j).object_version_number+1;
2297 IF la_account_tbl(i).active_end_date=fnd_api.g_miss_date
2298 THEN
2299 la_account_tbl(i).active_end_date:=l_tem_acct_tbl(j).active_end_date;
2300 END IF;
2301 */
2302 -- The following code is added for bug 3594408 (Rel 11.5.9)
2303 BEGIN
2304 SELECT object_version_number
2305 INTO la_account_tbl(i).object_version_number
2306 FROM csi_ip_accounts
2307 WHERE ip_account_id=la_account_tbl(i).ip_account_id;
2308 EXCEPTION
2309 WHEN NO_DATA_FOUND THEN
2310 NULL;
2311 END;
2312 -- End addition for bug 3594408 (Rel 11.5.9)
2313 END IF;
2314 END LOOP;
2315 END IF;
2316 END IF;
2317 END LOOP;
2318 END IF;
2319 csi_party_relationships_pub.create_inst_party_relationship
2320 ( p_api_version => p_api_version
2321 ,p_commit => fnd_api.g_false
2322 ,p_init_msg_list => p_init_msg_list
2323 ,p_validation_level => p_validation_level
2324 ,p_party_tbl => l_new_party_tbl
2325 ,p_party_account_tbl => la_account_tbl
2326 ,p_txn_rec => p_txn_rec
2327 ,p_oks_txn_inst_tbl => px_oks_txn_inst_tbl
2328 ,x_return_status => x_return_status
2329 ,x_msg_count => x_msg_count
2330 ,x_msg_data => x_msg_data
2331 );
2332 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2333 l_msg_index := 1;
2334 l_msg_count := x_msg_count;
2335 WHILE l_msg_count > 0 LOOP
2336 x_msg_data := FND_MSG_PUB.GET
2337 ( l_msg_index,
2338 FND_API.G_FALSE );
2339 csi_gen_utility_pvt.put_line('Error from CSI_PARTY_RELATIONSHIPS_PUB.. ');
2340 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
2341 l_msg_index := l_msg_index + 1;
2342 l_msg_count := l_msg_count - 1;
2343 END LOOP;
2344 RAISE FND_API.G_EXC_ERROR;
2345 END IF;
2346 END IF;
2347 x_return_status := l_tmp_return_status;
2348
2349 -- Create the contacts for oooo.
2350
2351 IF lb_party_tbl.COUNT > 0 THEN
2352 csi_party_relationships_pub.create_inst_party_relationship
2353 ( p_api_version => p_api_version
2354 ,p_commit => fnd_api.g_false
2355 ,p_init_msg_list => p_init_msg_list
2356 ,p_validation_level => p_validation_level
2357 ,p_party_tbl => lb_party_tbl
2358 ,p_party_account_tbl => l_temp_acct_tbl
2359 ,p_txn_rec => p_txn_rec
2360 ,p_oks_txn_inst_tbl => px_oks_txn_inst_tbl
2361 ,x_return_status => x_return_status
2362 ,x_msg_count => x_msg_count
2363 ,x_msg_data => x_msg_data
2364 );
2365 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2366 l_msg_index := 1;
2367 l_msg_count := x_msg_count;
2368 WHILE l_msg_count > 0 LOOP
2369 x_msg_data := FND_MSG_PUB.GET
2370 ( l_msg_index,
2371 FND_API.G_FALSE );
2372 csi_gen_utility_pvt.put_line('Error from CSI_PARTY_RELATIONSHIPS_PUB.. ');
2373 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
2374 l_msg_index := l_msg_index + 1;
2375 l_msg_count := l_msg_count - 1;
2376 END LOOP;
2377 RAISE FND_API.G_EXC_ERROR;
2378 END IF;
2379 END IF;
2380 x_return_status := l_tmp_return_status;
2381
2382 -- END MODIFICATION BY SK for bug 2172968
2383
2384
2385 -- Since some rows were deleted in accounts we need to add them up
2386 IF ((p_account_tbl.count > 0)
2387 OR (l_account_tbl.count > 0)) THEN
2388
2389 IF p_party_tbl.count = 0 THEN
2390 l_acct_row := l_account_tbl.LAST + 1;
2391 ELSE
2392
2393 l_acct_row := p_account_tbl.LAST + 1;
2394 IF l_acct_row IS NULL THEN
2395 l_acct_row := 1;
2396 END IF;
2397 END IF;
2398
2399 IF l_account_tbl.count > 0 THEN
2400 FOR acct_row IN l_account_tbl.FIRST .. l_account_tbl.LAST
2401 LOOP
2402 IF l_account_tbl.EXISTS(acct_row) THEN
2403 p_account_tbl(l_acct_row) := l_account_tbl(acct_row);
2404 l_acct_row := l_acct_row + 1;
2405 END IF;
2406 END LOOP;
2407 END IF;
2408 END IF;
2409
2410
2411 -- Call update_organization_unit to associate any org. assignments
2412 -- to the item instance
2413 IF (p_org_assignments_tbl.count > 0) THEN
2414 FOR tab_row IN p_org_assignments_tbl.FIRST .. p_org_assignments_tbl.LAST
2415 LOOP
2416 IF p_org_assignments_tbl.EXISTS(tab_row) THEN
2417 IF ((p_org_assignments_tbl(tab_row).instance_ou_id IS NULL)
2418 OR
2419 (p_org_assignments_tbl(tab_row).instance_ou_id = FND_API.G_MISS_NUM))
2420 THEN
2421 csi_organization_unit_pvt.create_organization_unit
2422 (p_api_version => p_api_version
2423 ,p_commit => fnd_api.g_false
2424 ,p_init_msg_list => p_init_msg_list
2425 ,p_validation_level => p_validation_level
2426 ,p_org_unit_rec => p_org_assignments_tbl(tab_row)
2427 ,p_txn_rec => p_txn_rec
2428 ,x_return_status => x_return_status
2429 ,x_msg_count => x_msg_count
2430 ,x_msg_data => x_msg_data
2431 ,p_lookup_tbl => l_ou_lookup_tbl
2432 ,p_ou_count_rec => l_ou_count_rec
2433 ,p_ou_id_tbl => l_ou_id_tbl
2434 );
2435 ELSE
2436 csi_organization_unit_pvt.update_organization_unit
2437 (p_api_version => p_api_version
2438 ,p_commit => fnd_api.g_false
2439 ,p_init_msg_list => p_init_msg_list
2440 ,p_validation_level => p_validation_level
2441 ,p_org_unit_rec => p_org_assignments_tbl(tab_row)
2442 ,p_txn_rec => p_txn_rec
2443 ,x_return_status => x_return_status
2444 ,x_msg_count => x_msg_count
2445 ,x_msg_data => x_msg_data
2446 ,p_lookup_tbl => l_ou_lookup_tbl
2447 ,p_ou_count_rec => l_ou_count_rec
2448 ,p_ou_id_tbl => l_ou_id_tbl
2449 );
2450 END IF;
2451 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2452 l_msg_index := 1;
2453 l_msg_count := x_msg_count;
2454 WHILE l_msg_count > 0 LOOP
2455 x_msg_data := FND_MSG_PUB.GET
2456 ( l_msg_index,
2457 FND_API.G_FALSE );
2458 csi_gen_utility_pvt.put_line( ' Error from CSI_ORGANIZATION_UNIT_PUB..');
2459 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
2460 l_msg_index := l_msg_index + 1;
2461 l_msg_count := l_msg_count - 1;
2462 END LOOP;
2463 RAISE FND_API.G_EXC_ERROR;
2464 END IF;
2465 END IF;
2466 END LOOP;
2467 END IF;
2468 x_return_status := l_tmp_return_status;
2469
2470 -- Call update_pricing_attribs to associate any pricing attributes
2471 -- to the item instance
2472 IF (p_pricing_attrib_tbl.count > 0) THEN
2473 FOR tab_row IN p_pricing_attrib_tbl.FIRST .. p_pricing_attrib_tbl.LAST
2474 LOOP
2475 IF p_pricing_attrib_tbl.EXISTS(tab_row) THEN
2476 IF ((p_pricing_attrib_tbl(tab_row).pricing_attribute_id IS NULL)
2477 OR
2478 (p_pricing_attrib_tbl(tab_row).pricing_attribute_id = FND_API.G_MISS_NUM))
2479 THEN
2480 csi_pricing_attribs_pvt.create_pricing_attribs
2481 ( p_api_version => p_api_version
2482 ,p_commit => p_commit
2483 ,p_init_msg_list => p_init_msg_list
2484 ,p_validation_level => p_validation_level
2485 ,p_pricing_attribs_rec => p_pricing_attrib_tbl(tab_row)
2486 ,p_txn_rec => p_txn_rec
2487 ,x_return_status => x_return_status
2488 ,x_msg_count => x_msg_count
2489 ,x_msg_data => x_msg_data
2490 );
2491 ELSE
2492 csi_pricing_attribs_pvt.update_pricing_attribs
2493 ( p_api_version => p_api_version
2494 ,p_commit => fnd_api.g_false
2495 ,p_init_msg_list => p_init_msg_list
2496 ,p_validation_level => p_validation_level
2497 ,p_pricing_attribs_rec => p_pricing_attrib_tbl(tab_row)
2498 ,p_txn_rec => p_txn_rec
2499 ,x_return_status => x_return_status
2500 ,x_msg_count => x_msg_count
2501 ,x_msg_data => x_msg_data
2502 );
2503 END IF;
2504
2505 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2506 l_msg_index := 1;
2507 l_msg_count := x_msg_count;
2508 WHILE l_msg_count > 0 LOOP
2509 x_msg_data := FND_MSG_PUB.GET
2510 ( l_msg_index,
2511 FND_API.G_FALSE );
2512 csi_gen_utility_pvt.put_line( ' Error from CSI_PRICING_ATTRIBS_PUB..');
2513 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
2514 l_msg_index := l_msg_index + 1;
2515 l_msg_count := l_msg_count - 1;
2516 END LOOP;
2517 RAISE FND_API.G_EXC_ERROR;
2518 END IF;
2519 END IF;
2520 END LOOP;
2521 END IF;
2522 x_return_status := l_tmp_return_status;
2523
2524 -- Call create_extended_attribs to associate any extended attributes
2525 -- to the item instance
2526 IF (p_ext_attrib_values_tbl.count > 0) THEN
2527 FOR tab_row IN p_ext_attrib_values_tbl.FIRST .. p_ext_attrib_values_tbl.LAST
2528 LOOP
2529 IF p_ext_attrib_values_tbl.EXISTS (tab_row) THEN
2530 IF ((p_ext_attrib_values_tbl(tab_row).attribute_value_id IS NULL)
2531 OR
2532 (p_ext_attrib_values_tbl(tab_row).attribute_value_id = FND_API.G_MISS_NUM))
2533 THEN
2534 csi_item_instance_pvt.create_extended_attrib_values
2535 ( p_api_version => p_api_version
2536 ,p_commit => fnd_api.g_false
2537 ,p_init_msg_list => p_init_msg_list
2538 ,p_validation_level => p_validation_level
2539 ,p_ext_attrib_rec => p_ext_attrib_values_tbl(tab_row)
2540 ,p_txn_rec => p_txn_rec
2541 ,x_return_status => x_return_status
2542 ,x_msg_count => x_msg_count
2543 ,x_msg_data => x_msg_data
2544 ,p_ext_id_tbl => l_ext_id_tbl
2545 ,p_ext_count_rec => l_ext_count_rec
2546 ,p_ext_attr_tbl => l_ext_attr_tbl
2547 ,p_ext_cat_tbl => l_ext_cat_tbl
2548 );
2549 ELSE
2550 -- call the update extended attributes api
2551 csi_item_instance_pvt.update_extended_attrib_values
2552 ( p_api_version => p_api_version
2553 ,p_commit => fnd_api.g_false
2554 ,p_init_msg_list => p_init_msg_list
2555 ,p_validation_level => p_validation_level
2556 ,p_ext_attrib_rec => p_ext_attrib_values_tbl(tab_row)
2557 ,p_txn_rec => p_txn_rec
2558 ,x_return_status => x_return_status
2559 ,x_msg_count => x_msg_count
2560 ,x_msg_data => x_msg_data
2561 -- ,p_ext_id_tbl => l_ext_id_tbl
2562 -- ,p_ext_count_rec => l_ext_count_rec
2563 -- ,p_ext_attr_tbl => l_ext_attr_tbl
2564 -- ,p_ext_cat_tbl => l_ext_cat_tbl
2565 );
2566 END IF;
2567 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2568 l_msg_index := 1;
2569 l_msg_count := x_msg_count;
2570 WHILE l_msg_count > 0 LOOP
2571 x_msg_data := FND_MSG_PUB.GET
2572 ( l_msg_index,
2573 FND_API.G_FALSE );
2574 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
2575 l_msg_index := l_msg_index + 1;
2576 l_msg_count := l_msg_count - 1;
2577 END LOOP;
2578 RAISE FND_API.G_EXC_ERROR;
2579 END IF;
2580 END IF; -- exist if
2581 END LOOP; -- for loop
2582 END IF;
2583 x_return_status := l_tmp_return_status;
2584
2585 -- Call create_asset_assignments to associate any assets associated
2586 -- to the item instance
2587 IF (p_asset_assignment_tbl.count > 0) THEN
2588 FOR tab_row IN p_asset_assignment_tbl.FIRST .. p_asset_assignment_tbl.LAST
2589 LOOP
2590 IF p_asset_assignment_tbl.EXISTS(tab_row) THEN
2591 IF ((p_asset_assignment_tbl(tab_row).instance_asset_id IS NULL)
2592 OR
2593 (p_asset_assignment_tbl(tab_row).instance_asset_id = FND_API.G_MISS_NUM)) THEN
2594 csi_asset_pvt.create_instance_asset
2595 (p_api_version => p_api_version
2596 ,p_commit => fnd_api.g_false
2597 ,p_init_msg_list => p_init_msg_list
2598 ,p_validation_level => p_validation_level
2599 ,p_instance_asset_rec => p_asset_assignment_tbl(tab_row)
2600 ,p_txn_rec => p_txn_rec
2601 ,x_return_status => x_return_status
2602 ,x_msg_count => x_msg_count
2603 ,x_msg_data => x_msg_data
2604 ,p_lookup_tbl => l_asset_lookup_tbl
2605 ,p_asset_count_rec => l_asset_count_rec
2606 ,p_asset_id_tbl => l_asset_id_tbl
2607 ,p_asset_loc_tbl => l_asset_loc_tbl
2608 );
2609 ELSE
2610 --call the update assets api
2611 csi_asset_pvt.update_instance_asset
2612 (p_api_version => p_api_version
2613 ,p_commit => fnd_api.g_false
2614 ,p_init_msg_list => p_init_msg_list
2615 ,p_validation_level => p_validation_level
2616 ,p_instance_asset_rec => p_asset_assignment_tbl(tab_row)
2617 ,p_txn_rec => p_txn_rec
2618 ,x_return_status => x_return_status
2619 ,x_msg_count => x_msg_count
2620 ,x_msg_data => x_msg_data
2621 ,p_lookup_tbl => l_asset_lookup_tbl
2622 ,p_asset_count_rec => l_asset_count_rec
2623 ,p_asset_id_tbl => l_asset_id_tbl
2624 ,p_asset_loc_tbl => l_asset_loc_tbl
2625 );
2626 END IF;
2627 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2628 l_msg_index := 1;
2629 l_msg_count := x_msg_count;
2630 WHILE l_msg_count > 0 LOOP
2631 x_msg_data := FND_MSG_PUB.GET
2632 ( l_msg_index,
2633 FND_API.G_FALSE );
2634 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
2635 l_msg_index := l_msg_index + 1;
2636 l_msg_count := l_msg_count - 1;
2637 END LOOP;
2638 RAISE FND_API.G_EXC_ERROR;
2639 END IF;
2640 END IF;
2641 END LOOP;
2642 END IF;
2643 x_return_status := l_tmp_return_status;
2644
2645 -- Start att enhancements
2646 IF p_instance_rec.call_batch_validation<>fnd_api.g_false
2647 THEN
2648 IF p_instance_rec.instance_id IS NOT NULL AND
2649 p_instance_rec.instance_id <> fnd_api.g_miss_num
2650 THEN
2651 IF ( l_old_ins_csr.config_inst_hdr_id IS NOT NULL
2652 AND (p_instance_rec.config_inst_hdr_id IS NULL OR p_instance_rec.config_inst_hdr_id = fnd_api.g_miss_num) )
2653 OR( l_old_ins_csr.config_inst_hdr_id IS NULL
2654 AND (p_instance_rec.config_inst_hdr_id IS NOT NULL AND p_instance_rec.config_inst_hdr_id <> fnd_api.g_miss_num) )
2655 OR( l_old_ins_csr.config_inst_hdr_id IS NOT NULL
2656 AND (p_instance_rec.config_inst_hdr_id IS NOT NULL AND p_instance_rec.config_inst_hdr_id <> fnd_api.g_miss_num)
2657 AND (l_old_ins_csr.config_inst_hdr_id <> p_instance_rec.config_inst_hdr_id) )
2658 OR( l_old_ins_csr.config_inst_item_id IS NOT NULL
2659 AND (p_instance_rec.config_inst_item_id IS NULL OR p_instance_rec.config_inst_item_id = fnd_api.g_miss_num) )
2660 OR( l_old_ins_csr.config_inst_item_id IS NULL
2661 AND (p_instance_rec.config_inst_item_id IS NOT NULL AND p_instance_rec.config_inst_item_id <> fnd_api.g_miss_num) )
2662 OR( l_old_ins_csr.config_inst_item_id IS NOT NULL
2663 AND (p_instance_rec.config_inst_item_id IS NOT NULL AND p_instance_rec.config_inst_item_id <> fnd_api.g_miss_num)
2664 AND (l_old_ins_csr.config_inst_item_id <> p_instance_rec.config_inst_item_id) )
2665 THEN
2666 l_no_config_keys:=TRUE;
2667 csi_gen_utility_pvt.put_line( 'Config keys were not provided. So no batch validation will be performed');
2668 END IF;
2669
2670 IF NOT l_no_config_keys
2671 THEN
2672 IF (p_instance_rec.config_inst_hdr_id IS NOT NULL AND p_instance_rec.config_inst_hdr_id <> fnd_api.g_miss_num)
2673 AND (p_instance_rec.config_inst_item_id IS NOT NULL AND p_instance_rec.config_inst_item_id <> fnd_api.g_miss_num)
2674 AND (p_instance_rec.config_inst_rev_num IS NOT NULL AND p_instance_rec.config_inst_rev_num <> fnd_api.g_miss_num)
2675 THEN
2676
2677 IF NOT csi_item_instance_vld_pvt.is_unique_config_key ( p_config_inst_hdr_id => p_instance_rec.config_inst_hdr_id
2678 ,p_config_inst_item_id => p_instance_rec.config_inst_item_id
2679 ,p_instance_id => p_instance_rec.instance_id
2680 ,p_validation_mode => 'UPDATE'
2681 )
2682 THEN
2683 FND_MESSAGE.SET_NAME('CSI','CSI_CONFIG_KEY_EXISTS');
2684 FND_MSG_PUB.Add;
2685 RAISE fnd_api.g_exc_error;
2686 END IF;
2687
2688 BEGIN
2689 SELECT component_instance_type
2690 ,config_hdr_id
2691 ,config_rev_nbr
2692 INTO l_component_ins_type
2693 ,l_config_hdr_id
2694 ,l_config_rev_nbr
2695 FROM cz_config_items_v
2696 WHERE instance_hdr_id = p_instance_rec.config_inst_hdr_id
2697 AND instance_rev_nbr = p_instance_rec.config_inst_rev_num
2698 AND config_item_id = p_instance_rec.config_inst_item_id;
2699 EXCEPTION
2700 WHEN OTHERS THEN
2701 FND_MESSAGE.SET_NAME('CSI','CSI_CONFIG_NOT_IN_CZ');
2702 FND_MESSAGE.SET_TOKEN('INSTANCE_HDR_ID',p_instance_rec.config_inst_hdr_id);
2703 FND_MESSAGE.SET_TOKEN('INSTANCE_REV_NBR',p_instance_rec.config_inst_rev_num);
2704 FND_MESSAGE.SET_TOKEN('CONFIG_ITEM_ID',p_instance_rec.config_inst_item_id);
2705
2706 FND_MSG_PUB.Add;
2707 RAISE FND_API.G_EXC_ERROR;
2708 END;
2709
2710 IF l_component_ins_type='I'
2711 THEN
2712
2713 Csi_item_instance_vld_pvt.Call_batch_validate
2714 ( p_instance_rec => p_instance_rec
2715 ,p_config_hdr_id => l_config_hdr_id
2716 ,p_config_rev_nbr => l_config_rev_nbr
2717 ,x_config_hdr_id => l_batch_hdr_id
2718 ,x_config_rev_nbr => l_batch_rev_nbr
2719 ,x_return_status => x_return_status);
2720
2721 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2722 FND_MESSAGE.SET_NAME('CSI','CSI_CONFIG_ERROR');
2723 FND_MSG_PUB.Add;
2724 csi_gen_utility_pvt.put_line('Call to batch validation has errored ');
2725 RAISE FND_API.G_EXC_ERROR;
2726 END IF;
2727 END IF;
2728
2729 ELSIF ( (p_instance_rec.config_inst_hdr_id IS NULL OR p_instance_rec.config_inst_hdr_id = fnd_api.g_miss_num)
2730 AND (p_instance_rec.config_inst_item_id IS NOT NULL AND p_instance_rec.config_inst_item_id <> fnd_api.g_miss_num))
2731 OR ( (p_instance_rec.config_inst_hdr_id IS NOT NULL AND p_instance_rec.config_inst_hdr_id <> fnd_api.g_miss_num)
2732 AND (p_instance_rec.config_inst_item_id IS NULL OR p_instance_rec.config_inst_item_id = fnd_api.g_miss_num))
2733 OR ( (p_instance_rec.config_inst_hdr_id IS NOT NULL AND p_instance_rec.config_inst_hdr_id <> fnd_api.g_miss_num)
2734 AND (p_instance_rec.config_inst_item_id IS NOT NULL AND p_instance_rec.config_inst_item_id <> fnd_api.g_miss_num)
2735 AND (p_instance_rec.config_inst_rev_num IS NULL OR p_instance_rec.config_inst_rev_num = fnd_api.g_miss_num))
2736 THEN
2737 FND_MESSAGE.SET_NAME('CSI','CSI_INVALID_CONFIG_COMB');
2738 FND_MSG_PUB.Add;
2739 RAISE fnd_api.g_exc_error;
2740 END IF;
2741 END IF;
2742 END IF;
2743 END IF;
2744 -- Adding new changes for bug 3799694
2745 IF (p_instance_rec.config_inst_hdr_id IS NOT NULL AND p_instance_rec.config_inst_hdr_id <> fnd_api.g_miss_num)
2746 AND (p_instance_rec.config_inst_item_id IS NOT NULL AND p_instance_rec.config_inst_item_id <> fnd_api.g_miss_num)
2747 AND (p_instance_rec.config_inst_rev_num IS NOT NULL AND p_instance_rec.config_inst_rev_num <> fnd_api.g_miss_num)
2748 THEN
2749 FOR l_config_ins_key IN new_config_ins_key(p_instance_rec.config_inst_hdr_id,p_instance_rec.config_inst_rev_num)
2750 LOOP
2751 IF l_config_ins_key.has_failures ='1'
2752 OR nvl(l_config_ins_key.config_status,'0') <> '2'
2753 THEN
2754 FOR l_instance_key IN new_instance_key(p_instance_rec.config_inst_hdr_id,p_instance_rec.config_inst_item_id)
2755 LOOP
2756
2757 l_config_instance_rec:=l_config_temp_rec;
2758 IF (l_instance_key.instance_id IS NOT NULL AND
2759 l_instance_key.instance_id <> fnd_api.g_miss_num) AND
2760 ( l_instance_key.config_valid_status IS NULL OR
2761 (l_instance_key.config_valid_status IS NOT NULL AND
2762 l_instance_key.config_valid_status <> '1'))
2763 THEN
2764 l_config_instance_rec.instance_id:=l_instance_key.instance_id;
2765 l_config_instance_rec.object_version_number:=l_instance_key.object_version_number;
2766 l_config_instance_rec.config_valid_status:='1'; --INVALID
2767
2768 csi_item_instance_pvt.update_item_instance
2769 (
2770 p_api_version => p_api_version
2771 ,p_commit => fnd_api.g_false
2772 ,p_init_msg_list => p_init_msg_list
2773 ,p_validation_level => p_validation_level
2774 ,p_instance_rec => l_config_instance_rec
2775 ,p_txn_rec => p_txn_rec
2776 ,x_instance_id_lst => l_instance_id_lst
2777 ,x_return_status => x_return_status
2778 ,x_msg_count => x_msg_count
2779 ,x_msg_data => x_msg_data
2780 ,p_item_attribute_tbl => l_item_attribute_tbl
2781 ,p_location_tbl => l_location_tbl
2782 ,p_generic_id_tbl => l_generic_id_tbl
2783 ,p_lookup_tbl => l_lookup_tbl
2784 ,p_ins_count_rec => l_ins_count_rec
2785 ,p_oks_txn_inst_tbl => px_oks_txn_inst_tbl
2786 ,p_child_inst_tbl => px_child_inst_tbl
2787 );
2788
2789 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2790 l_msg_index := 1;
2791 l_msg_count := x_msg_count;
2792 WHILE l_msg_count > 0 LOOP
2793 x_msg_data := FND_MSG_PUB.GET
2794 ( l_msg_index,
2795 FND_API.G_FALSE );
2796 csi_gen_utility_pvt.put_line( 'Error from UPDATE_ITEM_INSTANCE_PVT..');
2797 csi_gen_utility_pvt.put_line( 'while updating config status');
2798 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
2799 l_msg_index := l_msg_index + 1;
2800 l_msg_count := l_msg_count - 1;
2801 END LOOP;
2802 RAISE FND_API.G_EXC_ERROR;
2803 END IF;
2804 END IF;
2805 END LOOP;
2806 ELSE
2807 FOR l_instance_key IN new_instance_key(p_instance_rec.config_inst_hdr_id,p_instance_rec.config_inst_item_id)
2808 LOOP
2809 l_config_instance_rec:=l_config_temp_rec;
2810 IF (l_instance_key.instance_id IS NOT NULL AND
2811 l_instance_key.instance_id <> fnd_api.g_miss_num) AND
2812 ( l_instance_key.config_valid_status IS NULL OR
2813 (l_instance_key.config_valid_status IS NOT NULL AND
2814 l_instance_key.config_valid_status <> '0'))
2815 THEN
2816 l_config_instance_rec.instance_id:=l_instance_key.instance_id;
2817 l_config_instance_rec.object_version_number:=l_instance_key.object_version_number;
2818 l_config_instance_rec.config_valid_status:='0'; --VALID
2819 csi_item_instance_pvt.update_item_instance
2820 (
2821 p_api_version => p_api_version
2822 ,p_commit => fnd_api.g_false
2823 ,p_init_msg_list => p_init_msg_list
2824 ,p_validation_level => p_validation_level
2825 ,p_instance_rec => l_config_instance_rec
2826 ,p_txn_rec => p_txn_rec
2827 ,x_instance_id_lst => l_instance_id_lst
2828 ,x_return_status => x_return_status
2829 ,x_msg_count => x_msg_count
2830 ,x_msg_data => x_msg_data
2831 ,p_item_attribute_tbl => l_item_attribute_tbl
2832 ,p_location_tbl => l_location_tbl
2833 ,p_generic_id_tbl => l_generic_id_tbl
2834 ,p_lookup_tbl => l_lookup_tbl
2835 ,p_ins_count_rec => l_ins_count_rec
2836 ,p_oks_txn_inst_tbl => px_oks_txn_inst_tbl
2837 ,p_child_inst_tbl => px_child_inst_tbl
2838 );
2839
2840 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2841 l_msg_index := 1;
2842 l_msg_count := x_msg_count;
2843 WHILE l_msg_count > 0 LOOP
2844 x_msg_data := FND_MSG_PUB.GET
2845 ( l_msg_index,
2846 FND_API.G_FALSE );
2847 csi_gen_utility_pvt.put_line( 'Error from UPDATE_ITEM_INSTANCE_PVT..');
2848 csi_gen_utility_pvt.put_line( 'while updating config status');
2849 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
2850 l_msg_index := l_msg_index + 1;
2851 l_msg_count := l_msg_count - 1;
2852 END LOOP;
2853 RAISE FND_API.G_EXC_ERROR;
2854 END IF;
2855 END IF;
2856 END LOOP;
2857 END IF;
2858 END LOOP;
2859
2860 END IF;
2861
2862
2863 -- End addition of changes for bug 3799694
2864 x_return_status := l_tmp_return_status;
2865 -- End att enhancements
2866
2867 -- sguthiva Added the following for bug 2632869
2868 IF l_updated
2869 THEN
2870 l_instance_rec:=l_temp_instance_rec;
2871 l_instance_rec:=p_instance_rec;
2872 -- Bug 3804960 We need to honor the end_date passed to instance_rec
2873 /*** IF l_date
2874 THEN
2875 l_instance_rec.active_end_date:=SYSDATE;
2876 END IF; ***/
2877 -- End of 3804960
2878 l_instance_rec.call_contracts := l_new_instance_rec.call_contracts; -- added for avoiding multiple OKS calls
2879 BEGIN
2880 SELECT object_version_number
2881 INTO l_instance_rec.object_version_number
2882 FROM csi_item_instances
2883 WHERE instance_id=p_instance_rec.instance_id;
2884 EXCEPTION
2885 WHEN NO_DATA_FOUND THEN
2886 NULL;
2887 END;
2888 -- Call the update_item_instance private API to update the instances
2889 csi_item_instance_pvt.update_item_instance
2890 (
2891 p_api_version => p_api_version
2892 ,p_commit => fnd_api.g_false
2893 ,p_init_msg_list => p_init_msg_list
2894 ,p_validation_level => p_validation_level
2895 ,p_instance_rec => l_instance_rec
2896 ,p_txn_rec => p_txn_rec
2897 ,x_instance_id_lst => x_instance_id_lst
2898 ,x_return_status => x_return_status
2899 ,x_msg_count => x_msg_count
2900 ,x_msg_data => x_msg_data
2901 ,p_item_attribute_tbl => l_item_attribute_tbl
2902 ,p_location_tbl => l_location_tbl
2903 ,p_generic_id_tbl => l_generic_id_tbl
2904 ,p_lookup_tbl => l_lookup_tbl
2905 ,p_ins_count_rec => l_ins_count_rec
2906 ,p_oks_txn_inst_tbl => px_oks_txn_inst_tbl
2907 ,p_child_inst_tbl => px_child_inst_tbl
2908 );
2909
2910 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2911 l_msg_index := 1;
2912 l_msg_count := x_msg_count;
2913 WHILE l_msg_count > 0 LOOP
2914 x_msg_data := FND_MSG_PUB.GET
2915 ( l_msg_index,
2916 FND_API.G_FALSE );
2917 csi_gen_utility_pvt.put_line( 'Error from UPDATE_ITEM_INSTANCE_PVT..');
2918 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
2919 l_msg_index := l_msg_index + 1;
2920 l_msg_count := l_msg_count - 1;
2921 END LOOP;
2922 RAISE FND_API.G_EXC_ERROR;
2923 END IF;
2924 END IF;
2925 x_return_status := l_tmp_return_status;
2926 -- End addition for bug 2632869
2927
2928 -- Added by rtalluri for Bug 2256588 on 03/26/02
2929 -- Call the Version label API to associate a version label for the updated record
2930
2931 IF p_instance_rec.active_end_date = FND_API.G_MISS_DATE
2932 THEN
2933 BEGIN
2934 SELECT active_end_date
2935 INTO l_active_end_date
2936 FROM csi_item_instances
2937 WHERE instance_id = p_instance_rec.instance_id;
2938 EXCEPTION
2939 WHEN OTHERS THEN
2940 NULL;
2941 END;
2942 ELSE
2943 l_active_end_date := p_instance_rec.active_end_date;
2944 END IF;
2945
2946 IF ((l_active_end_date > SYSDATE) OR
2947 (l_active_end_date IS NULL))
2948 THEN
2949 IF ((p_instance_rec.version_label IS NOT NULL) AND
2950 (p_instance_rec.version_label <> FND_API.G_MISS_CHAR))
2951 THEN
2952 -- Check if version label already exists in csi_i_version_labels
2953 -- If exists then raise an error message
2954 BEGIN
2955
2956 SELECT 'x'
2957 INTO l_dummy
2958 FROM csi_i_version_labels
2959 WHERE instance_id = p_instance_rec.instance_id
2960 AND version_label = p_instance_rec.version_label
2961 AND ROWNUM=1;
2962
2963 fnd_message.set_name('CSI','CSI_VERSION_LABEL_EXIST');
2964 fnd_msg_pub.add;
2965 RAISE fnd_api.g_exc_error;
2966 EXCEPTION
2967 WHEN NO_DATA_FOUND THEN
2968 NULL;
2969 WHEN OTHERS THEN
2970 RAISE fnd_api.g_exc_error;
2971 END;
2972
2973 l_version_label_rec.instance_id := p_instance_rec.instance_id;
2974 l_version_label_rec.version_label := p_instance_rec.version_label;
2975 l_version_label_rec.description := p_instance_rec.version_label_description;
2976 l_version_label_rec.date_time_stamp := SYSDATE;
2977 -- calling create version label api
2978 csi_item_instance_pvt.create_version_label
2979 ( p_api_version => p_api_version
2980 ,p_commit => p_commit
2981 ,p_init_msg_list => p_init_msg_list
2982 ,p_validation_level => p_validation_level
2983 ,p_version_label_rec => l_version_label_rec
2984 ,p_txn_rec => p_txn_rec
2985 ,x_return_status => x_return_status
2986 ,x_msg_count => x_msg_count
2987 ,x_msg_data => x_msg_data );
2988
2989 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2990 FND_MESSAGE.SET_NAME('CSI','CSI_FAILED_TO_CREATE_VERSION');
2991 FND_MESSAGE.SET_TOKEN('API_ERROR', 'CREATE_VERSION_LABEL');
2992 FND_MSG_PUB.Add;
2993 RAISE FND_API.G_EXC_ERROR;
2994 END IF;
2995 END IF;
2996 END IF;
2997 x_return_status := l_tmp_return_status;
2998
2999 -- End of addition by rtalluri for Bug 2256588 on 03/26/02
3000
3001 -- Here we call update_version_time to update date_time_stamp of
3002 -- version labels created with this transaction_id to sysdate.
3003 -- Commented the following code, which is causing the prformance
3004 -- issue. -- bug 3558082 (reported in 11.5.8)
3005 --
3006 x_return_status := l_tmp_return_status;
3007
3008 -- Calling Contracts
3009 -- Added on 02-OCT-01
3010 OPEN instance_csr (p_instance_rec.instance_id);
3011 FETCH instance_csr INTO l_instance_csr;
3012 CLOSE instance_csr;
3013 --
3014 BEGIN
3015 SELECT cip.party_id
3016 INTO l_party_id
3017 FROM csi_i_parties cip
3018 WHERE cip.instance_id = p_instance_rec.instance_id
3019 AND cip.relationship_type_code = 'OWNER';
3020 EXCEPTION
3021 WHEN OTHERS THEN
3022 l_party_id := NULL;
3023 END;
3024 --
3025 -- srramakr. If the current party is Internal, then no need to call OKS
3026 -- with TRM or RET. The call would have been made when the ownership got changed.
3027 IF l_party_id IS NOT NULL AND
3028 l_party_id <> l_internal_party_id THEN
3029 IF l_old_ins_csr.instance_status_id <> l_instance_csr.instance_status_id THEN
3030 IF csi_item_instance_vld_pvt.termination_status
3031 ( p_instance_status_id => l_instance_csr.instance_status_id )
3032 THEN
3033 IF p_txn_rec.transaction_type_id in (53,54) THEN -- RMA
3034 l_transaction_type := 'RET';
3035 ELSE
3036 l_transaction_type := 'TRM';
3037 END IF;
3038 l_transaction_date := l_instance_csr.active_end_date;
3039 END IF;
3040 END IF;
3041 END IF;
3042 --
3043 IF l_transaction_type IS NULL
3044 THEN
3045 IF l_old_ins_csr.active_end_date <= SYSDATE
3046 AND (l_instance_csr.active_end_date IS NULL
3047 OR l_instance_csr.active_end_date > SYSDATE )
3048 THEN
3049 -- Added by sk for fixing bug 2245976
3050 -- OWNER Party_id and Internal_party_id selection moved up.
3051 IF l_party_id IS NOT NULL AND
3052 l_internal_party_id IS NOT NULL AND
3053 l_party_id <> l_internal_party_id
3054 THEN
3055 -- End addition by sk for fixing bug 2245976
3056 l_transaction_type := 'NEW';
3057 l_transaction_date := l_instance_csr.active_end_date;
3058 -- 11.5.10 ER. While un-expiring the instance, order Line ID will passed only if it is changing
3059 IF l_instance_csr.location_type_code = 'IN_TRANSIT' THEN
3060 IF nvl(l_old_ins_csr.in_transit_order_line_id,-99999) <>
3061 nvl(l_instance_csr.in_transit_order_line_id,-99999) THEN
3062 l_order_line_id := l_instance_csr.in_transit_order_line_id;
3063 ELSE
3064 l_order_line_id := NULL;
3065 END IF;
3066 ELSE
3067 IF nvl(l_old_ins_csr.last_oe_order_line_id,-99999) <>
3068 nvl(l_instance_csr.last_oe_order_line_id,-99999) THEN
3069 l_order_line_id := l_instance_csr.last_oe_order_line_id;
3070 ELSE
3071 l_order_line_id := NULL;
3072 END IF;
3073 END IF;
3074 ELSE
3075 l_transaction_type := NULL;
3076 END IF;
3077 END IF;
3078 END IF;
3079 --
3080 IF l_transaction_type IS NOT NULL THEN
3081 -- srramakr changed from p_instance_rec to l_new_instance_rec
3082 IF (l_new_instance_rec.call_contracts <> fnd_api.g_false) --added by radha on 04/04/02
3083 THEN
3084 IF p_txn_rec.transaction_type_id <> 7 -- Added for bug 3973706
3085 THEN
3086 csi_item_instance_pvt.Call_to_Contracts
3087 ( p_transaction_type => l_transaction_type
3088 ,p_instance_id => p_instance_rec.instance_id
3089 ,p_new_instance_id => NULL
3090 ,p_vld_org_id => p_instance_rec.vld_organization_id
3091 ,p_quantity => NULL
3092 ,p_party_account_id1 => NULL
3093 ,p_party_account_id2 => NULL
3094 ,p_transaction_date => p_txn_rec.transaction_date -- l_transaction_date
3095 ,p_source_transaction_date => p_txn_rec.source_transaction_date -- Added jpwilson
3096 ,p_txn_type_id => p_txn_rec.transaction_type_id --added for BUG# 5752271
3097 ,p_order_line_id => l_order_line_id -- will have a value only when there is a change in order line_id
3098 ,p_oks_txn_inst_tbl => px_oks_txn_inst_tbl
3099 ,x_return_status => x_return_status
3100 ,x_msg_count => x_msg_count
3101 ,x_msg_data => x_msg_data
3102 );
3103 --
3104 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
3105 l_msg_index := 1;
3106 l_msg_count := x_msg_count;
3107 WHILE l_msg_count > 0 LOOP
3108 x_msg_data := FND_MSG_PUB.GET
3109 ( l_msg_index,
3110 FND_API.G_FALSE
3111 );
3112 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
3113 l_msg_index := l_msg_index + 1;
3114 l_msg_count := l_msg_count - 1;
3115 END LOOP;
3116 RAISE FND_API.G_EXC_ERROR;
3117 END IF;
3118 END IF; -- Added for bug 3973706
3119 END IF;
3120 END IF;
3121 --
3122 x_return_status := l_tmp_return_status;
3123 --
3124 IF px_oks_txn_inst_tbl.count > 0 THEN
3125 csi_gen_utility_pvt.dump_oks_txn_inst_tbl(px_oks_txn_inst_tbl);
3126 csi_gen_utility_pvt.put_line('Calling OKS Core API...');
3127 --
3128 IF p_txn_rec.transaction_type_id = 3 THEN
3129 l_batch_id := p_txn_rec.source_header_ref_id;
3130 l_batch_type := p_txn_rec.source_group_ref;
3131 ELSE
3132 l_batch_id := NULL;
3133 l_batch_type := NULL;
3134 END IF;
3135 --
3136 UPDATE CSI_TRANSACTIONS
3137 set contracts_invoked = 'Y'
3138 where transaction_id = p_txn_rec.transaction_id;
3139 --
3140 OKS_IBINT_PUB.IB_interface
3141 (
3142 P_Api_Version => 1.0,
3143 P_init_msg_list => p_init_msg_list,
3144 P_single_txn_date_flag => 'Y',
3145 P_Batch_type => l_batch_type,
3146 P_Batch_ID => l_batch_id,
3147 P_OKS_Txn_Inst_tbl => px_oks_txn_inst_tbl,
3148 x_return_status => x_return_status,
3149 x_msg_count => x_msg_count,
3150 x_msg_data => x_msg_data
3151 );
3152 --
3153 IF x_return_status = 'W' THEN -- Warning from OKS
3154 l_msg_index := 1;
3155 l_msg_count := x_msg_count;
3156 WHILE l_msg_count > 0 LOOP
3157 x_msg_data := FND_MSG_PUB.GET
3158 ( l_msg_index,
3159 FND_API.G_FALSE
3160 );
3161 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
3162 l_msg_index := l_msg_index + 1;
3163 l_msg_count := l_msg_count - 1;
3164 END LOOP;
3165 FND_MSG_PUB.Count_And_Get
3166 ( p_count => x_msg_count,
3167 p_data => x_msg_data
3168 );
3169 ELSIF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
3170 l_msg_index := 1;
3171 l_msg_count := x_msg_count;
3172 WHILE l_msg_count > 0 LOOP
3173 x_msg_data := FND_MSG_PUB.GET
3174 ( l_msg_index,
3175 FND_API.G_FALSE );
3176 csi_gen_utility_pvt.put_line( 'Error from OKS_IBINT_PUB.IB_interface..');
3177 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
3178 l_msg_index := l_msg_index + 1;
3179 l_msg_count := l_msg_count - 1;
3180 END LOOP;
3181 RAISE FND_API.G_EXC_ERROR;
3182 END IF;
3183 END IF;
3184 -- End of API body
3185 -- Standard check of p_commit.
3186 IF FND_API.To_Boolean( p_commit ) THEN
3187 COMMIT WORK;
3188 END IF;
3189 /***** srramakr commented for bug # 3304439
3190 -- Check for the profile option and disable the trace
3191 IF (l_flag = 'Y') THEN
3192 dbms_session.set_sql_trace(FALSE);
3193 END IF;
3194 -- End disable trace
3195 ****/
3196 -- Standard call to get message count and if count is get message info.
3197 FND_MSG_PUB.Count_And_Get
3198 (p_count => x_msg_count ,
3199 p_data => x_msg_data
3200 );
3201
3202 -- Call Post Vertical user Hook
3203 BEGIN
3204
3205 IF JTF_USR_HKS.Ok_to_execute(G_PKG_NAME, l_api_name, 'A', 'V' ) THEN
3206 csi_gen_utility_pvt.put_line('Calling CSI_ITEM_INSTANCE_VUHK.Update_Item_Instance_Post ..');
3207 CSI_ITEM_INSTANCE_VUHK.Update_Item_Instance_Post
3208 (
3209 p_api_version => 1.0
3210 ,p_commit => fnd_api.g_false
3211 ,p_init_msg_list => fnd_api.g_false
3212 ,p_validation_level => fnd_api.g_valid_level_full
3213 ,p_instance_rec => p_instance_rec
3214 ,p_ext_attrib_values_tbl => p_ext_attrib_values_tbl
3215 ,p_party_tbl => p_party_tbl
3216 ,p_account_tbl => p_account_tbl
3217 ,p_pricing_attrib_tbl => p_pricing_attrib_tbl
3218 ,p_org_assignments_tbl => p_org_assignments_tbl
3219 ,p_asset_assignment_tbl => p_asset_assignment_tbl
3220 ,p_txn_rec => p_txn_rec
3221 ,x_instance_id_lst => x_instance_id_lst
3222 ,x_return_status => x_return_status
3223 ,x_msg_count => x_msg_count
3224 ,x_msg_data => x_msg_data
3225 );
3226 --
3227 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
3228 l_msg_index := 1;
3229 l_msg_count := x_msg_count;
3230 WHILE l_msg_count > 0 LOOP
3231 x_msg_data := FND_MSG_PUB.GET
3232 ( l_msg_index,
3233 FND_API.G_FALSE );
3234 csi_gen_utility_pvt.put_line('ERROR FROM CSI_ITEM_INSTANCE_VUHK.Update_Item_Instance_Post API ');
3235 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
3236 l_msg_index := l_msg_index + 1;
3237 l_msg_count := l_msg_count - 1;
3238 END LOOP;
3239 RAISE FND_API.G_EXC_ERROR;
3240 END IF;
3241 END IF;
3242
3243 EXCEPTION
3244 WHEN OTHERS THEN
3245 csi_gen_utility_pvt.put_line('ERROR FROM JTF_USR_HKS.Ok_to_execute API Update Post Vertical');
3246 RAISE FND_API.G_EXC_ERROR;
3247 END;
3248 x_return_status := l_tmp_return_status;
3249 -- End of POST User Hooks
3250 --
3251
3252 -- Begin Add Code for Siebel Genesis Project
3253 csi_gen_utility_pvt.put_line('Source code = '||l_instance_csr.source_code);
3254 csi_gen_utility_pvt.put_line('p_instance_rec.instance_id = '||to_char(p_instance_rec.instance_id));
3255 csi_gen_utility_pvt.put_line('p_instance_rec.source_code = '||p_instance_rec.source_code);
3256
3257 l_instance_id := p_instance_rec.instance_id;
3258 IF (l_instance_id = NULL OR l_instance_id = FND_API.G_MISS_NUM) THEN
3259 IF p_party_tbl.count > 0 THEN
3260 l_instance_id := p_party_tbl(1).instance_id;
3261 END IF;
3262 END IF;
3263
3264 BEGIN
3265 SELECT source_code, owner_party_id
3266 INTO l_source_code, l_owner_party_id
3267 FROM csi_item_instances
3268 WHERE instance_id = l_instance_id;
3269 EXCEPTION
3270 WHEN OTHERS THEN NULL;
3271 END;
3272
3273 IF l_raise_bes_event = 'Y' THEN
3274 csi_gen_utility_pvt.put_line('l_internal_party_id = '||to_char(l_internal_party_id));
3275 csi_gen_utility_pvt.put_line('l_owner_party_id = '||to_char(l_owner_party_id));
3276 csi_gen_utility_pvt.put_line('Before calling update instance event');
3277 IF (l_internal_party_id <> l_owner_party_id OR p_txn_rec.transaction_type_id IN (53,54)) THEN
3278 csi_gen_utility_pvt.put_line('Before last_oe_order_line_id');
3279 csi_gen_utility_pvt.put_line('last_oe_order_line_id = '||to_char(p_instance_rec.last_oe_order_line_id));
3280 IF (p_instance_rec.last_oe_order_line_id IS NULL OR p_instance_rec.last_oe_order_line_id = fnd_api.g_miss_num) THEN
3281 csi_gen_utility_pvt.put_line('Calling Update Instance Event');
3282 CSI_BUSINESS_EVENT_PVT.UPDATE_INSTANCE_EVENT
3283 (p_api_version => p_api_version
3284 ,p_commit => fnd_api.g_false
3285 ,p_init_msg_list => p_init_msg_list
3286 ,p_validation_level => p_validation_level
3287 ,p_instance_id => l_instance_id
3288 ,p_subject_instance_id => null
3289 ,x_return_status => x_return_status
3290 ,x_msg_count => x_msg_count
3291 ,x_msg_data => x_msg_data
3292 );
3293
3294 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
3295 l_msg_index := 1;
3296 l_msg_count := x_msg_count;
3297
3298 WHILE l_msg_count > 0 LOOP
3299 x_msg_data := FND_MSG_PUB.GET
3300 (l_msg_index,
3301 FND_API.G_FALSE );
3302 csi_gen_utility_pvt.put_line('Error from CSI_BUSINESS_EVENT.UPDATE_INSTANCE_EVENT');
3303 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
3304 l_msg_index := l_msg_index + 1;
3305 l_msg_count := l_msg_count - 1;
3306 END LOOP;
3307 RAISE FND_API.G_EXC_ERROR;
3308 END IF;
3309 ELSIF (p_instance_rec.last_oe_order_line_id IS NOT NULL or p_instance_rec.last_oe_order_line_id <> fnd_api.g_miss_num) THEN
3310 csi_gen_utility_pvt.put_line('Before link to line id');
3311 BEGIN
3312 SELECT link_to_line_id, item_type_code
3313 INTO l_link_to_line_id, l_item_type_code
3314 FROM oe_order_lines_all
3315 WHERE line_id = p_instance_rec.last_oe_order_line_id;
3316 EXCEPTION
3317 WHEN OTHERS THEN
3318 l_link_to_line_id := null;
3319 l_item_type_code := null;
3320 END;
3321
3322 IF l_link_to_line_id is null and l_item_type_code = 'STANDARD' THEN
3323 csi_gen_utility_pvt.put_line('It is standard calling update instance event');
3324 CSI_BUSINESS_EVENT_PVT.UPDATE_INSTANCE_EVENT
3325 (p_api_version => p_api_version
3326 ,p_commit => fnd_api.g_false
3327 ,p_init_msg_list => p_init_msg_list
3328 ,p_validation_level => p_validation_level
3329 ,p_instance_id => p_instance_rec.instance_id
3330 ,p_subject_instance_id => null
3331 ,x_return_status => x_return_status
3332 ,x_msg_count => x_msg_count
3333 ,x_msg_data => x_msg_data
3334 );
3335
3336 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
3337 l_msg_index := 1;
3338 l_msg_count := x_msg_count;
3339
3340 WHILE l_msg_count > 0 LOOP
3341 x_msg_data := FND_MSG_PUB.GET
3342 (l_msg_index,
3343 FND_API.G_FALSE );
3344 csi_gen_utility_pvt.put_line('Error from CSI_BUSINESS_EVENT.UPDATE_INSTANCE_EVENT');
3345 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
3346 l_msg_index := l_msg_index + 1;
3347 l_msg_count := l_msg_count - 1;
3348 END LOOP;
3349 RAISE FND_API.G_EXC_ERROR;
3350 END IF;
3351 ELSE
3352 csi_gen_utility_pvt.put_line(' Not standard it is in configuration');
3353 -- Check if relationships is already been built then allow update
3354 BEGIN
3355 SELECT 'Y',subject_id,object_id,relationship_type_code
3356 INTO l_relationship_exists,l_subject_id,l_object_id,l_relationship_type_code
3357 FROM csi_ii_relationships
3358 WHERE relationship_type_code = 'COMPONENT-OF'
3359 AND nvl(active_end_date, sysdate + 1) >= sysdate
3360 AND (object_id = p_instance_rec.instance_id OR
3361 subject_id = p_instance_rec.instance_id );
3362 EXCEPTION
3363 WHEN NO_DATA_FOUND THEN
3364 l_relationship_exists := 'N';
3365 WHEN TOO_MANY_ROWS THEN
3366 l_relationship_exists := 'Y';
3367 END;
3368
3369 csi_gen_utility_pvt.put_line('l_relationship_exists = '||l_relationship_exists);
3370 IF l_relationship_exists = 'Y' THEN
3371 csi_gen_utility_pvt.put_line('In relationships, therefore raise the update instance event');
3372 csi_gen_utility_pvt.put_line('The Subject Id '||l_subject_id);
3373 csi_gen_utility_pvt.put_line('The Object Id '||l_object_id);
3374 csi_gen_utility_pvt.put_line('The relationship_type_code '||l_relationship_type_code);
3375
3376 l_root_asset_id := csi_ii_relationships_pvt.Get_Root_Parent(l_subject_id,
3377 l_relationship_type_code,
3378 l_object_id);
3379
3380 CSI_BUSINESS_EVENT_PVT.UPDATE_INSTANCE_EVENT
3381 (p_api_version => p_api_version
3382 ,p_commit => fnd_api.g_false
3383 ,p_init_msg_list => p_init_msg_list
3384 ,p_validation_level => p_validation_level
3385 ,p_instance_id => p_instance_rec.instance_id
3386 ,p_subject_instance_id => nvl(l_root_asset_id,p_instance_rec.instance_id)
3387 ,x_return_status => x_return_status
3388 ,x_msg_count => x_msg_count
3389 ,x_msg_data => x_msg_data
3390 );
3391
3392 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
3393 l_msg_index := 1;
3394 l_msg_count := x_msg_count;
3395
3396 WHILE l_msg_count > 0 LOOP
3397 x_msg_data := FND_MSG_PUB.GET
3398 (l_msg_index,
3399 FND_API.G_FALSE );
3400 csi_gen_utility_pvt.put_line('Error from CSI_BUSINESS_EVENT.UPDATE_INSTANCE_EVENT');
3401 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
3402 l_msg_index := l_msg_index + 1;
3403 l_msg_count := l_msg_count - 1;
3404 END LOOP;
3405 RAISE FND_API.G_EXC_ERROR;
3406 END IF;
3407 END IF;
3408 END IF;
3409 END IF;
3410 END IF;
3411 END IF;
3412 -- End Add Code for Siebel Genesis Project
3413
3414 EXCEPTION
3415 WHEN FND_API.G_EXC_ERROR THEN
3416 ROLLBACK TO update_item_instance;
3417 x_return_status := FND_API.G_RET_STS_ERROR ;
3418 FND_MSG_PUB.Count_And_Get
3419 ( p_count => x_msg_count,
3420 p_data => x_msg_data
3421 );
3422 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3423 ROLLBACK TO update_item_instance;
3424 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
3425 FND_MSG_PUB.Count_And_Get
3426 ( p_count => x_msg_count,
3427 p_data => x_msg_data
3428 );
3429 WHEN OTHERS THEN
3430 ROLLBACK TO update_item_instance;
3431 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
3432 IF FND_MSG_PUB.Check_Msg_Level
3433 (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
3434 THEN
3435 FND_MSG_PUB.Add_Exc_Msg
3436 ( G_PKG_NAME,
3437 l_api_name
3438 );
3439 END IF;
3440 FND_MSG_PUB.Count_And_Get
3441 ( p_count => x_msg_count,
3442 p_data => x_msg_data
3443 );
3444 END update_item_instance;
3445
3446 /*----------------------------------------------------*/
3447 /* Procedure name: expire_item_instance */
3448 /* Description : procedure for */
3449 /* Expiring an Item Instance */
3450 /*----------------------------------------------------*/
3451
3452 PROCEDURE expire_item_instance
3453 (
3454 p_api_version IN NUMBER
3455 ,p_commit IN VARCHAR2
3456 ,p_init_msg_list IN VARCHAR2
3457 ,p_validation_level IN NUMBER
3458 ,p_instance_rec IN csi_datastructures_pub.instance_rec
3459 ,p_expire_children IN VARCHAR2
3460 ,p_txn_rec IN OUT NOCOPY csi_datastructures_pub.transaction_rec
3461 ,x_instance_id_lst OUT NOCOPY csi_datastructures_pub.id_tbl
3462 ,x_return_status OUT NOCOPY VARCHAR2
3463 ,x_msg_count OUT NOCOPY NUMBER
3464 ,x_msg_data OUT NOCOPY VARCHAR2
3465 )
3466 IS
3467 l_api_name CONSTANT VARCHAR2(30) := 'EXPIRE_ITEM_INSTANCE';
3468 l_api_version CONSTANT NUMBER := 1.0;
3469 l_debug_level NUMBER;
3470 l_flag VARCHAR2(1);
3471 l_msg_index NUMBER;
3472 l_msg_count NUMBER;
3473 -- The following were added for att
3474 l_component_ins_type VARCHAR2(1):=NULL;
3475 l_config_hdr_id NUMBER;
3476 l_config_rev_nbr NUMBER;
3477 l_config_key csi_utility_grp.config_instance_key;
3478 l_config_valid_status VARCHAR2(10);
3479 l_no_config_keys BOOLEAN := FALSE;
3480 l_return_message VARCHAR2(100);
3481 -- end addition
3482 CURSOR config_ins_key (p_config_hdr_id NUMBER, p_config_rev_nbr NUMBER) is
3483 SELECT instance_hdr_id
3484 ,config_item_id
3485 ,has_failures
3486 FROM cz_config_details_v d
3487 ,cz_config_hdrs_v h
3488 WHERE d.instance_hdr_id = h.config_hdr_id
3489 AND d.instance_rev_nbr = h.config_rev_nbr
3490 AND d.component_instance_type = 'I'
3491 AND d.config_hdr_id = p_config_hdr_id
3492 AND d.config_rev_nbr = p_config_rev_nbr;
3493
3494 CURSOR instance_key (p_config_inst_hdr_id NUMBER, p_config_inst_item_id NUMBER)is
3495 SELECT instance_id
3496 ,object_version_number
3497 ,config_valid_status
3498 FROM csi_item_instances
3499 WHERE config_inst_hdr_id=p_config_inst_hdr_id
3500 AND config_inst_item_id=p_config_inst_item_id;
3501
3502 CURSOR new_config_ins_key (p_config_ins_hdr_id NUMBER, p_config_ins_rev_nbr NUMBER) is
3503 SELECT has_failures
3504 ,config_status
3505 FROM cz_config_details_v d
3506 ,cz_config_hdrs h
3507 WHERE d.instance_hdr_id = p_config_ins_hdr_id
3508 AND d.instance_rev_nbr = p_config_ins_rev_nbr
3509 -- AND d.component_instance_type = 'I'
3510 AND d.config_hdr_id = h.config_hdr_id
3511 AND d.config_rev_nbr = h.config_rev_nbr;
3512
3513 CURSOR new_instance_key (p_config_inst_hdr_id NUMBER, p_config_inst_item_id NUMBER)is
3514 SELECT instance_id
3515 ,object_version_number
3516 ,config_valid_status
3517 FROM csi_item_instances
3518 WHERE config_inst_hdr_id=p_config_inst_hdr_id
3519 AND config_inst_item_id=p_config_inst_item_id;
3520
3521 l_config_instance_rec csi_datastructures_pub.instance_rec ;
3522 l_config_temp_rec csi_datastructures_pub.instance_rec ;
3523 l_batch_hdr_id NUMBER;
3524 l_batch_rev_nbr NUMBER;
3525 l_instance_id_lst csi_datastructures_pub.id_tbl;
3526 l_item_attribute_tbl csi_item_instance_pvt.item_attribute_tbl;
3527 l_location_tbl csi_item_instance_pvt.location_tbl;
3528 l_generic_id_tbl csi_item_instance_pvt.generic_id_tbl;
3529 l_lookup_tbl csi_item_instance_pvt.lookup_tbl;
3530 l_ins_count_rec csi_item_instance_pvt.ins_count_rec;
3531 l_config_ins_rec csi_datastructures_pub.instance_rec;
3532 l_config_tmp_rec csi_datastructures_pub.instance_rec;
3533 --
3534 px_oks_txn_inst_tbl OKS_IBINT_PUB.TXN_INSTANCE_TBL;
3535 px_child_inst_tbl csi_item_instance_grp.child_inst_tbl;
3536 l_batch_type VARCHAR2(50);
3537 l_batch_id NUMBER;
3538 BEGIN
3539 -- Standard Start of API savepoint
3540 SAVEPOINT expire_item_instance;
3541
3542 -- Check for freeze_flag in csi_install_parameters is set to 'Y'
3543
3544 csi_utility_grp.check_ib_active;
3545
3546 -- Standard call to check for call compatibility.
3547 IF NOT FND_API.Compatible_API_Call (l_api_version,
3548 p_api_version,
3549 l_api_name ,
3550 G_PKG_NAME )
3551 THEN
3552 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3553 END IF;
3554
3555 -- Initialize message list if p_init_msg_list is set to TRUE.
3556 IF FND_API.to_Boolean( p_init_msg_list ) THEN
3557 FND_MSG_PUB.initialize;
3558 END IF;
3559
3560 -- Initialize API return status to success
3561 x_return_status := FND_API.G_RET_STS_SUCCESS;
3562
3563 -- Check the profile option debug_level for debug message reporting
3564 l_debug_level:=fnd_profile.value('CSI_DEBUG_LEVEL');
3565
3566 -- If debug_level = 1 then dump the procedure name
3567 IF (l_debug_level > 0) THEN
3568 csi_gen_utility_pvt.put_line( 'expire_item_instance');
3569 END IF;
3570
3571 -- If the debug level = 2 then dump all the parameters values.
3572 IF (l_debug_level > 1) THEN
3573 csi_gen_utility_pvt.put_line( 'expire_item_instance:' ||
3574 p_api_version ||'-'||
3575 p_commit ||'-'||
3576 p_init_msg_list ||'-'||
3577 p_validation_level );
3578 -- Dump the records in the log file
3579 csi_gen_utility_pvt.dump_txn_rec(p_txn_rec);
3580 csi_gen_utility_pvt.dump_instance_rec(p_instance_rec);
3581 END IF;
3582 /***** srramakr commented for bug # 3304439
3583 -- Check for the profile option and enable trace
3584 l_flag:=CSI_GEN_UTILITY_PVT.enable_trace(l_trace_flag => l_flag);
3585 -- End enable trace
3586 ****/
3587 -- Start API body
3588 --
3589 -- Call Pre Customer User Hook
3590 BEGIN
3591 IF JTF_USR_HKS.Ok_to_execute(G_PKG_NAME, l_api_name, 'B', 'C' ) THEN
3592 csi_gen_utility_pvt.put_line('Calling CSI_ITEM_INSTANCE_CUHK.Expire_Item_Instance_Pre ..');
3593 CSI_ITEM_INSTANCE_CUHK.Expire_Item_Instance_Pre
3594 (
3595 p_api_version => 1.0
3596 ,p_commit => fnd_api.g_false
3597 ,p_init_msg_list => fnd_api.g_false
3598 ,p_validation_level => fnd_api.g_valid_level_full
3599 ,p_instance_rec => p_instance_rec
3600 ,p_expire_children => fnd_api.g_false
3601 ,p_txn_rec => p_txn_rec
3602 ,x_instance_id_lst => x_instance_id_lst
3603 ,x_return_status => x_return_status
3604 ,x_msg_count => x_msg_count
3605 ,x_msg_data => x_msg_data
3606 );
3607 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
3608 l_msg_index := 1;
3609 l_msg_count := x_msg_count;
3610 WHILE l_msg_count > 0 LOOP
3611 x_msg_data := FND_MSG_PUB.GET
3612 ( l_msg_index,
3613 FND_API.G_FALSE );
3614 csi_gen_utility_pvt.put_line('ERROR FROM CSI_ITEM_INSTANCE_CUHK.Expire_Item_Instance_Pre API ');
3615 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
3616 l_msg_index := l_msg_index + 1;
3617 l_msg_count := l_msg_count - 1;
3618 END LOOP;
3619 RAISE FND_API.G_EXC_ERROR;
3620 END IF;
3621 END IF;
3622 EXCEPTION
3623 WHEN OTHERS THEN
3624 csi_gen_utility_pvt.put_line('ERROR FROM JTF_USR_HKS.Ok_to_execute API Expire Pre Customer');
3625 RAISE FND_API.G_EXC_ERROR;
3626 END;
3627 --
3628 -- Call Pre Vertical User Hook
3629 BEGIN
3630 IF JTF_USR_HKS.Ok_to_execute(G_PKG_NAME, l_api_name, 'B', 'V' ) THEN
3631 csi_gen_utility_pvt.put_line('Calling CSI_ITEM_INSTANCE_VUHK.Expire_Item_Instance_Pre ..');
3632 CSI_ITEM_INSTANCE_VUHK.Expire_Item_Instance_Pre
3633 (
3634 p_api_version => 1.0
3635 ,p_commit => fnd_api.g_false
3636 ,p_init_msg_list => fnd_api.g_false
3637 ,p_validation_level => fnd_api.g_valid_level_full
3638 ,p_instance_rec => p_instance_rec
3639 ,p_expire_children => fnd_api.g_false
3640 ,p_txn_rec => p_txn_rec
3641 ,x_instance_id_lst => x_instance_id_lst
3642 ,x_return_status => x_return_status
3643 ,x_msg_count => x_msg_count
3644 ,x_msg_data => x_msg_data
3645 );
3646 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
3647 l_msg_index := 1;
3648 l_msg_count := x_msg_count;
3649 WHILE l_msg_count > 0 LOOP
3650 x_msg_data := FND_MSG_PUB.GET
3651 ( l_msg_index,
3652 FND_API.G_FALSE );
3653 csi_gen_utility_pvt.put_line('ERROR FROM CSI_ITEM_INSTANCE_VUHK.Expire_Item_Instance_Pre API ');
3654 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
3655 l_msg_index := l_msg_index + 1;
3656 l_msg_count := l_msg_count - 1;
3657 END LOOP;
3658 RAISE FND_API.G_EXC_ERROR;
3659 END IF;
3660 END IF;
3661 EXCEPTION
3662 WHEN OTHERS THEN
3663 csi_gen_utility_pvt.put_line('ERROR FROM JTF_USR_HKS.Ok_to_execute API Expire Pre Vertical');
3664 RAISE FND_API.G_EXC_ERROR;
3665 END;
3666 -- End PRE User Hooks
3667 --
3668 csi_item_instance_pvt.expire_item_instance
3669 (
3670 p_api_version => p_api_version
3671 ,p_commit => fnd_api.g_false
3672 ,p_init_msg_list => p_init_msg_list
3673 ,p_validation_level => p_validation_level
3674 ,p_instance_rec => p_instance_rec
3675 ,p_expire_children => p_expire_children
3676 ,p_txn_rec => p_txn_rec
3677 ,x_instance_id_lst => x_instance_id_lst
3678 ,p_oks_txn_inst_tbl => px_oks_txn_inst_tbl
3679 ,x_return_status => x_return_status
3680 ,x_msg_count => x_msg_count
3681 ,x_msg_data => x_msg_data
3682 );
3683 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
3684 l_msg_index := 1;
3685 l_msg_count := x_msg_count;
3686 WHILE l_msg_count > 0 LOOP
3687 x_msg_data := FND_MSG_PUB.GET(
3688 l_msg_index,
3689 FND_API.G_FALSE
3690 );
3691 csi_gen_utility_pvt.put_line('message data = '||x_msg_data);
3692 l_msg_index := l_msg_index + 1;
3693 l_msg_count := l_msg_count - 1;
3694 END LOOP;
3695 END IF;
3696 --
3697 -- Call Post Customer User Hook
3698 BEGIN
3699 IF JTF_USR_HKS.Ok_to_execute(G_PKG_NAME, l_api_name, 'A', 'C' ) THEN
3700 csi_gen_utility_pvt.put_line('Calling CSI_ITEM_INSTANCE_CUHK.Expire_Item_Instance_Post ..');
3701 CSI_ITEM_INSTANCE_CUHK.Expire_Item_Instance_Post
3702 (
3703 p_api_version => 1.0
3704 ,p_commit => fnd_api.g_false
3705 ,p_init_msg_list => fnd_api.g_false
3706 ,p_validation_level => fnd_api.g_valid_level_full
3707 ,p_instance_rec => p_instance_rec
3708 ,p_expire_children => fnd_api.g_false
3709 ,p_txn_rec => p_txn_rec
3710 ,x_instance_id_lst => x_instance_id_lst
3711 ,x_return_status => x_return_status
3712 ,x_msg_count => x_msg_count
3713 ,x_msg_data => x_msg_data
3714 );
3715 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
3716 l_msg_index := 1;
3717 l_msg_count := x_msg_count;
3718 WHILE l_msg_count > 0 LOOP
3719 x_msg_data := FND_MSG_PUB.GET
3720 ( l_msg_index,
3721 FND_API.G_FALSE );
3722 csi_gen_utility_pvt.put_line('ERROR FROM CSI_ITEM_INSTANCE_CUHK.Expire_Item_Instance_Post API ');
3723 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
3724 l_msg_index := l_msg_index + 1;
3725 l_msg_count := l_msg_count - 1;
3726 END LOOP;
3727 RAISE FND_API.G_EXC_ERROR;
3728 END IF;
3729 END IF;
3730 EXCEPTION
3731 WHEN OTHERS THEN
3732 csi_gen_utility_pvt.put_line('ERROR FROM JTF_USR_HKS.Ok_to_execute API Expire Post Customer');
3733 RAISE FND_API.G_EXC_ERROR;
3734 END;
3735 --
3736
3737 --
3738 -- Start att enhancements
3739 IF p_instance_rec.call_batch_validation<>fnd_api.g_false
3740 THEN
3741 IF p_instance_rec.instance_id IS NOT NULL AND
3742 p_instance_rec.instance_id <> fnd_api.g_miss_num
3743 THEN
3744 IF ((p_instance_rec.config_inst_hdr_id IS NULL OR p_instance_rec.config_inst_hdr_id = fnd_api.g_miss_num)
3745 AND (p_instance_rec.config_inst_item_id IS NULL OR p_instance_rec.config_inst_item_id = fnd_api.g_miss_num)
3746 )
3747 THEN
3748 l_no_config_keys:=TRUE;
3749 csi_gen_utility_pvt.put_line( 'Config keys were not provided. So no batch validation will be performed');
3750 END IF;
3751
3752 IF NOT l_no_config_keys
3753 THEN
3754 IF (p_instance_rec.config_inst_hdr_id IS NOT NULL AND p_instance_rec.config_inst_hdr_id <> fnd_api.g_miss_num)
3755 AND (p_instance_rec.config_inst_item_id IS NOT NULL AND p_instance_rec.config_inst_item_id <> fnd_api.g_miss_num)
3756 AND (p_instance_rec.config_inst_rev_num IS NOT NULL AND p_instance_rec.config_inst_rev_num <> fnd_api.g_miss_num)
3757 THEN
3758
3759 IF NOT csi_item_instance_vld_pvt.is_unique_config_key ( p_config_inst_hdr_id => p_instance_rec.config_inst_hdr_id
3760 ,p_config_inst_item_id => p_instance_rec.config_inst_item_id
3761 ,p_instance_id => p_instance_rec.instance_id
3762 ,p_validation_mode => 'UPDATE'
3763 )
3764 THEN
3765 FND_MESSAGE.SET_NAME('CSI','CSI_CONFIG_KEY_EXISTS');
3766 FND_MSG_PUB.Add;
3767 RAISE fnd_api.g_exc_error;
3768 END IF;
3769
3770 BEGIN
3771 SELECT component_instance_type
3772 ,config_hdr_id
3773 ,config_rev_nbr
3774 INTO l_component_ins_type
3775 ,l_config_hdr_id
3776 ,l_config_rev_nbr
3777 FROM cz_config_items_v
3778 WHERE instance_hdr_id = p_instance_rec.config_inst_hdr_id
3779 AND instance_rev_nbr = p_instance_rec.config_inst_rev_num
3780 AND config_item_id = p_instance_rec.config_inst_item_id;
3781 EXCEPTION
3782 WHEN OTHERS THEN
3783 FND_MESSAGE.SET_NAME('CSI','CSI_CONFIG_NOT_IN_CZ');
3784 FND_MESSAGE.SET_TOKEN('INSTANCE_HDR_ID',p_instance_rec.config_inst_hdr_id);
3785 FND_MESSAGE.SET_TOKEN('INSTANCE_REV_NBR',p_instance_rec.config_inst_rev_num);
3786 FND_MESSAGE.SET_TOKEN('CONFIG_ITEM_ID',p_instance_rec.config_inst_item_id);
3787
3788 FND_MSG_PUB.Add;
3789 RAISE FND_API.G_EXC_ERROR;
3790 END;
3791
3792 IF l_component_ins_type='I'
3793 THEN
3794
3795 Csi_item_instance_vld_pvt.Call_batch_validate
3796 ( p_instance_rec => p_instance_rec
3797 ,p_config_hdr_id => l_config_hdr_id
3798 ,p_config_rev_nbr => l_config_rev_nbr
3799 ,x_config_hdr_id => l_batch_hdr_id
3800 ,x_config_rev_nbr => l_batch_rev_nbr
3801 ,x_return_status => x_return_status);
3802
3803 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
3804 FND_MESSAGE.SET_NAME('CSI','CSI_CONFIG_ERROR');
3805 FND_MSG_PUB.Add;
3806 csi_gen_utility_pvt.put_line('Call to batch validation has errored ');
3807 RAISE FND_API.G_EXC_ERROR;
3808 END IF;
3809 END IF;
3810 -- Commenting the following code in order to maintain status history.
3811 ELSIF ( (p_instance_rec.config_inst_hdr_id IS NULL OR p_instance_rec.config_inst_hdr_id = fnd_api.g_miss_num)
3812 AND (p_instance_rec.config_inst_item_id IS NOT NULL AND p_instance_rec.config_inst_item_id <> fnd_api.g_miss_num))
3813 OR ( (p_instance_rec.config_inst_hdr_id IS NOT NULL AND p_instance_rec.config_inst_hdr_id <> fnd_api.g_miss_num)
3814 AND (p_instance_rec.config_inst_item_id IS NULL OR p_instance_rec.config_inst_item_id = fnd_api.g_miss_num))
3815 OR ( (p_instance_rec.config_inst_hdr_id IS NOT NULL AND p_instance_rec.config_inst_hdr_id <> fnd_api.g_miss_num)
3816 AND (p_instance_rec.config_inst_item_id IS NOT NULL AND p_instance_rec.config_inst_item_id <> fnd_api.g_miss_num)
3817 AND (p_instance_rec.config_inst_rev_num IS NULL OR p_instance_rec.config_inst_rev_num = fnd_api.g_miss_num))
3818 THEN
3819 FND_MESSAGE.SET_NAME('CSI','CSI_INVALID_CONFIG_COMB');
3820 FND_MSG_PUB.Add;
3821 RAISE fnd_api.g_exc_error;
3822 END IF;
3823 END IF;
3824 END IF;
3825 END IF;
3826 -- End att enhancements
3827 -- Adding new changes for bug 3799694
3828 IF (p_instance_rec.config_inst_hdr_id IS NOT NULL AND p_instance_rec.config_inst_hdr_id <> fnd_api.g_miss_num)
3829 AND (p_instance_rec.config_inst_item_id IS NOT NULL AND p_instance_rec.config_inst_item_id <> fnd_api.g_miss_num)
3830 AND (p_instance_rec.config_inst_rev_num IS NOT NULL AND p_instance_rec.config_inst_rev_num <> fnd_api.g_miss_num)
3831 THEN
3832 FOR l_config_ins_key IN new_config_ins_key(p_instance_rec.config_inst_hdr_id,p_instance_rec.config_inst_rev_num)
3833 LOOP
3834 IF l_config_ins_key.has_failures ='1'
3835 OR nvl(l_config_ins_key.config_status,'0') <> '2'
3836 THEN
3837 FOR l_instance_key IN new_instance_key(p_instance_rec.config_inst_hdr_id,p_instance_rec.config_inst_item_id)
3838 LOOP
3839 l_config_instance_rec:=l_config_temp_rec;
3840 IF (l_instance_key.instance_id IS NOT NULL AND
3841 l_instance_key.instance_id <> fnd_api.g_miss_num) AND
3842 ( l_instance_key.config_valid_status IS NULL OR
3843 (l_instance_key.config_valid_status IS NOT NULL AND
3844 l_instance_key.config_valid_status <> '1'))
3845 THEN
3846 l_config_instance_rec.instance_id:=l_instance_key.instance_id;
3847 l_config_instance_rec.object_version_number:=l_instance_key.object_version_number;
3848 l_config_instance_rec.config_valid_status:='1'; --INVALID
3849 --
3850 csi_item_instance_pvt.update_item_instance
3851 (
3852 p_api_version => p_api_version
3853 ,p_commit => fnd_api.g_false
3854 ,p_init_msg_list => p_init_msg_list
3855 ,p_validation_level => p_validation_level
3856 ,p_instance_rec => l_config_instance_rec
3857 ,p_txn_rec => p_txn_rec
3858 ,x_instance_id_lst => l_instance_id_lst
3859 ,x_return_status => x_return_status
3860 ,x_msg_count => x_msg_count
3861 ,x_msg_data => x_msg_data
3862 ,p_item_attribute_tbl => l_item_attribute_tbl
3863 ,p_location_tbl => l_location_tbl
3864 ,p_generic_id_tbl => l_generic_id_tbl
3865 ,p_lookup_tbl => l_lookup_tbl
3866 ,p_ins_count_rec => l_ins_count_rec
3867 ,p_oks_txn_inst_tbl => px_oks_txn_inst_tbl
3868 ,p_child_inst_tbl => px_child_inst_tbl
3869 );
3870
3871 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
3872 l_msg_index := 1;
3873 l_msg_count := x_msg_count;
3874 WHILE l_msg_count > 0 LOOP
3875 x_msg_data := FND_MSG_PUB.GET
3876 ( l_msg_index,
3877 FND_API.G_FALSE );
3878 csi_gen_utility_pvt.put_line( 'Error from UPDATE_ITEM_INSTANCE_PVT..');
3879 csi_gen_utility_pvt.put_line( 'while updating config status');
3880 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
3881 l_msg_index := l_msg_index + 1;
3882 l_msg_count := l_msg_count - 1;
3883 END LOOP;
3884 RAISE FND_API.G_EXC_ERROR;
3885 END IF;
3886 END IF;
3887 END LOOP;
3888 ELSE
3889 FOR l_instance_key IN new_instance_key(p_instance_rec.config_inst_hdr_id,p_instance_rec.config_inst_item_id)
3890 LOOP
3891 l_config_instance_rec:=l_config_temp_rec;
3892 IF (l_instance_key.instance_id IS NOT NULL AND
3893 l_instance_key.instance_id <> fnd_api.g_miss_num) AND
3894 ( l_instance_key.config_valid_status IS NULL OR
3895 (l_instance_key.config_valid_status IS NOT NULL AND
3896 l_instance_key.config_valid_status <> '0'))
3897 THEN
3898 l_config_instance_rec.instance_id:=l_instance_key.instance_id;
3899 l_config_instance_rec.object_version_number:=l_instance_key.object_version_number;
3900 l_config_instance_rec.config_valid_status:='0'; --VALID
3901 csi_item_instance_pvt.update_item_instance
3902 (
3903 p_api_version => p_api_version
3904 ,p_commit => fnd_api.g_false
3905 ,p_init_msg_list => p_init_msg_list
3906 ,p_validation_level => p_validation_level
3907 ,p_instance_rec => l_config_instance_rec
3908 ,p_txn_rec => p_txn_rec
3909 ,x_instance_id_lst => l_instance_id_lst
3910 ,x_return_status => x_return_status
3911 ,x_msg_count => x_msg_count
3912 ,x_msg_data => x_msg_data
3913 ,p_item_attribute_tbl => l_item_attribute_tbl
3914 ,p_location_tbl => l_location_tbl
3915 ,p_generic_id_tbl => l_generic_id_tbl
3916 ,p_lookup_tbl => l_lookup_tbl
3917 ,p_ins_count_rec => l_ins_count_rec
3918 ,p_oks_txn_inst_tbl => px_oks_txn_inst_tbl
3919 ,p_child_inst_tbl => px_child_inst_tbl
3920 );
3921
3922 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
3923 l_msg_index := 1;
3924 l_msg_count := x_msg_count;
3925 WHILE l_msg_count > 0 LOOP
3926 x_msg_data := FND_MSG_PUB.GET
3927 ( l_msg_index,
3928 FND_API.G_FALSE );
3929 csi_gen_utility_pvt.put_line( 'Error from UPDATE_ITEM_INSTANCE_PVT..');
3930 csi_gen_utility_pvt.put_line( 'while updating config status');
3931 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
3932 l_msg_index := l_msg_index + 1;
3933 l_msg_count := l_msg_count - 1;
3934 END LOOP;
3935 RAISE FND_API.G_EXC_ERROR;
3936 END IF;
3937 END IF;
3938 END LOOP;
3939 END IF;
3940 END LOOP;
3941 END IF;
3942 -- End addition of changes for bug 3799694
3943 IF px_oks_txn_inst_tbl.count > 0 THEN
3944 csi_gen_utility_pvt.dump_oks_txn_inst_tbl(px_oks_txn_inst_tbl);
3945 csi_gen_utility_pvt.put_line('Calling OKS Core API...');
3946 --
3947 IF p_txn_rec.transaction_type_id = 3 THEN
3948 l_batch_id := p_txn_rec.source_header_ref_id;
3949 l_batch_type := p_txn_rec.source_group_ref;
3950 ELSE
3951 l_batch_id := NULL;
3952 l_batch_type := NULL;
3953 END IF;
3954 --
3955 UPDATE CSI_TRANSACTIONS
3956 set contracts_invoked = 'Y'
3957 where transaction_id = p_txn_rec.transaction_id;
3958 --
3959 OKS_IBINT_PUB.IB_interface
3960 (
3961 P_Api_Version => 1.0,
3962 P_init_msg_list => p_init_msg_list,
3963 P_single_txn_date_flag => 'Y',
3964 P_Batch_type => l_batch_type,
3965 P_Batch_ID => l_batch_id,
3966 P_OKS_Txn_Inst_tbl => px_oks_txn_inst_tbl,
3967 x_return_status => x_return_status,
3968 x_msg_count => x_msg_count,
3969 x_msg_data => x_msg_data
3970 );
3971 --
3972 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
3973 l_msg_index := 1;
3974 l_msg_count := x_msg_count;
3975 WHILE l_msg_count > 0 LOOP
3976 x_msg_data := FND_MSG_PUB.GET
3977 ( l_msg_index,
3978 FND_API.G_FALSE );
3979 csi_gen_utility_pvt.put_line( 'Error from OKS_IBINT_PUB.IB_interface..');
3980 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
3981 l_msg_index := l_msg_index + 1;
3982 l_msg_count := l_msg_count - 1;
3983 END LOOP;
3984 RAISE FND_API.G_EXC_ERROR;
3985 END IF;
3986 END IF;
3987 -- End of API body
3988 -- Standard check of p_commit.
3989 IF FND_API.To_Boolean( p_commit ) THEN
3990 COMMIT WORK;
3991 END IF;
3992 /***** srramakr commented for bug # 3304439
3993 -- Check for the profile option and disable the trace
3994 IF (l_flag = 'Y') THEN
3995 dbms_session.set_sql_trace(FALSE);
3996 END IF;
3997 -- End disable trace
3998 ****/
3999 -- Standard call to get message count and if count is get message info.
4000 FND_MSG_PUB.Count_And_Get
4001 (p_count => x_msg_count ,
4002 p_data => x_msg_data );
4003 -- Call Post Vertical User Hook
4004 BEGIN
4005 IF JTF_USR_HKS.Ok_to_execute(G_PKG_NAME, l_api_name, 'A', 'V' ) THEN
4006 csi_gen_utility_pvt.put_line('Calling CSI_ITEM_INSTANCE_VUHK.Expire_Item_Instance_Post ..');
4007 CSI_ITEM_INSTANCE_VUHK.Expire_Item_Instance_Post
4008 (
4009 p_api_version => 1.0
4010 ,p_commit => fnd_api.g_false
4011 ,p_init_msg_list => fnd_api.g_false
4012 ,p_validation_level => fnd_api.g_valid_level_full
4013 ,p_instance_rec => p_instance_rec
4014 ,p_expire_children => fnd_api.g_false
4015 ,p_txn_rec => p_txn_rec
4016 ,x_instance_id_lst => x_instance_id_lst
4017 ,x_return_status => x_return_status
4018 ,x_msg_count => x_msg_count
4019 ,x_msg_data => x_msg_data
4020 );
4021 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
4022 l_msg_index := 1;
4023 l_msg_count := x_msg_count;
4024 WHILE l_msg_count > 0 LOOP
4025 x_msg_data := FND_MSG_PUB.GET
4026 ( l_msg_index,
4027 FND_API.G_FALSE );
4028 csi_gen_utility_pvt.put_line('ERROR FROM CSI_ITEM_INSTANCE_VUHK.Expire_Item_Instance_Post API ');
4029 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
4030 l_msg_index := l_msg_index + 1;
4031 l_msg_count := l_msg_count - 1;
4032 END LOOP;
4033 RAISE FND_API.G_EXC_ERROR;
4034 END IF;
4035 END IF;
4036 EXCEPTION
4037 WHEN OTHERS THEN
4038 csi_gen_utility_pvt.put_line('ERROR FROM JTF_USR_HKS.Ok_to_execute API Expire Post Vertical');
4039 RAISE FND_API.G_EXC_ERROR;
4040 END;
4041 -- End of POST User Hooks
4042
4043 EXCEPTION
4044 WHEN FND_API.G_EXC_ERROR THEN
4045 ROLLBACK TO expire_item_instance;
4046 x_return_status := FND_API.G_RET_STS_ERROR ;
4047 FND_MSG_PUB.Count_And_Get
4048 ( p_count => x_msg_count,
4049 p_data => x_msg_data
4050 );
4051
4052 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4053 ROLLBACK TO expire_item_instance;
4054 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4055 FND_MSG_PUB.Count_And_Get
4056 ( p_count => x_msg_count,
4057 p_data => x_msg_data );
4058
4059 WHEN OTHERS THEN
4060 ROLLBACK TO expire_item_instance;
4061 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4062 IF FND_MSG_PUB.Check_Msg_Level
4063 (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4064 THEN
4065 FND_MSG_PUB.Add_Exc_Msg
4066 ( G_PKG_NAME, l_api_name );
4067 END IF;
4068 FND_MSG_PUB.Count_And_Get
4069 ( p_count => x_msg_count,
4070 p_data => x_msg_data );
4071
4072 END expire_item_instance;
4073
4074 /*----------------------------------------------------*/
4075 /* Procedure name: get_item_instances */
4076 /* Description : procedure to */
4077 /* get an Item Instance */
4078 /*----------------------------------------------------*/
4079
4080 PROCEDURE get_item_instances
4081 (
4082 p_api_version IN NUMBER
4083 ,p_commit IN VARCHAR2
4084 ,p_init_msg_list IN VARCHAR2
4085 ,p_validation_level IN NUMBER
4086 ,p_instance_query_rec IN csi_datastructures_pub.instance_query_rec
4087 ,p_party_query_rec IN csi_datastructures_pub.party_query_rec
4088 ,p_account_query_rec IN csi_datastructures_pub.party_account_query_rec
4089 ,p_transaction_id IN NUMBER
4090 ,p_resolve_id_columns IN VARCHAR2
4091 ,p_active_instance_only IN VARCHAR2
4092 ,x_instance_header_tbl OUT NOCOPY csi_datastructures_pub.instance_header_tbl
4093 ,x_return_status OUT NOCOPY VARCHAR2
4094 ,x_msg_count OUT NOCOPY NUMBER
4095 ,x_msg_data OUT NOCOPY VARCHAR2
4096 )IS
4097
4098 l_api_name CONSTANT VARCHAR2(30) := 'GET_ITEM_INSTANCES';
4099 l_api_version CONSTANT NUMBER := 1.0;
4100 l_debug_level NUMBER;
4101 l_instance_rec csi_datastructures_pub.instance_rec;
4102 l_descriptions_rec csi_datastructures_pub.instance_rec;
4103 l_txn_rec csi_datastructures_pub.transaction_rec;
4104 l_flag VARCHAR2(1) :='N';
4105 l_error_code VARCHAR2(10);
4106 l_return_status NUMBER;
4107 l_msg_count NUMBER;
4108 l_txn_id NUMBER;
4109 l_msg_index NUMBER;
4110 l_line_count NUMBER;
4111 l_cur_get_inst_rel NUMBER;
4112 l_where_clause VARCHAR2(20000) := '';
4113 l_instance_header_rec csi_datastructures_pub.instance_header_rec;
4114 l_party_rec csi_datastructures_pub.party_rec;
4115 l_party_account_rec csi_datastructures_pub.party_account_rec;
4116 l_instance_id_list VARCHAR2(2000):= '';
4117 l_instance_id NUMBER;
4118 l_rows_processed NUMBER;
4119 l_count NUMBER := 0;
4120 l_select_stmt VARCHAR2(20000) := '';
4121
4122
4123 BEGIN
4124 -- Standard Start of API savepoint
4125 --SAVEPOINT get_item_instances;
4126
4127 -- Check for freeze_flag in csi_install_parameters is set to 'Y'
4128
4129 csi_utility_grp.check_ib_active;
4130
4131
4132 -- Standard call to check for call compatibility.
4133 IF NOT FND_API.Compatible_API_Call (l_api_version,
4134 p_api_version,
4135 l_api_name ,
4136 G_PKG_NAME )
4137 THEN
4138 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4139 END IF;
4140
4141 -- Initialize message list if p_init_msg_list is set to TRUE.
4142 IF FND_API.to_Boolean( p_init_msg_list ) THEN
4143 FND_MSG_PUB.initialize;
4144 END IF;
4145
4146 -- Initialize API return status to success
4147 x_return_status := FND_API.G_RET_STS_SUCCESS;
4148
4149 -- Check the profile option debug_level for debug message reporting
4150 l_debug_level:=fnd_profile.value('CSI_DEBUG_LEVEL');
4151
4152 -- If debug_level = 1 then dump the procedure name
4153 IF (l_debug_level > 0) THEN
4154 csi_gen_utility_pvt.put_line( 'get_item_instances');
4155 END IF;
4156
4157 -- If the debug level = 2 then dump all the parameters values.
4158 IF (l_debug_level > 1) THEN
4159 csi_gen_utility_pvt.put_line( 'get_item_instances' ||
4160 p_api_version ||'-'||
4161 p_commit ||'-'||
4162 p_init_msg_list ||'-'||
4163 p_validation_level );
4164 --dump the query records into a log file
4165 csi_gen_utility_pvt.dump_instance_query_rec(p_instance_query_rec);
4166 csi_gen_utility_pvt.dump_party_query_rec(p_party_query_rec);
4167 csi_gen_utility_pvt.dump_account_query_rec(p_account_query_rec);
4168 END IF;
4169
4170 /***** srramakr commented for bug # 3304439
4171 -- Check for the profile option and enable trace
4172 l_flag:=CSI_GEN_UTILITY_PVT.enable_trace(l_trace_flag => l_flag);
4173 -- End enable trace
4174 ****/
4175 -- Start API body
4176
4177 IF (p_party_query_rec.instance_party_id = FND_API.G_MISS_NUM)
4178 AND (p_party_query_rec.instance_id = FND_API.G_MISS_NUM)
4179 AND (p_party_query_rec.party_id = FND_API.G_MISS_NUM)
4180 AND (p_party_query_rec.relationship_type_code = FND_API.G_MISS_CHAR)
4181 AND (p_account_query_rec.ip_account_id = FND_API.G_MISS_NUM)
4182 AND (p_account_query_rec.instance_party_id = FND_API.G_MISS_NUM)
4183 AND (p_account_query_rec.party_account_id = FND_API.G_MISS_NUM)
4184 AND (p_account_query_rec.relationship_type_code = FND_API.G_MISS_CHAR)
4185 AND (p_transaction_id IS NULL)
4186 AND (p_instance_query_rec.INSTANCE_ID = FND_API.G_MISS_NUM)
4187 AND (p_instance_query_rec.INVENTORY_ITEM_ID = FND_API.G_MISS_NUM)
4188 AND (p_instance_query_rec.INVENTORY_REVISION = FND_API.G_MISS_CHAR)
4189 AND (p_instance_query_rec.INV_MASTER_ORGANIZATION_ID = FND_API.G_MISS_NUM)
4190 AND (p_instance_query_rec.SERIAL_NUMBER = FND_API.G_MISS_CHAR)
4191 AND (p_instance_query_rec.LOT_NUMBER = FND_API.G_MISS_CHAR)
4192 AND (p_instance_query_rec.UNIT_OF_MEASURE = FND_API.G_MISS_CHAR)
4193 AND (p_instance_query_rec.INSTANCE_CONDITION_ID = FND_API.G_MISS_NUM)
4194 AND (p_instance_query_rec.INSTANCE_STATUS_ID = FND_API.G_MISS_NUM)
4195 AND (p_instance_query_rec.SYSTEM_ID = FND_API.G_MISS_NUM)
4196 AND (p_instance_query_rec.INSTANCE_TYPE_CODE = FND_API.G_MISS_CHAR)
4197 AND (p_instance_query_rec.LOCATION_TYPE_CODE = FND_API.G_MISS_CHAR)
4198 AND (p_instance_query_rec.LOCATION_ID = FND_API.G_MISS_NUM)
4199 AND (p_instance_query_rec.INV_ORGANIZATION_ID = FND_API.G_MISS_NUM)
4200 AND (p_instance_query_rec.INV_SUBINVENTORY_NAME = FND_API.G_MISS_CHAR)
4201 AND (p_instance_query_rec.INV_LOCATOR_ID = FND_API.G_MISS_NUM)
4202 AND (p_instance_query_rec.PA_PROJECT_ID = FND_API.G_MISS_NUM)
4203 AND (p_instance_query_rec.PA_PROJECT_TASK_ID = FND_API.G_MISS_NUM)
4204 AND (p_instance_query_rec.IN_TRANSIT_ORDER_LINE_ID = FND_API.G_MISS_NUM)
4205 AND (p_instance_query_rec.WIP_JOB_ID = FND_API.G_MISS_NUM)
4206 AND (p_instance_query_rec.PO_ORDER_LINE_ID = FND_API.G_MISS_NUM)
4207 AND (p_instance_query_rec.LAST_OE_ORDER_LINE_ID = FND_API.G_MISS_NUM)
4208 AND (p_instance_query_rec.LAST_OE_RMA_LINE_ID = FND_API.G_MISS_NUM)
4209 AND (p_instance_query_rec.LAST_PO_PO_LINE_ID = FND_API.G_MISS_NUM)
4210 AND (p_instance_query_rec.LAST_OE_PO_NUMBER = FND_API.G_MISS_CHAR)
4211 AND (p_instance_query_rec.LAST_WIP_JOB_ID = FND_API.G_MISS_NUM)
4212 AND (p_instance_query_rec.LAST_PA_PROJECT_ID = FND_API.G_MISS_NUM)
4213 AND (p_instance_query_rec.LAST_PA_TASK_ID = FND_API.G_MISS_NUM)
4214 AND (p_instance_query_rec.LAST_OE_AGREEMENT_ID = FND_API.G_MISS_NUM)
4215 AND (p_instance_query_rec.INSTALL_DATE = FND_API.G_MISS_DATE)
4216 AND (p_instance_query_rec.MANUALLY_CREATED_FLAG = FND_API.G_MISS_CHAR)
4217 AND (p_instance_query_rec.RETURN_BY_DATE = FND_API.G_MISS_DATE)
4218 AND (p_instance_query_rec.ACTUAL_RETURN_DATE = FND_API.G_MISS_DATE)
4219 AND (p_instance_query_rec.CONTRACT_NUMBER = FND_API.G_MISS_CHAR)
4220 AND (p_instance_query_rec.INSTANCE_USAGE_CODE = FND_API.G_MISS_CHAR)
4221 AND (p_instance_query_rec.CONFIG_INST_HDR_ID = FND_API.G_MISS_NUM) -- sguthiva added for att
4222 AND (p_instance_query_rec.CONFIG_INST_REV_NUM = FND_API.G_MISS_NUM) -- sguthiva added for att
4223 AND (p_instance_query_rec.CONFIG_INST_ITEM_ID = FND_API.G_MISS_NUM) -- sguthiva added for att
4224 AND (p_instance_query_rec.INSTANCE_DESCRIPTION = FND_API.G_MISS_CHAR) -- sguthiva added for att
4225 AND (p_instance_query_rec.OPERATIONAL_STATUS_CODE = FND_API.G_MISS_CHAR) -- Addition of columns for FA Integration
4226 THEN
4227
4228 FND_MESSAGE.Set_Name('CSI', 'CSI_API_INVALID_PARAMETERS');
4229 FND_MSG_PUB.ADD;
4230 RAISE FND_API.G_EXC_ERROR;
4231
4232 END IF;
4233
4234 -- Generate the where clause
4235 csi_item_instance_pvt.Gen_Inst_Where_Clause
4236 ( p_instance_query_rec => p_instance_query_rec,
4237 p_party_query_rec => p_party_query_rec,
4238 p_pty_acct_query_rec => p_account_query_rec,
4239 p_transaction_id => p_transaction_id,
4240 x_select_stmt => l_select_stmt ,
4241 p_active_instance_only => p_active_instance_only);
4242
4243 -- Open the cursor
4244 l_cur_get_inst_rel := dbms_sql.open_cursor;
4245
4246 --Parse the select statement
4247 dbms_sql.parse(l_cur_get_inst_rel, l_select_stmt , dbms_sql.native);
4248
4249 -- Bind the variables
4250 csi_item_instance_pvt.Bind_inst_variable(p_instance_query_rec,
4251 p_party_query_rec,
4252 p_account_query_rec,
4253 p_transaction_id,
4254 l_cur_get_inst_rel);
4255
4256 -- Define output variables
4257 csi_item_instance_pvt.Define_Inst_Columns(l_cur_get_inst_rel,
4258 p_instance_query_rec );
4259
4260 -- execute the select statement
4261 l_rows_processed := dbms_sql.execute(l_cur_get_inst_rel);
4262 -- srramakr Bug # 2636868. Construct_inst_header_rec is called within the loop and
4263 -- x_instance_header_tbl is constructed. This is basically to l_instance_id_list
4264 -- with the bind variable p_instance_id.
4265 LOOP
4266 EXIT WHEN DBMS_SQL.FETCH_ROWS(l_cur_get_inst_rel) = 0;
4267 csi_item_instance_pvt.Get_Inst_Column_Values(l_cur_get_inst_rel,
4268 l_instance_id );
4269 l_count := l_count + 1;
4270 csi_item_instance_pvt.Construct_inst_header_rec(l_instance_id,
4271 x_instance_header_tbl);
4272 /***** COMMENTED FOR Bug # 2636868 IF l_instance_id_list IS NULL THEN
4273 l_instance_id_list := to_char(l_instance_id);
4274 ELSE
4275 l_instance_id_list := l_instance_id_list||' , '||to_char(l_instance_id);
4276 END IF; *****/
4277 END LOOP;
4278
4279 -- Close the cursor
4280 DBMS_SQL.CLOSE_CURSOR(l_cur_get_inst_rel);
4281
4282 /***** COMMENTED FOR Bug # 2636868 IF l_instance_id_list IS NOT NULL THEN
4283 csi_item_instance_pvt.Construct_inst_header_rec(l_instance_id_list,
4284 x_instance_header_tbl);
4285 END IF; *****/
4286 --
4287 -- srramakr Get_Item_Instances is a frequently called API. Unless there is a requirement,
4288 -- no need to get the version label for each of the item instance retreived.
4289 -- If there is a need, call csi_ietm_instance_vld_pvt.Get_Version_label by passing the instance_id
4290 -- and p_time_stamp as null (because this routine gets the current image of item instance).
4291 -- Resolve_id routine has already been modified to get the version label meaning.
4292 --
4293 IF p_resolve_id_columns = fnd_api.g_true THEN
4294 IF x_instance_header_tbl.count > 0 THEN
4295 csi_item_instance_pvt.resolve_id_columns
4296 (p_instance_header_tbl => x_instance_header_tbl);
4297
4298 -- Added by sguthiva for att enhancements
4299 csi_Item_Instance_Vld_pvt.get_link_locations
4300 (p_instance_header_tbl => x_instance_header_tbl,
4301 x_return_status => x_return_status
4302 );
4303 IF NOT x_return_status = FND_API.G_RET_STS_SUCCESS THEN
4304 RAISE FND_API.G_EXC_ERROR;
4305 END IF;
4306 -- End addition by sguthiva for att enhancements
4307
4308 END IF;
4309 END IF;
4310
4311 -- End of API body
4312 -- Standard check of p_commit.
4313 /*
4314 IF FND_API.To_Boolean( p_commit ) THEN
4315 COMMIT WORK;
4316 END IF;
4317 */
4318
4319 /***** srramakr commented for bug # 3304439
4320 -- Check for the profile option and disable the trace
4321 IF (l_flag = 'Y') THEN
4322 dbms_session.set_sql_trace(FALSE);
4323 END IF;
4324 -- End disable trace
4325 ****/
4326
4327 -- Standard call to get message count and if count is get message info.
4328 FND_MSG_PUB.Count_And_Get
4329 (p_count => x_msg_count ,
4330 p_data => x_msg_data
4331 );
4332
4333 EXCEPTION
4334
4335 WHEN FND_API.G_EXC_ERROR THEN
4336 -- ROLLBACK TO get_item_instances;
4337 x_return_status := FND_API.G_RET_STS_ERROR ;
4338 FND_MSG_PUB.Count_And_Get
4339 ( p_count => x_msg_count,
4340 p_data => x_msg_data
4341 );
4342
4343 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4344 -- ROLLBACK TO get_item_instances;
4345 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4346 FND_MSG_PUB.Count_And_Get
4347 ( p_count => x_msg_count,
4348 p_data => x_msg_data );
4349
4350 WHEN OTHERS THEN
4351 -- ROLLBACK TO get_item_instances;
4352 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4353 IF FND_MSG_PUB.Check_Msg_Level
4354 (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4355 THEN
4356 FND_MSG_PUB.Add_Exc_Msg
4357 ( G_PKG_NAME, l_api_name );
4358 END IF;
4359 FND_MSG_PUB.Count_And_Get
4360 ( p_count => x_msg_count,
4361 p_data => x_msg_data );
4362
4363 END get_item_instances;
4364
4365 /*----------------------------------------------------*/
4366 /* Procedure name: get_item_instance_details */
4367 /* Description : procedure to */
4368 /* get an Item Instance details */
4369 /*----------------------------------------------------*/
4370
4371 PROCEDURE get_item_instance_details
4372 (
4373 p_api_version IN NUMBER
4374 ,p_commit IN VARCHAR2
4375 ,p_init_msg_list IN VARCHAR2
4376 ,p_validation_level IN NUMBER
4377 ,p_instance_rec IN OUT NOCOPY csi_datastructures_pub.instance_header_rec
4378 ,p_get_parties IN VARCHAR2
4379 ,p_party_header_tbl OUT NOCOPY csi_datastructures_pub.party_header_tbl
4380 ,p_get_accounts IN VARCHAR2
4381 ,p_account_header_tbl OUT NOCOPY csi_datastructures_pub.party_account_header_tbl
4382 ,p_get_org_assignments IN VARCHAR2
4383 ,p_org_header_tbl OUT NOCOPY csi_datastructures_pub.org_units_header_tbl
4384 ,p_get_pricing_attribs IN VARCHAR2
4385 ,p_pricing_attrib_tbl OUT NOCOPY csi_datastructures_pub.pricing_attribs_tbl
4386 ,p_get_ext_attribs IN VARCHAR2
4387 ,p_ext_attrib_tbl OUT NOCOPY csi_datastructures_pub.extend_attrib_values_tbl
4388 ,p_ext_attrib_def_tbl OUT NOCOPY csi_datastructures_pub.extend_attrib_tbl --added
4389 ,p_get_asset_assignments IN VARCHAR2
4390 ,p_asset_header_tbl OUT NOCOPY csi_datastructures_pub.instance_asset_header_tbl
4391 ,p_resolve_id_columns IN VARCHAR2
4392 ,p_time_stamp IN DATE
4393 ,x_return_status OUT NOCOPY VARCHAR2
4394 ,x_msg_count OUT NOCOPY NUMBER
4395 ,x_msg_data OUT NOCOPY VARCHAR2
4396 )
4397 IS
4398 l_api_name CONSTANT VARCHAR2(30) := 'GET_ITEM_INSTANCE_DETAILS';
4399 l_api_version CONSTANT NUMBER := 1.0;
4400 l_debug_level NUMBER;
4401 l_party_query_rec csi_datastructures_pub.party_query_rec;
4402 l_account_query_rec csi_datastructures_pub.party_account_query_rec;
4403 l_org_unit_query_rec csi_datastructures_pub.organization_unit_query_rec;
4404 l_pricing_attrib_query_rec csi_datastructures_pub.pricing_attribs_query_rec;
4405 l_extend_attrib_query_rec csi_datastructures_pub.extend_attrib_query_rec;
4406 l_instance_asset_query_rec csi_datastructures_pub.instance_asset_query_rec;
4407 l_version_label_query_rec csi_datastructures_pub.version_label_query_rec;
4408 l_account_header_tbl csi_datastructures_pub.party_account_header_tbl;
4409 l_acct_header_row NUMBER;
4410 l_flag VARCHAR2(1) :='N';
4411 l_msg_data VARCHAR2(100);
4412 l_msg_count NUMBER;
4413 l_msg_index NUMBER;
4414 l_cur_get_instance_rel NUMBER;
4415 l_where_clause VARCHAR2(20000) := '';
4416 l_instance_rec csi_datastructures_pub.instance_header_rec;
4417 l_instance_header_tbl csi_datastructures_pub.instance_header_tbl;
4418 l_rows_processed NUMBER;
4419 l_count NUMBER := 0;
4420 l_instance_query_rec csi_datastructures_pub.instance_query_rec;
4421 --Modified the select for R12 build to resolve column sequencing issue in table--
4422 l_select_stmt VARCHAR2(20000) := ' select instance_id,instance_number, external_reference, '||
4423 'inventory_item_id,inventory_revision,inv_master_organization_id,serial_number, '||
4424 'mfg_serial_number_flag,lot_number,quantity,unit_of_measure,accounting_class_code, '||
4425 'instance_condition_id,instance_status_id,customer_view_flag,merchant_view_flag, '||
4426 'sellable_flag,system_id,instance_type_code,active_start_date,active_end_date, '||
4427 'location_type_code,location_id,inv_organization_id,inv_subinventory_name,inv_locator_id, '||
4428 'pa_project_id,pa_project_task_id,in_transit_order_line_id,wip_job_id,po_order_line_id, '||
4429 'last_oe_order_line_id,last_oe_rma_line_id,last_po_po_line_id,last_oe_po_number, '||
4430 'last_wip_job_id,last_pa_project_id,last_pa_task_id,last_oe_agreement_id,install_date, '||
4431 'manually_created_flag,return_by_date,actual_return_date,creation_complete_flag, '||
4432 'completeness_flag,context,attribute1,attribute2,attribute3,attribute4,attribute5, '||
4433 'attribute6,attribute7,attribute8,attribute9,attribute10,attribute11,attribute12, '||
4434 'attribute13,attribute14,attribute15,object_version_number,last_txn_line_detail_id, '||
4435 'install_location_type_code,install_location_id,instance_usage_code,last_vld_organization_id, '||
4436 'config_inst_hdr_id,config_inst_rev_num,config_inst_item_id,config_valid_status, '||
4437 'instance_description,network_asset_flag,maintainable_flag,pn_location_id, '||
4438 'asset_criticality_code,category_id,equipment_gen_object_id,instantiation_flag, '||
4439 'linear_location_id,operational_log_flag,checkin_status,supplier_warranty_exp_date,attribute16, '||
4440 'attribute17,attribute18,attribute19,attribute20,attribute21,attribute22,attribute23, '||
4441 'attribute24,attribute25,attribute26,attribute27,attribute28,attribute29,attribute30, '||
4442 -- Addition of columns for FA Integration
4443 'purchase_unit_price, purchase_currency_code, payables_unit_price, payables_currency_code, '||
4444 'sales_unit_price, sales_currency_code, operational_status_code '||
4445 -- End addition of columns for FA Integration
4446 'from csi_item_instances where instance_id = :instance_id ';
4447 l_last_purge_date DATE;
4448 l_time_stamp DATE;
4449
4450 BEGIN
4451
4452 -- Standard Start of API savepoint
4453 -- SAVEPOINT get_item_instance_details;
4454
4455
4456 -- Check for freeze_flag in csi_install_parameters is set to 'Y'
4457
4458 csi_utility_grp.check_ib_active;
4459
4460 -- Standard call to check for call compatibility.
4461 IF NOT FND_API.Compatible_API_Call (l_api_version,
4462 p_api_version,
4463 l_api_name ,
4464 G_PKG_NAME )
4465 THEN
4466 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4467 END IF;
4468
4469 -- Initialize message list if p_init_msg_list is set to TRUE.
4470 IF FND_API.to_Boolean( p_init_msg_list ) THEN
4471 FND_MSG_PUB.initialize;
4472 END IF;
4473
4474
4475 -- Initialize API return status to success
4476 x_return_status := FND_API.G_RET_STS_SUCCESS;
4477
4478 -- Check the profile option debug_level for debug message reporting
4479 l_debug_level:=fnd_profile.value('CSI_DEBUG_LEVEL');
4480
4481 -- If debug_level = 1 then dump the procedure name
4482 IF (l_debug_level > 0) THEN
4483 csi_gen_utility_pvt.put_line( 'get_item_instance_details');
4484 END IF;
4485
4486 -- If the debug level = 2 then dump all the parameters values.
4487 IF (l_debug_level > 1) THEN
4488 csi_gen_utility_pvt.put_line( 'get_item_instance_details:' ||
4489 p_api_version ||'-'||
4490 p_commit ||'-'||
4491 p_init_msg_list ||'-'||
4492 p_validation_level );
4493 --dump the queried records into a log file
4494 csi_gen_utility_pvt.dump_instance_header_rec(p_instance_rec);
4495 END IF;
4496
4497 /***** srramakr commented for bug # 3304439
4498 -- Check for the profile option and enable trace
4499 l_flag:=CSI_GEN_UTILITY_PVT.enable_trace(l_trace_flag => l_flag);
4500 -- End enable trace
4501 ****/
4502 -- Start API body
4503
4504 -- Open the cursor
4505 l_cur_get_instance_rel := dbms_sql.open_cursor;
4506
4507 --Parse the select statement
4508 dbms_sql.parse(l_cur_get_instance_rel, l_select_stmt , dbms_sql.native);
4509
4510 -- Bind the variables
4511 csi_item_instance_pvt.Bind_instance_variable(p_instance_rec,
4512 l_cur_get_instance_rel);
4513
4514 -- Define output variables
4515 csi_item_instance_pvt.Define_Instance_Columns(l_cur_get_instance_rel);
4516
4517 -- execute the select statement
4518 l_rows_processed := dbms_sql.execute(l_cur_get_instance_rel);
4519
4520 LOOP
4521 EXIT WHEN DBMS_SQL.FETCH_ROWS(l_cur_get_instance_rel) = 0;
4522 csi_item_instance_pvt.Get_Instance_Col_Values(l_cur_get_instance_rel,
4523 l_instance_rec
4524 );
4525 p_instance_rec := l_instance_rec;
4526 END LOOP;
4527
4528 -- Close the cursor
4529 DBMS_SQL.CLOSE_CURSOR(l_cur_get_instance_rel);
4530
4531 --
4532 -- Get the last purge date from csi_item_instances table
4533 --
4534 BEGIN
4535 SELECT last_purge_date
4536 INTO l_last_purge_date
4537 FROM CSI_ITEM_INSTANCES
4538 WHERE instance_id = p_instance_rec.instance_id;
4539 EXCEPTION
4540 WHEN no_data_found THEN
4541 null;
4542 WHEN others THEN
4543 null;
4544 END;
4545
4546 l_time_stamp := p_time_stamp;
4547 --call to get the history data
4548 IF ((p_time_stamp IS NOT NULL) AND (p_time_stamp <> FND_API.G_MISS_DATE))
4549 THEN
4550 IF ((l_last_purge_date IS NOT NULL) AND (p_time_stamp <= l_last_purge_date))
4551 THEN
4552 -- If the user is requesting the instance history before the purge date
4553 -- then display a warning message
4554 csi_gen_utility_pvt.put_line('Warning! History for this entity has already been purged for the datetime stamp passed. ' ||
4555 'Please provide a valid datetime stamp.');
4556 FND_MESSAGE.Set_Name('CSI', 'CSI_API_HIST_AFTER_PURGE_REQ');
4557 FND_MESSAGE.Set_Token('LAST_PURGE_DATE', l_last_purge_date);
4558 FND_MSG_PUB.ADD;
4559 END IF;
4560 IF (p_time_stamp <= sysdate) THEN
4561 -- construct from the history if the p_time_stamp
4562 -- is < than sysdate
4563 csi_item_instance_pvt.Construct_inst_from_hist(p_instance_rec, l_time_stamp);
4564 ELSE
4565 FND_MESSAGE.Set_Name('CSI', 'CSI_API_INVALID_HIST_PARAMS');
4566 FND_MSG_PUB.ADD;
4567 RAISE FND_API.G_EXC_ERROR;
4568 END IF;
4569 END IF;
4570 --
4571 -- srramakr Bug 4558115
4572 p_instance_rec.version_label := csi_item_instance_vld_pvt.Get_Version_Label
4573 ( p_instance_id => p_instance_rec.instance_id,
4574 p_time_stamp => p_time_stamp
4575 );
4576 --Resolve the id columns, get the corresponding descriptions for the passed ids
4577
4578 IF p_resolve_id_columns = fnd_api.g_true THEN
4579
4580 l_instance_header_tbl(1) := p_instance_rec;
4581
4582 csi_item_instance_pvt.resolve_id_columns
4583 (p_instance_header_tbl => l_instance_header_tbl);
4584
4585 p_instance_rec := l_instance_header_tbl(1);
4586 END IF;
4587
4588 IF p_get_parties = fnd_api.g_true THEN
4589
4590 l_party_query_rec.instance_id := p_instance_rec.instance_id;
4591 csi_party_relationships_pub.get_inst_party_relationships
4592 (
4593 p_api_version => p_api_version
4594 ,p_commit => fnd_api.g_false
4595 ,p_init_msg_list => fnd_api.g_false
4596 ,p_validation_level => fnd_api.g_valid_level_full
4597 ,p_party_query_rec => l_party_query_rec
4598 ,p_resolve_id_columns => p_resolve_id_columns --fnd_api.g_true
4599 ,p_time_stamp => l_time_stamp
4600 ,x_party_header_tbl => p_party_header_tbl
4601 ,x_return_status => x_return_status
4602 ,x_msg_count => x_msg_count
4603 ,x_msg_data => x_msg_data
4604 );
4605 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
4606 l_msg_index := 1;
4607 l_msg_count := x_msg_count;
4608 WHILE l_msg_count > 0 LOOP
4609 x_msg_data := FND_MSG_PUB.GET
4610 ( l_msg_index,
4611 FND_API.G_FALSE );
4612 csi_gen_utility_pvt.put_line( ' Error from csi_party_relationships_pub.get_inst_party_relationships.. ');
4613 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
4614 l_msg_index := l_msg_index + 1;
4615 l_msg_count := l_msg_count - 1;
4616 END LOOP;
4617 RAISE FND_API.G_EXC_ERROR;
4618 END IF;
4619 END IF;
4620
4621 IF p_get_accounts = fnd_api.g_true AND
4622 p_party_header_tbl.count > 0 THEN -- without this condition if p_party_header_tbl is blindly
4623 -- accessed, we will get an unhandled exception.
4624
4625 FOR tab_row IN p_party_header_tbl.FIRST..p_party_header_tbl.LAST LOOP
4626 IF p_party_header_tbl.EXISTS(tab_row) THEN
4627 l_account_query_rec.instance_party_id := p_party_header_tbl(tab_row).instance_party_id;
4628 END IF;
4629
4630 csi_party_relationships_pub.get_inst_party_accounts
4631 (
4632 p_api_version => p_api_version
4633 ,p_commit => fnd_api.g_false
4634 ,p_init_msg_list => fnd_api.g_false
4635 ,p_validation_level => fnd_api.g_valid_level_full
4636 ,p_account_query_rec => l_account_query_rec
4637 ,p_resolve_id_columns => p_resolve_id_columns --fnd_api.g_true
4638 ,p_time_stamp => l_time_stamp
4639 ,x_account_header_tbl => l_account_header_tbl
4640 ,x_return_status => x_return_status
4641 ,x_msg_count => x_msg_count
4642 ,x_msg_data => x_msg_data );
4643 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
4644 l_msg_index := 1;
4645 l_msg_count := x_msg_count;
4646 WHILE l_msg_count > 0 LOOP
4647 x_msg_data := FND_MSG_PUB.GET
4648 ( l_msg_index,
4649 FND_API.G_FALSE );
4650 csi_gen_utility_pvt.put_line( ' Error from csi_party_relationships_pub.get_inst_party_accounts.. ');
4651 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
4652 l_msg_index := l_msg_index + 1;
4653 l_msg_count := l_msg_count - 1;
4654 END LOOP;
4655 RAISE FND_API.G_EXC_ERROR;
4656 END IF;
4657 IF (l_account_header_tbl.count > 0) THEN
4658 IF (p_account_header_tbl.count = 0) THEN
4659 l_acct_header_row := 1;
4660 ELSE
4661 l_acct_header_row := p_account_header_tbl.LAST + 1;
4662 END IF;
4663
4664 FOR acct_header_row IN l_account_header_tbl.FIRST .. l_account_header_tbl.LAST
4665 LOOP
4666 IF l_account_header_tbl.EXISTS(acct_header_row) THEN
4667 p_account_header_tbl(l_acct_header_row) := l_account_header_tbl(acct_header_row);
4668 l_acct_header_row := l_acct_header_row + 1;
4669 END IF;
4670 END LOOP;
4671 END IF;
4672
4673 END LOOP;
4674 END IF;
4675
4676 IF p_get_org_assignments = fnd_api.g_true THEN
4677
4678 l_org_unit_query_rec.instance_id := p_instance_rec.instance_id;
4679 csi_organization_unit_pub.get_organization_unit
4680 (
4681 p_api_version => p_api_version
4682 ,p_commit => fnd_api.g_false
4683 ,p_init_msg_list => fnd_api.g_false
4684 ,p_validation_level => fnd_api.g_valid_level_full
4685 ,p_ou_query_rec => l_org_unit_query_rec
4686 ,p_resolve_id_columns => p_resolve_id_columns --fnd_api.g_true
4687 ,p_time_stamp => l_time_stamp
4688 ,x_org_unit_tbl => p_org_header_tbl
4689 ,x_return_status => x_return_status
4690 ,x_msg_count => x_msg_count
4691 ,x_msg_data => x_msg_data
4692 );
4693 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
4694 l_msg_index := 1;
4695 l_msg_count := x_msg_count;
4696 WHILE l_msg_count > 0 LOOP
4697 x_msg_data := FND_MSG_PUB.GET
4698 ( l_msg_index,
4699 FND_API.G_FALSE );
4700 csi_gen_utility_pvt.put_line( ' Error from csi_organization_unit_pub.get_organization_unit.. ');
4701 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
4702 l_msg_index := l_msg_index + 1;
4703 l_msg_count := l_msg_count - 1;
4704 END LOOP;
4705 RAISE FND_API.G_EXC_ERROR;
4706 END IF;
4707 END IF;
4708
4709 IF p_get_pricing_attribs = fnd_api.g_true THEN
4710
4711 l_pricing_attrib_query_rec.instance_id := p_instance_rec.instance_id;
4712 csi_pricing_attribs_pub.get_pricing_attribs
4713 (
4714 p_api_version => p_api_version
4715 ,p_commit => fnd_api.g_false
4716 ,p_init_msg_list => fnd_api.g_false
4717 ,p_validation_level => fnd_api.g_valid_level_full
4718 ,p_pricing_attribs_query_rec => l_pricing_attrib_query_rec
4719 ,p_time_stamp => l_time_stamp
4720 ,x_pricing_attribs_tbl => p_pricing_attrib_tbl
4721 ,x_return_status => x_return_status
4722 ,x_msg_count => x_msg_count
4723 ,x_msg_data => x_msg_data
4724 );
4725 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
4726 l_msg_index := 1;
4727 l_msg_count := x_msg_count;
4728 WHILE l_msg_count > 0 LOOP
4729 x_msg_data := FND_MSG_PUB.GET
4730 ( l_msg_index,
4731 FND_API.G_FALSE );
4732 csi_gen_utility_pvt.put_line( ' Error from csi_pricing_attribs_pub.get_pricing_attribs.. ');
4733 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
4734 l_msg_index := l_msg_index + 1;
4735 l_msg_count := l_msg_count - 1;
4736 END LOOP;
4737 RAISE FND_API.G_EXC_ERROR;
4738 END IF;
4739 END IF;
4740
4741 IF p_get_ext_attribs = fnd_api.g_true THEN
4742
4743 l_extend_attrib_query_rec.instance_id := p_instance_rec.instance_id;
4744 get_extended_attrib_values
4745 (
4746 p_api_version => p_api_version
4747 ,p_commit => fnd_api.g_false
4748 ,p_init_msg_list => fnd_api.g_false
4749 ,p_validation_level => fnd_api.g_valid_level_full
4750 ,p_ext_attribs_query_rec => l_extend_attrib_query_rec
4751 ,p_time_stamp => l_time_stamp
4752 ,x_ext_attrib_tbl => p_ext_attrib_tbl
4753 ,x_ext_attrib_def_tbl => p_ext_attrib_def_tbl -- added
4754 ,x_return_status => x_return_status
4755 ,x_msg_count => x_msg_count
4756 ,x_msg_data => x_msg_data
4757 );
4758 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
4759 l_msg_index := 1;
4760 l_msg_count := x_msg_count;
4761 WHILE l_msg_count > 0 LOOP
4762 x_msg_data := FND_MSG_PUB.GET
4763 ( l_msg_index,
4764 FND_API.G_FALSE );
4765 csi_gen_utility_pvt.put_line( ' Error from get_extended_attrib_values.. ');
4766 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
4767 l_msg_index := l_msg_index + 1;
4768 l_msg_count := l_msg_count - 1;
4769 END LOOP;
4770 RAISE FND_API.G_EXC_ERROR;
4771 END IF;
4772 END IF;
4773
4774 IF p_get_asset_assignments = fnd_api.g_true THEN
4775
4776 l_instance_asset_query_rec.instance_id := p_instance_rec.instance_id;
4777 csi_asset_pvt.get_instance_assets
4778 (
4779 p_api_version => p_api_version
4780 ,p_commit => fnd_api.g_false
4781 ,p_init_msg_list => fnd_api.g_false
4782 ,p_validation_level => fnd_api.g_valid_level_full
4783 ,p_instance_asset_query_rec => l_instance_asset_query_rec
4784 ,p_resolve_id_columns => p_resolve_id_columns --fnd_api.g_true
4785 ,p_time_stamp => l_time_stamp
4786 ,x_instance_asset_tbl => p_asset_header_tbl
4787 ,x_return_status => x_return_status
4788 ,x_msg_count => x_msg_count
4789 ,x_msg_data => x_msg_data
4790 );
4791 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
4792 l_msg_index := 1;
4793 l_msg_count := x_msg_count;
4794 WHILE l_msg_count > 0 LOOP
4795 x_msg_data := FND_MSG_PUB.GET
4796 ( l_msg_index,
4797 FND_API.G_FALSE );
4798 csi_gen_utility_pvt.put_line( ' Error from csi_asset_pvt.get_instance_assets.. ');
4799 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
4800 l_msg_index := l_msg_index + 1;
4801 l_msg_count := l_msg_count - 1;
4802 END LOOP;
4803 RAISE FND_API.G_EXC_ERROR;
4804 END IF;
4805 END IF;
4806
4807 -- End of API body
4808
4809 -- Standard check of p_commit.
4810 /*
4811 IF FND_API.To_Boolean( p_commit ) THEN
4812 COMMIT WORK;
4813 END IF;
4814 */
4815
4816 /***** srramakr commented for bug # 3304439
4817 -- Check for the profile option and disable the trace
4818 IF (l_flag = 'Y') THEN
4819 dbms_session.set_sql_trace(FALSE);
4820 END IF;
4821 -- End disable trace
4822 ****/
4823
4824 -- Standard call to get message count and if count is get message info.
4825 FND_MSG_PUB.Count_And_Get
4826 (p_count => x_msg_count ,
4827 p_data => x_msg_data
4828 );
4829
4830 EXCEPTION
4831
4832 WHEN FND_API.G_EXC_ERROR THEN
4833
4834 -- ROLLBACK TO get_item_instance_details;
4835 x_return_status := FND_API.G_RET_STS_ERROR ;
4836 FND_MSG_PUB.Count_And_Get
4837 ( p_count => x_msg_count,
4838 p_data => x_msg_data
4839 );
4840
4841 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4842
4843 -- ROLLBACK TO get_item_instance_details;
4844 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4845 FND_MSG_PUB.Count_And_Get
4846 ( p_count => x_msg_count,
4847 p_data => x_msg_data
4848 );
4849 WHEN OTHERS THEN
4850
4851 IF DBMS_SQL.IS_OPEN(l_cur_get_instance_rel) THEN
4852 DBMS_SQL.CLOSE_CURSOR(l_cur_get_instance_rel);
4853 END IF;
4854 -- ROLLBACK TO get_item_instance_details;
4855 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4856 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
4857 FND_MSG_PUB.Add_Exc_Msg
4858 ( G_PKG_NAME ,
4859 l_api_name );
4860 END IF;
4861 FND_MSG_PUB.Count_And_Get
4862 ( p_count => x_msg_count,
4863 p_data => x_msg_data );
4864
4865 END get_item_instance_details;
4866
4867 /*----------------------------------------------------*/
4868 /* Pocedure name: get_version_label */
4869 /* Description : procedure for creating */
4870 /* version label for */
4871 /* an Item Instance */
4872 /*----------------------------------------------------*/
4873
4874 PROCEDURE get_version_labels
4875 ( p_api_version IN NUMBER
4876 ,p_commit IN VARCHAR2
4877 ,p_init_msg_list IN VARCHAR2
4878 ,p_validation_level IN NUMBER
4879 ,p_version_label_query_rec IN csi_datastructures_pub.version_label_query_rec
4880 ,p_time_stamp IN DATE
4881 ,x_version_label_tbl OUT NOCOPY csi_datastructures_pub.version_label_tbl
4882 ,x_return_status OUT NOCOPY VARCHAR2
4883 ,x_msg_count OUT NOCOPY NUMBER
4884 ,x_msg_data OUT NOCOPY VARCHAR2
4885 )IS
4886
4887 l_api_name CONSTANT VARCHAR2(30) := 'GET_VERSION_LABEL';
4888 l_api_version CONSTANT NUMBER := 1.0;
4889 l_debug_level NUMBER;
4890 l_version_label_id NUMBER;
4891 l_version_label_tbl csi_datastructures_pub.version_label_tbl;
4892 l_line_count NUMBER;
4893 l_msg_index NUMBER;
4894 l_count NUMBER := 0;
4895 l_where_clause VARCHAR2(2000) ;
4896 l_get_ver_cursor_id NUMBER ;
4897 l_flag VARCHAR2(1) :='N';
4898 l_rows_processed NUMBER ;
4899 l_version_label_rec csi_datastructures_pub.version_label_rec;
4900 l_select_stmt VARCHAR2(20000) := ' SELECT * FROM CSI_I_VERSION_LABELS ';
4901
4902 BEGIN
4903 -- Standard Start of API savepoint
4904 -- SAVEPOINT get_version_label_pub;
4905
4906 -- Check for freeze_flag in csi_install_parameters is set to 'Y'
4907
4908 csi_utility_grp.check_ib_active;
4909
4910 -- Standard call to check for call compatibility.
4911 IF NOT FND_API.Compatible_API_Call (l_api_version ,
4912 p_api_version ,
4913 l_api_name ,
4914 G_PKG_NAME )
4915 THEN
4916 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4917 END IF;
4918
4919 -- Initialize message list if p_init_msg_list is set to TRUE.
4920 IF FND_API.to_Boolean( p_init_msg_list ) THEN
4921 FND_MSG_PUB.initialize;
4922 END IF;
4923
4924 -- Initialize API return status to success
4925 x_return_status := FND_API.G_RET_STS_SUCCESS;
4926
4927 -- Check the profile option debug_level for debug message reporting
4928 l_debug_level:=fnd_profile.value('CSI_DEBUG_LEVEL');
4929
4930 -- If debug_level = 1 then dump the procedure name
4931 IF (l_debug_level > 0) THEN
4932 csi_gen_utility_pvt.put_line( 'get_version_label');
4933 END IF;
4934
4935 -- If the debug level = 2 then dump all the parameters values.
4936 IF (l_debug_level > 1) THEN
4937 csi_gen_utility_pvt.put_line( 'get_version_label:' ||
4938 p_api_version ||'-'||
4939 p_commit ||'-'||
4940 p_init_msg_list ||'-'||
4941 p_validation_level );
4942
4943 END IF;
4944
4945 /***** srramakr commented for bug # 3304439
4946 -- Check for the profile option and enable trace
4947 l_flag:=CSI_GEN_UTILITY_PVT.enable_trace(l_trace_flag => l_flag);
4948 -- End enable trace
4949 ****/
4950
4951 -- Start API body
4952 IF (p_version_label_query_rec.version_label_id = FND_API.G_MISS_NUM)
4953 AND (p_version_label_query_rec.instance_id = FND_API.G_MISS_NUM)
4954 AND (p_version_label_query_rec.version_label = FND_API.G_MISS_CHAR)
4955 AND (p_version_label_query_rec.date_time_stamp = FND_API.G_MISS_DATE) THEN
4956
4957 FND_MESSAGE.Set_Name('CSI', 'CSI_API_INVALID_PARAMETERS');
4958 FND_MSG_PUB.ADD;
4959 RAISE FND_API.G_EXC_ERROR;
4960 END IF;
4961
4962 -- Generate the where clause
4963 csi_item_instance_pvt.Gen_Ver_Where_Clause
4964 ( p_ver_label_query_rec => p_version_label_query_rec,
4965 x_where_clause => l_where_clause );
4966
4967 -- Build the select statement
4968 l_select_stmt := l_select_stmt || ' where '||l_where_clause;
4969
4970 -- Open the cursor
4971 l_get_ver_cursor_id := dbms_sql.open_cursor;
4972
4973 --Parse the select statement
4974 dbms_sql.parse(l_get_ver_cursor_id, l_select_stmt , dbms_sql.native);
4975
4976 -- Bind the variables
4977 csi_item_instance_pvt.Bind_Ver_variable(p_version_label_query_rec, l_get_ver_cursor_id);
4978
4979 -- Define output variables
4980 csi_item_instance_pvt.Define_Ver_Columns(l_get_ver_cursor_id);
4981
4982 -- execute the select statement
4983 l_rows_processed := dbms_sql.execute(l_get_ver_cursor_id);
4984
4985 LOOP
4986 EXIT WHEN DBMS_SQL.FETCH_ROWS(l_get_ver_cursor_id) = 0;
4987 csi_item_instance_pvt.Get_Ver_Column_Values(l_get_ver_cursor_id, l_version_label_rec);
4988 l_count := l_count + 1;
4989 x_version_label_tbl(l_count) := l_version_label_rec;
4990 END LOOP;
4991
4992 -- Close the cursor
4993 DBMS_SQL.CLOSE_CURSOR(l_get_ver_cursor_id);
4994
4995 IF p_time_stamp < sysdate THEN
4996 csi_item_instance_pvt.Construct_ver_from_hist(x_version_label_tbl, p_time_stamp);
4997 ELSE
4998 If (p_time_stamp <> fnd_api.g_miss_date and p_time_stamp > sysdate) THEN
4999 FND_MESSAGE.Set_Name('CSI', 'CSI_API_INVALID_HIST_PARAMS');
5000 FND_MSG_PUB.ADD;
5001 RAISE FND_API.G_EXC_ERROR;
5002 END IF;
5003 END IF;
5004
5005 --
5006 -- End of API body
5007
5008 -- Standard check of p_commit.
5009 /*
5010 IF FND_API.To_Boolean( p_commit ) THEN
5011 COMMIT WORK;
5012 END IF;
5013 */
5014
5015 /***** srramakr commented for bug # 3304439
5016 -- Check for the profile option and disable the trace
5017 IF (l_flag = 'Y') THEN
5018 dbms_session.set_sql_trace(false);
5019 END IF;
5020 -- End disable trace
5021 ****/
5022
5023 -- Standard call to get message count and if count is get message info.
5024 FND_MSG_PUB.Count_And_Get
5025 (p_count => x_msg_count ,
5026 p_data => x_msg_data);
5027
5028 EXCEPTION
5029 WHEN FND_API.G_EXC_ERROR THEN
5030 -- ROLLBACK TO get_version_label_pub;
5031 x_return_status := FND_API.G_RET_STS_ERROR ;
5032 FND_MSG_PUB.Count_And_Get
5033 ( p_count => x_msg_count,
5034 p_data => x_msg_data);
5035 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5036 -- ROLLBACK TO get_version_label_pub;
5037 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
5038 FND_MSG_PUB.Count_And_Get
5039 ( p_count => x_msg_count,
5040 p_data => x_msg_data );
5041 WHEN OTHERS THEN
5042 -- ROLLBACK TO get_version_label_pub;
5043 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
5044 IF FND_MSG_PUB.Check_Msg_Level
5045 (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5046 THEN
5047 FND_MSG_PUB.Add_Exc_Msg
5048 ( G_PKG_NAME, l_api_name );
5049 END IF;
5050 FND_MSG_PUB.Count_And_Get
5051 ( p_count => x_msg_count,
5052 p_data => x_msg_data);
5053 END get_version_labels;
5054
5055 /*----------------------------------------------------*/
5056 /* Pocedure name: Create_version_label */
5057 /* Description : procedure for creating */
5058 /* version label for */
5059 /* an Item Instance */
5060 /*----------------------------------------------------*/
5061
5062 PROCEDURE create_version_label
5063 ( p_api_version IN NUMBER
5064 ,p_commit IN VARCHAR2
5065 ,p_init_msg_list IN VARCHAR2
5066 ,p_validation_level IN NUMBER
5067 ,p_version_label_tbl IN OUT NOCOPY csi_datastructures_pub.version_label_tbl
5068 ,p_txn_rec IN OUT NOCOPY csi_datastructures_pub.transaction_rec
5069 ,x_return_status OUT NOCOPY VARCHAR2
5070 ,x_msg_count OUT NOCOPY NUMBER
5071 ,x_msg_data OUT NOCOPY VARCHAR2
5072 ) IS
5073 l_api_name CONSTANT VARCHAR2(30) := 'CREATE_VERSION_LABEL';
5074 l_api_version CONSTANT NUMBER := 1.0 ;
5075 l_debug_level NUMBER ;
5076 l_line_count NUMBER ;
5077 l_version_label_rec csi_datastructures_pub.version_label_rec;
5078 l_msg_index NUMBER ;
5079 l_flag VARCHAR2(1) :='N' ;
5080 l_msg_count NUMBER;
5081 BEGIN
5082
5083 -- Standard Start of API savepoint
5084 SAVEPOINT create_version_label_pub;
5085
5086 -- Check for freeze_flag in csi_install_parameters is set to 'Y'
5087
5088 csi_utility_grp.check_ib_active;
5089
5090 -- Standard call to check for call compatibility.
5091 IF NOT FND_API.Compatible_API_Call ( l_api_version ,
5092 p_api_version ,
5093 l_api_name ,
5094 G_PKG_NAME )
5095 THEN
5096 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5097 END IF;
5098
5099 -- Initialize message list if p_init_msg_list is set to TRUE.
5100 IF FND_API.to_Boolean( p_init_msg_list ) THEN
5101 FND_MSG_PUB.initialize;
5102 END IF;
5103
5104 -- Initialize API return status to success
5105 x_return_status := FND_API.G_RET_STS_SUCCESS;
5106
5107 -- Check the profile option debug_level for debug message reporting
5108 l_debug_level:=fnd_profile.value('CSI_DEBUG_LEVEL');
5109
5110 -- If debug_level = 1 then dump the procedure name
5111 IF (l_debug_level > 0) THEN
5112 csi_gen_utility_pvt.put_line( 'create_version_label');
5113 END IF;
5114
5115
5116 -- If the debug level = 2 then dump all the parameters values.
5117 IF (l_debug_level > 1) THEN
5118 csi_gen_utility_pvt.put_line( 'create_version_label:'||
5119 p_api_version ||'-'||
5120 p_commit ||'-'||
5121 p_init_msg_list ||'-'||
5122 p_validation_level );
5123
5124 -- Dump the records in the log file
5125 csi_gen_utility_pvt.dump_version_label_tbl(p_version_label_tbl);
5126 csi_gen_utility_pvt.dump_txn_rec(p_txn_rec);
5127 END IF;
5128
5129 /***** srramakr commented for bug # 3304439
5130 -- Check for the profile option and enable trace
5131 l_flag:=CSI_GEN_UTILITY_PVT.enable_trace(l_trace_flag => l_flag);
5132 -- End enable trace
5133 ****/
5134
5135 -- Start API body
5136 --
5137 IF p_version_label_tbl.count > 0 THEN
5138 FOR l_count IN p_version_label_tbl.FIRST..p_version_label_tbl.LAST
5139 LOOP
5140 IF p_version_label_tbl.EXISTS(l_count) THEN
5141
5142 csi_item_instance_pvt.create_version_label
5143 ( p_api_version => p_api_version
5144 ,p_commit => p_commit
5145 ,p_init_msg_list => p_init_msg_list
5146 ,p_validation_level => p_validation_level
5147 ,p_version_label_rec => p_version_label_tbl(l_count)
5148 ,p_txn_rec => p_txn_rec
5149 ,x_return_status => x_return_status
5150 ,x_msg_count => x_msg_count
5151 ,x_msg_data => x_msg_data );
5152
5153 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
5154 l_msg_index := 1;
5155 l_msg_count := x_msg_count;
5156 WHILE l_msg_count > 0 LOOP
5157 x_msg_data := FND_MSG_PUB.GET(
5158 l_msg_index,
5159 FND_API.G_FALSE);
5160 csi_gen_utility_pvt.put_line('message data = '||x_msg_data);
5161 l_msg_index := l_msg_index + 1;
5162 l_msg_count := l_msg_count - 1;
5163 END LOOP;
5164 ROLLBACK TO create_version_label_pub;
5165 RETURN;
5166 END IF;
5167 END IF;
5168 END LOOP;
5169 END IF;
5170 --
5171 -- End of API body
5172
5173 -- Standard check of p_commit.
5174 IF FND_API.To_Boolean( p_commit ) THEN
5175 COMMIT WORK;
5176 END IF;
5177
5178 /***** srramakr commented for bug # 3304439
5179 -- Check for the profile option and disable the trace
5180 IF (l_flag = 'Y') THEN
5181 dbms_session.set_sql_trace(false);
5182 END IF;
5183 -- End disable trace
5184 ****/
5185
5186 -- Standard call to get message count and if count is get message info.
5187 FND_MSG_PUB.Count_And_Get
5188 (p_count => x_msg_count ,
5189 p_data => x_msg_data );
5190
5191 EXCEPTION
5192 WHEN FND_API.G_EXC_ERROR THEN
5193 ROLLBACK TO create_version_label_pub;
5194 x_return_status := FND_API.G_RET_STS_ERROR ;
5195 FND_MSG_PUB.Count_And_Get
5196 ( p_count => x_msg_count,
5197 p_data => x_msg_data );
5198
5199 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5200 ROLLBACK TO create_version_label_pub;
5201 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
5202 FND_MSG_PUB.Count_And_Get
5203 ( p_count => x_msg_count,
5204 p_data => x_msg_data );
5205 WHEN OTHERS THEN
5206 ROLLBACK TO create_version_label_pub;
5207 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
5208 IF FND_MSG_PUB.Check_Msg_Level
5209 (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5210 THEN
5211 FND_MSG_PUB.Add_Exc_Msg
5212 ( G_PKG_NAME, l_api_name );
5213 END IF;
5214 FND_MSG_PUB.Count_And_Get
5215 ( p_count => x_msg_count,
5216 p_data => x_msg_data);
5217 END create_version_label;
5218
5219 /*----------------------------------------------------*/
5220 /* Procedure name: Update_version_label */
5221 /* Description : procedure for Update */
5222 /* version label for */
5223 /* an Item Instance */
5224 /*----------------------------------------------------*/
5225
5226 PROCEDURE update_version_label
5227 ( p_api_version IN NUMBER
5228 ,p_commit IN VARCHAR2
5229 ,p_init_msg_list IN VARCHAR2
5230 ,p_validation_level IN NUMBER
5231 ,p_version_label_tbl IN csi_datastructures_pub.version_label_tbl
5232 ,p_txn_rec IN OUT NOCOPY csi_datastructures_pub.transaction_rec
5233 ,x_return_status OUT NOCOPY VARCHAR2
5234 ,x_msg_count OUT NOCOPY NUMBER
5235 ,x_msg_data OUT NOCOPY VARCHAR2
5236 ) IS
5237
5238 l_api_name CONSTANT VARCHAR2(30) := 'UPDATE_VERSION_LABEL';
5239 l_api_version CONSTANT NUMBER := 1.0;
5240 l_debug_level NUMBER;
5241 l_version_label_rec csi_datastructures_pub.version_label_rec;
5242 l_msg_index NUMBER;
5243 l_line_count NUMBER ;
5244 l_flag VARCHAR2(1) :='N';
5245 l_msg_count NUMBER;
5246
5247 BEGIN
5248
5249 -- Standard Start of API savepoint
5250 SAVEPOINT update_version_label_pub;
5251
5252 -- Check for freeze_flag in csi_install_parameters is set to 'Y'
5253
5254 csi_utility_grp.check_ib_active;
5255
5256 -- Standard call to check for call compatibility.
5257 IF NOT FND_API.Compatible_API_Call (l_api_version ,
5258 p_api_version ,
5259 l_api_name ,
5260 G_PKG_NAME )
5261 THEN
5262 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5263 END IF;
5264
5265
5266 -- Initialize message list if p_init_msg_list is set to TRUE.
5267 IF FND_API.to_Boolean( p_init_msg_list ) THEN
5268 FND_MSG_PUB.initialize;
5269 END IF;
5270
5271 -- Initialize API return status to success
5272 x_return_status := FND_API.G_RET_STS_SUCCESS;
5273
5274 -- Check the profile option debug_level for debug message reporting
5275 l_debug_level:=fnd_profile.value('CSI_DEBUG_LEVEL');
5276
5277 -- If debug_level = 1 then dump the procedure name
5278 IF (l_debug_level > 0) THEN
5279 csi_gen_utility_pvt.put_line( 'update_version_label');
5280 END IF;
5281
5282
5283 -- If the debug level = 2 then dump all the parameters values.
5284 IF (l_debug_level > 1) THEN
5285 csi_gen_utility_pvt.put_line( 'update_version_label:'||
5286 p_api_version ||'-'||
5287 p_commit ||'-'||
5288 p_init_msg_list );
5289
5290 -- Dump the records in the log file
5291 csi_gen_utility_pvt.dump_version_label_tbl(p_version_label_tbl);
5292 csi_gen_utility_pvt.dump_txn_rec(p_txn_rec);
5293
5294 END IF;
5295
5296 /***** srramakr commented for bug # 3304439
5297 -- Check for the profile option and enable trace
5298 l_flag:=CSI_GEN_UTILITY_PVT.enable_trace(l_trace_flag => l_flag);
5299 -- End enable trace
5300 ****/
5301 -- Start API body
5302 --
5303 IF p_version_label_tbl.count > 0 THEN
5304 FOR l_count IN p_version_label_tbl.FIRST..p_version_label_tbl.LAST
5305 LOOP
5306 IF p_version_label_tbl.EXISTS(l_count) THEN
5307
5308 csi_item_instance_pvt.update_version_label
5309 ( p_api_version => p_api_version
5310 ,p_commit => p_commit
5311 ,p_init_msg_list => p_init_msg_list
5312 ,p_validation_level => p_validation_level
5313 ,p_version_label_rec => p_version_label_tbl(l_count)
5314 ,p_txn_rec => p_txn_rec
5315 ,x_return_status => x_return_status
5316 ,x_msg_count => x_msg_count
5317 ,x_msg_data => x_msg_data );
5318
5319
5320 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
5321 l_msg_index := 1;
5322 l_msg_count := x_msg_count;
5323 WHILE l_msg_count > 0 LOOP
5324 x_msg_data := FND_MSG_PUB.GET(
5325 l_msg_index,
5326 FND_API.G_FALSE );
5327 csi_gen_utility_pvt.put_line('message data = '||x_msg_data);
5328 l_msg_index := l_msg_index + 1;
5329 l_msg_count := l_msg_count - 1;
5330 END LOOP;
5331 END IF;
5332 END IF;
5333 END LOOP;
5334 END IF;
5335 --
5336 -- End of API body
5337
5338 -- Standard check of p_commit.
5339 IF FND_API.To_Boolean( p_commit ) THEN
5340 COMMIT WORK;
5341 END IF;
5342
5343 /***** srramakr commented for bug # 3304439
5344 -- Check for the profile option and disable the trace
5345 IF (fnd_profile.value('CSI_ENABLE_SQL_TRACE') = 'Y') THEN
5346 dbms_session.set_sql_trace(false);
5347 END IF;
5348 -- End disable trace
5349 ****/
5350
5351 -- Standard call to get message count and if count is get message info.
5352 FND_MSG_PUB.Count_And_Get
5353 (p_count => x_msg_count ,
5354 p_data => x_msg_data);
5355 EXCEPTION
5356 WHEN FND_API.G_EXC_ERROR THEN
5357 ROLLBACK TO update_version_label_pub;
5358 x_return_status := FND_API.G_RET_STS_ERROR ;
5359 FND_MSG_PUB.Count_And_Get
5360 ( p_count => x_msg_count,
5361 p_data => x_msg_data);
5362 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5363 ROLLBACK TO update_version_label_pub;
5364 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
5365 FND_MSG_PUB.Count_And_Get
5366 ( p_count => x_msg_count,
5367 p_data => x_msg_data);
5368 WHEN OTHERS THEN
5369 ROLLBACK TO update_version_label_pub;
5370 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
5371 IF FND_MSG_PUB.Check_Msg_Level
5372 (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5373 THEN
5374 FND_MSG_PUB.Add_Exc_Msg
5375 ( G_PKG_NAME, l_api_name );
5376 END IF;
5377 FND_MSG_PUB.Count_And_Get
5378 ( p_count => x_msg_count,
5379 p_data => x_msg_data);
5380
5381 END update_version_label;
5382
5383 /*----------------------------------------------------*/
5384 /* Procedure name: expire_version_label */
5385 /* Description : procedure for expire */
5386 /* version label for */
5387 /* an Item Instance */
5388 /*----------------------------------------------------*/
5389
5390 PROCEDURE expire_version_label
5391 ( p_api_version IN NUMBER
5392 ,p_commit IN VARCHAR2
5393 ,p_init_msg_list IN VARCHAR2
5394 ,p_validation_level IN NUMBER
5395 ,p_version_label_tbl IN csi_datastructures_pub.version_label_tbl
5396 ,p_txn_rec IN OUT NOCOPY csi_datastructures_pub.transaction_rec
5397 ,x_return_status OUT NOCOPY VARCHAR2
5398 ,x_msg_count OUT NOCOPY NUMBER
5399 ,x_msg_data OUT NOCOPY VARCHAR2
5400 ) IS
5401 l_api_name CONSTANT VARCHAR2(30) := 'UPDATE_VERSION_LABEL';
5402 l_api_version CONSTANT NUMBER := 1.0;
5403 l_debug_level NUMBER;
5404 l_version_label_rec csi_datastructures_pub.version_label_rec;
5405 l_msg_index NUMBER;
5406 l_line_count NUMBER;
5407 l_version_label_id NUMBER;
5408 l_flag VARCHAR2(1) :='N';
5409 l_msg_count NUMBER;
5410
5411 BEGIN
5412
5413 -- Standard Start of API savepoint
5414 SAVEPOINT expire_version_label_pub;
5415
5416 -- Check for freeze_flag in csi_install_parameters is set to 'Y'
5417
5418 csi_utility_grp.check_ib_active;
5419
5420 -- Standard call to check for call compatibility.
5421 IF NOT FND_API.Compatible_API_Call (l_api_version ,
5422 p_api_version ,
5423 l_api_name ,
5424 G_PKG_NAME )
5425 THEN
5426 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5427 END IF;
5428
5429 -- Initialize message list if p_init_msg_list is set to TRUE.
5430 IF FND_API.to_Boolean( p_init_msg_list ) THEN
5431 FND_MSG_PUB.initialize;
5432 END IF;
5433
5434 -- Initialize API return status to success
5435 x_return_status := FND_API.G_RET_STS_SUCCESS;
5436
5437 -- Check the profile option debug_level for debug message reporting
5438 l_debug_level:=fnd_profile.value('CSI_DEBUG_LEVEL');
5439
5440 -- If debug_level = 1 then dump the procedure name
5441 IF (l_debug_level > 0) THEN
5442 csi_gen_utility_pvt.put_line( 'expire_version_label');
5443 END IF;
5444
5445 -- If the debug level = 2 then dump all the parameters values.
5446 IF (l_debug_level > 1) THEN
5447 csi_gen_utility_pvt.put_line( 'expire_version_label:'||
5448 p_api_version ||'-'||
5449 p_commit ||'-'||
5450 p_init_msg_list );
5451 -- Dump the records in the log file
5452 csi_gen_utility_pvt.dump_version_label_tbl(p_version_label_tbl);
5453 csi_gen_utility_pvt.dump_txn_rec(p_txn_rec);
5454 END IF;
5455 /***** srramakr commented for bug # 3304439
5456 -- Check for the profile option and enable trace
5457 l_flag:=CSI_GEN_UTILITY_PVT.enable_trace(l_trace_flag => l_flag);
5458 -- End enable trace
5459 ****/
5460 -- Start API body
5461 --
5462 IF p_version_label_tbl.count > 0 THEN
5463 FOR l_count IN p_version_label_tbl.FIRST..p_version_label_tbl.LAST
5464 LOOP
5465 IF p_version_label_tbl.EXISTS(l_count) THEN
5466
5467 csi_item_instance_pvt.expire_version_label
5468 ( p_api_version => p_api_version
5469 ,p_commit => p_commit
5470 ,p_init_msg_list => p_init_msg_list
5471 ,p_validation_level => p_validation_level
5472 ,p_version_label_rec => p_version_label_tbl(l_count)
5473 ,p_txn_rec => p_txn_rec
5474 ,x_return_status => x_return_status
5475 ,x_msg_count => x_msg_count
5476 ,x_msg_data => x_msg_data );
5477
5478 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
5479 l_msg_index := 1;
5480 l_msg_count := x_msg_count;
5481 WHILE l_msg_count > 0 LOOP
5482 x_msg_data := FND_MSG_PUB.GET(
5483 l_msg_index,
5484 FND_API.G_FALSE );
5485 csi_gen_utility_pvt.put_line('message data = '||x_msg_data);
5486 l_msg_index := l_msg_index + 1;
5487 l_msg_count := l_msg_count - 1;
5488 END LOOP;
5489 END IF;
5490 END IF;
5491 END LOOP;
5492 END IF;
5493 --
5494 -- End of API body
5495
5496 -- Standard check of p_commit.
5497 IF FND_API.To_Boolean( p_commit ) THEN
5498 COMMIT WORK;
5499 END IF;
5500
5501 /***** srramakr commented for bug # 3304439
5502 -- Check for the profile option and disable the trace
5503 IF (fnd_profile.value('CSI_ENABLE_SQL_TRACE') = 'Y') THEN
5504 dbms_session.set_sql_trace(false);
5505 END IF;
5506 -- End disable trace
5507 ****/
5508
5509 -- Standard call to get message count and if count is get message info.
5510 FND_MSG_PUB.Count_And_Get
5511 (p_count => x_msg_count ,
5512 p_data => x_msg_data );
5513 EXCEPTION
5514 WHEN FND_API.G_EXC_ERROR THEN
5515 ROLLBACK TO expire_version_label_pub;
5516 x_return_status := FND_API.G_RET_STS_ERROR ;
5517 FND_MSG_PUB.Count_And_Get
5518 ( p_count => x_msg_count,
5519 p_data => x_msg_data);
5520 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5521 ROLLBACK TO expire_version_label_pub;
5522 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
5523 FND_MSG_PUB.Count_And_Get
5524 ( p_count => x_msg_count,
5525 p_data => x_msg_data);
5526 WHEN OTHERS THEN
5527 ROLLBACK TO expire_version_label_pub;
5528 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
5529 IF FND_MSG_PUB.Check_Msg_Level
5530 (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5531 THEN
5532 FND_MSG_PUB.Add_Exc_Msg
5533 ( G_PKG_NAME, l_api_name );
5534 END IF;
5535 FND_MSG_PUB.Count_And_Get
5536 ( p_count => x_msg_count,
5537 p_data => x_msg_data);
5538 END expire_version_label;
5539
5540 /*----------------------------------------------------*/
5541 /* procedure name: get_extended_attrib_values */
5542 /* description : Gets the extended attribute */
5543 /* values of an item instance */
5544 /*----------------------------------------------------*/
5545
5546 PROCEDURE get_extended_attrib_values
5547 ( p_api_version IN NUMBER
5548 ,p_commit IN VARCHAR2
5549 ,p_init_msg_list IN VARCHAR2
5550 ,p_validation_level IN NUMBER
5551 ,p_ext_attribs_query_rec IN csi_datastructures_pub.extend_attrib_query_rec
5552 ,p_time_stamp IN DATE
5553 ,x_ext_attrib_tbl OUT NOCOPY csi_datastructures_pub.extend_attrib_values_tbl
5554 ,x_ext_attrib_def_tbl OUT NOCOPY csi_datastructures_pub.extend_attrib_tbl -- added
5555 ,x_return_status OUT NOCOPY VARCHAR2
5556 ,x_msg_count OUT NOCOPY NUMBER
5557 ,x_msg_data OUT NOCOPY VARCHAR2
5558 )
5559
5560 IS
5561 l_api_name CONSTANT VARCHAR2(30) := 'get_extended_attrib_values';
5562 l_api_version CONSTANT NUMBER := 1.0;
5563 l_debug_level NUMBER;
5564 l_ext_rec csi_datastructures_pub.extend_attrib_values_rec;
5565 l_rows_processed NUMBER;
5566 l_where_clause VARCHAR2(2000) := '' ;
5567 l_select_stmt VARCHAR2(20000);
5568 l_cur_get_ext NUMBER;
5569 l_count NUMBER := 0;
5570 l_trace_enable_flag VARCHAR2(1) :='N';
5571 l_row NUMBER := 0;
5572
5573 CURSOR ext_attrib_csr (p_instance_id NUMBER) IS
5574 SELECT /*+ INDEX(iea CSI_I_EXTENDED_ATTRIBS_N04)*/ -- Added by sguthiva for bug 2367664
5575 iea.attribute_id attribute_id
5576 ,iea.attribute_level attribute_level
5577 ,iea.master_organization_id master_organization_id
5578 ,iea.inventory_item_id inventory_item_id
5579 ,iea.item_category_id item_category_id
5580 ,iea.instance_id instance_id
5581 ,iea.attribute_code attribute_code
5582 ,iea.attribute_name attribute_name
5583 ,iea.attribute_category attribute_category
5584 ,iea.description description
5585 ,iea.active_start_date active_start_date
5586 ,iea.active_end_date active_end_date
5587 ,iea.context context
5588 ,iea.attribute1 attribute1
5589 ,iea.attribute2 attribute2
5590 ,iea.attribute3 attribute3
5591 ,iea.attribute4 attribute4
5592 ,iea.attribute5 attribute5
5593 ,iea.attribute6 attribute6
5594 ,iea.attribute7 attribute7
5595 ,iea.attribute8 attribute8
5596 ,iea.attribute9 attribute9
5597 ,iea.attribute10 attribute10
5598 ,iea.attribute11 attribute11
5599 ,iea.attribute12 attribute12
5600 ,iea.attribute13 attribute13
5601 ,iea.attribute14 attribute14
5602 ,iea.attribute15 attribute15
5603 ,iea.object_version_number object_version_number
5604 FROM csi_i_extended_attribs iea
5605 WHERE attribute_level = 'GLOBAL'
5606 UNION ALL
5607 SELECT /*+ INDEX(iea CSI_I_EXTENDED_ATTRIBS_N01)*/ -- Added by sguthiva for bug 2367664
5608 iea.attribute_id attribute_id
5609 ,iea.attribute_level attribute_level
5610 ,iea.master_organization_id master_organization_id
5611 ,iea.inventory_item_id inventory_item_id
5612 ,iea.item_category_id item_category_id
5613 ,iea.instance_id instance_id
5614 ,iea.attribute_code attribute_code
5615 ,iea.attribute_name attribute_name
5616 ,iea.attribute_category attribute_category
5617 ,iea.description description
5618 ,iea.active_start_date active_start_date
5619 ,iea.active_end_date active_end_date
5620 ,iea.context context
5621 ,iea.attribute1 attribute1
5622 ,iea.attribute2 attribute2
5623 ,iea.attribute3 attribute3
5624 ,iea.attribute4 attribute4
5625 ,iea.attribute5 attribute5
5626 ,iea.attribute6 attribute6
5627 ,iea.attribute7 attribute7
5628 ,iea.attribute8 attribute8
5629 ,iea.attribute9 attribute9
5630 ,iea.attribute10 attribute10
5631 ,iea.attribute11 attribute11
5632 ,iea.attribute12 attribute12
5633 ,iea.attribute13 attribute13
5634 ,iea.attribute14 attribute14
5635 ,iea.attribute15 attribute15
5636 ,iea.object_version_number object_version_number
5637 FROM csi_i_extended_attribs iea
5638 WHERE attribute_level = 'INSTANCE'
5639 AND instance_id = p_instance_id
5640 UNION ALL
5641 SELECT /*+ INDEX(ia CSI_ITEM_INSTANCES_U01)
5642 INDEX(iea CSI_I_EXTENDED_ATTRIBS_N01)
5643 */ -- Added by sguthiva for bug 2367664
5644 iea.attribute_id attribute_id
5645 ,iea.attribute_level attribute_level
5646 ,iea.master_organization_id master_organization_id
5647 ,iea.inventory_item_id inventory_item_id
5648 ,iea.item_category_id item_category_id
5649 ,iea.instance_id instance_id
5650 ,iea.attribute_code attribute_code
5651 ,iea.attribute_name attribute_name
5652 ,iea.attribute_category attribute_category
5653 ,iea.description description
5654 ,iea.active_start_date active_start_date
5655 ,iea.active_end_date active_end_date
5656 ,iea.context context
5657 ,iea.attribute1 attribute1
5658 ,iea.attribute2 attribute2
5659 ,iea.attribute3 attribute3
5660 ,iea.attribute4 attribute4
5661 ,iea.attribute5 attribute5
5662 ,iea.attribute6 attribute6
5663 ,iea.attribute7 attribute7
5664 ,iea.attribute8 attribute8
5665 ,iea.attribute9 attribute9
5666 ,iea.attribute10 attribute10
5667 ,iea.attribute11 attribute11
5668 ,iea.attribute12 attribute12
5669 ,iea.attribute13 attribute13
5670 ,iea.attribute14 attribute14
5671 ,iea.attribute15 attribute15
5672 ,iea.object_version_number object_version_number
5673 FROM csi_i_extended_attribs iea, csi_item_instances ia
5674 WHERE iea.attribute_level = 'ITEM'
5675 AND iea.inventory_item_id = ia.inventory_item_id --p_inv_item_id
5676 AND iea.master_organization_id = ia.inv_master_organization_id --p_org_id;
5677 AND ia.instance_id = p_instance_id
5678 UNION ALL
5679 SELECT /*+ INDEX(ia CSI_ITEM_INSTANCES_U01)
5680 INDEX(iea CSI_I_EXTENDED_ATTRIBS_N01)
5681 INDEX(ic MTL_ITEM_CATEGORIES_U1)
5682 */ -- Added by sguthiva for bug 2367664
5683 iea.attribute_id attribute_id
5684 ,iea.attribute_level attribute_level
5685 ,iea.master_organization_id master_organization_id
5686 ,iea.inventory_item_id inventory_item_id
5687 ,iea.item_category_id item_category_id
5688 ,iea.instance_id instance_id
5689 ,iea.attribute_code attribute_code
5690 ,iea.attribute_name attribute_name
5691 ,iea.attribute_category attribute_category
5692 ,iea.description description
5693 ,iea.active_start_date active_start_date
5694 ,iea.active_end_date active_end_date
5695 ,iea.context context
5696 ,iea.attribute1 attribute1
5697 ,iea.attribute2 attribute2
5698 ,iea.attribute3 attribute3
5699 ,iea.attribute4 attribute4
5700 ,iea.attribute5 attribute5
5701 ,iea.attribute6 attribute6
5702 ,iea.attribute7 attribute7
5703 ,iea.attribute8 attribute8
5704 ,iea.attribute9 attribute9
5705 ,iea.attribute10 attribute10
5706 ,iea.attribute11 attribute11
5707 ,iea.attribute12 attribute12
5708 ,iea.attribute13 attribute13
5709 ,iea.attribute14 attribute14
5710 ,iea.attribute15 attribute15
5711 ,iea.object_version_number object_version_number
5712 FROM csi_i_extended_attribs iea
5713 ,csi_item_instances ia
5714 ,mtl_item_categories ic
5715 WHERE iea.attribute_level = 'CATEGORY'
5716 -- AND iea.inventory_item_id = ia.inventory_item_id -- commented for Bug # 3189494
5717 -- AND iea.master_organization_id = ia.inv_master_organization_id -- commented for Bug # 3189494
5718 AND ic.organization_id = ia.inv_master_organization_id
5719 AND ic.inventory_item_id = ia.inventory_item_id
5720 AND ic.category_id = iea.item_category_id
5721 AND ia.instance_id = p_instance_id;
5722
5723 BEGIN
5724
5725 -- Standard Start of API savepoint
5726 -- SAVEPOINT get_extended_attrib_values;
5727
5728 -- Check for freeze_flag in csi_install_parameters is set to 'Y'
5729
5730 csi_utility_grp.check_ib_active;
5731
5732 -- Standard call to check for call compatibility.
5733 IF NOT FND_API.Compatible_API_Call (l_api_version,
5734 p_api_version,
5735 l_api_name,
5736 g_pkg_name)
5737 THEN
5738 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5739 END IF;
5740
5741
5742 -- Initialize message list if p_init_msg_list is set to TRUE.
5743 IF FND_API.to_Boolean( p_init_msg_list ) THEN
5744 FND_MSG_PUB.initialize;
5745 END IF;
5746
5747
5748 -- Initialize API return status to success
5749 x_return_status := FND_API.G_RET_STS_SUCCESS;
5750
5751
5752 -- Check the profile option debug_level for debug message reporting
5753 l_debug_level:=fnd_profile.value('CSI_DEBUG_LEVEL');
5754
5755 -- If debug_level = 1 then dump the procedure name
5756 IF (l_debug_level > 0) THEN
5757 csi_gen_utility_pvt.put_line( 'get_extended_attrib_values');
5758 END IF;
5759
5760
5761 -- If the debug level = 2 then dump all the parameters values.
5762 IF (l_debug_level > 1) THEN
5763 csi_gen_utility_pvt.put_line( p_api_version ||'-'
5764 || p_commit ||'-'
5765 || p_init_msg_list ||'-'
5766 || p_validation_level ||'-'
5767 || p_time_stamp);
5768
5769 -- Dump extended attribs
5770 csi_gen_utility_pvt.dump_ext_attrib_query_rec(p_ext_attribs_query_rec);
5771 END IF;
5772
5773 /***** srramakr commented for bug # 3304439
5774 -- Check for the profile option and enable trace
5775 l_trace_enable_flag:=CSI_GEN_UTILITY_PVT.enable_trace(l_trace_flag => l_trace_enable_flag);
5776 -- End enable trace
5777 ****/
5778
5779 -- Start API body
5780 -- Check if atleast one query parameters are passed
5781 IF (p_ext_attribs_query_rec.attribute_value_id = FND_API.G_MISS_NUM)
5782 AND ( p_ext_attribs_query_rec.instance_id = FND_API.G_MISS_NUM)
5783 AND ( p_ext_attribs_query_rec.attribute_id = FND_API.G_MISS_NUM)
5784 THEN
5785
5786 FND_MESSAGE.Set_Name('CSI', 'CSI_API_INVALID_PARAMETERS');
5787 FND_MSG_PUB.ADD;
5788 RAISE FND_API.G_EXC_ERROR;
5789 END IF;
5790
5791
5792 -- Generate the where clause
5793 csi_item_instance_pvt.Gen_ext_Where_Clause
5794 ( p_ext_query_rec => p_ext_attribs_query_rec,
5795 x_where_clause => l_where_clause );
5796
5797 -- Build the select statement
5798 l_select_stmt := 'SELECT cv.attribute_value_id attribute_value_id' ||
5799 ',cv.attribute_id attribute_id' ||
5800 ',cv.instance_id instance_id' ||
5801 ',ca.attribute_code attribute_code' ||
5802 ',cv.attribute_value attribute_value' ||
5803 ',cv.active_start_date active_start_date' ||
5804 ',cv.active_end_date active_end_date' ||
5805 ',cv.context context' ||
5806 ',cv.attribute1 attribute1' ||
5807 ',cv.attribute2 attribute2' ||
5808 ',cv.attribute3 attribute3' ||
5809 ',cv.attribute4 attribute4' ||
5810 ',cv.attribute5 attribute5' ||
5811 ',cv.attribute6 attribute6' ||
5812 ',cv.attribute7 attribute7' ||
5813 ',cv.attribute8 attribute8' ||
5814 ',cv.attribute9 attribute9' ||
5815 ',cv.attribute10 attribute10' ||
5816 ',cv.attribute11 attribute11' ||
5817 ',cv.attribute12 attribute12' ||
5818 ',cv.attribute13 attribute13' ||
5819 ',cv.attribute14 attribute14' ||
5820 ',cv.attribute15 attribute15' ||
5821 ',cv.object_version_number object_version_number '||
5822 'FROM csi_iea_values cv, csi_i_extended_attribs ca ' ||
5823 'WHERE cv.attribute_id = ca.attribute_id' ;
5824
5825 l_select_stmt := l_select_stmt || ' AND '||l_where_clause;
5826
5827 -- Open the cursor
5828 l_cur_get_ext := dbms_sql.open_cursor;
5829
5830
5831 --Parse the select statement
5832 dbms_sql.parse(l_cur_get_ext, l_select_stmt , dbms_sql.native);
5833
5834 -- Bind the variables
5835 csi_item_instance_pvt.Bind_ext_variable
5836 ( p_ext_attribs_query_rec,
5837 l_cur_get_ext );
5838
5839 -- Define output variables
5840 csi_item_instance_pvt.Define_ext_Columns(l_cur_get_ext);
5841
5842 -- execute the select statement
5843 l_rows_processed := dbms_sql.execute(l_cur_get_ext);
5844
5845
5846 LOOP
5847 EXIT WHEN DBMS_SQL.FETCH_ROWS(l_cur_get_ext) = 0;
5848 csi_item_instance_pvt.Get_ext_Column_Values(l_cur_get_ext, l_ext_rec);
5849 l_count := l_count + 1;
5850 x_ext_attrib_tbl(l_count) := l_ext_rec;
5851 END LOOP;
5852
5853 -- Close the cursor
5854 DBMS_SQL.CLOSE_CURSOR(l_cur_get_ext);
5855
5856 IF (p_time_stamp IS NOT NULL) AND (p_time_stamp <> FND_API.G_MISS_DATE) THEN
5857 IF p_time_stamp <= sysdate THEN
5858 csi_item_instance_pvt.Construct_ext_From_Hist(x_ext_attrib_tbl, p_time_stamp);
5859 ELSE
5860 FND_MESSAGE.Set_Name('CSI', 'CSI_API_INVALID_HIST_PARAMS');
5861 FND_MSG_PUB.ADD;
5862 RAISE FND_API.G_EXC_ERROR;
5863 END IF;
5864 END IF;
5865
5866 IF (p_ext_attribs_query_rec.instance_id IS NOT NULL AND p_ext_attribs_query_rec.instance_id <> fnd_api.g_miss_num)
5867 THEN
5868
5869 FOR attrib_csr IN ext_attrib_csr(p_ext_attribs_query_rec.instance_id)
5870 LOOP
5871 l_row:=l_row+1;
5872 x_ext_attrib_def_tbl(l_row).attribute_id := attrib_csr.attribute_id;
5873 x_ext_attrib_def_tbl(l_row).attribute_level := attrib_csr.attribute_level;
5874 x_ext_attrib_def_tbl(l_row).master_organization_id := attrib_csr.master_organization_id;
5875 x_ext_attrib_def_tbl(l_row).inventory_item_id := attrib_csr.inventory_item_id;
5876 x_ext_attrib_def_tbl(l_row).item_category_id := attrib_csr.item_category_id;
5877 x_ext_attrib_def_tbl(l_row).instance_id := attrib_csr.instance_id;
5878 x_ext_attrib_def_tbl(l_row).attribute_code := attrib_csr.attribute_code;
5879 x_ext_attrib_def_tbl(l_row).attribute_name := attrib_csr.attribute_name;
5880 x_ext_attrib_def_tbl(l_row).attribute_category := attrib_csr.attribute_category;
5881 x_ext_attrib_def_tbl(l_row).description := attrib_csr.description;
5882 x_ext_attrib_def_tbl(l_row).active_start_date := attrib_csr.active_start_date;
5883 x_ext_attrib_def_tbl(l_row).active_end_date := attrib_csr.active_end_date;
5884 x_ext_attrib_def_tbl(l_row).context := attrib_csr.context;
5885 x_ext_attrib_def_tbl(l_row).attribute1 := attrib_csr.attribute1;
5886 x_ext_attrib_def_tbl(l_row).attribute2 := attrib_csr.attribute2;
5887 x_ext_attrib_def_tbl(l_row).attribute3 := attrib_csr.attribute3;
5888 x_ext_attrib_def_tbl(l_row).attribute4 := attrib_csr.attribute4;
5889 x_ext_attrib_def_tbl(l_row).attribute5 := attrib_csr.attribute5;
5890 x_ext_attrib_def_tbl(l_row).attribute6 := attrib_csr.attribute6;
5891 x_ext_attrib_def_tbl(l_row).attribute7 := attrib_csr.attribute7;
5892 x_ext_attrib_def_tbl(l_row).attribute8 := attrib_csr.attribute8;
5893 x_ext_attrib_def_tbl(l_row).attribute9 := attrib_csr.attribute9;
5894 x_ext_attrib_def_tbl(l_row).attribute10 := attrib_csr.attribute10;
5895 x_ext_attrib_def_tbl(l_row).attribute11 := attrib_csr.attribute11;
5896 x_ext_attrib_def_tbl(l_row).attribute12 := attrib_csr.attribute12;
5897 x_ext_attrib_def_tbl(l_row).attribute13 := attrib_csr.attribute13;
5898 x_ext_attrib_def_tbl(l_row).attribute14 := attrib_csr.attribute14;
5899 x_ext_attrib_def_tbl(l_row).attribute15 := attrib_csr.attribute15;
5900 x_ext_attrib_def_tbl(l_row).object_version_number := attrib_csr.object_version_number;
5901
5902 END LOOP;
5903 END IF;
5904
5905 -- End of API body
5906
5907 -- Standard check of p_commit.
5908 /*
5909 IF FND_API.To_Boolean( p_commit ) THEN
5910 COMMIT WORK;
5911 END IF;
5912 */
5913
5914 /***** srramakr commented for bug # 3304439
5915 -- Check for the profile option and disable the trace
5916 IF (l_trace_enable_flag = 'Y') THEN
5917 dbms_session.set_sql_trace(false);
5918 END IF;
5919 -- End disable trace
5920 ****/
5921
5922 -- Standard call to get message count and if count is get message info.
5923 FND_MSG_PUB.Count_And_Get
5924 (p_count => x_msg_count ,
5925 p_data => x_msg_data
5926 );
5927
5928
5929 EXCEPTION
5930 WHEN FND_API.G_EXC_ERROR THEN
5931 -- ROLLBACK TO get_extended_attrib_values;
5932 x_return_status := FND_API.G_RET_STS_ERROR ;
5933 FND_MSG_PUB.Count_And_Get
5934 ( p_count => x_msg_count,
5935 p_data => x_msg_data
5936 );
5937
5938 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5939 -- ROLLBACK TO get_extended_attrib_values;
5940 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
5941 FND_MSG_PUB.Count_And_Get
5942 ( p_count => x_msg_count,
5943 p_data => x_msg_data
5944 );
5945
5946 WHEN OTHERS THEN
5947 IF DBMS_SQL.IS_OPEN(l_cur_get_ext) THEN
5948 DBMS_SQL.CLOSE_CURSOR(l_cur_get_ext);
5949 END IF;
5950
5951 -- ROLLBACK TO get_extended_attrib_values;
5952 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
5953
5954 IF FND_MSG_PUB.Check_Msg_Level
5955 (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5956 THEN
5957 FND_MSG_PUB.Add_Exc_Msg
5958 ( g_pkg_name,
5959 l_api_name
5960 );
5961 END IF;
5962
5963 FND_MSG_PUB.Count_And_Get
5964 ( p_count => x_msg_count,
5965 p_data => x_msg_data
5966 );
5967
5968 END get_extended_attrib_values;
5969
5970 /*----------------------------------------------------*/
5971 /* procedure name: create_extended_attrib_values */
5972 /* description : Associates extended attribute */
5973 /* values to an item instance */
5974 /*----------------------------------------------------*/
5975
5976 PROCEDURE create_extended_attrib_values
5977 ( p_api_version IN NUMBER
5978 ,p_commit IN VARCHAR2
5979 ,p_init_msg_list IN VARCHAR2
5980 ,p_validation_level IN NUMBER
5981 ,p_ext_attrib_tbl IN OUT NOCOPY csi_datastructures_pub.extend_attrib_values_tbl
5982 ,p_txn_rec IN OUT NOCOPY csi_datastructures_pub.transaction_rec
5983 ,x_return_status OUT NOCOPY VARCHAR2
5984 ,x_msg_count OUT NOCOPY NUMBER
5985 ,x_msg_data OUT NOCOPY VARCHAR2
5986 )
5987
5988 IS
5989 l_api_name CONSTANT VARCHAR2(30) := 'create_extended_attrib_values';
5990 l_api_version CONSTANT NUMBER := 1.0;
5991 l_debug_level NUMBER;
5992 l_msg_index NUMBER;
5993 l_msg_count NUMBER;
5994 l_trace_enable_flag VARCHAR2(1) :='N';
5995 l_ext_id_tbl csi_item_instance_pvt.ext_id_tbl;
5996 l_ext_count_rec csi_item_instance_pvt.ext_count_rec;
5997 l_ext_attr_tbl csi_item_instance_pvt.ext_attr_tbl;
5998 l_ext_cat_tbl csi_item_instance_pvt.ext_cat_tbl;
5999 BEGIN
6000
6001 -- Standard Start of API savepoint
6002 SAVEPOINT create_extended_attrib_values;
6003
6004 -- Check for freeze_flag in csi_install_parameters is set to 'Y'
6005
6006 csi_utility_grp.check_ib_active;
6007
6008 -- Standard call to check for call compatibility.
6009 IF NOT FND_API.Compatible_API_Call (l_api_version,
6010 p_api_version,
6011 l_api_name ,
6012 g_pkg_name)
6013 THEN
6014 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6015 END IF;
6016
6017
6018 -- Initialize message list if p_init_msg_list is set to TRUE.
6019 IF FND_API.to_Boolean( p_init_msg_list ) THEN
6020 FND_MSG_PUB.initialize;
6021 END IF;
6022
6023
6024 -- Initialize API return status to success
6025 x_return_status := FND_API.G_RET_STS_SUCCESS;
6026
6027
6028 -- Check the profile option debug_level for debug message reporting
6029
6030 l_debug_level:=fnd_profile.value('CSI_DEBUG_LEVEL');
6031
6032 -- If debug_level = 1 then dump the procedure name
6033 IF (l_debug_level > 0) THEN
6034 csi_gen_utility_pvt.put_line( 'create_extended_attrib_values');
6035 END IF;
6036
6037
6038 -- If the debug level = 2 then dump all the parameters values.
6039 IF (l_debug_level > 1) THEN
6040 csi_gen_utility_pvt.put_line( p_api_version ||'-'
6041 || p_commit ||'-'
6042 || p_init_msg_list ||'-'
6043 || p_validation_level );
6044
6045 -- Dump extended attribs tbl
6046 csi_gen_utility_pvt.dump_ext_attrib_values_tbl(p_ext_attrib_tbl);
6047 -- Dump txn_rec
6048 csi_gen_utility_pvt.dump_txn_rec(p_txn_rec);
6049
6050 END IF;
6051
6052 /***** srramakr commented for bug # 3304439
6053 -- Check for the profile option and enable trace
6054 l_trace_enable_flag:=CSI_GEN_UTILITY_PVT.enable_trace(l_trace_flag => l_trace_enable_flag);
6055 -- End enable trace
6056 ****/
6057
6058
6059 -- Start API body
6060
6061 IF p_ext_attrib_tbl.COUNT > 0 THEN
6062 FOR tab_row IN p_ext_attrib_tbl.FIRST .. p_ext_attrib_tbl.LAST
6063 LOOP
6064 IF p_ext_attrib_tbl.EXISTS(tab_row) THEN
6065 csi_item_instance_pvt.create_extended_attrib_values
6066 ( p_api_version => p_api_version
6067 ,p_commit => fnd_api.g_false
6068 ,p_init_msg_list => p_init_msg_list
6069 ,p_validation_level => p_validation_level
6070 ,p_ext_attrib_rec => p_ext_attrib_tbl(tab_row)
6071 ,p_txn_rec => p_txn_rec
6072 ,x_return_status => x_return_status
6073 ,x_msg_count => x_msg_count
6074 ,x_msg_data => x_msg_data
6075 ,p_ext_id_tbl => l_ext_id_tbl
6076 ,p_ext_count_rec => l_ext_count_rec
6077 ,p_ext_attr_tbl => l_ext_attr_tbl
6078 ,p_ext_cat_tbl => l_ext_cat_tbl
6079 );
6080
6081 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
6082 l_msg_index := 1;
6083 l_msg_count := x_msg_count;
6084 WHILE l_msg_count > 0 LOOP
6085 x_msg_data := FND_MSG_PUB.GET
6086 (l_msg_index,
6087 FND_API.G_FALSE );
6088
6089 csi_gen_utility_pvt.put_line( ' Failed Pub:create_extended_attrib_values..');
6090 csi_gen_utility_pvt.put_line('message data = '||x_msg_data);
6091 l_msg_index := l_msg_index + 1;
6092 l_msg_count := l_msg_count - 1;
6093 END LOOP;
6094 RAISE FND_API.G_EXC_ERROR;
6095 END IF;
6096 END IF;
6097 END LOOP;
6098 END IF;
6099
6100 -- End of API body
6101
6102
6103 -- Standard check of p_commit.
6104 IF FND_API.To_Boolean( p_commit ) THEN
6105 COMMIT WORK;
6106 END IF;
6107
6108 /***** srramakr commented for bug # 3304439
6109 -- Check for the profile option and disable the trace
6110 IF (fnd_profile.value('CSI_ENABLE_SQL_TRACE') = 'Y') THEN
6111 dbms_session.set_sql_trace(false);
6112 END IF;
6113 -- End disable trace
6114 ****/
6115
6116
6117 -- Standard call to get message count and if count is get message info.
6118 FND_MSG_PUB.Count_And_Get
6119 (p_count => x_msg_count ,
6120 p_data => x_msg_data
6121 );
6122
6123
6124 EXCEPTION
6125
6126 WHEN FND_API.G_EXC_ERROR THEN
6127 ROLLBACK TO create_extended_attrib_values;
6128 x_return_status := FND_API.G_RET_STS_ERROR ;
6129 FND_MSG_PUB.Count_And_Get
6130 ( p_count => x_msg_count,
6131 p_data => x_msg_data
6132 );
6133
6134 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6135 ROLLBACK TO create_extended_attrib_values;
6136 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6137 FND_MSG_PUB.Count_And_Get
6138 ( p_count => x_msg_count,
6139 p_data => x_msg_data
6140 );
6141
6142 WHEN OTHERS THEN
6143
6144 ROLLBACK TO create_extended_attrib_values;
6145 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6146
6147 IF FND_MSG_PUB.Check_Msg_Level
6148 (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6149 THEN
6150 FND_MSG_PUB.Add_Exc_Msg
6151 ( g_pkg_name,
6152 l_api_name
6153 );
6154 END IF;
6155
6156 FND_MSG_PUB.Count_And_Get
6157 ( p_count => x_msg_count,
6158 p_data => x_msg_data
6159 );
6160
6161 END create_extended_attrib_values;
6162
6163 /*----------------------------------------------------*/
6164 /* procedure name: update_extended_attrib_values */
6165 /* description : Updates extended attrib values for */
6166 /* for an item instance */
6167 /*----------------------------------------------------*/
6168
6169 PROCEDURE update_extended_attrib_values
6170 ( p_api_version IN NUMBER
6171 ,p_commit IN VARCHAR2
6172 ,p_init_msg_list IN VARCHAR2
6173 ,p_validation_level IN NUMBER
6174 ,p_ext_attrib_tbl IN csi_datastructures_pub.extend_attrib_values_tbl
6175 ,p_txn_rec IN OUT NOCOPY csi_datastructures_pub.transaction_rec
6176 ,x_return_status OUT NOCOPY VARCHAR2
6177 ,x_msg_count OUT NOCOPY NUMBER
6178 ,x_msg_data OUT NOCOPY VARCHAR2
6179 )
6180
6181 IS
6182 l_api_name CONSTANT VARCHAR2(30) := 'update_extended_attrib_values';
6183 l_api_version CONSTANT NUMBER := 1.0;
6184 l_debug_level NUMBER;
6185 l_msg_index NUMBER;
6186 l_msg_count NUMBER;
6187 l_trace_enable_flag VARCHAR2(1) :='N';
6188 l_ext_id_tbl csi_item_instance_pvt.ext_id_tbl;
6189 l_ext_count_rec csi_item_instance_pvt.ext_count_rec;
6190 l_ext_attr_tbl csi_item_instance_pvt.ext_attr_tbl;
6191 l_ext_cat_tbl csi_item_instance_pvt.ext_cat_tbl;
6192 BEGIN
6193
6194 -- Standard Start of API savepoint
6195 SAVEPOINT update_extended_attrib_values;
6196
6197 -- Check for freeze_flag in csi_install_parameters is set to 'Y'
6198
6199 csi_utility_grp.check_ib_active;
6200
6201 -- Standard call to check for call compatibility.
6202 IF NOT FND_API.Compatible_API_Call (l_api_version,
6203 p_api_version,
6204 l_api_name,
6205 g_pkg_name)
6206 THEN
6207 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6208 END IF;
6209
6210
6211 -- Initialize message list if p_init_msg_list is set to TRUE.
6212 IF FND_API.to_Boolean( p_init_msg_list ) THEN
6213 FND_MSG_PUB.initialize;
6214 END IF;
6215
6216
6217 -- Initialize API return status to success
6218 x_return_status := FND_API.G_RET_STS_SUCCESS;
6219
6220
6221 -- Check the profile option debug_level for debug message reporting
6222 l_debug_level:=fnd_profile.value('CSI_DEBUG_LEVEL');
6223
6224 -- If debug_level = 1 then dump the procedure name
6225 IF (l_debug_level > 0) THEN
6226 csi_gen_utility_pvt.put_line( 'update_extended_attrib_values');
6227 END IF;
6228
6229
6230 -- If the debug level = 2 then dump all the parameters values.
6231 IF (l_debug_level > 1) THEN
6232 csi_gen_utility_pvt.put_line( p_api_version ||'-'
6233 || p_commit ||'-'
6234 || p_init_msg_list ||'-'
6235 || p_validation_level );
6236
6237 -- Dump extended attribs tbl
6238 csi_gen_utility_pvt.dump_ext_attrib_values_tbl(p_ext_attrib_tbl);
6239 -- Dump txn_rec
6240 csi_gen_utility_pvt.dump_txn_rec(p_txn_rec);
6241 END IF;
6242
6243 /***** srramakr commented for bug # 3304439
6244 -- Check for the profile option and enable trace
6245 l_trace_enable_flag:=CSI_GEN_UTILITY_PVT.enable_trace(l_trace_flag => l_trace_enable_flag);
6246 -- End enable trace
6247 ****/
6248
6249
6250 -- Start API body
6251 IF p_ext_attrib_tbl.COUNT > 0 THEN
6252 FOR tab_row IN p_ext_attrib_tbl.FIRST .. p_ext_attrib_tbl.LAST
6253 LOOP
6254 IF p_ext_attrib_tbl.EXISTS(tab_row) THEN
6255 csi_item_instance_pvt.update_extended_attrib_values
6256 (p_api_version => p_api_version
6257 ,p_commit => fnd_api.g_false
6258 ,p_init_msg_list => p_init_msg_list
6259 ,p_validation_level => p_validation_level
6260 ,p_ext_attrib_rec => p_ext_attrib_tbl(tab_row)
6261 ,p_txn_rec => p_txn_rec
6262 ,x_return_status => x_return_status
6263 ,x_msg_count => x_msg_count
6264 ,x_msg_data => x_msg_data
6265 -- ,p_ext_id_tbl => l_ext_id_tbl
6266 -- ,p_ext_count_rec => l_ext_count_rec
6267 -- ,p_ext_attr_tbl => l_ext_attr_tbl
6268 -- ,p_ext_cat_tbl => l_ext_cat_tbl
6269 );
6270
6271 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
6272 l_msg_index := 1;
6273 l_msg_count := x_msg_count;
6274 WHILE l_msg_count > 0 LOOP
6275 x_msg_data := FND_MSG_PUB.GET
6276 (l_msg_index,
6277 FND_API.G_FALSE );
6278
6279 csi_gen_utility_pvt.put_line( ' Failed Pub:update_extended_attrib_values..');
6280 csi_gen_utility_pvt.put_line('message data = '||x_msg_data);
6281 l_msg_index := l_msg_index + 1;
6282 l_msg_count := l_msg_count - 1;
6283 END LOOP;
6284 RAISE FND_API.G_EXC_ERROR;
6285 END IF;
6286
6287 END IF;
6288 END LOOP;
6289 END IF;
6290
6291 -- End of API body
6292
6293 -- Standard check of p_commit.
6294 IF FND_API.To_Boolean( p_commit ) THEN
6295 COMMIT WORK;
6296 END IF;
6297
6298 /***** srramakr commented for bug # 3304439
6299 -- Check for the profile option and disable the trace
6300 IF (l_trace_enable_flag = 'Y') THEN
6301 dbms_session.set_sql_trace(false);
6302 END IF;
6303 -- End disable trace
6304 ****/
6305
6306 -- Standard call to get message count and if count is get message info.
6307 FND_MSG_PUB.Count_And_Get
6308 (p_count => x_msg_count ,
6309 p_data => x_msg_data
6310 );
6311
6312
6313 EXCEPTION
6314
6315 WHEN FND_API.G_EXC_ERROR THEN
6316 ROLLBACK TO update_extended_attrib_values;
6317 x_return_status := FND_API.G_RET_STS_ERROR ;
6318 FND_MSG_PUB.Count_And_Get
6319 ( p_count => x_msg_count,
6320 p_data => x_msg_data
6321 );
6322
6323 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6324 ROLLBACK TO update_extended_attrib_values;
6325 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6326 FND_MSG_PUB.Count_And_Get
6327 ( p_count => x_msg_count,
6328 p_data => x_msg_data
6329 );
6330
6331 WHEN OTHERS THEN
6332 ROLLBACK TO update_extended_attrib_values;
6333 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6334
6335 IF FND_MSG_PUB.Check_Msg_Level
6336 (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6337 THEN
6338 FND_MSG_PUB.Add_Exc_Msg
6339 ( g_pkg_name ,
6340 l_api_name
6341 );
6342 END IF;
6343
6344 FND_MSG_PUB.Count_And_Get
6345 ( p_count => x_msg_count,
6346 p_data => x_msg_data
6347 );
6348
6349 END update_extended_attrib_values;
6350
6351 /*----------------------------------------------------*/
6352 /* procedure name: Expire_extended_attrib_values */
6353 /* description : Expires extended attribute values */
6354 /* for an item instance */
6355 /*----------------------------------------------------*/
6356
6357 PROCEDURE expire_extended_attrib_values
6358 ( p_api_version IN NUMBER
6359 ,p_commit IN VARCHAR2
6360 ,p_init_msg_list IN VARCHAR2
6361 ,p_validation_level IN NUMBER
6362 ,p_ext_attrib_tbl IN csi_datastructures_pub.extend_attrib_values_tbl
6363 ,p_txn_rec IN OUT NOCOPY csi_datastructures_pub.transaction_rec
6364 ,x_return_status OUT NOCOPY VARCHAR2
6365 ,x_msg_count OUT NOCOPY NUMBER
6366 ,x_msg_data OUT NOCOPY VARCHAR2
6367 )
6368
6369 IS
6370 l_api_name CONSTANT VARCHAR2(30) := 'delete_extended_attrib_values';
6371 l_api_version CONSTANT NUMBER := 1.0;
6372 l_debug_level NUMBER;
6373 l_msg_index NUMBER;
6374 l_msg_count NUMBER;
6375 l_trace_enable_flag VARCHAR2(1) :='N';
6376 BEGIN
6377
6378 -- Standard Start of API savepoint
6379 SAVEPOINT delete_extended_attrib_values;
6380
6381 -- Check for freeze_flag in csi_install_parameters is set to 'Y'
6382
6383 csi_utility_grp.check_ib_active;
6384
6385 -- Standard call to check for call compatibility.
6386 IF NOT FND_API.Compatible_API_Call (l_api_version,
6387 p_api_version,
6388 l_api_name ,
6389 g_pkg_name)
6390 THEN
6391 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6392 END IF;
6393
6394
6395 -- Initialize message list if p_init_msg_list is set to TRUE.
6396 IF FND_API.to_Boolean( p_init_msg_list ) THEN
6397 FND_MSG_PUB.initialize;
6398 END IF;
6399
6400
6401 -- Initialize API return status to success
6402 x_return_status := FND_API.G_RET_STS_SUCCESS;
6403
6404
6405 -- Check the profile option debug_level for debug message reporting
6406
6407 l_debug_level:=fnd_profile.value('CSI_DEBUG_LEVEL');
6408
6409 -- If debug_level = 1 then dump the procedure name
6410 IF (l_debug_level > 0) THEN
6411 csi_gen_utility_pvt.put_line( 'delete_extended_attrib_values');
6412 END IF;
6413
6414
6415 -- If the debug level = 2 then dump all the parameters values.
6416 IF (l_debug_level > 1) THEN
6417 csi_gen_utility_pvt.put_line( p_api_version ||'-'
6418 || p_commit ||'-'
6419 || p_init_msg_list ||'-'
6420 || p_validation_level );
6421 -- Dump extended attribs tbl
6422 csi_gen_utility_pvt.dump_ext_attrib_values_tbl(p_ext_attrib_tbl);
6423 -- Dump txn_rec
6424 csi_gen_utility_pvt.dump_txn_rec(p_txn_rec);
6425 END IF;
6426
6427 /***** srramakr commented for bug # 3304439
6428 -- Check for the profile option and enable trace
6429 l_trace_enable_flag:=CSI_GEN_UTILITY_PVT.enable_trace(l_trace_flag => l_trace_enable_flag);
6430 -- End enable trace
6431 ****/
6432
6433
6434 -- Start API body
6435
6436 IF p_ext_attrib_tbl.COUNT > 0 THEN
6437 FOR tab_row IN p_ext_attrib_tbl.FIRST .. p_ext_attrib_tbl.LAST
6438 LOOP
6439 IF p_ext_attrib_tbl.EXISTS(tab_row) THEN
6440
6441 csi_item_instance_pvt.expire_extended_attrib_values
6442 ( p_api_version => p_api_version
6443 ,p_commit => fnd_api.g_false
6444 ,p_init_msg_list => p_init_msg_list
6445 ,p_validation_level => p_validation_level
6446 ,p_ext_attrib_rec => p_ext_attrib_tbl(tab_row)
6447 ,p_txn_rec => p_txn_rec
6448 ,x_return_status => x_return_status
6449 ,x_msg_count => x_msg_count
6450 ,x_msg_data => x_msg_data
6451 );
6452
6453 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
6454 l_msg_index := 1;
6455 l_msg_count := x_msg_count;
6456 WHILE l_msg_count > 0 LOOP
6457 x_msg_data := FND_MSG_PUB.GET
6458 (l_msg_index,
6459 FND_API.G_FALSE );
6460
6461 csi_gen_utility_pvt.put_line( ' Failed Pub:expire_extended_attrib_values..');
6462 csi_gen_utility_pvt.put_line('message data = '||x_msg_data);
6463 l_msg_index := l_msg_index + 1;
6464 l_msg_count := l_msg_count - 1;
6465 END LOOP;
6466 RAISE FND_API.G_EXC_ERROR;
6467 END IF;
6468 END IF;
6469 END LOOP;
6470 END IF;
6471
6472 -- End of API body
6473
6474
6475 -- Standard check of p_commit.
6476 IF FND_API.To_Boolean( p_commit ) THEN
6477 COMMIT WORK;
6478 END IF;
6479
6480 /***** srramakr commented for bug # 3304439
6481 -- Check for the profile option and disable the trace
6482 IF (l_trace_enable_flag = 'Y') THEN
6483 dbms_session.set_sql_trace(false);
6484 END IF;
6485 -- End disable trace
6486 ****/
6487
6488
6489 -- Standard call to get message count and if count is get message info.
6490 FND_MSG_PUB.Count_And_Get
6491 (p_count => x_msg_count ,
6492 p_data => x_msg_data
6493 );
6494
6495
6496 EXCEPTION
6497
6498 WHEN FND_API.G_EXC_ERROR THEN
6499 ROLLBACK TO delete_extended_attrib_values;
6500 x_return_status := FND_API.G_RET_STS_ERROR ;
6501 FND_MSG_PUB.Count_And_Get
6502 ( p_count => x_msg_count,
6503 p_data => x_msg_data
6504 );
6505
6506 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6507 ROLLBACK TO delete_extended_attrib_values;
6508 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6509 FND_MSG_PUB.Count_And_Get
6510 ( p_count => x_msg_count,
6511 p_data => x_msg_data
6512 );
6513
6514 WHEN OTHERS THEN
6515 ROLLBACK TO delete_extended_attrib_values;
6516 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6517
6518 IF FND_MSG_PUB.Check_Msg_Level
6519 (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6520 THEN
6521 FND_MSG_PUB.Add_Exc_Msg
6522 ( g_pkg_name ,
6523 l_api_name
6524 );
6525 END IF;
6526
6527 FND_MSG_PUB.Count_And_Get
6528 ( p_count => x_msg_count,
6529 p_data => x_msg_data
6530 );
6531
6532 END expire_extended_attrib_values;
6533
6534
6535
6536
6537 /*------------------------------------------------------*/
6538 /* procedure name: copy_item_instance */
6539 /* description : Copies an instace from an instance */
6540 /* */
6541 /*------------------------------------------------------*/
6542
6543 PROCEDURE copy_item_instance
6544 (
6545 p_api_version IN NUMBER
6546 ,p_commit IN VARCHAR2
6547 ,p_init_msg_list IN VARCHAR2
6548 ,p_validation_level IN NUMBER
6549 ,p_source_instance_rec IN csi_datastructures_pub.instance_rec
6550 ,p_copy_ext_attribs IN VARCHAR2
6551 ,p_copy_org_assignments IN VARCHAR2
6552 ,p_copy_parties IN VARCHAR2
6553 ,p_copy_party_contacts IN VARCHAR2
6554 ,p_copy_accounts IN VARCHAR2
6555 ,p_copy_asset_assignments IN VARCHAR2
6556 ,p_copy_pricing_attribs IN VARCHAR2
6557 ,p_copy_inst_children IN VARCHAR2
6558 ,p_txn_rec IN OUT NOCOPY csi_datastructures_pub.transaction_rec
6559 ,x_new_instance_tbl OUT NOCOPY csi_datastructures_pub.instance_tbl
6560 ,x_return_status OUT NOCOPY VARCHAR2
6561 ,x_msg_count OUT NOCOPY NUMBER
6562 ,x_msg_data OUT NOCOPY VARCHAR2
6563 )
6564 IS
6565
6566 l_api_name CONSTANT VARCHAR2(30) := 'copy_item_instance';
6567 l_api_version CONSTANT NUMBER := 1.0;
6568 l_debug_level NUMBER;
6569
6570 l_msg_index NUMBER;
6571 l_msg_count NUMBER;
6572 x_msg_index_out NUMBER;
6573 BEGIN
6574
6575 -- Standard Start of API savepoint
6576 SAVEPOINT copy_item_instance;
6577
6578 -- Check for freeze_flag in csi_install_parameters is set to 'Y'
6579
6580 csi_utility_grp.check_ib_active;
6581
6582 -- Standard call to check for call compatibility.
6583 IF NOT FND_API.Compatible_API_Call (l_api_version,
6584 p_api_version,
6585 l_api_name ,
6586 G_PKG_NAME)
6587 THEN
6588 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6589 END IF;
6590
6591 -- Initialize message list if p_init_msg_list is set to TRUE.
6592 IF FND_API.to_Boolean( p_init_msg_list ) THEN
6593 FND_MSG_PUB.initialize;
6594 END IF;
6595
6596 -- Initialize API return status to success
6597 x_return_status := FND_API.G_RET_STS_SUCCESS;
6598
6599 -- Check the profile option debug_level for debug message reporting
6600 l_debug_level:=fnd_profile.value('CSI_DEBUG_LEVEL');
6601
6602 -- If debug_level = 1 then dump the procedure name
6603 IF (l_debug_level > 0) THEN
6604 csi_gen_utility_pvt.put_line('copy_item_instance ');
6605 END IF;
6606
6607 -- If the debug level = 2 then dump all the parameters values.
6608 IF (l_debug_level > 1) THEN
6609 csi_gen_utility_pvt.put_line('copy_item_instance '||
6610 p_api_version ||'-'
6611 || p_commit ||'-'
6612 || p_init_msg_list ||'-'
6613 || p_validation_level ||'-'
6614 || p_copy_ext_attribs ||'-'
6615 || p_copy_org_assignments ||'-'
6616 || p_copy_parties ||'-'
6617 || p_copy_party_contacts ||'-'
6618 || p_copy_accounts ||'-'
6619 || p_copy_asset_assignments ||'-'
6620 || p_copy_pricing_attribs
6621 );
6622
6623 -- Dump item instanc red
6624 csi_gen_utility_pvt.dump_instance_rec(p_source_instance_rec);
6625 -- Dump txn_rec
6626 csi_gen_utility_pvt.dump_txn_rec(p_txn_rec);
6627
6628 END IF;
6629
6630 -- Start API body
6631
6632 csi_item_instance_pvt.copy_item_instance
6633 ( p_api_version => p_api_version
6634 ,p_commit => fnd_api.g_false
6635 ,p_init_msg_list => p_init_msg_list
6636 ,p_validation_level => p_validation_level
6637 ,p_source_instance_rec => p_source_instance_rec
6638 ,p_copy_ext_attribs => p_copy_ext_attribs
6639 ,p_copy_org_assignments => p_copy_org_assignments
6640 ,p_copy_parties => p_copy_parties
6641 ,p_copy_contacts => p_copy_party_contacts
6642 ,p_copy_accounts => p_copy_accounts
6643 ,p_copy_asset_assignments => p_copy_asset_assignments
6644 ,p_copy_pricing_attribs => p_copy_pricing_attribs
6645 ,p_copy_inst_children => p_copy_inst_children
6646 ,p_call_from_split => fnd_api.g_false
6647 ,p_txn_rec => p_txn_rec
6648 ,x_new_instance_tbl => x_new_instance_tbl
6649 ,x_return_status => x_return_status
6650 ,x_msg_count => x_msg_count
6651 ,x_msg_data => x_msg_data
6652 );
6653
6654 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
6655 FOR i in 1..x_msg_Count LOOP
6656 FND_MSG_PUB.Get(p_msg_index => i,
6657 p_encoded => 'F',
6658 p_data => x_msg_data,
6659 p_msg_index_out => x_msg_index_out );
6660
6661 csi_gen_utility_pvt.put_line('message data = '||x_msg_data);
6662 End LOOP;
6663 RAISE fnd_api.g_exc_error;
6664 END IF;
6665
6666 -- End of API body
6667
6668 -- Standard check of p_commit
6669 IF FND_API.To_Boolean( p_commit ) THEN
6670 COMMIT WORK;
6671 END IF;
6672
6673
6674 -- Standard call to get message count and if count is get message info.
6675
6676 FND_MSG_PUB.Count_And_Get
6677 (p_count => x_msg_count ,
6678 p_data => x_msg_data
6679 );
6680
6681
6682 EXCEPTION
6683 WHEN FND_API.G_EXC_ERROR THEN
6684 ROLLBACK TO copy_item_instance;
6685 x_return_status := FND_API.G_RET_STS_ERROR ;
6686 FND_MSG_PUB.Count_And_Get
6687 ( p_count => x_msg_count,
6688 p_data => x_msg_data
6689 );
6690
6691 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6692 ROLLBACK TO copy_item_instance;
6693 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6694 FND_MSG_PUB.Count_And_Get
6695 ( p_count => x_msg_count,
6696 p_data => x_msg_data
6697 );
6698
6699 WHEN OTHERS THEN
6700 ROLLBACK TO copy_item_instance;
6701 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6702 IF FND_MSG_PUB.Check_Msg_Level
6703 (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
6704 THEN
6705 FND_MSG_PUB.Add_Exc_Msg
6706 ( G_PKG_NAME ,
6707 l_api_name
6708 );
6709 END IF;
6710
6711 FND_MSG_PUB.Count_And_Get
6712 ( p_count => x_msg_count,
6713 p_data => x_msg_data
6714 );
6715
6716
6717 END copy_item_instance;
6718
6719 PROCEDURE get_oks_txn_types (
6720 p_api_version IN NUMBER
6721 ,p_commit IN VARCHAR2
6722 ,p_init_msg_list IN VARCHAR2
6723 ,p_instance_rec IN CSI_DATASTRUCTURES_PUB.INSTANCE_REC
6724 ,p_check_contracts_yn IN VARCHAR2
6725 ,p_txn_type IN VARCHAR2
6726 ,x_txn_type_tbl OUT NOCOPY CSI_ITEM_INSTANCE_PUB.TXN_OKS_TYPE_TBL
6727 ,x_configflag OUT NOCOPY VARCHAR2
6728 ,px_txn_date IN OUT NOCOPY DATE
6729 ,x_imp_contracts_flag OUT NOCOPY VARCHAR2
6730 ,x_return_status OUT NOCOPY VARCHAR2
6731 ,x_msg_count OUT NOCOPY NUMBER
6732 ,x_msg_data OUT NOCOPY VARCHAR2
6733 ) IS
6734
6735 CURSOR old_instance_rec ( cp_instance_id NUMBER) is
6736 SELECT quantity, install_date, active_end_date
6737 FROM csi_item_instances
6738 WHERE instance_id = cp_instance_id;
6739
6740 l_curr_instance_rec old_instance_rec%ROWTYPE;
6741 l_row_index NUMBER := 0;
6742 l_exists VARCHAR(1);
6743 l_msg_count NUMBER;
6744 l_msg_index NUMBER;
6745 l_oks_txn_tbl oks_ibint_pub.txn_tbl_type;
6746
6747 BEGIN
6748 SAVEPOINT get_oks_txn_types;
6749
6750 OPEN old_instance_rec(p_instance_rec.INSTANCE_ID);
6751 FETCH old_instance_rec INTO l_curr_instance_rec;
6752 CLOSE old_instance_rec;
6753
6754 IF p_txn_type IS NULL THEN
6755
6756 IF l_curr_instance_rec.quantity <> p_instance_rec.quantity THEN
6757 x_txn_type_tbl(l_row_index) := 'UPD';
6758 l_row_index := l_row_index + 1;
6759 END IF;
6760
6761 IF NVL(l_curr_instance_rec.install_date,FND_API.G_MISS_DATE) <>
6762 NVL(p_instance_rec.install_date,FND_API.G_MISS_DATE) THEN
6763 x_txn_type_tbl(l_row_index) := 'IDC';
6764 l_row_index := l_row_index + 1;
6765 END IF;
6766
6767 IF p_instance_rec.active_end_date IS NOT NULL AND
6768 p_instance_rec.active_end_date <> FND_API.G_MISS_DATE AND
6769 p_instance_rec.active_end_date <= SYSDATE THEN
6770 x_txn_type_tbl(l_row_index) := 'TRM';
6771 l_row_index := l_row_index + 1;
6772 END IF;
6773
6774 /*
6775 IF l_curr_instance_rec.active_end_date IS NOT NULL AND
6776 l_curr_instance_rec.active_end_date <= SYSDATE AND
6777 (p_instance_rec.active_end_date IS NULL OR
6778 (p_instance_rec.active_end_date IS NOT NULL AND
6779 p_instance_rec.active_end_date <> FND_API.G_MISS_DATE AND
6780 p_instance_rec.active_end_date > SYSDATE) ) THEN
6781 */
6782 IF (l_curr_instance_rec.active_end_date IS NOT NULL
6783 AND ( p_instance_rec.active_end_date <> FND_API.G_MISS_DATE or p_instance_rec.active_end_date is null))
6784 AND ((l_curr_instance_rec.active_end_date < p_instance_rec.active_end_date
6785 AND p_instance_rec.active_end_date > SYSDATE)
6786 OR (p_instance_rec.active_end_date IS NULL)) THEN
6787 x_txn_type_tbl(l_row_index) := 'RIN';
6788 l_row_index := l_row_index + 1;
6789 END IF;
6790
6791 ELSE
6792 x_txn_type_tbl(l_row_index) := p_txn_type;
6793 l_row_index := l_row_index + 1;
6794 END IF;
6795
6796 l_exists := NULL;
6797 Begin
6798 -- Commenting the following code for bug 4775959
6799 /*
6800 SELECT 'x' INTO l_exists
6801 FROM dual
6802 WHERE EXISTS (SELECT 'x'
6803 FROM csi_ii_relationships
6804 WHERE object_id = p_instance_rec.instance_id
6805 AND relationship_type_code = 'COMPONENT-OF'
6806 AND NVL (active_end_date,(sysdate+1)) > sysdate);
6807 */
6808 SELECT 'x'
6809 INTO l_exists
6810 FROM csi_ii_relationships
6811 WHERE object_id = p_instance_rec.instance_id
6812 AND relationship_type_code = 'COMPONENT-OF'
6813 AND NVL (active_end_date,(sysdate+1)) > sysdate
6814 AND ROWNUM=1;
6815 Exception
6816 when no_data_found then
6817 l_exists := null;
6818 End;
6819
6820 IF l_exists IS NULL THEN
6821 x_configflag := 'N';
6822 ELSE
6823 x_configflag := 'Y';
6824 END IF;
6825
6826 IF px_txn_date IS NULL THEN
6827 px_txn_date := sysdate;
6828 END IF;
6829
6830 IF x_txn_type_tbl.count > 0 THEN
6831 FOR i in x_txn_type_tbl.FIRST..x_txn_type_tbl.LAST
6832 LOOP
6833 l_oks_txn_tbl(i) := x_txn_type_tbl(i);
6834 END LOOP;
6835 END IF;
6836
6837 IF p_check_contracts_yn = 'Y' THEN
6838 OKS_IBINT_PUB.CHECK_CONTRACTS_IMPACTED(
6839 p_api_version => 1.0,
6840 P_instance_id => p_instance_rec.INSTANCE_ID,
6841 p_parent_instance_yn => x_configflag,
6842 p_transaction_date => px_txn_date,
6843 p_new_install_date => p_instance_rec.install_date,
6844 P_txn_tbl => l_oks_txn_tbl,
6845 x_contract_exists_yn => x_imp_contracts_flag,
6846 X_msg_Count => x_msg_count,
6847 X_msg_Data => x_msg_data,
6848 x_return_status => x_return_status
6849 );
6850
6851 IF l_oks_txn_tbl.count > 0 THEN
6852 FOR i in l_oks_txn_tbl.FIRST..l_oks_txn_tbl.LAST
6853 LOOP
6854 x_txn_type_tbl(i) := l_oks_txn_tbl(i);
6855 END LOOP;
6856 END IF;
6857
6858 IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS)
6859 THEN
6860 csi_gen_utility_pvt.put_line('Error from Call_to_contracts...');
6861 l_msg_index := 1;
6862 l_msg_count := x_msg_count;
6863 WHILE l_msg_count > 0 LOOP
6864 x_msg_data := FND_MSG_PUB.GET
6865 ( l_msg_index,
6866 FND_API.G_FALSE
6867 );
6868 csi_gen_utility_pvt.put_line('MESSAGE DATA = '||x_msg_data);
6869 l_msg_index := l_msg_index + 1;
6870 l_msg_count := l_msg_count - 1;
6871 END LOOP;
6872 RAISE FND_API.G_EXC_ERROR;
6873 END IF;
6874
6875 END IF;
6876
6877 EXCEPTION
6878 WHEN FND_API.G_EXC_ERROR THEN
6879 ROLLBACK TO get_oks_txn_types;
6880 x_return_status := FND_API.G_RET_STS_ERROR ;
6881
6882 END get_oks_txn_types;
6883
6884
6885 END CSI_ITEM_INSTANCE_PUB;