采购接口管理
RCV_TRANSACTION_INTERFACE
RCV_LOTS_INTERFACE
PO_INTERFACE_ERRORS
MTL_TRANSACTION_LOTS_TEMP
MTL_TRANSACTION_LOTS_INTERFACE
MTL_SUPPLY
RCV_SUPPLY
MTL_SUPPLY表的作用
1、当请购单创建、审批后,MTL_SUPPLY的变化
a.当创建完请购单,MTL_SUPPLY为空
b.当审批后,MTL_SUPPLY中产生一条数据,SUPPLY_TYPE_CODE=REQ
c.当请购单审批后,请购头与请购行存入MS.REQ_HEADER_ID, MS.REQ_LINE_ID,此时MS.SUPPLY_TYPE_CODE=REQ
2、当PO创建、审批后,MTL_SUPPLY的变化
a.当请购单转换成po后,在未审批时,MTL_SUPPLY为空
b.当审批后,MTL_SUPPLY中原有的SUPPLY_TYPE_CODE=REQ被更改为SUPPLY_TYPE_CODE=PO
c.一般而言,当请购单自动创建为采购单时,其SUPPLY_TYPE_CODE=REQ被更改为SUPPLY_TYPE_CODE=PO
d.当审批后的po做取消时,MTL_SUPPLY中SUPPLY_TYPE_CODE=PO被更改为SUPPLY_TYPE_CODE=REQ
e.--当调用由请购单自动开采购单的程序时,如果未审批,MS.PO_HEADER_ID ,MS.PO_LINE_ID,
--MS.PO_RELEASE_ID, MS.PO_LINE_LOCATION_ID ,MS.PO_DISTRIBUTION_ID,为空,如果已审批
--MS.REQ_HEADER_ID, MS.REQ_LINE_ID被清空,MS.SUPPLY_TYPE_CODE=PO,对于在po单中修改数量或添加新的采购订单行
--而未审批,原有已审批的采购订单行数据不变,但新添加的行未录入该表
--当审批后的po做取消时,MTL_SUPPLY中SUPPLY_TYPE_CODE=PO被更改为SUPPLY_TYPE_CODE=REQ,
--MS.REQ_HEADER_ID, MS.REQ_LINE_ID被填入原有的请购单的头和行值,同时, MS.PO_HEADER_ID,MS.PO_LINE_ID,
--MS.PO_RELEASE_ID, MS.PO_LINE_LOCATION_ID,MS.PO_DISTRIBUTION_ID, MS.NEED_BY_DATE,MS.RECEIPT_DATE,
--MS.EXPECTED_DELIVERY_DATE, 被清空
3、当PO接收后,MTL_SUPPLY的变化
a.当po完全接收后,MTL_SUPPLY中原有的SUPPLY_TYPE_CODE=PO被更改为SUPPLY_TYPE_CODE=RECEIVING
b. --当采购单做完接收后,MTL_SUPPLY中SUPPLY_TYPE_CODE=PO被更改为SUPPLY_TYPE_CODE=RECEIVING,
--同时 MS.SHIPMENT_HEADER_ID,MS.SHIPMENT_LINE_ID, MS.RCV_TRANSACTION_ID ,存入shipment的头信息,行信息,及
--rcv_transaction的transaction_id
4、当PO某行部分接收后,MTL_SUPPLY的变化
a.当PO某行部分接收后,接受行中原有的SUPPLY_TYPE_CODE=PO被更改为SUPPLY_TYPE_CODE=RECEIVING
5、当PO检验后,MTL_SUPPLY有什么变化
a.当PO检验后,接受行中原有的SUPPLY_TYPE_CODE=RECEIVING不变
6、当PO部分入库后,MTL_SUPPLY有什么变化;全部入库后呢
a.当PO部分入库后,MTL_SUPPLY中该行记录被删除,而全部入库则该采购单所有行记录被删除
涉及的表
--已审批的请购单
SELECT prh.requisition_header_id, prl.requisition_line_id,prh.segment1
from PO_REQUISITION_HEADERS_ALL PRH, PO_REQUISITION_LINES_ALL PRL
where prh.requisition_header_id = prl.requisition_header_id
and prh.requisition_header_id = 662
and prh.authorization_status = 'APPROVED'
--已审批的采购单
SELECT ph.po_header_id,pl.PO_LINE_ID,ph.segment1,ph.*
from Po_Lines_all pl,Po_Headers_All ph
where pl.PO_HEADER_ID=ph.po_header_id
/* and ph.po_header_id = 41526*/
and ph.authorization_status = 'APPROVED'
and NVL(ph.cancel_flag,'N')<>'Y'
and ph.creation_date>=trunc(sysdate)
--接收
select *
from RCV_SHIPMENT_HEADERS rsh,
rcv_shipment_lines rsl
where rsh.shipment_header_id=rsl.shipment_header_id
and rsh.creation_date>=trunc(sysdate)
and rsh.receipt_num='185631'
select *
from rcv_transactions rt
where rt.transaction_id=870339
trm上的解释如下
MTL_SUPPLY stores incoming supply information for an organization.
This table forms one of the sources in Inventory's Demand-Supply form.
There are four different types of supply captured in this table:
1) Approved Requisitions
2) Approved Purchase orders
3) Shipments from suppliers
4) Intransit shipments from another organization
Types 3 and 4 could be distinguished by the presence of data in the
INTRANSIT_OWNING_ORGANIZATION_ID column, which identifies the
ownership of the items in intransit. If this column is null then it
means that the shipment supply is from a Vendor.
.
This information is used by the available to promise routine to derive
the ATP information as appropiate. Quantities of items in intransit
are also kept track of in the table.
.
Records in MTL_SUPPLY are created every time you approve a requisition
or a PO or create an intransit shipment. One record of REQ type will
be created for one requisition line when the requisition is approved.
One record of PO type will be created per PO distribution when a PO is
approved and one record per shipment line will be created when a
shipment is created.
.
Records in MTL_SUPPLY will be recreated whenever there are
transactions such as return to receiving, return to vendor or
cancellation of purchase orders.
.
Records in MTL_SUPPLY are deleted every time you change the document
status to not approved. For example, a PO would require approval if
you change the line and shipment quantity.
If such a PO is re-approved then the PO supply will be recreated for
the new quantity.
.
The supply type code of a REQ supply record is changed to PO every
time a requisition is autocreated. Similarly the supply type code is
changed from PO to RECEIVING when a PO is fully received. If a PO is
partially received then a supply with the supply type code of
RECEIVING will be created for the quantity received. When the receipt
is delivered the RECEIVING supply is deleted. SHIPMENT supply works in
the same way as PO supply.
.
There is a database trigger on MTL_SUPPLY with the name MTL_SUPPLY_T.
This trigger fires on insert, update or deletion of records in
MTL_SUPPLY. It inserts records into MRP_RELIEF_INTERFACE table
RCV:处理模式
此选项指明在保存对接收事务处理所做的工作之后使用的处理模式:
联机—直接调用“接收事务处理程序”。
即期—将事务处理传送至接口表,并为自上一次保存所做的工作之后输入的事务处理组调用“接收事务处理处理程序”。
批—将事务处理传送至接口表(“接收事务处理处理程序”在下一次运行时将从接口表中挑选这些事务处理)
更新接口表数据
更新接口表数据,让错误数据重新提交
UPDATE RCV_HEADERS_INTERFACE T SET T.PROCESSING_REQUEST_ID = NULL, T.RECEIPT_HEADER_ID = NULL, T.VALIDATION_FLAG = 'Y', T.PROCESSING_STATUS_CODE = 'PENDING' WHERE T.HEADER_INTERFACE_ID IN (SELECT RTI.HEADER_INTERFACE_ID FROM RCV_TRANSACTIONS_INTERFACE RTI); UPDATE PO.RCV_TRANSACTIONS_INTERFACE T SET T.REQUEST_ID = NULL, T.PROCESSING_REQUEST_ID = NULL, T.ORDER_TRANSACTION_ID = NULL, T.PRIMARY_QUANTITY = NULL, T.PRIMARY_UNIT_OF_MEASURE = NULL, T.INTERFACE_TRANSACTION_QTY = NULL, T.VALIDATION_FLAG = 'Y', T.PROCESSING_STATUS_CODE = 'PENDING', T.TRANSACTION_STATUS_CODE = 'PENDING', T.SHIPMENT_HEADER_ID = NULL |
接收入库的例子
CREATE OR REPLACE PACKAGE BODY XXUTS_O2C_PO_RECEIPT_PKG AS PROCEDURE MAIN(ERRBUF OUT VARCHAR2, RETCODE OUT NUMBER, P_ORGANIZATION_ID IN NUMBER, P_PO_LAST_TWO IN VARCHAR2) IS 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; V_LOCATOR_ID NUMBER; V_LOCATION_ID 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; V_USER_ID NUMBER; V_COUNT NUMBER; CURSOR CUR_PO_INFO IS SELECT PHA.SEGMENT1, PHA.CURRENCY_CODE, PHA.VENDOR_ID, PHA.VENDOR_SITE_ID, PHA.SHIP_TO_LOCATION_ID, PDA.PO_DISTRIBUTION_ID, PDA.DESTINATION_TYPE_CODE, PDA.DELIVER_TO_PERSON_ID, PDA.QUANTITY_ORDERED, PDA.LINE_LOCATION_ID, NVL(PDA.QUANTITY_ORDERED, 0) - NVL(PDA.QUANTITY_DELIVERED, 0) TRANS_QTY, PLA.* FROM PO_HEADERS_ALL PHA, PO_LINES_ALL PLA, PO_DISTRIBUTIONS_ALL PDA 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 PDA.PO_HEADER_ID = PLA.PO_HEADER_ID AND PDA.PO_LINE_ID = PLA.PO_LINE_ID AND EXISTS (SELECT 1 FROM PO_LINE_LOCATIONS_ALL PLLA WHERE PLLA.PO_HEADER_ID = PLA.PO_HEADER_ID AND PLLA.PO_LINE_ID = PLA.PO_LINE_ID AND (PLLA.QUANTITY - PLLA.QUANTITY_RECEIVED - PLLA.QUANTITY_CANCELLED) > 0 AND PLLA.SHIP_TO_ORGANIZATION_ID = P_ORGANIZATION_ID) AND PHA.SEGMENT1 LIKE '%' || P_PO_LAST_TWO; BEGIN V_USER_ID := FND_GLOBAL.USER_ID; UPDATE PO_HEADERS_ALL PHA SET PHA.RATE_TYPE = 'User' WHERE PHA.CURRENCY_CODE <> 'RMB' 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.RATE_TYPE IS NULL AND PHA.SEGMENT1 LIKE '%' || P_PO_LAST_TWO; COMMIT; BEGIN SELECT MIL.INVENTORY_LOCATION_ID INTO V_LOCATOR_ID FROM MTL_ITEM_LOCATIONS MIL WHERE MIL.SUBINVENTORY_CODE = 'NA01' AND MIL.ORGANIZATION_ID = P_ORGANIZATION_ID AND ROWNUM = 1; EXCEPTION WHEN OTHERS THEN FND_FILE.PUT_LINE(1, 'Please define subinventory:NA01 and it is locator:NA01......;'); RETURN; END; BEGIN SELECT COUNT(*) INTO V_COUNT FROM MTL_SECONDARY_INVENTORIES MSI WHERE MSI.SECONDARY_INVENTORY_NAME = 'NA01' AND MSI.ORGANIZATION_ID = P_ORGANIZATION_ID; IF V_COUNT = 0 THEN FND_FILE.PUT_LINE(1, 'Please define subinventory:NA01;'); RETURN; END IF; END; IF P_ORGANIZATION_ID = 122 THEN BEGIN SELECT LOC.LOCATION_ID INTO V_LOCATION_ID FROM HR_LOCATIONS LOC WHERE LOC.LOCATION_CODE = 'HUTS-HQ Hangzhou' AND LOC.INVENTORY_ORGANIZATION_ID = P_ORGANIZATION_ID AND ROWNUM = 1; EXCEPTION WHEN OTHERS THEN FND_FILE.PUT_LINE(1, 'Location: HUTS-HQ Hangzhou not found!'); RETURN; END; END IF; SELECT RCV_INTERFACE_GROUPS_S.NEXTVAL INTO V_GROUP_ID FROM DUAL; 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 = P_ORGANIZATION_ID; --p_organization_id; --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 PLLA.LINE_LOCATION_ID = C_PO_INFO.LINE_LOCATION_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; V_PO_DISTRIBUTION_ID := C_PO_INFO.PO_DISTRIBUTION_ID; V_DESTINATION_TYPE_CODE := C_PO_INFO.DESTINATION_TYPE_CODE; V_DELIVER_TO_PERSON_ID := C_PO_INFO.DELIVER_TO_PERSON_ID; V_TRANS_QTY := NVL(C_PO_INFO.TRANS_QTY, 0); IF P_ORGANIZATION_ID <> 122 THEN V_LOCATION_ID := C_PO_INFO.SHIP_TO_LOCATION_ID; END IF; IF V_TRANS_QTY > 0 THEN --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 V_USER_ID, --Last_Updated_By V_USER_ID, --Last_Update_Login SYSDATE, --Creation_Date V_USER_ID, --Created_By C_PO_INFO.VENDOR_ID, --Vendor_Id P_ORGANIZATION_ID, --Ship_To_Organization_Id, SYSDATE, --Expected_Receipt_Date 'Y' --Validation_Flag ); 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, ITEM_DESCRIPTION, 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, PO_DISTRIBUTION_ID, DELIVER_TO_PERSON_ID, LOCATION_ID, DELIVER_TO_LOCATION_ID, SUBINVENTORY, LOCATOR_ID, HEADER_INTERFACE_ID, DOCUMENT_NUM, TO_ORGANIZATION_ID, CURRENCY_CONVERSION_TYPE, VALIDATION_FLAG) VALUES (V_INTERFACE_TRANSACTION_ID, --INTERFACE_TRANSACTION_ID, V_GROUP_ID, --GROUP_ID, SYSDATE, --LAST_UPDATE_DATE, V_USER_ID, --LAST_UPDATED_BY, SYSDATE, --CREATION_DATE, V_USER_ID, --CREATED_BY, V_USER_ID, --LAST_UPDATE_LOGIN, 'RECEIVE', --TRANSACTION_TYPE, SYSDATE, --TRANSACTION_DATE, 'PENDING', --PROCESSING_STATUS_CODE, 'IMMEDIATE', --PROCESSING_MODE_CODE, 'PENDING', --TRANSACTION_STATUS_CODE, V_TRANS_QTY, --QUANTITY, C_PO_INFO.UNIT_MEAS_LOOKUP_CODE, --UNIT_OF_MEASURE, C_PO_INFO.ITEM_ID, --ITEM_ID, C_PO_INFO.ITEM_DESCRIPTION, --ITEM_DESCRIPTION 0, --EMPLOYEE_ID, 'DELIVER', --AUTO_TRANSACT_CODE, V_LOCATION_ID, --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_PO_DISTRIBUTION_ID, --po_distribution_id V_DELIVER_TO_PERSON_ID, --DELIVER_TO_PERSON_ID, V_LOCATION_ID, --200,--LOCATION_ID, V_LOCATION_ID, --200,--DELIVER_TO_LOCATION_ID, 'NA01', --SUBINVENTORY, V_LOCATOR_ID, --locator_id, V_HEADER_INTERFACE_ID, --HEADER_INTERFACE_ID, C_PO_INFO.SEGMENT1, --DOCUMENT_NUM, P_ORGANIZATION_ID, --TO_ORGANIZATION_ID, 'Corporate', 'Y' --VALIDATION_FLAG ); IF V_LOT_CONTROL = 2 THEN 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 V_USER_ID, --LAST_UPDATED_BY SYSDATE, --CREATION_DATE V_USER_ID, --CREATED_BY V_USER_ID, --LAST_UPDATE_LOGIN 'Un-invoiced-CON', --LOT_NUMBER V_TRANS_QTY, --TRANSACTION_QUANTITY V_TRANS_QTY, --PRIMARY_QUANTITY --0,--MTL_MATERIAL_TRANSACTIONS_S.NEXTVAL, --SERIAL_TRANSACTION_TEMP_ID 'RCV', --PRODUCT_CODE V_INTERFACE_TRANSACTION_ID --PRODUCT_TRANSACTION_ID ); END IF; END IF; END LOOP; 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=' || P_ORGANIZATION_ID); FND_FILE.PUT_LINE(2, 'Receiving Transaction Processor: ' || L_REQUEST_ID || ' Receipt Traveller Concurrent program: ' || L_REQUEST_ID2); FND_FILE.PUT_LINE(2, 'Group Id: ' || V_GROUP_ID); COMMIT; END MAIN; END XXUTS_O2C_PO_RECEIPT_PKG; |
成长
/ | \
学习 总结 分享
QQ交流群:122230156