43:
44: ret_code NUMBER := 0;
45: l_err_text VARCHAR2(2000);
46:
47: l_return_status VARCHAR2(1); -- := fnd_api.g_MISS_CHAR
48: l_msg_count NUMBER;
49: l_msg_data VARCHAR2(2000);
50:
51: l_msg_name VARCHAR2(2000);
57: l_item_desc_element_table ITEM_DESC_ELEMENT_TABLE;
58: BEGIN
59:
60: -- Check for call compatibility.
61: IF NOT FND_API.Compatible_API_Call (l_api_version,
62: p_api_version ,
63: l_api_name ,
64: G_PKG_NAME)
65: THEN
62: p_api_version ,
63: l_api_name ,
64: G_PKG_NAME)
65: THEN
66: RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
67: END IF;
68:
69: -- Standard Start of API savepoint
70: SAVEPOINT Process_item_descr_elem_PUB;
69: -- Standard Start of API savepoint
70: SAVEPOINT Process_item_descr_elem_PUB;
71:
72: -- Initialize message list if p_init_msg_list is set to TRUE.
73: IF FND_API.to_Boolean( p_init_msg_list ) THEN
74: FND_MSG_PUB.initialize;
75: END IF;
76:
77: INV_ITEM_MSG.set_Message_Mode('PLSQL');
94: INV_ITEM_MSG.g_Prog_appid := FND_GLOBAL.prog_appl_id ;
95: INV_ITEM_MSG.g_Prog_id := FND_GLOBAL.conc_program_id;
96: INV_ITEM_MSG.g_Request_id := FND_GLOBAL.conc_request_id;
97:
98: x_return_status := fnd_api.g_RET_STS_SUCCESS;
99: ------------------------------------------------------------------------------------------
100: -- Process step 1: Loop through item catlog group elements interface records --
101: -- (a) Check for duplicate records in the interface table table --
102: ------------------------------------------------------------------------------------------
113: , p_token1 => 'ELEMENT_NAME'
114: , p_value1 => l_item_desc_element_table(icoi_rec).ELEMENT_NAME
115: );
116: l_item_desc_element_table.DELETE(icoi_rec_dup);
117: x_return_status := fnd_api.g_RET_STS_ERROR;
118: END IF;
119: END IF;
120: END LOOP;--} icoi_csr_dup
121: END LOOP; --} icoi_csr
133: INV_ITEM_MSG.Debug(Mctx, 'starting the main ICatalogOI loop step2');
134:
135: FOR icoi_rec IN l_item_desc_element_table.first .. l_item_desc_element_table.last LOOP --{
136:
137: l_return_status := fnd_api.g_RET_STS_SUCCESS;
138:
139: -- call the API to process item catalog element values
140:
141: IF ( l_item_desc_element_table.EXISTS(icoi_rec) ) THEN
145:
146: INV_ITEM_CATALOG_ELE_PVT.Catalog_Grp_Ele_Val_Assignment
147: (
148: p_api_version => 1.0
149: , p_init_msg_list => fnd_api.g_TRUE
150: , p_commit => fnd_api.g_FALSE
151: , p_validation_level => p_validation_level
152: , p_inventory_item_id => p_inventory_item_id
153: , p_item_number => p_item_number
146: INV_ITEM_CATALOG_ELE_PVT.Catalog_Grp_Ele_Val_Assignment
147: (
148: p_api_version => 1.0
149: , p_init_msg_list => fnd_api.g_TRUE
150: , p_commit => fnd_api.g_FALSE
151: , p_validation_level => p_validation_level
152: , p_inventory_item_id => p_inventory_item_id
153: , p_item_number => p_item_number
154: , p_element_name => l_item_desc_element_table(icoi_rec).ELEMENT_NAME
158: , x_msg_count => l_msg_count
159: , x_msg_data => l_msg_data
160: );
161:
162: IF ( l_return_status = fnd_api.g_RET_STS_SUCCESS ) THEN
163: NULL;
164: ELSE
165: INV_ITEM_MSG.Debug(Mctx, 'error in Catalog_Grp_Ele_Val_Assignment. Msg count=' || TO_CHAR(INV_ITEM_MSG.Count_Msg));
166: x_return_status := l_return_status;
166: x_return_status := l_return_status;
167: END IF; -- l_return_status
168:
169: -- If unexpected error in Catalog_Grp_Ele_Val_Assignment API, stop the processing
170: IF ( l_return_status = fnd_api.g_RET_STS_UNEXP_ERROR ) THEN
171: x_return_status := l_return_status;
172: RAISE Processing_Error;
173: END IF;
174:
187: show_all_delim=>'Y',
188: error_text=>l_error_msg);
189:
190: -- Check of commit
191: IF ( FND_API.To_Boolean(p_commit_flag) ) THEN
192: COMMIT WORK;
193: END IF;
194: --
195: -- Determine request return code
212:
213: WHEN others THEN
214: ROLLBACK TO Process_item_descr_elem_PUB;
215: l_err_text := SUBSTRB(SQLERRM, 1,240);
216: x_return_status := fnd_api.g_RET_STS_UNEXP_ERROR;
217: INV_ITEM_MSG.Add_Message
218: ( p_Msg_Name => 'INV_ITEM_UNEXPECTED_ERROR'
219: , p_token1 => 'PKG_NAME'
220: , p_value1 => G_PKG_NAME
305: ret_code NUMBER := 0;
306: l_err_text VARCHAR2(2000);
307:
308: l_commit VARCHAR2(1);
309: l_return_status VARCHAR2(1); -- := fnd_api.g_MISS_CHAR
310: l_msg_count NUMBER;
311: l_msg_data VARCHAR2(2000);
312:
313: l_msg_name VARCHAR2(2000);
360: INV_ITEM_MSG.g_Prog_id := g_Prog_id;
361: INV_ITEM_MSG.g_Request_id := g_Request_id;
362:
363: IF ( p_commit_flag = 1 ) THEN
364: l_commit := fnd_api.g_TRUE;
365: ELSE
366: l_commit := fnd_api.g_FALSE;
367: END IF;
368:
362:
363: IF ( p_commit_flag = 1 ) THEN
364: l_commit := fnd_api.g_TRUE;
365: ELSE
366: l_commit := fnd_api.g_FALSE;
367: END IF;
368:
369: l_RETCODE := G_SUCCESS;
370:
402: --
403: -- Assign missing inventory_item_id from item_number
404: --
405:
406: l_return_status := fnd_api.g_RET_STS_SUCCESS;
407:
408: item_id := icoi_rec1.inventory_item_id;
409: l_item_number := icoi_rec1.item_number;
410:
416: IF ( ret_code = 0 ) THEN
417: l_inventory_item_id := flex_id;
418: IF ((item_id IS NOT NULL)AND
419: (l_inventory_item_id <> item_id)) THEN
420: l_return_status := fnd_api.g_RET_STS_ERROR;
421: l_msg_name := 'INV_CEOI_ITEM_NUM_ID_MISMATCH';
422: l_token := 'VALUE1';
423: l_token_value := l_item_number;
424: l_column_name := 'ITEM_NUMBER';
426: l_token_value := item_id;
427: l_column_name := 'INVENTORY_ITEM_ID';
428: END IF;
429: ELSE
430: l_return_status := fnd_api.g_RET_STS_ERROR;
431: l_msg_name := 'INV_ICOI_INVALID_ITEM_NUMBER';
432: l_token := 'VALUE';
433: l_token_value := l_item_number;
434: l_column_name := 'ITEM_NUMBER';
434: l_column_name := 'ITEM_NUMBER';
435: END IF;
436:
437: ELSIF ( item_id IS NULL )THEN
438: l_return_status := fnd_api.g_RET_STS_ERROR;
439: l_msg_name := 'INV_CEOI_MISS_ITEM_NUMBER';
440: l_token := fnd_api.g_MISS_CHAR;
441: l_token_value := l_item_number||item_id;
442: l_column_name := 'ITEM_NUMBER';
436:
437: ELSIF ( item_id IS NULL )THEN
438: l_return_status := fnd_api.g_RET_STS_ERROR;
439: l_msg_name := 'INV_CEOI_MISS_ITEM_NUMBER';
440: l_token := fnd_api.g_MISS_CHAR;
441: l_token_value := l_item_number||item_id;
442: l_column_name := 'ITEM_NUMBER';
443: END IF;
444: IF (l_return_status = fnd_api.g_RET_STS_ERROR) THEN
440: l_token := fnd_api.g_MISS_CHAR;
441: l_token_value := l_item_number||item_id;
442: l_column_name := 'ITEM_NUMBER';
443: END IF;
444: IF (l_return_status = fnd_api.g_RET_STS_ERROR) THEN
445: INV_ITEM_MSG.Add_Message
446: ( p_Msg_Name => l_msg_name
447: , p_token1 => l_token
448: , p_value1 => l_token_value
466:
467: END LOOP; -- icoi_rec1
468:
469: -- Check of commit
470: IF ( FND_API.To_Boolean(l_commit) ) THEN
471: COMMIT WORK;
472: END IF;
473: -- Write all accumulated messages
474: INV_ITEM_MSG.Write_List (p_delete => TRUE);
504:
505: END LOOP; --} icoi_csr_dup
506: END IF; -- Upload Rec Flag is 1
507: -- Check of commit
508: IF ( FND_API.To_Boolean(l_commit) ) THEN
509: COMMIT WORK;
510: END IF;
511: -- Write all accumulated messages
512: INV_ITEM_MSG.Write_List (p_delete => TRUE);
532: --
533: -- Assign missing inventory_item_id from item_number
534: --
535:
536: l_return_status := fnd_api.g_RET_STS_SUCCESS;
537: l_inventory_item_id := icoi_rec.inventory_item_id;
538: l_item_number := icoi_rec.item_number;
539: l_element_value := icoi_rec.element_value;
540: l_element_name := icoi_rec.element_name;
549:
550: INV_ITEM_CATALOG_ELE_PVT.Catalog_Grp_Ele_Val_Assignment
551: (
552: p_api_version => 1.0
553: , p_init_msg_list => fnd_api.g_TRUE
554: , p_commit => fnd_api.g_FALSE
555: , p_validation_level => g_VALIDATE_IDS
556: , p_inventory_item_id => l_inventory_item_id
557: , p_item_number => l_item_number
550: INV_ITEM_CATALOG_ELE_PVT.Catalog_Grp_Ele_Val_Assignment
551: (
552: p_api_version => 1.0
553: , p_init_msg_list => fnd_api.g_TRUE
554: , p_commit => fnd_api.g_FALSE
555: , p_validation_level => g_VALIDATE_IDS
556: , p_inventory_item_id => l_inventory_item_id
557: , p_item_number => l_item_number
558: , p_element_name => l_element_name
562: , x_msg_count => l_msg_count
563: , x_msg_data => l_msg_data
564: );
565:
566: IF ( l_return_status = fnd_api.g_RET_STS_SUCCESS ) THEN
567: l_process_flag := 7;
568: ELSE
569: l_process_flag := 3;
570: INV_ITEM_MSG.Debug(Mctx, 'error in Catalog_Grp_Ele_Val_Assignment. Msg count=' || TO_CHAR(INV_ITEM_MSG.Count_Msg));
571: l_RETCODE := G_WARNING;
572: END IF; -- l_return_status
573:
574: -- If unexpected error in Catalog_Grp_Ele_Val_Assignment API, stop the processing
575: IF ( l_return_status = fnd_api.g_RET_STS_UNEXP_ERROR ) THEN
576: l_RETCODE := G_ERROR;
577: RAISE Processing_Error;
578: END IF;
579:
606:
607: END LOOP; --} icoi_csr
608:
609: -- Check of commit
610: IF ( FND_API.To_Boolean(l_commit) ) THEN
611: COMMIT WORK;
612: END IF;
613:
614: --
626: );
627:
628: INV_ITEM_MSG.Debug(Mctx, 'done delete_OI_records: return_status=' || l_return_status);
629:
630: IF ( l_return_status <> fnd_api.g_RET_STS_SUCCESS ) THEN
631: RAISE Processing_Error;
632: END IF;
633:
634: -- Write all accumulated messages
658: -- Write all accumulated messages
659: INV_ITEM_MSG.Write_List (p_delete => TRUE);
660:
661: -- Check of commit
662: IF ( FND_API.To_Boolean(l_commit) ) THEN
663: COMMIT WORK;
664: END IF;
665:
666: WHEN others THEN
683: -- Write all accumulated messages
684: INV_ITEM_MSG.Write_List (p_delete => TRUE);
685:
686: -- Check of commit
687: IF ( FND_API.To_Boolean(l_commit) ) THEN
688: COMMIT WORK;
689: END IF;
690:
691: END process_Item_Catalog_grp_recs;
711:
712: INV_ITEM_MSG.Debug(Mctx, 'begin');
713:
714: -- Initialize API return status to success
715: x_return_status := FND_API.g_RET_STS_SUCCESS;
716:
717: LOOP
718: DELETE FROM mtl_desc_elem_val_interface
719: WHERE set_process_id = p_rec_set_id
724:
725: INV_ITEM_MSG.Debug(Mctx, 'deleted ' || TO_CHAR(SQL%ROWCOUNT) || ' record(s)');
726:
727: -- Check of commit
728: IF ( FND_API.To_Boolean(p_commit) ) THEN
729: COMMIT WORK;
730: END IF;
731:
732: END LOOP;
733:
734: EXCEPTION
735:
736: WHEN others THEN
737: x_return_status := FND_API.g_RET_STS_UNEXP_ERROR;
738:
739: INV_ITEM_MSG.Add_Unexpected_Error (Mctx, SQLERRM);
740:
741: -- Check of commit
738:
739: INV_ITEM_MSG.Add_Unexpected_Error (Mctx, SQLERRM);
740:
741: -- Check of commit
742: IF ( FND_API.To_Boolean(p_commit) ) THEN
743: COMMIT WORK;
744: END IF;
745:
746: END delete_OI_records;