1: PACKAGE BODY IBE_Order_Save_pvt AS
2: /* $Header: IBEVORDB.pls 120.5 2006/06/30 11:58:44 akhgupta ship $ */
3:
4: G_PKG_NAME CONSTANT VARCHAR2(30) := 'IBE_Order_Save_pvt';
5: l_true VARCHAR2(1) := FND_API.G_TRUE;
6:
7:
8: PROCEDURE Get_Order_Status(p_header_id IN NUMBER
9: ,x_order_status OUT NOCOPY VARCHAR2
14: SELECT flow_status_code,last_update_date FROM oe_order_headers_all WHERE header_id = p_header_id;
15:
16:
17: l_gethdrstatus c_gethdrstatus%rowtype;
18: lx_order_status VARCHAR2(30) := FND_API.G_MISS_CHAR;
19:
20:
21: BEGIN
22:
26:
27: OPEN c_gethdrstatus(p_header_id);
28: FETCH c_gethdrstatus INTO l_gethdrstatus;
29: IF (c_gethdrstatus%NOTFOUND) THEN
30: x_order_status:= FND_API.G_MISS_CHAR;
31: x_last_update_date := null;
32: ELSE
33: x_order_status := l_gethdrstatus.flow_status_code;
34: x_last_update_date := l_gethdrstatus.last_update_date;
87: FOR k IN 1 .. l_msg_count LOOP
88: i:=1;
89: oe_msg_pub.get (
90: p_msg_index => k
91: ,p_encoded => FND_API.G_FALSE
92: ,p_data => l_msg_data
93: ,p_msg_index_out => l_msg_index);
94:
95: IF (upper(l_msg_data) <> 'ORDER HAS BEEN BOOKED.') THEN -- bug# 1935468
128: IF oe_msg_pub.g_msg_tbl(l_msg_index).message_text IS NULL THEN
129: x_msg_data := oe_msg_pub.get(l_msg_index, 'F');
130: END IF;
131:
132: IF l_msg_orig_sys_line_ref IS NOT NULL AND l_msg_orig_sys_line_ref <> FND_API.G_MISS_CHAR THEN
133: l_msg_context := 'Error in Line: '||rtrim(l_msg_orig_sys_line_ref)||' :';
134: END IF;
135:
136: x_msg_data := l_msg_context||l_msg_data;
420:
421: PROCEDURE DefaultLineRecord(
422: p_order_line_tbl IN OE_Order_PUB.Line_Tbl_Type
423: ,p_order_header_rec IN OE_Order_PUB.Header_Rec_Type
424: ,p_save_type IN NUMBER := FND_API.G_MISS_NUM
425: ,x_order_line_tbl OUT NOCOPY OE_Order_Pub.Line_Tbl_Type
426: )
427: IS
428:
464: -- so chk it and fetch if not present.
465:
466: l_orderhdr_typeid := p_order_header_rec.order_type_id;
467:
468: IF (l_orderhdr_typeid is null OR l_orderhdr_typeid=FND_API.G_MISS_NUM)
469: THEN
470: open c_defaulthdrline_rec(p_order_header_rec.header_id);
471: fetch c_defaulthdrline_rec into l_orderhdr_typeid;
472: close c_defaulthdrline_rec;
488: ELSIF (p_save_type = SAVE_ADDITEMS AND p_order_header_rec.ORDER_CATEGORY_CODE = 'RETURN') THEN
489:
490: -- salesrep_id
491: -- IF (l_order_line_tbl(i).return_attribute2 is not null AND
492: -- l_order_line_tbl(i).return_attribute2 <> FND_API.G_MISS_CHAR) THEN
493: for l_salesrep_inforec in c_salesrep_info(l_order_line_tbl(i).return_attribute2)
494: loop
495: l_salesrep_id := l_salesrep_inforec.salesrep_id;
496: end loop;
530: end if;
531: end loop;
532:
533: IF(l_order_line_tbl(i).LINE_TYPE_ID is null OR
534: l_order_line_tbl(i).LINE_TYPE_ID = FND_API.G_MISS_NUM)
535: THEN
536: IF (l_linetype_id is not null AND l_linetype_id <> FND_API.G_MISS_NUM)
537: THEN
538: l_order_line_tbl(i).line_type_id := l_linetype_id;
532:
533: IF(l_order_line_tbl(i).LINE_TYPE_ID is null OR
534: l_order_line_tbl(i).LINE_TYPE_ID = FND_API.G_MISS_NUM)
535: THEN
536: IF (l_linetype_id is not null AND l_linetype_id <> FND_API.G_MISS_NUM)
537: THEN
538: l_order_line_tbl(i).line_type_id := l_linetype_id;
539: IF (IBE_UTIL.G_DEBUGON = l_true) then
540: ibe_util.debug('line type id..'||l_order_line_tbl(i).line_type_id);
541: end if;
542: ELSE
543: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_LINE_TYPE_ID_MISS');
544: FND_Msg_Pub.Add;
545: RAISE FND_API.G_EXC_ERROR;
546: END IF;
547: END IF;
548: END IF; -- l_order_line_tbl.operation =create
549: ELSE -- headerrec.operation.operation ='update'
573: close OrigOrderQtyCur;
574: end if;
575: end loop;
576:
577: IF(l_order_line_tbl(i).LINE_TYPE_ID is null OR l_order_line_tbl(i).LINE_TYPE_ID = FND_API.G_MISS_NUM)
578: THEN
579: IF (l_linetype_id is not null AND l_linetype_id <> FND_API.G_MISS_NUM)
580: THEN
581: l_order_line_tbl(i).line_type_id := l_linetype_id;
575: end loop;
576:
577: IF(l_order_line_tbl(i).LINE_TYPE_ID is null OR l_order_line_tbl(i).LINE_TYPE_ID = FND_API.G_MISS_NUM)
578: THEN
579: IF (l_linetype_id is not null AND l_linetype_id <> FND_API.G_MISS_NUM)
580: THEN
581: l_order_line_tbl(i).line_type_id := l_linetype_id;
582: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
583: ibe_util.debug('line type id..'||l_order_line_tbl(i).line_type_id);
584: end if;
585: ELSE
586: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_LINE_TYPE_ID_MISS');
587: FND_Msg_Pub.Add;
588: RAISE FND_API.G_EXC_ERROR;
589: END IF;
590: END IF;
591:
592: END IF; -- headerrec.operation.operation ='update'
622: AND aq.record_type = 'ORDER'
623: AND aq.order_header_id = oh.header_id
624: AND oh.flow_status_code IN ('ENTERED','WORKING');
625:
626: l_active_returnid NUMBER:= FND_API.G_MISS_NUM;
627:
628: BEGIN
629:
630: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
638: FETCH c_getactive_pendret INTO l_active_returnid;
639: IF (c_getactive_pendret%FOUND) THEN
640: x_order_header_id := l_active_returnid;
641: ELSE
642: x_order_header_id := FND_API.G_MISS_NUM;
643: END IF;
644:
645: CLOSE c_getactive_pendret;
646:
653:
654: PROCEDURE DefaultHeaderRecord(
655: p_order_header_rec IN OE_Order_PUB.Header_Rec_Type := OE_Order_PUB.G_MISS_HEADER_REC
656: ,p_party_id IN NUMBER
657: ,p_save_type IN NUMBER := FND_API.G_MISS_NUM
658: ,x_order_header_rec OUT NOCOPY OE_Order_PUB.Header_Rec_Type
659: )
660: IS
661:
661:
662: CURSOR c_defaulthdr_rec(c_ordhdr_id number) IS
663: select order_type_id from oe_order_headers_all where header_id = c_ordhdr_id;
664:
665: l_order_header_id NUMBER := FND_API.G_MISS_NUM;
666: l_ordertype_id NUMBER;
667: l_salesrep_id VARCHAR2(360);
668:
669: l_salesrep_number VARCHAR2(360); --MOAC Changes by ASO::Obsoletion of ASO_DEFAULT_PERSON_ID
688:
689:
690: IF (p_save_type = SAVE_ADDITEMS) THEN
691: IF (x_order_header_rec.ORDER_CATEGORY_CODE is null
692: OR x_order_header_rec.ORDER_CATEGORY_CODE = FND_API.G_MISS_CHAR)
693: THEN
694: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_ORDER_CATG_MISS');
695: FND_Msg_Pub.Add;
696: RAISE FND_API.G_EXC_ERROR;
692: OR x_order_header_rec.ORDER_CATEGORY_CODE = FND_API.G_MISS_CHAR)
693: THEN
694: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_ORDER_CATG_MISS');
695: FND_Msg_Pub.Add;
696: RAISE FND_API.G_EXC_ERROR;
697: END IF;
698: END IF;
699:
700: /*** Assumptions:
705:
706: ***/
707:
708: IF (x_order_header_rec.header_id is not null AND
709: x_order_header_rec.header_id <> FND_API.G_MISS_NUM)
710: THEN
711:
712: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
713: Ibe_util.Debug('Header id is not null, so cheking its status');
730: OR l_last_update_date > x_order_header_rec.last_update_date)
731: THEN
732: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_REFRESH_RETURN');
733: FND_Msg_Pub.Add;
734: RAISE FND_API.G_EXC_ERROR;
735: ELSE
736: x_order_header_rec.operation := OE_Globals.G_OPR_UPDATE;
737: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
738: Ibe_util.Debug('Return not booked loop: ' ||x_order_header_rec.operation);
749: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
750: Ibe_util.Debug('Active pending Return: '||l_order_header_id);
751: END IF;
752:
753: IF(l_order_header_id is null OR l_order_header_id = FND_API.G_MISS_NUM) THEN
754:
755: IF (p_save_type = SAVE_ADDITEMS) THEN
756:
757: x_order_header_rec.header_id := l_order_header_id;
759:
760: /** -- As the flow is for CREATE do set the necessary attributes -- **/
761:
762: IF (x_order_header_rec.order_type_id is null OR
763: x_order_header_rec.order_type_id = FND_API.G_MISS_NUM)
764: then
765: x_order_header_rec.order_type_id := FND_PROFILE.VALUE('IBE_RETURN_TRANSACTION_TYPE');
766: IF (x_order_header_rec.order_type_id IS NULL OR x_order_header_rec.order_type_id = FND_API.G_MISS_NUM)
767: THEN
762: IF (x_order_header_rec.order_type_id is null OR
763: x_order_header_rec.order_type_id = FND_API.G_MISS_NUM)
764: then
765: x_order_header_rec.order_type_id := FND_PROFILE.VALUE('IBE_RETURN_TRANSACTION_TYPE');
766: IF (x_order_header_rec.order_type_id IS NULL OR x_order_header_rec.order_type_id = FND_API.G_MISS_NUM)
767: THEN
768: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_ORDER_TYPE_ID_MISS');
769: FND_Msg_Pub.Add;
770: RAISE FND_API.G_EXC_ERROR;
766: IF (x_order_header_rec.order_type_id IS NULL OR x_order_header_rec.order_type_id = FND_API.G_MISS_NUM)
767: THEN
768: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_ORDER_TYPE_ID_MISS');
769: FND_Msg_Pub.Add;
770: RAISE FND_API.G_EXC_ERROR;
771: END IF;
772: end if; -- if order type id
773:
774: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
789: -- Bug 5255625, Proper error message when default salesrep is not set
790: IF (l_salesrep_number is null) THEN
791: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_SALESREPID_MISS');
792: FND_Msg_Pub.Add;
793: RAISE FND_API.G_EXC_ERROR;
794: ELSE
795: -- Get the sales rep id from the sales rep number using the JTF table
796: select SALESREP_ID into l_salesrep_id from JTF_RS_SALESREPS where SALESREP_NUMBER = l_salesrep_number and ORG_ID = l_user_orgid;
797: END IF;
803:
804: IF (l_salesrep_id is null) THEN
805: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_SALESREPID_MISS');
806: FND_Msg_Pub.Add;
807: RAISE FND_API.G_EXC_ERROR;
808: ELSE
809: x_order_header_rec.salesrep_id := l_salesrep_id;
810: END IF;
811: x_order_header_rec.source_document_type_id := 13; -- iStore Account
827:
828: ELSIF(p_save_type = SAVE_NORMAL OR p_save_type = SAVE_REMOVEITEMS) THEN
829: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_REFRESH_RETURN');
830: FND_Msg_Pub.Add;
831: RAISE FND_API.G_EXC_ERROR;
832: END If; --save type= normal
833: ELSE
834:
835: -- This flow will be reached when there is aleady an existing active pending return
844: open c_defaulthdr_rec(l_order_header_id);
845: fetch c_defaulthdr_rec into l_ordertype_id;
846: close c_defaulthdr_rec;
847: if (x_order_header_rec.order_type_id is null or
848: x_order_header_rec.order_type_id = FND_API.G_MISS_NUM)
849: then
850: x_order_header_rec.order_type_id := l_ordertype_id;
851: end if;
852: x_order_header_rec.operation := OE_Globals.G_OPR_UPDATE;
905: IF (x_order_header_rec.FLOW_STATUS_CODE in ('ENTERED','WORKING') AND
906: x_order_header_rec.ORDER_CATEGORY_CODE = 'RETURN') THEN
907:
908: x_order_header_rec.operation := OE_Globals.G_OPR_DELETE;
909: x_order_header_rec.cancelled_flag := FND_API.G_MISS_CHAR;
910:
911: ELSE
912: x_order_header_rec.operation := OE_Globals.G_OPR_UPDATE;
913: x_order_header_rec.cancelled_flag := 'Y';
925:
926: PROCEDURE DefaultHdrLineAddress(
927: p_order_line_tbl IN OE_Order_PUB.Line_Tbl_Type
928: ,p_order_header_rec IN OE_Order_PUB.Header_Rec_Type
929: ,p_party_id IN NUMBER:= FND_API.G_MISS_NUM
930: ,p_shipto_partysite_id IN NUMBER:= FND_API.G_MISS_NUM
931: ,p_billto_partysite_id IN NUMBER:= FND_API.G_MISS_NUM
932: ,x_order_header_rec OUT NOCOPY OE_Order_PUB.Header_Rec_Type
933: ,x_order_line_tbl OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
926: PROCEDURE DefaultHdrLineAddress(
927: p_order_line_tbl IN OE_Order_PUB.Line_Tbl_Type
928: ,p_order_header_rec IN OE_Order_PUB.Header_Rec_Type
929: ,p_party_id IN NUMBER:= FND_API.G_MISS_NUM
930: ,p_shipto_partysite_id IN NUMBER:= FND_API.G_MISS_NUM
931: ,p_billto_partysite_id IN NUMBER:= FND_API.G_MISS_NUM
932: ,x_order_header_rec OUT NOCOPY OE_Order_PUB.Header_Rec_Type
933: ,x_order_line_tbl OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
934: ,x_return_status OUT NOCOPY VARCHAR2
927: p_order_line_tbl IN OE_Order_PUB.Line_Tbl_Type
928: ,p_order_header_rec IN OE_Order_PUB.Header_Rec_Type
929: ,p_party_id IN NUMBER:= FND_API.G_MISS_NUM
930: ,p_shipto_partysite_id IN NUMBER:= FND_API.G_MISS_NUM
931: ,p_billto_partysite_id IN NUMBER:= FND_API.G_MISS_NUM
932: ,x_order_header_rec OUT NOCOPY OE_Order_PUB.Header_Rec_Type
933: ,x_order_line_tbl OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
934: ,x_return_status OUT NOCOPY VARCHAR2
935: ,x_msg_count OUT NOCOPY NUMBER
960: Ibe_util.Debug('Begin IBE_ORDER_SAVE_PVT:DefaultHdrLineAddress');
961: end if;
962:
963: -- Initialize API return status to success
964: x_return_status := FND_API.G_RET_STS_SUCCESS;
965:
966: x_order_header_rec := p_order_header_rec;
967:
968:
1022: Ibe_util.Debug('DefaultHdrLineAddress: After call to Get_Cust_Acct_Site_Use-ShipTO '||x_return_status);
1023: END IF;
1024:
1025:
1026: IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1027: -- raise FND_API.G_EXC_ERROR;
1028: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_INVALID_SHIPTO_ADDR');
1029: FND_Msg_Pub.Add;
1030: RAISE FND_API.G_EXC_ERROR;
1023: END IF;
1024:
1025:
1026: IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1027: -- raise FND_API.G_EXC_ERROR;
1028: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_INVALID_SHIPTO_ADDR');
1029: FND_Msg_Pub.Add;
1030: RAISE FND_API.G_EXC_ERROR;
1031: END IF;
1026: IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1027: -- raise FND_API.G_EXC_ERROR;
1028: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_INVALID_SHIPTO_ADDR');
1029: FND_Msg_Pub.Add;
1030: RAISE FND_API.G_EXC_ERROR;
1031: END IF;
1032:
1033: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1034: Ibe_util.Debug('DefaultHdrLineAddress: '||lx_header_siteuse_id);
1033: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1034: Ibe_util.Debug('DefaultHdrLineAddress: '||lx_header_siteuse_id);
1035: END IF;
1036:
1037: IF (lx_header_siteuse_id is not null AND lx_header_siteuse_id <> FND_API.G_MISS_NUM)
1038: THEN
1039: x_order_header_rec.ship_to_org_id := lx_header_siteuse_id;
1040: ELSIF (l_party_type = 'PARTY_RELATIONSHIP') THEN
1041:
1047: ,p_siteuse_type => 'SHIP_TO'
1048: ,x_site_use_id => lx_header_siteuse_id
1049: );
1050:
1051: IF (lx_header_siteuse_id is not null AND lx_header_siteuse_id <> FND_API.G_MISS_NUM)
1052: THEN
1053: x_order_header_rec.ship_to_org_id := lx_header_siteuse_id;
1054: ELSE
1055:
1060:
1061: -- If final attempt also fails, no other go, Raise An Exception
1062: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_INVALID_SHIPTO_ADDR');
1063: FND_Msg_Pub.Add;
1064: RAISE FND_API.G_EXC_ERROR; -- Error Message should indicate the
1065: -- user to select/ create a valid Shipping address
1066: -- in the profiles tab.
1067: END IF;
1068: ELSE
1068: ELSE
1069: -- FOR B2C raise an exception.
1070: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_INVALID_SHIPTO_ADDR');
1071: FND_Msg_Pub.Add;
1072: RAISE FND_API.G_EXC_ERROR;
1073: END IF;
1074:
1075: ----
1076: -- For 'INVOICE_TO_ORG_ID'
1091: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1092: Ibe_util.Debug('DefaultHdrLineAddress: After call to Get_Cust_Acct_Site_Use-BillTO '||x_return_status);
1093: END IF;
1094:
1095: IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1096: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_INVALID_BILLTO_ADDR');
1097: FND_Msg_Pub.Add;
1098: RAISE FND_API.G_EXC_ERROR;
1099: END IF;
1094:
1095: IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1096: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_INVALID_BILLTO_ADDR');
1097: FND_Msg_Pub.Add;
1098: RAISE FND_API.G_EXC_ERROR;
1099: END IF;
1100:
1101: IF (lx_header_siteuse_id is not null AND lx_header_siteuse_id <> FND_API.G_MISS_NUM)
1102: THEN
1097: FND_Msg_Pub.Add;
1098: RAISE FND_API.G_EXC_ERROR;
1099: END IF;
1100:
1101: IF (lx_header_siteuse_id is not null AND lx_header_siteuse_id <> FND_API.G_MISS_NUM)
1102: THEN
1103: x_order_header_rec.invoice_to_org_id := lx_header_siteuse_id;
1104: ELSIF (l_party_type = 'PARTY_RELATIONSHIP') THEN
1105:
1111: ,p_siteuse_type => 'BILL_TO'
1112: ,x_site_use_id => lx_header_siteuse_id
1113: );
1114:
1115: IF (lx_header_siteuse_id is not null AND lx_header_siteuse_id <> FND_API.G_MISS_NUM)
1116: THEN
1117: x_order_header_rec.invoice_to_org_id := lx_header_siteuse_id;
1118: ELSE
1119: -- If final attempt also fails, no other go,Raise An Exception
1122: END IF;
1123:
1124: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_INVALID_BILLTO_ADDR');
1125: FND_Msg_Pub.Add;
1126: RAISE FND_API.G_EXC_ERROR; -- Error Message should indicate the
1127: -- user to select/ create a valid Shipping address
1128: -- in the profiles tab.
1129: END IF;
1130: ELSE
1130: ELSE
1131: -- FOR B2C raise an exception.
1132: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_INVALID_BILLTO_ADDR');
1133: FND_Msg_Pub.Add;
1134: RAISE FND_API.G_EXC_ERROR;
1135: END IF;
1136:
1137: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1138: Ibe_util.Debug('DefaultHdrLineAddress ship_to_org_id: ' || x_order_header_rec.ship_to_org_id);
1212: p_data => x_msg_data
1213: );
1214:
1215: EXCEPTION
1216: WHEN FND_API.G_EXC_ERROR THEN
1217: x_return_status := FND_API.G_RET_STS_ERROR;
1218: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
1219: p_count => x_msg_count ,
1220: p_data => x_msg_data);
1213: );
1214:
1215: EXCEPTION
1216: WHEN FND_API.G_EXC_ERROR THEN
1217: x_return_status := FND_API.G_RET_STS_ERROR;
1218: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
1219: p_count => x_msg_count ,
1220: p_data => x_msg_data);
1221: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1214:
1215: EXCEPTION
1216: WHEN FND_API.G_EXC_ERROR THEN
1217: x_return_status := FND_API.G_RET_STS_ERROR;
1218: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
1219: p_count => x_msg_count ,
1220: p_data => x_msg_data);
1221: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1222: IBE_Util.Debug('Error IBE_ORDER_SAVE_PVT:DefaultHdrLineAddress()'|| sqlerrm);
1221: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1222: IBE_Util.Debug('Error IBE_ORDER_SAVE_PVT:DefaultHdrLineAddress()'|| sqlerrm);
1223: END IF;
1224:
1225: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1226: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1227: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
1228: p_count => x_msg_count ,
1229: p_data => x_msg_data);
1222: IBE_Util.Debug('Error IBE_ORDER_SAVE_PVT:DefaultHdrLineAddress()'|| sqlerrm);
1223: END IF;
1224:
1225: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1226: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1227: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
1228: p_count => x_msg_count ,
1229: p_data => x_msg_data);
1230: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1223: END IF;
1224:
1225: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1226: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1227: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
1228: p_count => x_msg_count ,
1229: p_data => x_msg_data);
1230: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1231: IBE_Util.Debug('UNEXPError IBE_ORDER_SAVE_PVT:DefaultHdrLineAddress()' || sqlerrm);
1231: IBE_Util.Debug('UNEXPError IBE_ORDER_SAVE_PVT:DefaultHdrLineAddress()' || sqlerrm);
1232: END IF;
1233:
1234: WHEN OTHERS THEN
1235: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1236: IF FND_Msg_Pub.Check_Msg_Level( FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR ) THEN
1237: FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
1238: L_API_NAME);
1239: END IF;
1237: FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
1238: L_API_NAME);
1239: END IF;
1240:
1241: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
1242: p_count => x_msg_count ,
1243: p_data => x_msg_data);
1244: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1245: IBE_Util.Debug('Other IBE_ORDER_SAVE_PVT:DefaultHdrLineAddress()' || sqlerrm);
1324: l_db_invoiceto_org_id := l_get_hdr_ids.invoice_to_org_id;
1325: end loop;
1326:
1327: -- Bug# 3334581
1328: IF (l_shipto_org_id is null OR l_shipto_org_id = FND_API.G_MISS_NUM)
1329: THEN
1330: l_shipto_org_id := l_db_shipto_org_id;
1331: END IF;
1332:
1330: l_shipto_org_id := l_db_shipto_org_id;
1331: END IF;
1332:
1333:
1334: IF (l_invoiceto_org_id is null OR l_invoiceto_org_id = FND_API.G_MISS_NUM)
1335: THEN
1336: l_invoiceto_org_id := l_db_invoiceto_org_id;
1337: END IF;
1338:
1417:
1418: Procedure SaveMDLRelatedOperations(p_context_type IN VARCHAR2,
1419: p_order_line_tbl IN OE_Order_PUB.Line_Tbl_Type,
1420: p_order_header_id IN NUMBER,
1421: p_save_type IN VARCHAR2:=FND_API.G_MISS_CHAR,
1422: x_order_line_tbl OUT NOCOPY OE_Order_PUB.Line_Tbl_Type
1423: )
1424: IS
1425:
1523: l_order_line_tbl(l_linetbl_count).LINE_ID := l_childlineid_rec.LINE_ID;
1524: l_order_line_tbl(l_linetbl_count).OPERATION := OE_Globals.G_OPR_UPDATE;
1525:
1526: if(l_order_line_tbl(i).ORDERED_QUANTITY is not null
1527: AND l_order_line_tbl(i).ORDERED_QUANTITY <> FND_API.G_MISS_NUM)
1528: then
1529: l_new_qty := l_order_line_tbl(i).ORDERED_QUANTITY;
1530: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1531: IBE_Util.Debug('Incoming qty: ' || l_new_qty);
1544: := (l_origchild_qty/l_origparent_qty)* l_new_qty;
1545: END IF;
1546: end if;
1547: if(l_order_line_tbl(i).RETURN_REASON_CODE is not null
1548: AND l_order_line_tbl(i).RETURN_REASON_CODE <> FND_API.G_MISS_CHAR)
1549: then
1550: l_order_line_tbl(l_linetbl_count).RETURN_REASON_CODE := l_order_line_tbl(i).RETURN_REASON_CODE;
1551: end if;
1552: end loop;
1576: l_order_line_tbl(l_linetbl_count).LINE_ID := l_childlineid_rec.LINE_ID;
1577: l_order_line_tbl(l_linetbl_count).OPERATION := OE_Globals.G_OPR_UPDATE;
1578:
1579: if(l_order_line_tbl(k).ship_to_contact_id is not null AND
1580: l_order_line_tbl(k).ship_to_contact_id <> FND_API.G_MISS_NUM) then
1581: l_order_line_tbl(l_linetbl_count).ship_to_contact_id
1582: := l_order_line_tbl(k).ship_to_contact_id;
1583: end if;
1584: if(l_order_line_tbl(k).ship_to_org_id is not null AND
1581: l_order_line_tbl(l_linetbl_count).ship_to_contact_id
1582: := l_order_line_tbl(k).ship_to_contact_id;
1583: end if;
1584: if(l_order_line_tbl(k).ship_to_org_id is not null AND
1585: l_order_line_tbl(k).ship_to_org_id <> FND_API.G_MISS_NUM) then
1586: l_order_line_tbl(l_linetbl_count).ship_to_org_id
1587: := l_order_line_tbl(k).ship_to_org_id;
1588: end if;
1589: if(l_order_line_tbl(k).invoice_to_contact_id is not null AND
1586: l_order_line_tbl(l_linetbl_count).ship_to_org_id
1587: := l_order_line_tbl(k).ship_to_org_id;
1588: end if;
1589: if(l_order_line_tbl(k).invoice_to_contact_id is not null AND
1590: l_order_line_tbl(k).invoice_to_contact_id <> FND_API.G_MISS_NUM) then
1591: l_order_line_tbl(l_linetbl_count).invoice_to_contact_id
1592: := l_order_line_tbl(k).invoice_to_contact_id;
1593: end if;
1594: if(l_order_line_tbl(k).invoice_to_org_id is not null AND
1591: l_order_line_tbl(l_linetbl_count).invoice_to_contact_id
1592: := l_order_line_tbl(k).invoice_to_contact_id;
1593: end if;
1594: if(l_order_line_tbl(k).invoice_to_org_id is not null AND
1595: l_order_line_tbl(k).invoice_to_org_id <> FND_API.G_MISS_NUM) then
1596: l_order_line_tbl(l_linetbl_count).invoice_to_org_id
1597: := l_order_line_tbl(k).invoice_to_org_id;
1598: end if;
1599: end loop;
1608:
1609: for k in 1..l_order_line_tbl.count
1610: loop
1611: x_order_line_tbl(k) := l_order_line_tbl(k);
1612: x_order_line_tbl(k).item_type_code := FND_API.G_MISS_CHAR;
1613: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1614: IBE_Util.Debug('x_order_line_tbl.LineId: ' || x_order_line_tbl(k).LINE_ID);
1615: IBE_Util.Debug('x_order_line_tbl.orderd_qty: ' || x_order_line_tbl(k).ORDERED_QUANTITY);
1616: IBE_Util.Debug('x_order_line_tbl.reason_code: ' || x_order_line_tbl(k).RETURN_REASON_CODE);
1645: IBE_UTIL.DEBUG('Incoming Header Id: '||p_order_header_id);
1646: END IF;
1647:
1648: -- Initialize API return status to success
1649: x_return_status := FND_API.G_RET_STS_SUCCESS;
1650:
1651: open c_createdby_info(p_order_header_id);
1652: fetch c_createdby_info into l_db_user_id;
1653: close c_createdby_info;
1662: IBE_UTIL.DEBUG('Inside If');
1663: END IF;
1664: FND_Message.Set_Name('IBE', 'IBE_OT_ERR_USERACCESS');
1665: FND_Msg_Pub.Add;
1666: RAISE FND_API.G_EXC_ERROR;
1667: END IF;
1668:
1669: IF (IBE_UTIL.G_DEBUGON = l_true) then
1670: IBE_UTIL.DEBUG('Order_Save_Pvt: ValidateOrderAccess - END');
1749: IBE_Util.Debug('Incoming Order Header Id: '|| p_order_header_id);
1750: END IF;
1751:
1752: -- Initialize API return status to success
1753: x_return_status := FND_API.G_RET_STS_SUCCESS;
1754:
1755: -- Start OF API body --
1756:
1757: /*******
1806: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
1807: IBE_Util.Debug('After Calling Is_Over_Return - return_status: '|| x_return_status);
1808: END IF;
1809:
1810: IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
1811: IF (IBE_UTIL.G_DEBUGON = l_true) then
1812: IBE_UTIL.DEBUG('Error Table Count: ' || x_error_tbl.count);
1813: end if;
1814:
1996: x_qtyfail_LineIds(failCnt) := 'QTY:'||l_tmp_order_line_tbl(l_tmp_qty_idx).return_line_id;
1997: l_tmp_qty_idx := l_tmp_order_line_tbl.NEXT(l_tmp_qty_idx);
1998: end loop;
1999:
2000: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
2001: raise FND_API.G_EXC_ERROR;
2002: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2003: raise FND_API.G_EXC_UNEXPECTED_ERROR;
2004: END IF;
1997: l_tmp_qty_idx := l_tmp_order_line_tbl.NEXT(l_tmp_qty_idx);
1998: end loop;
1999:
2000: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
2001: raise FND_API.G_EXC_ERROR;
2002: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2003: raise FND_API.G_EXC_UNEXPECTED_ERROR;
2004: END IF;
2005: END IF;
1998: end loop;
1999:
2000: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
2001: raise FND_API.G_EXC_ERROR;
2002: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2003: raise FND_API.G_EXC_UNEXPECTED_ERROR;
2004: END IF;
2005: END IF;
2006:
1999:
2000: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
2001: raise FND_API.G_EXC_ERROR;
2002: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2003: raise FND_API.G_EXC_UNEXPECTED_ERROR;
2004: END IF;
2005: END IF;
2006:
2007:
2020:
2021:
2022: EXCEPTION
2023:
2024: WHEN FND_API.G_EXC_ERROR THEN
2025: x_return_status := FND_API.G_RET_STS_ERROR;
2026: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2027: p_count => x_msg_count ,
2028: p_data => x_msg_data);
2021:
2022: EXCEPTION
2023:
2024: WHEN FND_API.G_EXC_ERROR THEN
2025: x_return_status := FND_API.G_RET_STS_ERROR;
2026: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2027: p_count => x_msg_count ,
2028: p_data => x_msg_data);
2029: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2022: EXCEPTION
2023:
2024: WHEN FND_API.G_EXC_ERROR THEN
2025: x_return_status := FND_API.G_RET_STS_ERROR;
2026: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2027: p_count => x_msg_count ,
2028: p_data => x_msg_data);
2029: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2030: IBE_Util.Debug('Error IBE_ORDER_SAVE_PVT:CheckOverReturnQty()'|| sqlerrm);
2029: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2030: IBE_Util.Debug('Error IBE_ORDER_SAVE_PVT:CheckOverReturnQty()'|| sqlerrm);
2031: END IF;
2032:
2033: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2034: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2035: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2036: p_count => x_msg_count ,
2037: p_data => x_msg_data);
2030: IBE_Util.Debug('Error IBE_ORDER_SAVE_PVT:CheckOverReturnQty()'|| sqlerrm);
2031: END IF;
2032:
2033: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2034: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2035: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2036: p_count => x_msg_count ,
2037: p_data => x_msg_data);
2038: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2031: END IF;
2032:
2033: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2034: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2035: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2036: p_count => x_msg_count ,
2037: p_data => x_msg_data);
2038: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2039: IBE_Util.Debug('UNEXPECTEDError IBE_ORDER_SAVE_PVT:CheckOverReturnQty()' || sqlerrm);
2038: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2039: IBE_Util.Debug('UNEXPECTEDError IBE_ORDER_SAVE_PVT:CheckOverReturnQty()' || sqlerrm);
2040: END IF;
2041: WHEN OTHERS THEN
2042: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2043:
2044: IF FND_Msg_Pub.Check_Msg_Level( FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR ) THEN
2045: FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
2046: L_API_NAME);
2045: FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
2046: L_API_NAME);
2047: END IF;
2048:
2049: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2050: p_count => x_msg_count ,
2051: p_data => x_msg_data);
2052: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2053: IBE_Util.Debug('Other IBE_ORDER_SAVE_PVT:CheckOverReturnQty()' || sqlerrm);
2072: INDEX BY BINARY_INTEGER;
2073:
2074: l_tmpfail_line_id tmp_line_id_type;
2075: tmpCount NUMBER:=0;
2076: FailLines VARCHAR2(10):=FND_API.G_FALSE;
2077: l_index NUMBER;
2078: l_addr_validate_qry VARCHAR2(4000);
2079: failCnt NUMBER:=0;
2080:
2079: failCnt NUMBER:=0;
2080:
2081: BEGIN
2082:
2083: x_return_status := FND_API.G_RET_STS_SUCCESS;
2084:
2085: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2086: IBE_Util.debug('IBE_Order_Save_Pvt.TCA_AddressValidate BEGIN order_hdr_id: '||p_order_header_id);
2087: end if;
2196: loop
2197: fetch Addr_error_cur into l_tmpfail_line_id(tmpCount);
2198: Exit when Addr_error_cur%notfound;
2199: tmpCount := tmpCount+1;
2200: FailLines := FND_API.G_TRUE;
2201: end loop;
2202:
2203: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2204: IBE_Util.debug('Check whether any lines failed: '||FailLines);
2207: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2208: IBE_Util.debug('Check whether any lines failed: '||FailLines);
2209: end if;
2210:
2211: if(FND_API.to_boolean(FailLines)) then
2212: x_return_status := FND_API.G_RET_STS_ERROR;
2213: l_index := l_tmpfail_line_id.FIRST;
2214: while(l_index is not null)
2215: loop
2208: IBE_Util.debug('Check whether any lines failed: '||FailLines);
2209: end if;
2210:
2211: if(FND_API.to_boolean(FailLines)) then
2212: x_return_status := FND_API.G_RET_STS_ERROR;
2213: l_index := l_tmpfail_line_id.FIRST;
2214: while(l_index is not null)
2215: loop
2216: failCnt:=failCnt+1;
2256: INDEX BY BINARY_INTEGER;
2257:
2258: l_tmpfail_line_id tmp_line_id_type;
2259: tmpCount NUMBER:=0;
2260: FailLines VARCHAR2(10):=FND_API.G_FALSE;
2261: l_index NUMBER;
2262: l_contact_validate_qry VARCHAR2(4000);
2263: failCnt NUMBER:=0;
2264:
2263: failCnt NUMBER:=0;
2264:
2265: BEGIN
2266:
2267: x_return_status := FND_API.G_RET_STS_SUCCESS;
2268:
2269: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2270: IBE_Util.debug('IBE_Order_Save_Pvt.TCA_AddressValidate BEGIN');
2271: end if;
2311: loop
2312: fetch Contact_error_cur into l_tmpfail_line_id(tmpCount);
2313: Exit when Contact_error_cur%notfound;
2314: tmpCount := tmpCount+1;
2315: FailLines := FND_API.G_TRUE;
2316: end loop;
2317:
2318: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2319: IBE_Util.debug('Whether Any Lines failed for Contact check: '|| FailLines);
2318: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2319: IBE_Util.debug('Whether Any Lines failed for Contact check: '|| FailLines);
2320: end if;
2321:
2322: if(FND_API.to_boolean(FailLines)) then
2323: x_return_status := FND_API.G_RET_STS_ERROR;
2324: l_index := l_tmpfail_line_id.FIRST;
2325: while(l_index is not null)
2326: loop
2319: IBE_Util.debug('Whether Any Lines failed for Contact check: '|| FailLines);
2320: end if;
2321:
2322: if(FND_API.to_boolean(FailLines)) then
2323: x_return_status := FND_API.G_RET_STS_ERROR;
2324: l_index := l_tmpfail_line_id.FIRST;
2325: while(l_index is not null)
2326: loop
2327: failCnt:=failCnt+1;
2351:
2352: PROCEDURE Complete_RetOrder_Validate
2353: ( P_order_header_id IN NUMBER,
2354: p_user_type IN VARCHAR2,
2355: p_init_msg_list IN VARCHAR2 := FND_API.G_TRUE,
2356: X_failed_line_ids OUT NOCOPY JTF_VARCHAR2_TABLE_300,
2357: X_return_status OUT NOCOPY VARCHAR2,
2358: X_msg_count OUT NOCOPY NUMBER,
2359: X_msg_data OUT NOCOPY VARCHAR2
2370: l_inv_index NUMBER;
2371: l_shp_index NUMBER;
2372: l_inv_index1 NUMBER;
2373: l_shp_index1 NUMBER;
2374: FailLines VARCHAR2(10):=FND_API.G_FALSE;
2375: x_qtyfail_LineIds x_qtyfail_LineType;
2376: x_TCAfail_LineIds x_qtyfail_LineType;
2377: l_return_status varchar2(100);
2378: ll_return_status varchar2(100);
2386:
2387: X_failed_line_ids := JTF_VARCHAR2_TABLE_300();
2388:
2389: -- Initialize API return status to success
2390: x_return_status := FND_API.G_RET_STS_SUCCESS;
2391:
2392: IF FND_API.To_Boolean( p_init_msg_list ) THEN
2393: FND_Msg_Pub.initialize;
2394: END IF;
2388:
2389: -- Initialize API return status to success
2390: x_return_status := FND_API.G_RET_STS_SUCCESS;
2391:
2392: IF FND_API.To_Boolean( p_init_msg_list ) THEN
2393: FND_Msg_Pub.initialize;
2394: END IF;
2395:
2396:
2416: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2417: IBE_Util.Debug('After calling TCA_AddressValidate Billto: '||l_return_status);
2418: END IF;
2419:
2420: IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2421: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2422: IBE_Util.Debug('Address Failing Line count Billto:'|| x_TCAfail_LineIds.count);
2423: END IF;
2424: tCount := X_failed_line_ids.count;
2457:
2458: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2459: IBE_Util.Debug('After calling TCA_ContactValidate: '||ll_return_status);
2460: END IF;
2461: IF ll_return_status = FND_API.G_RET_STS_ERROR THEN
2462: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2463: IBE_Util.Debug('Failing Line count:'|| x_TCAfail_LineIds.count);
2464: END IF;
2465: tCount := X_failed_line_ids.count;
2485:
2486: /*
2487: Set the Message if either the contact or address is invalid
2488: */
2489: if(l_return_status =FND_API.G_RET_STS_ERROR
2490: OR ll_return_status =FND_API.G_RET_STS_ERROR) then
2491: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2492: IBE_Util.Debug('Invalid Billing Details- Settig the Error to FND stack');
2493: END IF;
2486: /*
2487: Set the Message if either the contact or address is invalid
2488: */
2489: if(l_return_status =FND_API.G_RET_STS_ERROR
2490: OR ll_return_status =FND_API.G_RET_STS_ERROR) then
2491: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2492: IBE_Util.Debug('Invalid Billing Details- Settig the Error to FND stack');
2493: END IF;
2494: FND_MESSAGE.Set_Name('IBE','IBE_ERR_OT_INVALID_BILLDET');
2510: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2511: IBE_Util.Debug('After calling TCA_AddressValidate Ship to: '||l_return_status);
2512: END IF;
2513:
2514: IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2515: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2516: IBE_Util.Debug('Address Failing Line count Shipto:'|| x_TCAfail_LineIds.count);
2517: END IF;
2518: tCount := X_failed_line_ids.count;
2545:
2546: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2547: IBE_Util.Debug('After calling TCA_ContactValidate: '||ll_return_status);
2548: END IF;
2549: IF ll_return_status = FND_API.G_RET_STS_ERROR THEN
2550: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2551: IBE_Util.Debug('Failing Line count:'|| x_TCAfail_LineIds.count);
2552: END IF;
2553: tCount := X_failed_line_ids.count;
2577:
2578: END IF;
2579:
2580:
2581: if(l_return_status =FND_API.G_RET_STS_ERROR
2582: OR ll_return_status =FND_API.G_RET_STS_ERROR) then
2583: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2584: IBE_Util.Debug('Invalid Billing Details- Settig the Error to FND stack');
2585: END IF;
2578: END IF;
2579:
2580:
2581: if(l_return_status =FND_API.G_RET_STS_ERROR
2582: OR ll_return_status =FND_API.G_RET_STS_ERROR) then
2583: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2584: IBE_Util.Debug('Invalid Billing Details- Settig the Error to FND stack');
2585: END IF;
2586: FND_MESSAGE.Set_Name('IBE','IBE_ERR_OT_INVALID_SHIPDET');
2605: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2606: IBE_Util.Debug('After Calling CheckOverRetQty');
2607: END IF;
2608:
2609: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
2610: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2611: IBE_Util.Debug('No. of Lines failing after Qty validations:'|| x_qtyfail_LineIds.count);
2612: END IF;
2613: tCount := X_failed_line_ids.count;
2627: loop
2628: IBE_Util.Debug('Total failLine Ids in final Loop: '|| X_failed_line_ids(k));
2629: end loop;
2630: END IF;
2631: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2632: raise FND_API.G_EXC_UNEXPECTED_ERROR;
2633: END IF;
2634:
2635: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2628: IBE_Util.Debug('Total failLine Ids in final Loop: '|| X_failed_line_ids(k));
2629: end loop;
2630: END IF;
2631: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2632: raise FND_API.G_EXC_UNEXPECTED_ERROR;
2633: END IF;
2634:
2635: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2636: IBE_Util.Debug('Total Failing LineCounts:'||tCount);
2641:
2642: -- If there are validation failing line IDs then set the status as ERROR.
2643:
2644: IF (X_failed_line_ids.count > 0) THEN
2645: raise FND_API.G_EXC_ERROR;
2646: ENd IF;
2647:
2648: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2649: Ibe_util.Debug('End IBE_ORDER_SAVE_PVT:Complete_RetOrder_Validate');
2654: p_data => x_msg_data
2655: );
2656:
2657: EXCEPTION
2658: WHEN FND_API.G_EXC_ERROR THEN
2659: x_return_status := FND_API.G_RET_STS_ERROR;
2660: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2661: p_count => x_msg_count ,
2662: p_data => x_msg_data);
2655: );
2656:
2657: EXCEPTION
2658: WHEN FND_API.G_EXC_ERROR THEN
2659: x_return_status := FND_API.G_RET_STS_ERROR;
2660: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2661: p_count => x_msg_count ,
2662: p_data => x_msg_data);
2663: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2656:
2657: EXCEPTION
2658: WHEN FND_API.G_EXC_ERROR THEN
2659: x_return_status := FND_API.G_RET_STS_ERROR;
2660: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2661: p_count => x_msg_count ,
2662: p_data => x_msg_data);
2663: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2664: IBE_Util.Debug('Error IBE_ORDER_SAVE_PVT:Complete_RetOrder_Validate()'|| sqlerrm);
2663: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2664: IBE_Util.Debug('Error IBE_ORDER_SAVE_PVT:Complete_RetOrder_Validate()'|| sqlerrm);
2665: END IF;
2666:
2667: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2668: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2669: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2670: p_count => x_msg_count ,
2671: p_data => x_msg_data);
2664: IBE_Util.Debug('Error IBE_ORDER_SAVE_PVT:Complete_RetOrder_Validate()'|| sqlerrm);
2665: END IF;
2666:
2667: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2668: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2669: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2670: p_count => x_msg_count ,
2671: p_data => x_msg_data);
2672: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2665: END IF;
2666:
2667: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2668: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2669: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2670: p_count => x_msg_count ,
2671: p_data => x_msg_data);
2672: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2673: IBE_Util.Debug('UNEXPError IBE_ORDER_SAVE_PVT:Complete_RetOrder_Validate()' || sqlerrm);
2673: IBE_Util.Debug('UNEXPError IBE_ORDER_SAVE_PVT:Complete_RetOrder_Validate()' || sqlerrm);
2674: END IF;
2675:
2676: WHEN OTHERS THEN
2677: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2678: IF FND_Msg_Pub.Check_Msg_Level( FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR ) THEN
2679: FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
2680: L_API_NAME);
2681: END IF;
2679: FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
2680: L_API_NAME);
2681: END IF;
2682:
2683: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
2684: p_count => x_msg_count ,
2685: p_data => x_msg_data);
2686: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2687: IBE_Util.Debug('Other IBE_ORDER_SAVE_PVT:Complete_RetOrder_Validate()' || sqlerrm);
2763: l_return_values varchar2(2000);
2764: l_api_name VARCHAR2(50) := 'Save_Order';
2765: l_api_version NUMBER := 1.0;
2766:
2767: l_cancel_flow VARCHAR2(10) := FND_API.G_FALSE;
2768: l_reqtbl_count NUMBER;
2769: l_apply_hold VARCHAR2(10);
2770: l_hold_id NUMBER;
2771: l_user_type VARCHAR2(30);
2769: l_apply_hold VARCHAR2(10);
2770: l_hold_id NUMBER;
2771: l_user_type VARCHAR2(30);
2772: linetblcount NUMBER := 0;
2773: l_ProcessOrder_Flow VARCHAR2(10) := FND_API.G_TRUE;
2774: p_api_service_level VARCHAR2(30);
2775:
2776: -- Delete Order when last Line deleted loop
2777: p_dl_line_ids VARCHAR2(3000);
2798: -- Standard Start of API savepoint
2799: SAVEPOINT SAVE_ORDER_SAVE_PVT;
2800:
2801: -- Standard call to check for call compatibility.
2802: IF NOT FND_API.Compatible_API_Call (l_api_version,
2803: P_Api_Version_Number,
2804: l_api_name,
2805: G_PKG_NAME )
2806: THEN
2803: P_Api_Version_Number,
2804: l_api_name,
2805: G_PKG_NAME )
2806: THEN
2807: RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2808: END IF;
2809:
2810: -- Initialize message list if p_init_msg_list is set to TRUE.
2811: IF FND_API.To_Boolean( p_init_msg_list ) THEN
2807: RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2808: END IF;
2809:
2810: -- Initialize message list if p_init_msg_list is set to TRUE.
2811: IF FND_API.To_Boolean( p_init_msg_list ) THEN
2812: FND_Msg_Pub.initialize;
2813: END IF;
2814:
2815: -- Initialize API return status to success
2812: FND_Msg_Pub.initialize;
2813: END IF;
2814:
2815: -- Initialize API return status to success
2816: x_return_status := FND_API.G_RET_STS_SUCCESS;
2817:
2818: -- Start OF API body --
2819:
2820:
2850:
2851: /********** User Authentication *************/
2852:
2853: IF (l_order_header_rec.header_id is not null AND
2854: l_order_header_rec.header_id <> FND_API.G_MISS_NUM)
2855: THEN
2856: ValidateOrderAccess(p_order_header_id => l_order_header_rec.header_id
2857: ,x_return_status => x_return_status
2858: );
2855: THEN
2856: ValidateOrderAccess(p_order_header_id => l_order_header_rec.header_id
2857: ,x_return_status => x_return_status
2858: );
2859: IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) then
2860: raise FND_API.G_EXC_ERROR;
2861: END IF;
2862: END IF;
2863:
2856: ValidateOrderAccess(p_order_header_id => l_order_header_rec.header_id
2857: ,x_return_status => x_return_status
2858: );
2859: IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) then
2860: raise FND_API.G_EXC_ERROR;
2861: END IF;
2862: END IF;
2863:
2864:
2870: ,p_save_type => p_save_type
2871: ,x_order_line_tbl => l_order_line_tbl
2872: );
2873: IF ((l_order_header_rec.operation = OE_Globals.G_OPR_CREATE) OR
2874: (p_billto_partysite_id is not null AND p_billto_partysite_id <> FND_API.G_MISS_NUM) OR
2875: (p_shipto_partysite_id is not null AND p_shipto_partysite_id <> FND_API.G_MISS_NUM))
2876: THEN
2877: DefaultHdrLineAddress(p_order_line_tbl => l_order_line_tbl
2878: ,p_order_header_rec => l_order_header_rec
2871: ,x_order_line_tbl => l_order_line_tbl
2872: );
2873: IF ((l_order_header_rec.operation = OE_Globals.G_OPR_CREATE) OR
2874: (p_billto_partysite_id is not null AND p_billto_partysite_id <> FND_API.G_MISS_NUM) OR
2875: (p_shipto_partysite_id is not null AND p_shipto_partysite_id <> FND_API.G_MISS_NUM))
2876: THEN
2877: DefaultHdrLineAddress(p_order_line_tbl => l_order_line_tbl
2878: ,p_order_header_rec => l_order_header_rec
2879: ,p_party_id => p_party_id
2885: ,x_msg_count => x_msg_count
2886: ,x_msg_data => x_msg_data
2887: );
2888:
2889: IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) then
2890: raise FND_API.G_EXC_ERROR;
2891: END IF;
2892:
2893: IF (IBE_UTIL.G_DEBUGON = l_true) then
2886: ,x_msg_data => x_msg_data
2887: );
2888:
2889: IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) then
2890: raise FND_API.G_EXC_ERROR;
2891: END IF;
2892:
2893: IF (IBE_UTIL.G_DEBUGON = l_true) then
2894: Ibe_Util.DEBUG('ship_to_org_id returned: ' || lx_order_header_rec.ship_to_org_id);
2894: Ibe_Util.DEBUG('ship_to_org_id returned: ' || lx_order_header_rec.ship_to_org_id);
2895: Ibe_Util.DEBUG('bill_to_org_id returned: ' || lx_order_header_rec.invoice_to_org_id);
2896: end if;
2897:
2898: IF(lx_order_header_rec.invoice_to_org_id is null OR lx_order_header_rec.invoice_to_org_id = FND_API.G_MISS_NUM)
2899: THEN
2900: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_SHIPTO_BILLTO_MISS');
2901: FND_Msg_Pub.Add;
2902: RAISE FND_API.G_EXC_ERROR;
2898: IF(lx_order_header_rec.invoice_to_org_id is null OR lx_order_header_rec.invoice_to_org_id = FND_API.G_MISS_NUM)
2899: THEN
2900: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_SHIPTO_BILLTO_MISS');
2901: FND_Msg_Pub.Add;
2902: RAISE FND_API.G_EXC_ERROR;
2903: END IF;
2904:
2905: l_order_header_rec := lx_order_header_rec;
2906: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
2985: ibe_util.debug('after cancelorder operation:' ||l_order_header_rec.operation);
2986: end if;
2987:
2988: IF(l_order_header_rec.operation = OE_Globals.G_OPR_DELETE) THEN
2989: l_cancel_flow := FND_API.G_TRUE;
2990: END IF;
2991:
2992: end if;
2993:
2999: -- This is used currently by the Return-Flow-Orders alone.
3000:
3001: IF (l_order_header_rec.operation = OE_GLOBALS.G_OPR_UPDATE AND
3002: (p_submit_control_rec.submit_flag is null
3003: OR p_submit_control_rec.submit_flag = FND_API.G_MISS_CHAR))
3004: THEN
3005: IF l_order_header_rec.order_category_code = 'RETURN' then
3006: SaveMDLRelatedOperations(p_context_type => 'SAVE',
3007: p_order_line_tbl => l_order_line_tbl,
3064: ibe_util.debug('after Remove-cancelorder operation:' ||l_order_header_rec.operation);
3065: end if;
3066:
3067: IF(l_order_header_rec.operation = OE_Globals.G_OPR_DELETE) THEN
3068: l_cancel_flow := FND_API.G_TRUE;
3069: l_order_line_tbl := OE_ORDER_PUB.G_MISS_LINE_TBL;
3070: END IF;
3071: END IF; --No Of Existing Lines
3072:
3124: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3125: IBE_Util.Debug('After Complete Validate API: '|| x_return_status);
3126: END IF;
3127:
3128: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3129: raise FND_API.G_EXC_ERROR;
3130: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3131: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3132: END IF;
3125: IBE_Util.Debug('After Complete Validate API: '|| x_return_status);
3126: END IF;
3127:
3128: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3129: raise FND_API.G_EXC_ERROR;
3130: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3131: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3132: END IF;
3133:
3126: END IF;
3127:
3128: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3129: raise FND_API.G_EXC_ERROR;
3130: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3131: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3132: END IF;
3133:
3134: -- For post 11590 flow, submit_order() flow would be called directly for booking.
3127:
3128: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3129: raise FND_API.G_EXC_ERROR;
3130: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3131: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3132: END IF;
3133:
3134: -- For post 11590 flow, submit_order() flow would be called directly for booking.
3135: -- But for a b2c user, the header level values(invoice_to_org_id) would be
3141: IF ((l_user_type = 'PERSON') AND
3142: (l_order_header_rec.operation = OE_Globals.G_OPR_UPDATE) AND
3143: (p_submit_control_rec.cancel_flag <> 'Y')) THEN
3144:
3145: l_ProcessOrder_Flow := FND_API.G_TRUE;
3146: ELSE
3147: l_ProcessOrder_Flow := FND_API.G_FALSE;
3148: End If; --user_type ='Person'
3149:
3143: (p_submit_control_rec.cancel_flag <> 'Y')) THEN
3144:
3145: l_ProcessOrder_Flow := FND_API.G_TRUE;
3146: ELSE
3147: l_ProcessOrder_Flow := FND_API.G_FALSE;
3148: End If; --user_type ='Person'
3149:
3150: Else
3151: l_request_tbl(1).entity_code := OE_GLOBALS.G_ENTITY_HEADER;
3166: IBE_Util.Debug('Save Bef Process Ord:order_hdr_rec.Invoice_to_org_id: ' || l_order_header_rec.INVOICE_TO_ORG_ID);
3167: IBE_Util.Debug('Save Bef Process Ord:order_hdr_rec.header_id: ' || l_order_header_rec.HEADER_ID);
3168: END IF;
3169:
3170: IF(FND_API.to_Boolean(l_ProcessOrder_Flow)) THEN
3171:
3172: /*************--call process order;--*****************/
3173:
3174: IF (IBE_UTIL.G_DEBUGON = l_true) then
3176: end if;
3177:
3178: OE_Order_GRP.Process_Order
3179: ( p_api_version_number => 1.0
3180: , p_init_msg_list => FND_API.G_TRUE
3181: , p_return_values => l_return_values
3182: , p_commit => FND_API.G_FALSE
3183: , x_return_status => x_return_status
3184: , x_msg_count => x_msg_count
3178: OE_Order_GRP.Process_Order
3179: ( p_api_version_number => 1.0
3180: , p_init_msg_list => FND_API.G_TRUE
3181: , p_return_values => l_return_values
3182: , p_commit => FND_API.G_FALSE
3183: , x_return_status => x_return_status
3184: , x_msg_count => x_msg_count
3185: , x_msg_data => x_msg_data
3186: --, p_api_service_level => p_api_service_level
3227: end if;
3228:
3229: for j in 1 .. x_msg_count
3230: loop
3231: x_msg_data:= OE_MSG_PUB.get(fnd_msg_pub.g_next,FND_API.G_FALSE);
3232: IF (IBE_UTIL.G_DEBUGON = l_true) then
3233: IBE_UTIL.DEBUG('Message from OE Save: ' || x_msg_data );
3234: end if;
3235: end loop;
3240: -- first 2 condns would be satisfied. But for the third condn.,
3241: -- l_action_request_tbl will be empty as we are not sending l_request_tbl()
3242: -- params above. So its safer to check for Exists and chk the return_status.
3243:
3244: IF (x_return_status = FND_API.G_RET_STS_SUCCESS
3245: AND p_submit_control_rec.submit_flag = 'Y'
3246: AND (l_action_request_tbl.EXISTS(1) AND
3247: l_action_request_tbl(1).return_status <> FND_API.G_RET_STS_SUCCESS))
3248: THEN
3243:
3244: IF (x_return_status = FND_API.G_RET_STS_SUCCESS
3245: AND p_submit_control_rec.submit_flag = 'Y'
3246: AND (l_action_request_tbl.EXISTS(1) AND
3247: l_action_request_tbl(1).return_status <> FND_API.G_RET_STS_SUCCESS))
3248: THEN
3249: IF (IBE_UTIL.G_DEBUGON = l_true) then
3250: IBE_UTIL.DEBUG('Error in ProcessOrder Booking Flow' );
3251: end if;
3249: IF (IBE_UTIL.G_DEBUGON = l_true) then
3250: IBE_UTIL.DEBUG('Error in ProcessOrder Booking Flow' );
3251: end if;
3252: retrieve_oe_messages;
3253: x_return_status := FND_API.G_RET_STS_ERROR;
3254: RAISE FND_API.G_EXC_ERROR;
3255: END IF;
3256:
3257: -- This check is for catching all generic Exceptions.
3250: IBE_UTIL.DEBUG('Error in ProcessOrder Booking Flow' );
3251: end if;
3252: retrieve_oe_messages;
3253: x_return_status := FND_API.G_RET_STS_ERROR;
3254: RAISE FND_API.G_EXC_ERROR;
3255: END IF;
3256:
3257: -- This check is for catching all generic Exceptions.
3258: IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
3254: RAISE FND_API.G_EXC_ERROR;
3255: END IF;
3256:
3257: -- This check is for catching all generic Exceptions.
3258: IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
3259: IF (IBE_UTIL.G_DEBUGON = l_true) then
3260: IBE_UTIL.DEBUG('Error in Procees Order Flow: '||x_return_status );
3261: end if;
3262: retrieve_oe_messages;
3259: IF (IBE_UTIL.G_DEBUGON = l_true) then
3260: IBE_UTIL.DEBUG('Error in Procees Order Flow: '||x_return_status );
3261: end if;
3262: retrieve_oe_messages;
3263: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3264: raise FND_API.G_EXC_ERROR;
3265: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3266: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3267: END IF;
3260: IBE_UTIL.DEBUG('Error in Procees Order Flow: '||x_return_status );
3261: end if;
3262: retrieve_oe_messages;
3263: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3264: raise FND_API.G_EXC_ERROR;
3265: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3266: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3267: END IF;
3268: END IF;
3261: end if;
3262: retrieve_oe_messages;
3263: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3264: raise FND_API.G_EXC_ERROR;
3265: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3266: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3267: END IF;
3268: END IF;
3269:
3262: retrieve_oe_messages;
3263: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3264: raise FND_API.G_EXC_ERROR;
3265: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3266: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3267: END IF;
3268: END IF;
3269:
3270: x_order_header_id := lx_order_header_rec.header_id;
3296: --for logging appropriate error message
3297: if(x_msg_count is not null AND x_msg_count > 0) then
3298: for j in 1 .. x_msg_count
3299: loop
3300: x_msg_data:= OE_MSG_PUB.get(fnd_msg_pub.g_next,FND_API.G_FALSE);
3301: IF (IBE_UTIL.G_DEBUGON = l_true) then
3302: IBE_UTIL.DEBUG('Message from OE Save: ' || x_msg_data );
3303: end if;
3304: end loop;
3303: end if;
3304: end loop;
3305: end if;
3306:
3307: IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
3308: retrieve_oe_messages;
3309: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3310: raise FND_API.G_EXC_ERROR;
3311: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3305: end if;
3306:
3307: IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
3308: retrieve_oe_messages;
3309: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3310: raise FND_API.G_EXC_ERROR;
3311: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3312: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3313: END IF;
3306:
3307: IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
3308: retrieve_oe_messages;
3309: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3310: raise FND_API.G_EXC_ERROR;
3311: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3312: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3313: END IF;
3314: END IF;
3307: IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
3308: retrieve_oe_messages;
3309: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3310: raise FND_API.G_EXC_ERROR;
3311: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3312: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3313: END IF;
3314: END IF;
3315: x_order_header_id := l_order_header_rec.header_id;
3308: retrieve_oe_messages;
3309: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3310: raise FND_API.G_EXC_ERROR;
3311: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3312: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3313: END IF;
3314: END IF;
3315: x_order_header_id := l_order_header_rec.header_id;
3316:
3336: IBE_UTIL.DEBUG('x_flow_status_code: ' || x_flow_status_code );
3337: IBE_UTIL.DEBUG('calling ibe_active_quotes_all package handler: ' || l_cancel_flow);
3338: END IF;
3339:
3340: IF (FND_API.to_Boolean(l_cancel_flow)
3341: OR ((p_save_type = SAVE_NORMAL AND p_submit_control_rec.submit_flag = 'Y')
3342: -- AND (l_action_request_tbl(1).return_status = FND_API.G_RET_STS_SUCCESS)
3343: ))
3344: THEN
3338: END IF;
3339:
3340: IF (FND_API.to_Boolean(l_cancel_flow)
3341: OR ((p_save_type = SAVE_NORMAL AND p_submit_control_rec.submit_flag = 'Y')
3342: -- AND (l_action_request_tbl(1).return_status = FND_API.G_RET_STS_SUCCESS)
3343: ))
3344: THEN
3345: DeactivateOrder(p_party_id,l_order_header_rec.sold_to_org_id,l_order_header_rec.transactional_curr_code);
3346: ELSE
3374: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3375: IBE_UTIL.debug('IBE_ORDER_SAVE_PVT: Notification API is called');
3376: END IF;
3377:
3378: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3379: RAISE FND_API.G_EXC_ERROR;
3380: END IF;
3381:
3382: IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3375: IBE_UTIL.debug('IBE_ORDER_SAVE_PVT: Notification API is called');
3376: END IF;
3377:
3378: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3379: RAISE FND_API.G_EXC_ERROR;
3380: END IF;
3381:
3382: IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3383: RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3378: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3379: RAISE FND_API.G_EXC_ERROR;
3380: END IF;
3381:
3382: IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3383: RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3384: END IF;
3385:
3386: END IF; -- IF (p_save_type....)
3379: RAISE FND_API.G_EXC_ERROR;
3380: END IF;
3381:
3382: IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3383: RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3384: END IF;
3385:
3386: END IF; -- IF (p_save_type....)
3387:
3390: -- End of API body
3391: --
3392:
3393: -- Standard check for p_commit
3394: IF FND_API.to_Boolean( p_commit )
3395: THEN
3396: COMMIT WORK;
3397: END IF;
3398:
3405: FND_MSG_PUB.Count_And_Get ( p_count => x_msg_count,
3406: p_data => x_msg_data);
3407:
3408: EXCEPTION
3409: WHEN FND_API.G_EXC_ERROR THEN
3410: ROLLBACK TO SAVE_ORDER_SAVE_PVT;
3411: x_return_status := FND_API.G_RET_STS_ERROR;
3412: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3413: p_count => x_msg_count ,
3407:
3408: EXCEPTION
3409: WHEN FND_API.G_EXC_ERROR THEN
3410: ROLLBACK TO SAVE_ORDER_SAVE_PVT;
3411: x_return_status := FND_API.G_RET_STS_ERROR;
3412: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3413: p_count => x_msg_count ,
3414: p_data => x_msg_data);
3415: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3408: EXCEPTION
3409: WHEN FND_API.G_EXC_ERROR THEN
3410: ROLLBACK TO SAVE_ORDER_SAVE_PVT;
3411: x_return_status := FND_API.G_RET_STS_ERROR;
3412: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3413: p_count => x_msg_count ,
3414: p_data => x_msg_data);
3415: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3416: IBE_Util.Debug('Error IBE_ORDER_SAVE_PVT:Save()'|| sqlerrm);
3415: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3416: IBE_Util.Debug('Error IBE_ORDER_SAVE_PVT:Save()'|| sqlerrm);
3417: END IF;
3418:
3419: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3420: ROLLBACK TO SAVE_ORDER_SAVE_PVT;
3421: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3422: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3423: p_count => x_msg_count ,
3417: END IF;
3418:
3419: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3420: ROLLBACK TO SAVE_ORDER_SAVE_PVT;
3421: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3422: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3423: p_count => x_msg_count ,
3424: p_data => x_msg_data);
3425: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3418:
3419: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3420: ROLLBACK TO SAVE_ORDER_SAVE_PVT;
3421: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3422: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3423: p_count => x_msg_count ,
3424: p_data => x_msg_data);
3425: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3426: IBE_Util.Debug('UNEXPECTEDError IBE_ORDER_SAVE_PVT:Save()' || sqlerrm);
3426: IBE_Util.Debug('UNEXPECTEDError IBE_ORDER_SAVE_PVT:Save()' || sqlerrm);
3427: END IF;
3428: WHEN OTHERS THEN
3429: ROLLBACK TO SAVE_ORDER_SAVE_PVT;
3430: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3431:
3432: IF FND_Msg_Pub.Check_Msg_Level( FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR ) THEN
3433: FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
3434: L_API_NAME);
3433: FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
3434: L_API_NAME);
3435: END IF;
3436:
3437: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3438: p_count => x_msg_count ,
3439: p_data => x_msg_data);
3440: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3441: IBE_Util.Debug('Other IBE_ORDER_SAVE_PVT:Save()' || sqlerrm);
3528:
3529: l_count NUMBER := 0;
3530: l_salesrep_id VARCHAR2(360);
3531: l_order_type_id NUMBER;
3532: l_commit VARCHAR2(10):=FND_API.G_FALSE;
3533:
3534: l_salesrep_number VARCHAR2(360); --MOAC Changes by ASO::Obsoletion of ASO_DEFAULT_PERSON_ID
3535: l_user_orgid NUMBER;
3536:
3546: -- Standard Start of API savepoint
3547: SAVEPOINT ORDER_CHKCONSTRAINT;
3548:
3549: -- Standard call to check for call compatibility.
3550: IF NOT FND_API.Compatible_API_Call (l_api_version,
3551: P_Api_Version_Number,
3552: l_api_name,
3553: G_PKG_NAME )
3554: THEN
3551: P_Api_Version_Number,
3552: l_api_name,
3553: G_PKG_NAME )
3554: THEN
3555: RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3556: END IF;
3557:
3558: -- Initialize message list if p_init_msg_list is set to TRUE.
3559: IF FND_API.To_Boolean( p_init_msg_list ) THEN
3555: RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3556: END IF;
3557:
3558: -- Initialize message list if p_init_msg_list is set to TRUE.
3559: IF FND_API.To_Boolean( p_init_msg_list ) THEN
3560: FND_Msg_Pub.initialize;
3561: END IF;
3562:
3563: -- Initialize API return status to success
3560: FND_Msg_Pub.initialize;
3561: END IF;
3562:
3563: -- Initialize API return status to success
3564: x_return_status := FND_API.G_RET_STS_SUCCESS;
3565:
3566:
3567: -- Start OF API body --
3568: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3578:
3579: IF (l_order_type_id is null) THEN
3580: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_ORDER_TYPE_ID_MISS');
3581: FND_Msg_Pub.Add;
3582: RAISE FND_API.G_EXC_ERROR;
3583: ELSE
3584: l_order_header_rec.order_type_id := l_order_type_id;
3585: END IF;
3586:
3599: -- Bug 5359687, Proper error message when default salesrep is not set
3600: IF (l_salesrep_number is null) THEN
3601: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_SALESREPID_MISS');
3602: FND_Msg_Pub.Add;
3603: RAISE FND_API.G_EXC_ERROR;
3604: ELSE
3605: -- Get the sales rep id from the sales rep number using the JTF table
3606: select SALESREP_ID into l_salesrep_id from JTF_RS_SALESREPS where SALESREP_NUMBER = l_salesrep_number and ORG_ID = l_user_orgid;
3607: END IF;
3614:
3615: IF (l_salesrep_id is null) THEN
3616: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_SALESREPID_MISS');
3617: FND_Msg_Pub.Add;
3618: RAISE FND_API.G_EXC_ERROR;
3619: ELSE
3620: l_order_header_rec.salesrep_id := l_salesrep_id;
3621: END IF;
3622:
3678: -- This would avoid the NoDataFound thrown from OM as reported in the bug.
3679:
3680: OE_Order_GRP.Process_Order
3681: ( p_api_version_number => 1.0
3682: , p_init_msg_list => FND_API.G_TRUE
3683: , p_return_values => l_return_values
3684: , p_commit => FND_API.G_FALSE
3685: , x_return_status => x_return_status
3686: , x_msg_count => x_msg_count
3680: OE_Order_GRP.Process_Order
3681: ( p_api_version_number => 1.0
3682: , p_init_msg_list => FND_API.G_TRUE
3683: , p_return_values => l_return_values
3684: , p_commit => FND_API.G_FALSE
3685: , x_return_status => x_return_status
3686: , x_msg_count => x_msg_count
3687: , x_msg_data => x_msg_data
3688: , p_control_rec => l_control_rec
3715: IBE_UTIL.DEBUG('Return Status of First-Call to Process_Order() : ' || x_return_status);
3716: IBE_UTIL.DEBUG('header id from OE: ' || lx_order_header_rec.header_id);
3717: end if;
3718:
3719: IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
3720: retrieve_oe_messages;
3721: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3722: raise FND_API.G_EXC_ERROR;
3723: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3717: end if;
3718:
3719: IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
3720: retrieve_oe_messages;
3721: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3722: raise FND_API.G_EXC_ERROR;
3723: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3724: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3725: END IF;
3718:
3719: IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
3720: retrieve_oe_messages;
3721: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3722: raise FND_API.G_EXC_ERROR;
3723: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3724: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3725: END IF;
3726: END IF;
3719: IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
3720: retrieve_oe_messages;
3721: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3722: raise FND_API.G_EXC_ERROR;
3723: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3724: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3725: END IF;
3726: END IF;
3727:
3720: retrieve_oe_messages;
3721: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3722: raise FND_API.G_EXC_ERROR;
3723: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3724: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3725: END IF;
3726: END IF;
3727:
3728: --SET HEADER RECORD
3758: -- Now call Process_Order API for Policy check.
3759:
3760: OE_Order_GRP.Process_Order
3761: ( p_api_version_number => 1.0
3762: , p_init_msg_list => FND_API.G_TRUE
3763: , p_return_values => l_return_values
3764: , p_commit => FND_API.G_FALSE
3765: , x_return_status => x_return_status
3766: , x_msg_count => x_msg_count
3760: OE_Order_GRP.Process_Order
3761: ( p_api_version_number => 1.0
3762: , p_init_msg_list => FND_API.G_TRUE
3763: , p_return_values => l_return_values
3764: , p_commit => FND_API.G_FALSE
3765: , x_return_status => x_return_status
3766: , x_msg_count => x_msg_count
3767: , x_msg_data => x_msg_data
3768: , p_api_service_level => OE_GLOBALS.G_CHECK_SECURITY_ONLY
3828: end if;
3829:
3830: for j in 1 .. x_msg_count
3831: loop
3832: x_msg_data:= OE_MSG_PUB.get(fnd_msg_pub.g_next,FND_API.G_FALSE);
3833: IF (IBE_UTIL.G_DEBUGON = l_true) then
3834: IBE_Util.debug('Chk Constraint Exception Message' || x_msg_data);
3835: end if;
3836: end loop;
3834: IBE_Util.debug('Chk Constraint Exception Message' || x_msg_data);
3835: end if;
3836: end loop;
3837:
3838: IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
3839: retrieve_oe_messages;
3840: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3841: raise FND_API.G_EXC_ERROR;
3842: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3836: end loop;
3837:
3838: IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
3839: retrieve_oe_messages;
3840: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3841: raise FND_API.G_EXC_ERROR;
3842: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3843: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3844: END IF;
3837:
3838: IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
3839: retrieve_oe_messages;
3840: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3841: raise FND_API.G_EXC_ERROR;
3842: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3843: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3844: END IF;
3845: END IF;
3838: IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
3839: retrieve_oe_messages;
3840: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3841: raise FND_API.G_EXC_ERROR;
3842: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3843: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3844: END IF;
3845: END IF;
3846:
3839: retrieve_oe_messages;
3840: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
3841: raise FND_API.G_EXC_ERROR;
3842: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
3843: raise FND_API.G_EXC_UNEXPECTED_ERROR;
3844: END IF;
3845: END IF;
3846:
3847: --
3854: ROLLBACK TO ORDER_CHKCONSTRAINT;
3855: l_commit := p_commit;
3856:
3857: -- Standard check for p_commit
3858: IF FND_API.to_Boolean(l_commit)
3859: THEN
3860: COMMIT WORK;
3861: END IF;
3862:
3869: p_data => x_msg_data);
3870:
3871:
3872: EXCEPTION
3873: WHEN FND_API.G_EXC_ERROR THEN
3874: ROLLBACK TO ORDER_CHKCONSTRAINT;
3875: x_return_status := FND_API.G_RET_STS_ERROR;
3876: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3877: p_count => x_msg_count ,
3871:
3872: EXCEPTION
3873: WHEN FND_API.G_EXC_ERROR THEN
3874: ROLLBACK TO ORDER_CHKCONSTRAINT;
3875: x_return_status := FND_API.G_RET_STS_ERROR;
3876: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3877: p_count => x_msg_count ,
3878: p_data => x_msg_data);
3879: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3872: EXCEPTION
3873: WHEN FND_API.G_EXC_ERROR THEN
3874: ROLLBACK TO ORDER_CHKCONSTRAINT;
3875: x_return_status := FND_API.G_RET_STS_ERROR;
3876: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3877: p_count => x_msg_count ,
3878: p_data => x_msg_data);
3879: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3880: IBE_Util.Debug('Error IBE_ORDER_SAVE_PVT:CHECKCONSTRAINT()'|| sqlerrm);
3879: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3880: IBE_Util.Debug('Error IBE_ORDER_SAVE_PVT:CHECKCONSTRAINT()'|| sqlerrm);
3881: END IF;
3882:
3883: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3884: ROLLBACK TO ORDER_CHKCONSTRAINT;
3885: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3886: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3887: p_count => x_msg_count ,
3881: END IF;
3882:
3883: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3884: ROLLBACK TO ORDER_CHKCONSTRAINT;
3885: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3886: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3887: p_count => x_msg_count ,
3888: p_data => x_msg_data);
3889: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3882:
3883: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3884: ROLLBACK TO ORDER_CHKCONSTRAINT;
3885: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3886: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3887: p_count => x_msg_count ,
3888: p_data => x_msg_data);
3889: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3890: IBE_Util.Debug('UNEXPECTEDError IBE_ORDER_SAVE_PVT:CHECKCONSTRAINT()' || sqlerrm);
3891: END IF;
3892:
3893: WHEN OTHERS THEN
3894: ROLLBACK TO ORDER_CHKCONSTRAINT;
3895: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3896: IF FND_Msg_Pub.Check_Msg_Level( FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR ) THEN
3897: FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
3898: L_API_NAME);
3899: END IF;
3897: FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
3898: L_API_NAME);
3899: END IF;
3900:
3901: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
3902: p_count => x_msg_count ,
3903: p_data => x_msg_data);
3904: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
3905: IBE_Util.Debug('Other IBE_ORDER_SAVE_PVT:CHECKCONSTRAINT()' || sqlerrm);
3976: -- Standard Start of API savepoint
3977: SAVEPOINT ORDER_UPDTLINEBILL;
3978:
3979: -- Standard call to check for call compatibility.
3980: IF NOT FND_API.Compatible_API_Call (l_api_version,
3981: P_Api_Version_Number,
3982: l_api_name,
3983: G_PKG_NAME )
3984: THEN
3981: P_Api_Version_Number,
3982: l_api_name,
3983: G_PKG_NAME )
3984: THEN
3985: RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3986: END IF;
3987:
3988: -- Initialize message list if p_init_msg_list is set to TRUE.
3989: IF FND_API.To_Boolean( p_init_msg_list ) THEN
3985: RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3986: END IF;
3987:
3988: -- Initialize message list if p_init_msg_list is set to TRUE.
3989: IF FND_API.To_Boolean( p_init_msg_list ) THEN
3990: FND_Msg_Pub.initialize;
3991: END IF;
3992:
3993: -- Initialize API return status to success
3990: FND_Msg_Pub.initialize;
3991: END IF;
3992:
3993: -- Initialize API return status to success
3994: x_return_status := FND_API.G_RET_STS_SUCCESS;
3995:
3996: -- Start OF API body --
3997:
3998: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4001:
4002: /********** User Authentication *************/
4003:
4004: IF (p_order_header_id is not null AND
4005: p_order_header_id <> FND_API.G_MISS_NUM)
4006: THEN
4007: ValidateOrderAccess(p_order_header_id => p_order_header_id
4008: ,x_return_status => x_return_status
4009: );
4006: THEN
4007: ValidateOrderAccess(p_order_header_id => p_order_header_id
4008: ,x_return_status => x_return_status
4009: );
4010: IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) then
4011: raise FND_API.G_EXC_ERROR;
4012: END IF;
4013: END IF;
4014:
4007: ValidateOrderAccess(p_order_header_id => p_order_header_id
4008: ,x_return_status => x_return_status
4009: );
4010: IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) then
4011: raise FND_API.G_EXC_ERROR;
4012: END IF;
4013: END IF;
4014:
4015: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4032: OR l_last_update_date > p_last_update_date)
4033: THEN
4034: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_REFRESH_RETURN');
4035: FND_Msg_Pub.Add;
4036: RAISE FND_API.G_EXC_ERROR;
4037: END IF;
4038:
4039:
4040: IF (p_billto_cust_acct_id is not null AND p_billto_cust_acct_id <> FND_API.G_MISS_NUM
4036: RAISE FND_API.G_EXC_ERROR;
4037: END IF;
4038:
4039:
4040: IF (p_billto_cust_acct_id is not null AND p_billto_cust_acct_id <> FND_API.G_MISS_NUM
4041: AND p_billto_party_site_id is not null AND p_billto_party_site_id <> FND_API.G_MISS_NUM)
4042: THEN
4043: --l_siteuse_type := 'BILL_TO';
4044: l_siteuse_billto := 'BILL_TO';
4037: END IF;
4038:
4039:
4040: IF (p_billto_cust_acct_id is not null AND p_billto_cust_acct_id <> FND_API.G_MISS_NUM
4041: AND p_billto_party_site_id is not null AND p_billto_party_site_id <> FND_API.G_MISS_NUM)
4042: THEN
4043: --l_siteuse_type := 'BILL_TO';
4044: l_siteuse_billto := 'BILL_TO';
4045: END IF;
4043: --l_siteuse_type := 'BILL_TO';
4044: l_siteuse_billto := 'BILL_TO';
4045: END IF;
4046:
4047: IF (p_shipto_cust_acct_id is not null AND p_shipto_cust_acct_id <> FND_API.G_MISS_NUM
4048: AND p_shipto_party_site_id is not null AND p_shipto_party_site_id <> FND_API.G_MISS_NUM)
4049: THEN
4050: --l_siteuse_type := 'SHIP_TO';
4051: l_siteuse_shipto := 'SHIP_TO';
4044: l_siteuse_billto := 'BILL_TO';
4045: END IF;
4046:
4047: IF (p_shipto_cust_acct_id is not null AND p_shipto_cust_acct_id <> FND_API.G_MISS_NUM
4048: AND p_shipto_party_site_id is not null AND p_shipto_party_site_id <> FND_API.G_MISS_NUM)
4049: THEN
4050: --l_siteuse_type := 'SHIP_TO';
4051: l_siteuse_shipto := 'SHIP_TO';
4052: END IF;
4069: ,x_msg_count => x_msg_count
4070: ,x_msg_data => x_msg_data
4071: );
4072:
4073: IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
4074: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4075: IBE_Util.Debug('UpdateLinebilling- Get_Cust_Account_Site_Use() fails raise exception');
4076: END IF;
4077:
4076: END IF;
4077:
4078: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_INVALID_BILLTO_ADDR');
4079: FND_Msg_Pub.Add;
4080: RAISE FND_API.G_EXC_ERROR;
4081: END IF;
4082:
4083: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4084: IBE_Util.Debug('UpdateLinebilling-l_acct_siteuse_id: ' || l_billto_acct_siteuse_id);
4097: ,x_msg_count => x_msg_count
4098: ,x_msg_data => x_msg_data
4099: );
4100:
4101: IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
4102: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4103: IBE_Util.Debug('UpdateLinebilling- Get_Cust_Account_Site_Use() fails raise exception');
4104: END IF;
4105:
4104: END IF;
4105:
4106: FND_Message.Set_Name('IBE', 'IBE_ERR_OT_INVALID_SHIPTO_ADDR');
4107: FND_Msg_Pub.Add;
4108: RAISE FND_API.G_EXC_ERROR;
4109: END IF;
4110: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4111: IBE_Util.Debug('UpdateLinebilling-l_acct_siteuse_id: ' || l_shipto_acct_siteuse_id);
4112: END IF;
4132: IBE_Util.Debug('billto_ party_id :: billto_custacct_id: '||p_billto_party_id||' :: '||p_billto_cust_acct_id);
4133: END IF;
4134:
4135: If(p_billto_party_id is not null AND
4136: p_billto_party_id <> FND_API.G_MISS_NUM AND
4137: l_siteuse_billto = 'BILL_TO') then
4138:
4139: IBE_CUSTOMER_ACCT_PVT.Get_Cust_Acct_Role(
4140: p_party_id => p_billto_party_id
4150: l_order_line_tbl(1).invoice_to_contact_id := l_cust_acct_role_id;
4151: end if;
4152:
4153: if(p_shipto_party_id is not null AND
4154: p_shipto_party_id <> FND_API.G_MISS_NUM AND
4155: l_siteuse_shipto = 'SHIP_TO') then
4156:
4157: IBE_CUSTOMER_ACCT_PVT.Get_Cust_Acct_Role(
4158: p_party_id => p_shipto_party_id
4198:
4199: -- Calling Process Order
4200: OE_Order_GRP.Process_Order
4201: ( p_api_version_number => 1.0
4202: , p_init_msg_list => FND_API.G_TRUE
4203: , p_return_values => l_return_values
4204: , p_commit => FND_API.G_FALSE
4205: , x_return_status => x_return_status
4206: , x_msg_count => x_msg_count
4200: OE_Order_GRP.Process_Order
4201: ( p_api_version_number => 1.0
4202: , p_init_msg_list => FND_API.G_TRUE
4203: , p_return_values => l_return_values
4204: , p_commit => FND_API.G_FALSE
4205: , x_return_status => x_return_status
4206: , x_msg_count => x_msg_count
4207: , x_msg_data => x_msg_data
4208: , p_control_rec => l_control_rec
4238: end if;
4239:
4240: for j in 1 .. x_msg_count
4241: loop
4242: x_msg_data:= OE_MSG_PUB.get(fnd_msg_pub.g_next,FND_API.G_FALSE);
4243: IF (IBE_UTIL.G_DEBUGON = l_true) then
4244: IBE_UTIL.DEBUG('Message from OE update line bill: ' || x_msg_data );
4245: end if;
4246: end loop;
4244: IBE_UTIL.DEBUG('Message from OE update line bill: ' || x_msg_data );
4245: end if;
4246: end loop;
4247:
4248: IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
4249: retrieve_oe_messages;
4250: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
4251: raise FND_API.G_EXC_ERROR;
4252: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4246: end loop;
4247:
4248: IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
4249: retrieve_oe_messages;
4250: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
4251: raise FND_API.G_EXC_ERROR;
4252: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4253: raise FND_API.G_EXC_UNEXPECTED_ERROR;
4254: END IF;
4247:
4248: IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
4249: retrieve_oe_messages;
4250: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
4251: raise FND_API.G_EXC_ERROR;
4252: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4253: raise FND_API.G_EXC_UNEXPECTED_ERROR;
4254: END IF;
4255: END IF;
4248: IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
4249: retrieve_oe_messages;
4250: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
4251: raise FND_API.G_EXC_ERROR;
4252: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4253: raise FND_API.G_EXC_UNEXPECTED_ERROR;
4254: END IF;
4255: END IF;
4256:
4249: retrieve_oe_messages;
4250: IF x_return_status = FND_API.G_RET_STS_ERROR THEN
4251: raise FND_API.G_EXC_ERROR;
4252: ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4253: raise FND_API.G_EXC_UNEXPECTED_ERROR;
4254: END IF;
4255: END IF;
4256:
4257: --
4258: -- End of API body
4259: --
4260:
4261: -- Standard check for p_commit
4262: IF FND_API.to_Boolean( p_commit )
4263: THEN
4264: COMMIT WORK;
4265: END IF;
4266:
4272: FND_MSG_PUB.Count_And_Get ( p_count => x_msg_count,
4273: p_data => x_msg_data);
4274:
4275: EXCEPTION
4276: WHEN FND_API.G_EXC_ERROR THEN
4277: ROLLBACK TO ORDER_UPDTLINEBILL;
4278: x_return_status := FND_API.G_RET_STS_ERROR;
4279: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
4280: p_count => x_msg_count ,
4274:
4275: EXCEPTION
4276: WHEN FND_API.G_EXC_ERROR THEN
4277: ROLLBACK TO ORDER_UPDTLINEBILL;
4278: x_return_status := FND_API.G_RET_STS_ERROR;
4279: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
4280: p_count => x_msg_count ,
4281: p_data => x_msg_data);
4282: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4275: EXCEPTION
4276: WHEN FND_API.G_EXC_ERROR THEN
4277: ROLLBACK TO ORDER_UPDTLINEBILL;
4278: x_return_status := FND_API.G_RET_STS_ERROR;
4279: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
4280: p_count => x_msg_count ,
4281: p_data => x_msg_data);
4282: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4283: IBE_Util.Debug('Error IBE_ORDER_SAVE_PVT:UpdateLineShippingBilling()'|| sqlerrm);
4282: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4283: IBE_Util.Debug('Error IBE_ORDER_SAVE_PVT:UpdateLineShippingBilling()'|| sqlerrm);
4284: END IF;
4285:
4286: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4287: ROLLBACK TO ORDER_UPDTLINEBILL;
4288: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4289: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
4290: p_count => x_msg_count ,
4284: END IF;
4285:
4286: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4287: ROLLBACK TO ORDER_UPDTLINEBILL;
4288: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4289: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
4290: p_count => x_msg_count ,
4291: p_data => x_msg_data);
4292: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4285:
4286: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4287: ROLLBACK TO ORDER_UPDTLINEBILL;
4288: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4289: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
4290: p_count => x_msg_count ,
4291: p_data => x_msg_data);
4292: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4293: IBE_Util.Debug('UNEXPECTEDErr IBE_ORDER_SAVE_PVT:UpdateLineShippingBilling()' || sqlerrm);
4294: END IF;
4295:
4296: WHEN OTHERS THEN
4297: ROLLBACK TO ORDER_UPDTLINEBILL;
4298: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4299: IF FND_Msg_Pub.Check_Msg_Level( FND_Msg_Pub.G_MSG_LVL_UNEXP_ERROR ) THEN
4300: FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
4301: L_API_NAME);
4302: END IF;
4300: FND_Msg_Pub.Add_Exc_Msg(G_PKG_NAME,
4301: L_API_NAME);
4302: END IF;
4303:
4304: FND_Msg_Pub.Count_And_Get(p_encoded => FND_API.G_FALSE,
4305: p_count => x_msg_count ,
4306: p_data => x_msg_data);
4307: IF (IBE_UTIL.G_DEBUGON = l_true) THEN
4308: IBE_Util.Debug('OtherExc IBE_ORDER_SAVE_PVT:UpdateLineShippingBilling()' || sqlerrm);