Sunteți pe pagina 1din 6

Transaction Open Interface

1. All Input Parameters Are:-


SOURCE_CODE,
SOURCE_HEADER_ID,
SOURCE_LINE_ID,
PROCESS_FLAG,
TRANSACTION_MODE,
LOCK_FLAG,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
CREATION_DATE,
CREATED_BY,
TRANSACTION_QUANTITY,
ORGANIZATION_ID,
TRANSACTION_UOM,
TRANSACTION_DATE,
SUBINVENTORY_CODE,
INVENTORY_ITEM_ID,
TRANSACTION_SOURCE_ID,
PRIMARY_QUANTITY,
TRANSACTION_COST,
TRANSACTION_TYPE_ID,
TRANSACTION_ACTION_ID,
TRANSACTION_SOURCE_TYPE_ID,
dst_segment1,
dst_segment2,
dst_segment3,
dst_segment4,
dst_segment5,
dst_segment6

2. Validation Programme

create or replace PACKAGE BODY XX_TRANSACTIONS_VALIDATION AS

PROCEDURE XX_VALIDATION (x_errbuf out varchar2,


x_ret_code out number) as
lv_error_code varchar2(2000);
lv_error_flag varchar2(10);
lv_error_message varchar2(2000 byte);
lv_inventory_ITEM_id number;
lv_org_id number;
lv_transaction_type_id number;
lv_subinventory_code varchar2(200);
lv_uom varchar2(10);
lv_transaction_type_name varchar2(2000);
lv_source_name varchar2(2000);

cursor mtl_transaction_header is
select xmt.rowid, xmt.* from xx_material_transactions xmt;

cursor org_check(P_org NUMBER) is


SELECT ORGANIZATION_ID FROM org_organization_definitions
WHERE ORGANIZATION_ID=P_ORG;

CURSOR ITEM_CHECK(P_ITEM VARCHAR2, P_ORG NUMBER) IS


SELECT INVENTORY_ITEM_ID FROM MTL_SYSTEM_ITEMS_B
WHERE INVENTORY_ITEM_ID=P_ITEM
AND ORGANIZATION_ID=P_ORG;

CURSOR SUBINVENTORY_CHECK( P_ORG NUMBER, P_SUBINVENTORY_CODE


VARCHAR2) IS
SELECT SECONDARY_INVENTORY_NAME FROM
MTL_SECONDARY_INVENTORIES
WHERE ORGANIZATION_ID =p_org
and secondary_inventory_name=p_subinventory_code;

cursor uom_check (p_uom varchar2, p_inventory_item_id number, p_org


number) is
SELECT primary_uom_code FROM MTL_SYSTEM_ITEMS_B
WHERE INVENTORY_ITEM_ID=p_inventory_item_id
and organization_id= p_org
and primary_uom_code=p_uom;

cursor transaction_type_check(p_transaction_type_ID number) is


SELECT TRANSACTION_TYPE_ID, TRANSACTION_TYPE_NAME FROM
MTL_TRANSACTION_TYPES
WHERE TRANSACTION_TYPE_ID=P_TRANSACTION_TYPE_ID;

CURSOR SOURCE_CHECK(P_SOURCE_NAME varchar2) IS


SELECT TRANSACTION_SOURCE_TYPE_NAME FROM MTL_TXN_SOURCE_TYPES
WHERE TRANSACTION_SOURCE_TYPE_NAME=P_SOURCE_NAME;

begin

for i in mtl_transaction_header loop

lv_org_id :=null;
lv_error_message :=null;
lv_subinventory_code :=null;
lv_inventory_item_id :=null;
lv_uom := null;
lv_transaction_type_id := null;
lv_transaction_type_name := null;
lv_source_name := null;
---- gv_error_location :=null;

open org_check(i.organization_id);
fetch ORG_check INTO LV_ORG_ID;
CLOSE ORG_CHECK;
IF LV_ORG_ID IS NULL THEN
LV_ERROR_MESSAGE :='This Organization does not exit'||i.organization_id;
end if;

open subinventory_check(i.organization_id, i.subinventory_code);


fetch subinventory_check into lv_subinventory_code;
close subinventory_check;
if lv_subinventory_code is null then
lv_error_message := ' This subinventory does not exit' ||
i.subinventory_code;
end if;

open item_check(i.inventory_item_id, i.organization_id);


fetch item_check into lv_inventory_item_id;
close item_check;
if lv_inventory_item_id is null then
lv_error_message :=' This item does not exit '||i.inventory_item_id;
end if;

open uom_check(i.transaction_uom, i.inventory_item_id, i.organization_id);


fetch uom_check into lv_uom;
close uom_check;
if lv_uom is null then
lv_error_message := 'This uom '||i.transaction_uom ||' does not exit for item
'||i.inventory_item_id;
end if;

open transaction_type_check(i.transaction_type_id);
fetch transaction_type_check into lv_transaction_type_id,
lv_transaction_type_name;
close transaction_type_check;
if lv_transaction_type_id is null then
lv_error_message :=' This transaction type is not defined' ||
i.transaction_type_id;
end if;

open source_check(i.source_code);
fetch source_check into lv_source_name;
close source_check;
if lv_source_name is null then
lv_error_message :='This source type does not exit '|| i.source_code;
end if;

if lv_error_message IS NULL then


begin
insert into MTL_TRANSACTIONS_INTERFACE (
SOURCE_CODE,
SOURCE_HEADER_ID,
SOURCE_LINE_ID,
PROCESS_FLAG,
TRANSACTION_MODE,
LOCK_FLAG,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
CREATION_DATE,
CREATED_BY,
TRANSACTION_QUANTITY,
ORGANIZATION_ID,
TRANSACTION_UOM,
TRANSACTION_DATE,
SUBINVENTORY_CODE,
INVENTORY_ITEM_ID,
TRANSACTION_SOURCE_ID,
PRIMARY_QUANTITY,
TRANSACTION_COST,
TRANSACTION_TYPE_ID,
--- TRANSACTION_ACTION_ID,
TRANSACTION_SOURCE_TYPE_ID,
dst_segment1,
dst_segment2,
dst_segment3,
dst_segment4,
dst_segment5,
dst_segment6
) VALUES
(i.SOURCE_CODE ,
i.source_header_id,
i.source_line_id,
i.process_flag,
i.transaction_mode,
i.lock_flag,
i.last_update_date,
i.last_updated_by,
i.creation_date,
i.created_by,
i.transaction_quantity,
i.organization_id,
i.transaction_uom,
i.transaction_date,
i.subinventory_code,
i.inventory_item_id,
i.transaction_source_id,
i.primary_quantity,
i.transaction_cost,
i.transaction_type_id,
--- i.transaction_action_id,
i.transaction_source_id,
'01',
'00',
'00000',
'311611',
'0000',
'0000'
);
--- gv_error_loc :=' ERROR IN UPDATING INTERFACE TABLE';
/* EXCEPTION
WHEN NO_DATA_FOUND THEN
x_ret_code := 1;
x_errbuf := gv_error_loc;
---- FND_FILE.PUT_LINE(FND_FILE.LOG||'Error occurred at: Error:'||
SUBSTR(SQLERRM,1,500));
WHEN OTHERS THEN
x_errbuf := SUBSTR
(SQLERRM,1,200);
x_ret_code := 2;
--- FND_FILE.PUT_LINE(FND_FILE.LOG||'Unexpected error occurred in
process_invoices procedure at: Error:'||SQLERRM); */
end;
ELSE
-- FND_FILE.PUT_LINE(FND_FILE.LOG , 'Error Details Occured in
process_TRANSACTIONS procedure at: '||': '||LV_ERROR_MESSAGE);
--- FND_FILE.PUT_LINE(FND_FILE.OUTPUT,I.INVENTORY_item_ID||',Error
Details Occured in process_TRANSACTIONS at: '||': '||LV_ERROR_MESSAGE);
-- X_ERRBUF :=LV_ERROR_MESSAGE;
-- X_RET_CODE :=1;
INSERT INTO YYY VALUES(I.INVENTORY_ITEM_ID);
END IF;

END LOOP;
commit;
end XX_VALIDATION;

end XX_TRANSACTIONS_VALIDATION;

3. Then Run Process transaction interface

All transactions which is made by Transaction interface are

S-ar putea să vă placă și