Professional Documents
Culture Documents
mtl_system_items_b itm
where a.INVENTORY_ITEM_CODE=itm.SEGMENT1(+) and itm.ORGANIZATION_ID(+)=370
and itm.SEGMENT1 is null
----------
-- select * from rfl_scm_item_list a where a.AMSU_TEXT='PCS' and AMIM_TEXT in
('0538107211','0526558051')
l_org_id number(3);
l_uom varchar2(15);
l_suom varchar2(15);
l_item_type varchar2(60);
l_desc varchar2(60);
l_temp_id varchar2(3);
l_sale_ac number(16);
l_exp_ac number(16);
l_cost_sale_ac number(16);
l_item_number varchar2(100);
l_flag varchar2(4) default'A';
l_msg varchar2(200);
begin
--delete from MTL_SYSTEM_ITEMS_INTERFACE;
--commit;
for x1 in c1 loop
/* Validation For Organization */
-- begin
-- select organization_id into l_org_id
-- from ORG_ORGANIZATION_DEFINITIONS
-- where organization_code = x1.organization_code;
-- exception
-- when others then
-- l_flag :='E';
-- l_msg :='Item Interface'||'Organization Id'||l_org_id||' not in
system';
-- fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
-- end;
begin
select COST_OF_SALES_ACCOUNT into l_cost_sale_ac
from MTL_PARAMETERS
where ORGANIZATION_ID = 102;
exception
when no_data_found then
l_flag :='E';
l_msg :='Cost of Sales Account should not be Null';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
when others then
l_flag :='E';
l_msg :='Cost of Sales Account is not Valid';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
end;
begin
select SALES_ACCOUNT into l_sale_ac
from MTL_PARAMETERS
where ORGANIZATION_ID = 102;
exception
when no_data_found then
l_flag :='E';
l_msg :='Sales Account should not be Null';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
when others then
l_flag :='E';
l_msg :='Sales Account is not Valid';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
end;
begin
exception
when no_data_found then
l_flag :='E';
l_msg :='Expence Account should not be Null';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
when others then
l_flag :='E';
l_msg :='Expence Account is not Valid';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
end;
if l_flag!='E' then
insert into MTL_SYSTEM_ITEMS_INTERFACE
( ORGANIZATION_ID,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_LOGIN,
DESCRIPTION,
SEGMENT1,
PRIMARY_UOM_CODE,
TEMPLATE_ID,
SUMMARY_FLAG,
ENABLED_FLAG,
SALES_ACCOUNT,
COST_OF_SALES_ACCOUNT,
EXPENSE_ACCOUNT,
PROCESS_QUALITY_ENABLED_FLAG,
PROCESS_COSTING_ENABLED_FLAG,
RECIPE_ENABLED_FLAG,
PROCESS_EXECUTION_ENABLED_FLAG,
RESTRICT_SUBINVENTORIES_CODE,
RESTRICT_LOCATORS_CODE ,
LOCATION_CONTROL_CODE ,
SET_PROCESS_ID,
PROCESS_FLAG,
TRANSACTION_TYPE/*,
ATTRIBUTE1, -- ou
ATTRIBUTE25, -- TF
ATTRIBUTE26, -- unload
ATTRIBUTE27, -- load
ATTRIBUTE28, -- DP
ATTRIBUTE29, -- TP
ATTRIBUTE30 -- MRP*/
)
values( 102,
sysdate,
fnd_global.USER_ID,
sysdate,
fnd_global.USER_ID,
fnd_global.LOGIN_ID,
x1.DESCRIPTION,
x1.SEGMENT1,
l_uom,
-- l_item_type,
-- 1, -- 1 for FG item, 2 for Purchase
1,
'Y',
'Y',
l_sale_ac,
l_cost_sale_ac,
l_exp_ac,
x1.PROCESS_QUALITY_ENABLED_FLAG,
x1.PROCESS_COSTING_ENABLED_FLAG,
x1.RECIPE_ENABLED_FLAG,
x1.PROCESS_EXECUTION_ENABLED_FLAG,
1,
1,
2,
2,
1,
'CREATE'/*,
x1.ATTRIBUTE1,
x1.ATTRIBUTE25, -- TF
x1.ATTRIBUTE29, -- unload
x1.ATTRIBUTE30, -- load
x1.ATTRIBUTE27, -- DP
x1.ATTRIBUTE28, -- TP
x1.ATTRIBUTE26 -- MRP*/
);
-- MTL_INTERFACE_ERRORS
commit;
end;
/
--------------------
DECLARE
CURSOR c_header IS
CURSOR c_master (
p_formula varchar2 --TEST_M020
) IS
SELECT *
FROM JLN_formula_headers --mii_gmd_formula
WHERE flag IS NULL
AND formula_no = p_formula;
l_formula_header_tbl gmd_formula_pub.formula_insert_hdr_tbl_type;
l_formula JLN_formula_headers%ROWTYPE; -- mii_gmd_formula%ROWTYPE;
l_count NUMBER := 0;
l_loop_cnt NUMBER := 0;
l_record_count NUMBER := 0;
l_data VARCHAR2 (2000);
l_return_status VARCHAR2 (1);
l_status VARCHAR2 (1);
i NUMBER := 1;
l_dummy_cnt NUMBER;
l_api_version NUMBER := 1;
l_init_msg_list BOOLEAN;
l_commit BOOLEAN;
return_sts BOOLEAN;
v_item_id number;
v_organization_id number;
v_user_id number;
BEGIN
--FND_GLOBAL.APPS_INITIALIZE(1112,22882,552,0);
fnd_global.apps_initialize (user_id => 1187,
resp_id => 50774,
resp_appl_id => 555
);
-- FND_RESPONSIBILITY_VL , FND_user
dbms_output.put_line (c_master%ROWCOUNT);
BEGIN
SELECT DISTINCT inventory_item_id
INTO v_item_id
FROM mtl_system_items_b
WHERE segment1 = UPPER(l_formula.inventory_item_code);
SELECT organization_id
INTO v_organization_id
FROM mtl_parameters
WHERE organization_code = l_formula.owner_organization_code;
SELECT user_id
INTO v_user_id
FROM fnd_user
WHERE user_name = l_formula.owner_name;
EXCEPTION
WHEN others THEN
UPDATE JLN_formula_headers --mii_gmd_formula
set flag = 'E'
--, note = 'Ada exception'
WHERE formula_no = l_formula.formula_no;
END;
-- UPDATE mii_gmd_formula
-- set flag = 'Y'
-- WHERE formula_no = l_formula.formula_no
-- AND line_no = l_formula.line_no
-- AND inventory_item_code = l_formula.inventory_item_code;
END LOOP;
CLOSE c_master;
gmd_formula_pub.insert_formula
(p_api_version => 1.0,
p_formula_header_tbl => l_formula_header_tbl,
x_return_status => l_return_status,
x_msg_count => l_count,
x_msg_data => l_data
);
DBMS_OUTPUT.put_line ('l_return_status:'||
l_return_status);
DBMS_OUTPUT.put_line ('l_data:'||l_data);
END LOOP;
IF l_count >= 0
THEN
l_loop_cnt := 1;
LOOP
fnd_msg_pub.get (p_msg_index => l_loop_cnt,
p_data => l_data,
p_encoded => fnd_api.g_false,
p_msg_index_out => l_dummy_cnt
);
DBMS_OUTPUT.put_line ('Record = ' || l_loop_cnt);
DBMS_OUTPUT.put_line (l_data);
IF l_status = 'E' OR l_status = 'U'
THEN
l_data := CONCAT ('ERROR ', l_data);
END IF;
DBMS_OUTPUT.put_line (l_data);
IF (l_status = 'U')
THEN
l_return_status := l_status;
ELSIF (l_status = 'E' AND l_return_status <> 'U')
THEN
l_return_status := l_status;
ELSE
l_return_status := l_status;
END IF;
l_loop_cnt := l_loop_cnt + 1;
END;
--fm_form_mst b, fm_form_mst_tl
---------------------------------------------
CREATE OR REPLACE PROCEDURE APPS.XXPFL_SUBINV_LOC_INSERT(ERRBUFF OUT
VARCHAR2,RETCODE OUT VARCHAR2) IS
/
***********************************************************************************
*************/
/* Purpose : Assign Itemes to Subinventory and Locator
*/
/* Client : Pran
*/
/* Created By : Suheeb Ali
*/
/* Creation Date : 01-OCT-2013
*/
/
***********************************************************************************
*************/
--DECLARE
M_EXISTS VARCHAR2 (1);
L_ERR_FLAG CHAR (1) := 'N';
--xxpran_item_assig_stg
CURSOR C1 IS
SELECT 'M'
--INTO M_EXISTS
FROM APPS.MTL_ITEM_SUB_INVENTORIES
MH5
-- P_ITEM_ID
AND UPPER(MIL.SUBINVENTORY_CODE) LIKE UPPER(P_SEC_INV)
BEGIN
FOR I IN C1 LOOP
IF (L_ERR_FLAG <> 'Y') THEN
FOR R_SUB_INV IN SUB_INV(I.ORGANIZATION_ID) LOOP
-- CHECK IF THE ITEM- ORGANIZATION - SUBINVENTORY COMBINATION IS ALREADY
EXISTING --
begin
SELECT 'M'
INTO M_EXISTS
FROM APPS.MTL_ITEM_SUB_INVENTORIES
WHERE INVENTORY_ITEM_ID = R_SUB_INV.INVENTORY_ITEM_ID
AND ORGANIZATION_ID = R_SUB_INV.ORGANIZATION_ID
--AND UPPER(SECONDARY_INVENTORY) LIKE
UPPER(R_SUB_INV.SECONDARY_INVENTORY)
;
exception
when others then
DBMS_OUTPUT.PUT_LINE('error -'||SQLERRM||
R_SUB_INV.INVENTORY_ITEM_ID);
M_EXISTS := 'N';
end;
FOR R_SEC_LOC IN
SEC_LOC(I.ORGANIZATION_ID,R_SUB_INV.SECONDARY_INVENTORY,R_SUB_INV.INVENTORY_ITEM_ID
) LOOP
INSERT INTO MTL_SECONDARY_LOCATORS
(
INVENTORY_ITEM_ID,
ORGANIZATION_ID,
SECONDARY_LOCATOR,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_LOGIN,
SUBINVENTORY_CODE
)
VALUES
( R_SEC_LOC.INVENTORY_ITEM_ID,
R_SEC_LOC.ORGANIZATION_ID,
R_SEC_LOC.SECONDARY_LOCATOR,
R_SEC_LOC.LAST_UPDATE_DATE,
R_SEC_LOC.LAST_UPDATED_BY,
R_SEC_LOC.CREATION_DATE,
R_SEC_LOC.CREATED_BY,
R_SEC_LOC.LAST_UPDATE_LOGIN,
R_SUB_INV.SECONDARY_INVENTORY
);
END LOOP; -- LOCATOR
COMMIT;
END;
ELSE
DBMS_OUTPUT.PUT_LINE('Combination Exist For Item id -'||
R_SUB_INV.INVENTORY_ITEM_ID||'- Org -'||R_SUB_INV.ORGANIZATION_ID||'- SubInv -'||
R_SUB_INV.SECONDARY_INVENTORY);
END IF;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Error -'||SQLERRM);
FND_FILE.PUT_LINE( FND_FILE.LOG, 'Error - '||SQLERRM);
END;
/
----------------------------
CREATE OR REPLACE PROCEDURE APPS."PRAN_ITEM_STOCK_STG_PROC_R" as
cursor c1 is
select transaction_interface_id,source_code,source_line_id,
source_header_id,i.inventory_item_id, inventory_item_code , primary_uom_code
,process_flag,validation_required,
transaction_mode,transaction_quantity,o.organization_id, o.organization_code,
primary_quantity,
primary_uom_code transaction_uom ,transaction_date ,subinventory_code,locator_id,
transaction_type_id,transaction_cost,mp.MATERIAL_ACCOUNT MATERIAL_ACCOUNT,
--distribution_account_id,
si.last_update_date,si.last_updated_by,si.creation_date,si.created_by from
pran_item_stock_stg_M si, mtl_system_items_b i, org_organization_definitions o,
mtl_parameters mp
where si.INVENTORY_ITEM_CODE=i.SEGMENT1 and
si.ORGANIZATION_CODE=o.ORGANIZATION_CODE and o.ORGANIZATION_ID=i.ORGANIZATION_ID
and FLAG is not null
and o.ORGANIZATION_ID=mp.ORGANIZATION_ID
c1_rec c1%rowtype;
v_organization_id number(5);
v_inventory_item_id number(10);
v_primary_uom_code varchar2(6);
v_inventory_location_id number(10);
v_subinventory_code varchar2(10);
v_code_combination_id number(10);
v_transaction_type_id number(8);
Begin
begin
-- location
select
inventory_location_id,
subinventory_code
into v_inventory_location_id, v_subinventory_code
from mtl_item_locations
where subinventory_code =c1_rec.subinventory_code;
exception
when no_data_found then
v_organization_id :=null;
v_inventory_item_id :=null;
v_primary_uom_code :=null;
v_inventory_location_id :=null;
v_subinventory_code :=null;
end;
if
update
pran_item_stock_stg_m set flag='Y' where
INVENTORY_ITEM_CODE=c1_rec.INVENTORY_ITEM_CODE
and organization_code =c1_rec.organization_code
and SUBINVENTORY_CODE =c1_rec.SUBINVENTORY_CODE
;
end if;
end loop;
commit;
End pran_item_stock_stg_proc_R;
/
------------------------------
/* Cursor Declaration ***/
declare
cursor c1 is --select * from XX_ITEM_INTERFACE_STG_DEBUG where SEGMENT1 in
('911461','911462'); --xx_item_interface_stg1;
l_org_id number(3);
l_uom varchar2(15);
l_suom varchar2(15);
l_item_type varchar2(30);
l_desc varchar2(30);
l_temp_id varchar2(3);
l_sale_ac number(16);
l_exp_ac number(16);
l_cost_sale_ac number(16);
l_item_number varchar2(100);
l_flag varchar2(4) default'A';
l_msg varchar2(200);
begin
--delete from MTL_SYSTEM_ITEMS_INTERFACE;
--commit;
l_msg :='OK';
for x1 in c1 loop
/* Validation For Organization */
-- begin
-- select organization_id into l_org_id
-- from ORG_ORGANIZATION_DEFINITIONS
-- where organization_code = x1.organization_code;
-- exception
-- when others then
-- l_flag :='E';
-- l_msg :='Item Interface'||'Organization Id'||l_org_id||' not in
system';
-- fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
-- end;
begin
select COST_OF_SALES_ACCOUNT into l_cost_sale_ac
from MTL_PARAMETERS
where ORGANIZATION_ID = 102;
exception
when no_data_found then
l_flag :='E';
l_msg :='Cost of Sales Account should not be Null';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
when others then
l_flag :='E';
l_msg :='Cost of Sales Account is not Valid';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
end;
begin
select SALES_ACCOUNT into l_sale_ac
from MTL_PARAMETERS
where ORGANIZATION_ID = 102;
exception
when no_data_found then
l_flag :='E';
l_msg :='Sales Account should not be Null';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
when others then
l_flag :='E';
l_msg :='Sales Account is not Valid';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
end;
begin
exception
when no_data_found then
l_flag :='E';
l_msg :='Expence Account should not be Null';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
when others then
l_flag :='E';
l_msg :='Expence Account is not Valid';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
end;
if l_flag!='E' then
insert into MTL_SYSTEM_ITEMS_INTERFACE
( ORGANIZATION_ID,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_LOGIN,
DESCRIPTION,
SEGMENT1,
PRIMARY_UOM_CODE,
TEMPLATE_ID,
SUMMARY_FLAG,
ENABLED_FLAG,
SALES_ACCOUNT,
COST_OF_SALES_ACCOUNT,
EXPENSE_ACCOUNT,
PROCESS_QUALITY_ENABLED_FLAG,
PROCESS_COSTING_ENABLED_FLAG,
RECIPE_ENABLED_FLAG,
PROCESS_EXECUTION_ENABLED_FLAG,
RESTRICT_SUBINVENTORIES_CODE,
RESTRICT_LOCATORS_CODE ,
LOCATION_CONTROL_CODE ,
SET_PROCESS_ID,
PROCESS_FLAG,
TRANSACTION_TYPE,
LONG_DESCRIPTION
--ATTRIBUTE_CATEGORY
)
values( 102,
sysdate,
fnd_global.USER_ID,
sysdate,
fnd_global.USER_ID,
fnd_global.LOGIN_ID,
x1.DESCRIPTION,
x1.SEGMENT1,
l_uom,
-- l_item_type,
2,
'Y',
'Y',
l_sale_ac,
l_cost_sale_ac,
l_exp_ac,
x1.PROCESS_QUALITY_ENABLED_FLAG,
x1.PROCESS_COSTING_ENABLED_FLAG,
x1.RECIPE_ENABLED_FLAG,
x1.PROCESS_EXECUTION_ENABLED_FLAG,
1,
1,
2,
2,
1,
'CREATE',
x1.LONG_DESC
);
else
update XX_ITEM_INTERFACE_STG_DEBUG set I_STSTAUS=l_msg where SEGMENT1=
x1.SEGMENT1;
end if;
end loop;
commit;
end;
/
---------------------------
select * from cm.T_amim a, cm.t_amsu b, cm.t_amig c
where a.AMIM_AMSU=b.OID and a.AMIM_AMIG=c.OID
l_org_id number(3);
l_uom varchar2(15);
l_suom varchar2(15);
l_item_type varchar2(30);
l_desc varchar2(30);
l_temp_id varchar2(3);
l_sale_ac number(16);
l_exp_ac number(16);
l_cost_sale_ac number(16);
l_item_number varchar2(100);
l_flag varchar2(4) default'A';
l_msg varchar2(200);
begin
--delete from MTL_SYSTEM_ITEMS_INTERFACE;
--commit;
for x1 in c1 loop
/* Validation For Organization */
-- begin
-- select organization_id into l_org_id
-- from ORG_ORGANIZATION_DEFINITIONS
-- where organization_code = x1.organization_code;
-- exception
-- when others then
-- l_flag :='E';
-- l_msg :='Item Interface'||'Organization Id'||l_org_id||' not in
system';
-- fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
-- end;
begin
select COST_OF_SALES_ACCOUNT into l_cost_sale_ac
from MTL_PARAMETERS
where ORGANIZATION_ID = 102;
exception
when no_data_found then
l_flag :='E';
l_msg :='Cost of Sales Account should not be Null';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
when others then
l_flag :='E';
l_msg :='Cost of Sales Account is not Valid';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
end;
begin
select SALES_ACCOUNT into l_sale_ac
from MTL_PARAMETERS
where ORGANIZATION_ID = 102;
exception
when no_data_found then
l_flag :='E';
l_msg :='Sales Account should not be Null';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
when others then
l_flag :='E';
l_msg :='Sales Account is not Valid';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
end;
begin
exception
when no_data_found then
l_flag :='E';
l_msg :='Expence Account should not be Null';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
when others then
l_flag :='E';
l_msg :='Expence Account is not Valid';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
end;
if l_flag!='E' then
insert into MTL_SYSTEM_ITEMS_INTERFACE
( ORGANIZATION_ID,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_LOGIN,
DESCRIPTION,
SEGMENT1,
PRIMARY_UOM_CODE,
TEMPLATE_ID,
SUMMARY_FLAG,
ENABLED_FLAG,
SALES_ACCOUNT,
COST_OF_SALES_ACCOUNT,
EXPENSE_ACCOUNT,
PROCESS_QUALITY_ENABLED_FLAG,
PROCESS_COSTING_ENABLED_FLAG,
RECIPE_ENABLED_FLAG,
PROCESS_EXECUTION_ENABLED_FLAG,
RESTRICT_SUBINVENTORIES_CODE,
RESTRICT_LOCATORS_CODE ,
LOCATION_CONTROL_CODE ,
SET_PROCESS_ID,
PROCESS_FLAG,
TRANSACTION_TYPE)
values( 102,
sysdate,
fnd_global.USER_ID,
sysdate,
fnd_global.USER_ID,
fnd_global.LOGIN_ID,
x1.DESCRIPTION,
x1.SEGMENT1,
l_uom,
-- l_item_type,
2,
'Y',
'Y',
l_sale_ac,
l_cost_sale_ac,
l_exp_ac,
x1.PROCESS_QUALITY_ENABLED_FLAG,
x1.PROCESS_COSTING_ENABLED_FLAG,
x1.RECIPE_ENABLED_FLAG,
x1.PROCESS_EXECUTION_ENABLED_FLAG,
1,
1,
2,
2,
1,
'CREATE'
);
else
update XX_ITEM_INTERFACE_STG_DEBUG set I_STSTAUS=l_msg where SEGMENT1=
x1.SEGMENT1;
end if;
end loop;
commit;
end;
/
mtl_parameters d,
eng_ecn_approval_lists e,
hr_locations_all h,
mtl_material_statuses_tl m,
mtl_material_statuses_tl n,
cst_cost_groups cg
--------------------------------------
-- select * from rfl_scm_item_list a where a.AMSU_TEXT='PCS' and AMIM_TEXT in
('0538107211','0526558051')
l_org_id number(3);
l_uom varchar2(15);
l_suom varchar2(15);
l_item_type varchar2(60);
l_desc varchar2(60);
l_temp_id varchar2(3);
l_sale_ac number(16);
l_exp_ac number(16);
l_cost_sale_ac number(16);
l_item_number varchar2(100);
l_flag varchar2(4) default'A';
l_msg varchar2(200);
begin
--delete from MTL_SYSTEM_ITEMS_INTERFACE;
--commit;
for x1 in c1 loop
/* Validation For Organization */
-- begin
-- select organization_id into l_org_id
-- from ORG_ORGANIZATION_DEFINITIONS
-- where organization_code = x1.organization_code;
-- exception
-- when others then
-- l_flag :='E';
-- l_msg :='Item Interface'||'Organization Id'||l_org_id||' not in
system';
-- fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
-- end;
begin
select COST_OF_SALES_ACCOUNT into l_cost_sale_ac
from MTL_PARAMETERS
where ORGANIZATION_ID = 102;
exception
when no_data_found then
l_flag :='E';
l_msg :='Cost of Sales Account should not be Null';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
when others then
l_flag :='E';
l_msg :='Cost of Sales Account is not Valid';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
end;
begin
select SALES_ACCOUNT into l_sale_ac
from MTL_PARAMETERS
where ORGANIZATION_ID = 102;
exception
when no_data_found then
l_flag :='E';
l_msg :='Sales Account should not be Null';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
when others then
l_flag :='E';
l_msg :='Sales Account is not Valid';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
end;
begin
exception
when no_data_found then
l_flag :='E';
l_msg :='Expence Account should not be Null';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
when others then
l_flag :='E';
l_msg :='Expence Account is not Valid';
fnd_file.PUT_LINE(fnd_file.log,'Error Occured'||l_msg);
end;
if l_flag!='E' then
insert into MTL_SYSTEM_ITEMS_INTERFACE
( ORGANIZATION_ID,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_LOGIN,
DESCRIPTION,
SEGMENT1,
PRIMARY_UOM_CODE,
TEMPLATE_ID,
SUMMARY_FLAG,
ENABLED_FLAG,
SALES_ACCOUNT,
COST_OF_SALES_ACCOUNT,
EXPENSE_ACCOUNT,
PROCESS_QUALITY_ENABLED_FLAG,
PROCESS_COSTING_ENABLED_FLAG,
RECIPE_ENABLED_FLAG,
PROCESS_EXECUTION_ENABLED_FLAG,
RESTRICT_SUBINVENTORIES_CODE,
RESTRICT_LOCATORS_CODE ,
LOCATION_CONTROL_CODE ,
SET_PROCESS_ID,
PROCESS_FLAG,
TRANSACTION_TYPE,
ATTRIBUTE1, -- ou
ATTRIBUTE25, -- TF
ATTRIBUTE26, -- unload
ATTRIBUTE27, -- load
ATTRIBUTE28, -- DP
ATTRIBUTE29, -- TP
ATTRIBUTE30 -- MRP
)
values( 102,
sysdate,
fnd_global.USER_ID,
sysdate,
fnd_global.USER_ID,
fnd_global.LOGIN_ID,
x1.DESCRIPTION,
x1.SEGMENT1,
l_uom,
-- l_item_type,
-- 1, -- 1 for FG item, 2 for Purchase
1,
'Y',
'Y',
l_sale_ac,
l_cost_sale_ac,
l_exp_ac,
x1.PROCESS_QUALITY_ENABLED_FLAG,
x1.PROCESS_COSTING_ENABLED_FLAG,
x1.RECIPE_ENABLED_FLAG,
x1.PROCESS_EXECUTION_ENABLED_FLAG,
1,
1,
2,
2,
1,
'CREATE',
x1.ATTRIBUTE1,
x1.ATTRIBUTE25, -- TF
x1.ATTRIBUTE29, -- unload
x1.ATTRIBUTE30, -- load
x1.ATTRIBUTE27, -- DP
x1.ATTRIBUTE28, -- TP
x1.ATTRIBUTE26 -- MRP
);
-- MTL_INTERFACE_ERRORS
commit;
end;
/
--------------------------------
, mtl_transaction_types tp
WHERE legal_entity_id = 23275
AND ledger_id = 2021
AND entity_code = 'INVENTORY'
AND reference_no IN (579, 580)
AND TO_DATE (transaction_date, 'dd-mm-yy') >=
TO_DATE ('01/11/20', 'dd-mm-yy')
AND a.transaction_type_id = tp.transaction_type_id
AND a.transaction_action_id = tp.transaction_action_id
AND valuation_cost_type_id = 1000
AND valuation_cost_type = 'PFL PMAC'
AND currency_code = 'BDT'
create table t6 as
--create view p_item_cogs_v as
select --b.ae_header_id ,
c.segment1 ou, to_char(e.TRANSACTION_DATE, 'YYYYMM') period_SLNO,
ah.PERIOD_NAME, i.INVENTORY_ITEM_ID,i.segment1 item, i.description itemname,
b.accounted_dr, b.accounted_cr, b.code_combination_id, u1.NAME rcvou , ah.entity_id
,d.source_id_int_1
, f.organization_name rcvorgnm, f.organization_code rcvdorg from xla_ae_lines b,
gl_code_combinations c, hr_operating_units u1, xla_ae_headers ah,
xla.xla_transaction_entities d, mtl_material_transactions e
, mtl_system_items_b i, org_organization_definitions f--
,--,MTL_ITEM_CATEGORIES_V ct,
-- org_acct_periods pd
where b.application_id=555 and b.ledger_id=2021 and
to_date(b.accounting_date,'dd/mm/yy') between to_date('01/10/20','dd/mm/yy') and
to_date('31/10/20','dd/mm/yy')
AND b.code_combination_id =c.code_combination_id
AND c.segment6 = '124818'
AND b.ae_header_id in (
select a.ae_header_id from xla_ae_headers a--, gl_code_combinations c
where a.application_id=555 and a.ledger_id=2021 and a.PERIOD_NAME='Oct-20-21'
)
and c.segment1=u1.SHORT_CODE
and b.ae_header_id=ah.ae_header_id and ah.application_id=555 and
ah.ledger_id=2021 and ah.PERIOD_NAME='Oct-20-21'
and ah.entity_id = d.entity_id
and ah.application_id = d.application_id
and d.source_id_int_1 = e.transaction_id
and e.inventory_item_id = i.inventory_item_id
and e.organization_id = i.organization_id
and e.organization_id = f.organization_id
SELECT
g.ATTRIBUTE1 ou, f.attribute3 trn_ou, organization_code, category_id, 'Stock'
stocktype,
0 stock_amount, ROUND (SUM (nvl(sales_amount,0)),2) sales_amount,
0 cogs_amount, 0 rcv_amount, 0 issue_amount from item_sales_tl s
order by f.attribute3,g.segment1,f.interface_line_attribute2,g.ATTRIBUTE1
SALES_AMOUNT