133: AND substr(form_header_number , 1 , 3 ) = ShipNumPfx;
134:
135: BEGIN
136:
137: fnd_file.put_line(fnd_file.log , '... Assigning new shipment number');
138:
139: --
140: -- Getting prefix from user extension. If none, derive it from org
141: --
150: FETCH ShipNumPrefix INTO ShipNumPfx;
151: CLOSE ShipNumPrefix;
152: end if;
153:
154: fnd_file.put_line(fnd_file.log , 'Shipment Prefix = ' || ShipNumPfx);
155:
156: OPEN ShipNum;
157: FETCH ShipNum INTO LastShipNum;
158: CLOSE ShipNum;
156: OPEN ShipNum;
157: FETCH ShipNum INTO LastShipNum;
158: CLOSE ShipNum;
159:
160: fnd_file.put_line(fnd_file.log , 'Last Shipment Num = ' || LastShipNum);
161:
162: IF ( LastShipNum IS NULL ) THEN
163: --
164: -- This is the first DD250 for this contract and org
174: , 4 , '0' );
175:
176: END IF;
177:
178: fnd_file.put_line(fnd_file.log , 'Next Shipment Num = ' || NextShipNum);
179:
180: RETURN ( NextShipNum );
181:
182: EXCEPTION
460: , P_Shipment_Number => l_hdr_rec.Shipment_Number
461: , P_Form_Header_ID => FormHdrID
462: );
463:
464: fnd_file.put_line(fnd_file.log , '... Business Event raised');
465:
466: EXCEPTION
467: WHEN FND_API.G_EXC_ERROR THEN
468: x_return_status := FND_API.G_RET_STS_ERROR;
826: i NUMBER;
827:
828: BEGIN
829:
830: fnd_file.put_line(fnd_file.log , '... Begin DD250 generation');
831:
832: X_Return_Status := FND_API.G_RET_STS_SUCCESS;
833:
834: --
837: OPEN BillLading;
838: FETCH BillLading INTO BillLadingRec;
839: CLOSE BillLading;
840:
841: fnd_file.put_line(fnd_file.log , '... Fetching Bill of Lading information');
842:
843: -- FOR FrmHdrRec IN FrmHdr LOOP
844:
845: OPEN FrmHdr;
845: OPEN FrmHdr;
846: FETCH FrmHdr INTO FrmHdrRec;
847:
848: IF FrmHdr%NOTFOUND THEN
849: fnd_file.put_line(fnd_file.log , 'No data found for DD250.');
850: CLOSE FrmHdr;
851:
852: ELSE
853:
861:
862: --
863: -- Check for previously created DD250 for the same delivery
864: --
865: fnd_file.put_line(fnd_file.log , '... Check for previously created DD250');
866:
867: hdr_rec.Shipment_Number := NULL;
868: OPEN ShipmentNum( FrmHdrRec.K_Header_ID
869: , P_Delivery_ID
880: , FrmHdrRec.Inv_Org_ID
881: , P_Delivery_ID
882: , FrmHdrRec.Ship_From_Loc );
883: ELSE
884: fnd_file.put_line(fnd_file.log , '... Shipment Number ' ||
885: hdr_rec.Shipment_Number || ' located');
886: END IF;
887:
888: --
902: CLOSE CageCode;
903: AdminByRec.Code := AdminByCode.Code;
904: END IF;
905:
906: fnd_file.put_line(fnd_file.log , '... Fetching Admin By information');
907: fnd_file.put_line(fnd_file.log , '==> ' || AdminByRec.Object_Code || ' / ' ||
908: AdminByRec.Code || ' / ' ||
909: AdminByRec.ID1);
910:
903: AdminByRec.Code := AdminByCode.Code;
904: END IF;
905:
906: fnd_file.put_line(fnd_file.log , '... Fetching Admin By information');
907: fnd_file.put_line(fnd_file.log , '==> ' || AdminByRec.Object_Code || ' / ' ||
908: AdminByRec.Code || ' / ' ||
909: AdminByRec.ID1);
910:
911: IF ( AdminByRec.Object_Code = 'OKE_CUST_KADMIN' ) THEN
911: IF ( AdminByRec.Object_Code = 'OKE_CUST_KADMIN' ) THEN
912: OPEN CustSiteAddr( AdminByRec.ID1 );
913: FETCH CustSiteAddr INTO AdminByAddrRec;
914: CLOSE CustSiteAddr;
915: fnd_file.put_line(fnd_file.log , '==> ' || rtrim(substr(AdminByAddrRec.Address , 1 , 80)));
916: END IF;
917:
918: --
919: -- Fetch Contractor Information
928: CLOSE CageCode;
929: ContractorRec.Code := ContractorCode.Code;
930: END IF;
931:
932: fnd_file.put_line(fnd_file.log , '... Fetching contractor information');
933: fnd_file.put_line(fnd_file.log , '==> ' || ContractorRec.Object_Code || ' / ' ||
934: ContractorRec.Code || ' / ' ||
935: ContractorRec.ID1);
936:
929: ContractorRec.Code := ContractorCode.Code;
930: END IF;
931:
932: fnd_file.put_line(fnd_file.log , '... Fetching contractor information');
933: fnd_file.put_line(fnd_file.log , '==> ' || ContractorRec.Object_Code || ' / ' ||
934: ContractorRec.Code || ' / ' ||
935: ContractorRec.ID1);
936:
937: IF ( ContractorRec.Object_Code = 'OKX_OPERUNIT' OR ContractorRec.Object_Code = 'OKX_INVENTORY' ) THEN
937: IF ( ContractorRec.Object_Code = 'OKX_OPERUNIT' OR ContractorRec.Object_Code = 'OKX_INVENTORY' ) THEN
938: OPEN OrgAddr( ContractorRec.ID1 );
939: FETCH OrgAddr INTO ContractorAddrRec;
940: CLOSE OrgAddr;
941: fnd_file.put_line(fnd_file.log , '==> ' || rtrim(substr(ContractorAddrRec.Address , 1 , 80)));
942: END IF;
943:
944: --
945: -- Ship From Organization
951: OPEN ShipCode( FrmHdrRec.Deliverable_ID , 'SHIP_FROM', FrmHdrRec.Inv_Org_ID );
952: FETCH ShipCode INTO ShipFromCode;
953: CLOSE ShipCode;
954:
955: fnd_file.put_line(fnd_file.log , '... Fetching ship from information');
956: fnd_file.put_line(fnd_file.log , '==> ' || ShipFromRec.Object_Code || ' / ' ||
957: ShipFromCode.Code || ' / ' ||
958: ShipFromRec.ID1 || ' / ' || FrmHdrRec.Inv_Org_ID );
959:
952: FETCH ShipCode INTO ShipFromCode;
953: CLOSE ShipCode;
954:
955: fnd_file.put_line(fnd_file.log , '... Fetching ship from information');
956: fnd_file.put_line(fnd_file.log , '==> ' || ShipFromRec.Object_Code || ' / ' ||
957: ShipFromCode.Code || ' / ' ||
958: ShipFromRec.ID1 || ' / ' || FrmHdrRec.Inv_Org_ID );
959:
960: OPEN OrgAddr( FrmHdrRec.Inv_Org_ID );
959:
960: OPEN OrgAddr( FrmHdrRec.Inv_Org_ID );
961: FETCH OrgAddr INTO ShipFrmAddrRec;
962: CLOSE OrgAddr;
963: fnd_file.put_line(fnd_file.log , '==> ' || rtrim(substr(ShipFrmAddrRec.Address , 1 , 80)));
964:
965: --
966: -- Ship To Location
967: --
976: OPEN ShipCode( FrmHdrRec.Deliverable_ID , 'SHIP_TO', ShipToLoc.ID1 );
977: FETCH ShipCode INTO ShipToCode;
978: CLOSE ShipCode;
979:
980: fnd_file.put_line(fnd_file.log , '... Fetching ship to information');
981: fnd_file.put_line(fnd_file.log , '==> ' || ShipToRec.Object_Code || ' / ' ||
982: ShipToCode.Code || ' / ' ||
983: ShipToRec.ID1);
984:
977: FETCH ShipCode INTO ShipToCode;
978: CLOSE ShipCode;
979:
980: fnd_file.put_line(fnd_file.log , '... Fetching ship to information');
981: fnd_file.put_line(fnd_file.log , '==> ' || ShipToRec.Object_Code || ' / ' ||
982: ShipToCode.Code || ' / ' ||
983: ShipToRec.ID1);
984:
985: --
989: IF ( ShipToLoc.ID1 IS NOT NULL ) THEN
990: OPEN CustSiteAddr( ShipToLoc.ID1 );
991: FETCH CustSiteAddr INTO ShipToAddrRec;
992: CLOSE CustSiteAddr;
993: fnd_file.put_line(fnd_file.log , '==> ' || rtrim(substr(ShipToAddrRec.Address , 1 , 80)));
994: END IF;
995:
996: --
997: -- Mark For Location
1006: CLOSE CageCode;
1007: MarkForRec.Code := MarkForCode.Code;
1008: END IF;
1009:
1010: fnd_file.put_line(fnd_file.log , '... Fetching mark for information');
1011: fnd_file.put_line(fnd_file.log , '==> ' || MarkForRec.Object_Code || ' / ' ||
1012: MarkForRec.Code || ' / ' ||
1013: MarkForRec.ID1);
1014:
1007: MarkForRec.Code := MarkForCode.Code;
1008: END IF;
1009:
1010: fnd_file.put_line(fnd_file.log , '... Fetching mark for information');
1011: fnd_file.put_line(fnd_file.log , '==> ' || MarkForRec.Object_Code || ' / ' ||
1012: MarkForRec.Code || ' / ' ||
1013: MarkForRec.ID1);
1014:
1015: IF ( MarkForRec.Object_Code = 'OKE_MARKFOR' ) THEN
1015: IF ( MarkForRec.Object_Code = 'OKE_MARKFOR' ) THEN
1016: OPEN CustSiteAddr( MarkForRec.ID1 );
1017: FETCH CustSiteAddr INTO MarkForAddrRec;
1018: CLOSE CustSiteAddr;
1019: fnd_file.put_line(fnd_file.log , '==> ' || rtrim(substr(MarkForAddrRec.Address , 1 , 80)));
1020: END IF;
1021:
1022: --
1023: -- Bill To Location
1032: CLOSE CageCode;
1033: BillToRec.Code := BillToCode.Code;
1034: END IF;
1035:
1036: fnd_file.put_line(fnd_file.log , '... Fetching bill to information');
1037: fnd_file.put_line(fnd_file.log , '==> ' || BillToRec.Object_Code || ' / ' ||
1038: BillToRec.Code || ' / ' ||
1039: BillToRec.ID1);
1040:
1033: BillToRec.Code := BillToCode.Code;
1034: END IF;
1035:
1036: fnd_file.put_line(fnd_file.log , '... Fetching bill to information');
1037: fnd_file.put_line(fnd_file.log , '==> ' || BillToRec.Object_Code || ' / ' ||
1038: BillToRec.Code || ' / ' ||
1039: BillToRec.ID1);
1040:
1041: IF ( BillToRec.Object_Code = 'OKE_BILLTO' ) THEN
1041: IF ( BillToRec.Object_Code = 'OKE_BILLTO' ) THEN
1042: OPEN CustSiteAddr( BillToRec.ID1 );
1043: FETCH CustSiteAddr INTO BillToAddrRec;
1044: CLOSE CustSiteAddr;
1045: fnd_file.put_line(fnd_file.log , '==> ' || rtrim(substr(BillToAddrRec.Address , 1 , 80)));
1046: END IF;
1047:
1048: --
1049: -- Fetching other Terms and Conditions
1047:
1048: --
1049: -- Fetching other Terms and Conditions
1050: --
1051: fnd_file.put_line(fnd_file.log , '... Fetching various terms');
1052:
1053: OPEN TermValue( FrmHdrRec.Deliverable_ID , 'ACCEPTANCE_METHOD' );
1054: FETCH TermValue INTO AccptMethodRec;
1055: CLOSE TermValue;
1053: OPEN TermValue( FrmHdrRec.Deliverable_ID , 'ACCEPTANCE_METHOD' );
1054: FETCH TermValue INTO AccptMethodRec;
1055: CLOSE TermValue;
1056:
1057: fnd_file.put_line(fnd_file.log , 'Acceptance Method = ' || AccptMethodRec.Code);
1058:
1059: OPEN TermValue( FrmHdrRec.Deliverable_ID , 'ACCEPTANCE_POINT' );
1060: FETCH TermValue INTO AccptPointRec;
1061: CLOSE TermValue;
1059: OPEN TermValue( FrmHdrRec.Deliverable_ID , 'ACCEPTANCE_POINT' );
1060: FETCH TermValue INTO AccptPointRec;
1061: CLOSE TermValue;
1062:
1063: fnd_file.put_line(fnd_file.log , 'Acceptance Point = ' || AccptPointRec.Code);
1064:
1065: OPEN TermValue( FrmHdrRec.Deliverable_ID , 'INSPECTION_POINT' );
1066: FETCH TermValue INTO InspPointRec;
1067: CLOSE TermValue;
1065: OPEN TermValue( FrmHdrRec.Deliverable_ID , 'INSPECTION_POINT' );
1066: FETCH TermValue INTO InspPointRec;
1067: CLOSE TermValue;
1068:
1069: fnd_file.put_line(fnd_file.log , 'Inspection Point = ' || InspPointRec.Code);
1070:
1071: OPEN TermValue( FrmHdrRec.Deliverable_ID , 'OB_SHIP_METHOD' );
1072: FETCH TermValue INTO ShipMethodRec;
1073: CLOSE TermValue;
1071: OPEN TermValue( FrmHdrRec.Deliverable_ID , 'OB_SHIP_METHOD' );
1072: FETCH TermValue INTO ShipMethodRec;
1073: CLOSE TermValue;
1074:
1075: fnd_file.put_line(fnd_file.log , 'Ship Method = ' || ShipMethodRec.Code);
1076:
1077: OPEN TermValue( FrmHdrRec.Deliverable_ID , 'RA_PAYMENT_TERMS' );
1078: FETCH TermValue INTO DiscTermsRec;
1079: CLOSE TermValue;
1077: OPEN TermValue( FrmHdrRec.Deliverable_ID , 'RA_PAYMENT_TERMS' );
1078: FETCH TermValue INTO DiscTermsRec;
1079: CLOSE TermValue;
1080:
1081: fnd_file.put_line(fnd_file.log , 'Payment Terms = ' || DiscTermsRec.Name);
1082:
1083: --
1084: -- Preparing Form Header Record
1085: --
1122: hdr_rec.Volume_UOM_Code := FrmHdrRec.Volume_UOM_Code;
1123:
1124: i := 0;
1125:
1126: fnd_file.put_line(fnd_file.log , fnd_global.newline || '... Processing Line Information');
1127:
1128: FOR FrmLineRec IN FrmLine ( P_Delivery_ID
1129: , FrmHdrRec.Inv_Org_ID
1130: , FrmHdrRec.K_Header_ID
1135: OPEN LineInfo( FrmLineRec.Deliverable_ID );
1136: FETCH LineInfo INTO LineInfoRec;
1137: CLOSE LineInfo;
1138:
1139: fnd_file.put_line(fnd_file.log , 'CLIN = ' || LineInfoRec.Line_Number);
1140: fnd_file.put_line(fnd_file.log , 'Desc = ' || FrmLineRec.Item_Description);
1141: fnd_file.put_line(fnd_file.log , 'UOM = ' || LineInfoRec.UOM_Code);
1142: fnd_file.put_line(fnd_file.log , 'Qty = ' || FrmLineRec.Shipped_Qty);
1143: fnd_file.put_line(fnd_file.log , 'Price = ' || LineInfoRec.Unit_Price);
1136: FETCH LineInfo INTO LineInfoRec;
1137: CLOSE LineInfo;
1138:
1139: fnd_file.put_line(fnd_file.log , 'CLIN = ' || LineInfoRec.Line_Number);
1140: fnd_file.put_line(fnd_file.log , 'Desc = ' || FrmLineRec.Item_Description);
1141: fnd_file.put_line(fnd_file.log , 'UOM = ' || LineInfoRec.UOM_Code);
1142: fnd_file.put_line(fnd_file.log , 'Qty = ' || FrmLineRec.Shipped_Qty);
1143: fnd_file.put_line(fnd_file.log , 'Price = ' || LineInfoRec.Unit_Price);
1144:
1137: CLOSE LineInfo;
1138:
1139: fnd_file.put_line(fnd_file.log , 'CLIN = ' || LineInfoRec.Line_Number);
1140: fnd_file.put_line(fnd_file.log , 'Desc = ' || FrmLineRec.Item_Description);
1141: fnd_file.put_line(fnd_file.log , 'UOM = ' || LineInfoRec.UOM_Code);
1142: fnd_file.put_line(fnd_file.log , 'Qty = ' || FrmLineRec.Shipped_Qty);
1143: fnd_file.put_line(fnd_file.log , 'Price = ' || LineInfoRec.Unit_Price);
1144:
1145: line_tbl(i).Line_Number := LineInfoRec.Line_Number;
1138:
1139: fnd_file.put_line(fnd_file.log , 'CLIN = ' || LineInfoRec.Line_Number);
1140: fnd_file.put_line(fnd_file.log , 'Desc = ' || FrmLineRec.Item_Description);
1141: fnd_file.put_line(fnd_file.log , 'UOM = ' || LineInfoRec.UOM_Code);
1142: fnd_file.put_line(fnd_file.log , 'Qty = ' || FrmLineRec.Shipped_Qty);
1143: fnd_file.put_line(fnd_file.log , 'Price = ' || LineInfoRec.Unit_Price);
1144:
1145: line_tbl(i).Line_Number := LineInfoRec.Line_Number;
1146: line_tbl(i).Item_Number := LineInfoRec.Item_Number;
1139: fnd_file.put_line(fnd_file.log , 'CLIN = ' || LineInfoRec.Line_Number);
1140: fnd_file.put_line(fnd_file.log , 'Desc = ' || FrmLineRec.Item_Description);
1141: fnd_file.put_line(fnd_file.log , 'UOM = ' || LineInfoRec.UOM_Code);
1142: fnd_file.put_line(fnd_file.log , 'Qty = ' || FrmLineRec.Shipped_Qty);
1143: fnd_file.put_line(fnd_file.log , 'Price = ' || LineInfoRec.Unit_Price);
1144:
1145: line_tbl(i).Line_Number := LineInfoRec.Line_Number;
1146: line_tbl(i).Item_Number := LineInfoRec.Item_Number;
1147: line_tbl(i).Natl_Stock_Number := LineInfoRec.Natl_Stock_Number;
1160: line_tbl(i).Reference5 := NULL;
1161:
1162: END LOOP;
1163:
1164: fnd_file.put_line(fnd_file.log , '... Inserting into OKE_K_FORM_HEADERS');
1165:
1166: Create_DD250
1167: ( P_Commit => FND_API.G_FALSE
1168: , P_Hdr_Rec => hdr_rec
1173: );
1174:
1175: -- END LOOP;
1176:
1177: fnd_file.put_line(fnd_file.log , 'DD250 created.');
1178:
1179: END IF;
1180:
1181: END Create_DD250_From_Delivery;
1322: fnd_message.set_name('OKE' , 'OKE_API_ERROR_MULTI');
1323: fnd_message.set_token( 'CURR' , i);
1324: fnd_message.set_token( 'TOTAL' , Msg_Count);
1325: fnd_message.set_token( 'TEXT', Error_Buf );
1326: fnd_file.put_line( fnd_file.log , fnd_message.get );
1327: end loop;
1328:
1329: END IF;
1330: