采购接收接口开发 (PO RECEIPTS INTERFACE)

 
标签: 采购接收 接口开发 po receipts interface it 分类: OracleERP

RCV_TRANSACTIONS_INTERFACE;

RCV_HEADERS_INTERFACE;

mtl_transaction_lots_interface; (物料属于批次控制)

**************************************************

 

Declare v_interface_transaction_id number; v_group_id number; v_shipment_header_id number; v_shipment_line_id number; v_line_location_id number; v_po_distribution_id number; v_header_interface_id number; v_deliver_to_person_id number; l_request_id number; l_request_id2 number; v_destination_type_code varchar2(100); v_expected_receipt_date date; v_country_of_origin_code varchar2(100); v_lot_control number; v_use_mtl_serial number; v_rcv_qty number; v_trans_qty number; l_phase varchar2(10); l_status varchar2(10); l_dev_phase varchar2(10); l_dev_status varchar2(10); l_message varchar2(10); l_request_lauch1_status boolean; v_interface_id number; Cursor Cur_po_info Is select pha.segment1 ,pha.currency_code ,pha.ship_to_location_id ,pha.vendor_id ,pha.vendor_site_id ,pla.* from po_headers_all pha ,po_lines_all pla where pha.po_header_id = pla.po_header_id and pha.org_id = pla.org_id and pha.org_id = 104--OU:HUTS and pha.authorization_status = 'APPROVED' and pha.type_lookup_code = 'STANDARD' and pha.wf_item_type = 'POAPPRV' and pha.segment1 = '800743'--'800743' --Subinv,Locator --'UHU070925ZDW033-1' --Location ; Begin fnd_global.APPS_INITIALIZE(user_id=> 7256--7137 -- User name:hz00100 ,resp_id =>51707--21623 -- Purchasing Super User, Vision UK ,resp_appl_id =>201 --Purchasing Super User , PO ); mo_global.set_policy_context('S',104); mo_global.set_org_context(104,'','ONT'); mo_global.init('ONT'); DBMS_APPLICATION_INFO.set_client_info (104); For c_po_info in Cur_po_info Loop Select rcv_transactions_interface_s.nextval into v_interface_transaction_id from dual; Select RCV_INTERFACE_GROUPS_S.nextval into v_group_id from dual; select rcv_shipment_headers_s.nextval into v_shipment_header_id from dual; select rcv_shipment_lines_s.nextval into v_shipment_line_id from dual; select rcv_headers_interface_s.nextval into v_header_interface_id from dual; select MTL_MATERIAL_TRANSACTIONS_S.NEXTVAL into v_interface_id from dual; Begin select msib.lot_control_code into v_lot_control from mtl_system_items_b msib where msib.inventory_item_id = c_po_info.item_id and msib.organization_id = 122;--HUTS Exception when others then v_lot_control := null; End; If v_lot_control is null then v_use_mtl_serial := null; else v_use_mtl_serial := 1; End if; --Get po line location informations Begin select plla.line_location_id, plla.need_by_date, plla.country_of_origin_code, (plla.quantity - plla.quantity_received) into v_line_location_id, v_expected_receipt_date, v_country_of_origin_code, v_trans_qty from po_line_locations_all plla where plla.po_header_id = c_po_info.po_header_id and plla.po_line_id = c_po_info.po_line_id and rownum = 1; Exception when others then v_line_location_id := null; v_expected_receipt_date := null; v_country_of_origin_code := null; v_trans_qty := 0; End; --Get po_distribution_id Begin select pda.po_distribution_id ,pda.destination_type_code,pda.deliver_to_person_id into v_po_distribution_id ,v_destination_type_code,v_deliver_to_person_id from po_distributions_all pda where pda.po_header_id = c_po_info.po_header_id and pda.po_line_id = c_po_info.po_line_id and rownum = 1; Exception when others then v_po_distribution_id := null; v_destination_type_code := null; End; If v_trans_qty > 0 then INSERT INTO RCV_TRANSACTIONS_INTERFACE (INTERFACE_TRANSACTION_ID, GROUP_ID, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, TRANSACTION_TYPE, TRANSACTION_DATE, PROCESSING_STATUS_CODE, PROCESSING_MODE_CODE, TRANSACTION_STATUS_CODE, QUANTITY, UNIT_OF_MEASURE, ITEM_ID, EMPLOYEE_ID, AUTO_TRANSACT_CODE, SHIP_TO_LOCATION_ID, RECEIPT_SOURCE_CODE, VENDOR_ID, SOURCE_DOCUMENT_CODE, PO_HEADER_ID, PO_LINE_ID, PO_LINE_LOCATION_ID, DESTINATION_TYPE_CODE, DELIVER_TO_PERSON_ID, LOCATION_ID, DELIVER_TO_LOCATION_ID, SUBINVENTORY, locator_id, HEADER_INTERFACE_ID, DOCUMENT_NUM, TO_ORGANIZATION_ID, VALIDATION_FLAG ) Values ( v_interface_transaction_id,--INTERFACE_TRANSACTION_ID, v_group_id,--GROUP_ID, sysdate,--LAST_UPDATE_DATE, 7256,--LAST_UPDATED_BY, sysdate,--CREATION_DATE, 7256,--CREATED_BY, 7256,--LAST_UPDATE_LOGIN, 'RECEIVE',--TRANSACTION_TYPE, sysdate,--TRANSACTION_DATE, 'PENDING',--PROCESSING_STATUS_CODE, 'IMMEDIATE',--PROCESSING_MODE_CODE, 'PENDING',--TRANSACTION_STATUS_CODE, 1,--QUANTITY, c_po_info.unit_meas_lookup_code,--UNIT_OF_MEASURE, c_po_info.item_id,--ITEM_ID, 0,--EMPLOYEE_ID, 'DELIVER',--AUTO_TRANSACT_CODE, c_po_info.ship_to_location_id,--SHIP_TO_LOCATION_ID, 'VENDOR',--RECEIPT_SOURCE_CODE, c_po_info.vendor_id,--VENDOR_ID, 'PO',--SOURCE_DOCUMENT_CODE, c_po_info.po_header_id,--PO_HEADER_ID, c_po_info.PO_LINE_ID,--PO_LINE_ID, v_line_location_id,--PO_LINE_LOCATION_ID, v_destination_type_code,--DESTINATION_TYPE_CODE, v_DELIVER_TO_PERSON_ID,--DELIVER_TO_PERSON_ID, 200,--LOCATION_ID, 200,--DELIVER_TO_LOCATION_ID, 'NA01',--SUBINVENTORY, 2001,--locator_id, v_header_interface_id,--HEADER_INTERFACE_ID, c_po_info.segment1,--DOCUMENT_NUM, 122,--TO_ORGANIZATION_ID, 'Y'--VALIDATION_FLAG ); --Insert into header interface INSERT INTO RCV_HEADERS_INTERFACE (HEADER_INTERFACE_ID, GROUP_ID, PROCESSING_STATUS_CODE, RECEIPT_SOURCE_CODE, TRANSACTION_TYPE, AUTO_TRANSACT_CODE, LAST_UPDATE_DATE, LAST_UPDATED_BY, LAST_UPDATE_LOGIN, CREATION_DATE, CREATED_BY, VENDOR_ID, SHIP_TO_ORGANIZATION_ID, EXPECTED_RECEIPT_DATE, VALIDATION_FLAG ) VALUES (v_header_interface_id , --Header_Interface_Id v_group_id, --Group_Id 'PENDING', --Processing_Status_Code 'VENDOR', --Receipt_Source_Code 'NEW', --Transaction_Type 'DELIVER', --Auto_Transact_Code SYSDATE, --Last_Update_Date 7256, --Last_Updated_By 7256, --Last_Update_Login SYSDATE, --Creation_Date 7256, --Created_By c_po_info.Vendor_Id, --Vendor_Id 122, --Ship_To_Organization_Id, SYSDATE, --Expected_Receipt_Date 'Y' --Validation_Flag ); INSERT INTO mtl_transaction_lots_interface ( TRANSACTION_INTERFACE_ID, ORIGINATION_TYPE, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, LAST_UPDATE_LOGIN, LOT_NUMBER, TRANSACTION_QUANTITY, PRIMARY_QUANTITY, --SERIAL_TRANSACTION_TEMP_ID, PRODUCT_CODE, PRODUCT_TRANSACTION_ID ) VALUES (v_interface_id,--TRANSACTION_INTERFACE_ID 3,--ORIGINATION_TYPE SYSDATE, --LAST_UPDATE_DATE 7256, --LAST_UPDATED_BY SYSDATE, --CREATION_DATE 7256, --CREATED_BY 7256, --LAST_UPDATE_LOGIN 'Un-invoiced-CON', --LOT_NUMBER 1, --TRANSACTION_QUANTITY 1, --PRIMARY_QUANTITY --0,--MTL_MATERIAL_TRANSACTIONS_S.NEXTVAL, --SERIAL_TRANSACTION_TEMP_ID 'RCV', --PRODUCT_CODE v_interface_transaction_id --PRODUCT_TRANSACTION_ID ); End if; l_request_id := fnd_request.submit_request('PO', --APPLICATIONI SHORT NAME; 'RVCTP', --PROGRAME SHORT NAME; '', '', FALSE, 'IMMEDIATE', v_group_id --104--104, --CHR(0) ); l_request_id2 := fnd_request.submit_request('PO', --APPLICATIONI SHORT NAME; 'RCVDLPDT', --PROGRAME SHORT NAME; '', '', FALSE, 'P_group_id='||v_group_id, 'P_receipt_source_type=Supplier', 'P_qty_precision=2', 'P_org_id=122' ); dbms_output.put_line('l_request_id: '||l_request_id ||' l_request_id2: '||l_request_id2); End loop; commit; End;


你可能感兴趣的:(ORACLE,EBS)