Update MMT for Inter Org Profit :
============================
update mtl_material_transactions t
set t.TRANSFER_PRICE=
(select nvl(ACCTG_COST,0) glcost
from gl_item_cst c,(
select b.ORGANIZATION_CODE,b.ORGANIZATION_NAME,gp.PERIOD_ID, PERIOD_YEAR, p.PERIOD_NAME,PERIOD_START_DATE,SCHEDULE_CLOSE_DATE,PERIOD_CLOSE_DATE,gp.START_DATE, gp.END_DATE,
a.transaction_id,a.organization_id,a.subinventory_code,a.inventory_item_id,a.transaction_date,a.transaction_type_id,a.transaction_quantity,
a.transfer_organization_id--, a.TRANSFER_ORGANIZATION_ID
from mtl_material_transactions a,org_organization_definitions b, org_acct_periods p,gmf_period_statuses gp--,
where a.costed_flag = 'N' and a.TRANSFER_ORGANIZATION_ID = b.ORGANIZATION_ID
and a.ACCT_PERIOD_ID=p.ACCT_PERIOD_ID
and trunc(p.PERIOD_START_DATE)=trunc(gp.START_DATE) and trunc(p.SCHEDULE_CLOSE_DATE )=trunc(gp.END_DATE)
) y
where c.PERIOD_ID(+)=y.PERIOD_ID and c.INVENTORY_ITEM_ID(+)=y.INVENTORY_ITEM_ID and c.ORGANIZATION_ID(+) =y.TRANSFER_ORGANIZATION_ID
and y.TRANSACTION_ID=t.TRANSACTION_ID --and t.TRANSACTION_ID=31073262
)
where exists (
select TRANSACTION_ID,y.INVENTORY_ITEM_ID,TRANSFER_ORGANIZATION_ID,TRANSACTION_TYPE_ID, nvl(ACCTG_COST,0) glcost, y.TRANSFER_PRICE
from gl_item_cst c,(
select b.ORGANIZATION_CODE,b.ORGANIZATION_NAME,gp.PERIOD_ID, PERIOD_YEAR, p.PERIOD_NAME,PERIOD_START_DATE,SCHEDULE_CLOSE_DATE,PERIOD_CLOSE_DATE,gp.START_DATE, gp.END_DATE,
a.transaction_id,a.organization_id,a.subinventory_code,a.inventory_item_id,a.transaction_date,a.transaction_type_id,a.transaction_quantity,
a.transfer_organization_id,a.TRANSFER_PRICE--, a.TRANSFER_ORGANIZATION_ID
from mtl_material_transactions a,org_organization_definitions b, org_acct_periods p,gmf_period_statuses gp--,
where a.costed_flag = 'N' and a.TRANSFER_ORGANIZATION_ID = b.ORGANIZATION_ID
and a.ACCT_PERIOD_ID=p.ACCT_PERIOD_ID
and trunc(p.PERIOD_START_DATE)=trunc(gp.START_DATE) and trunc(p.SCHEDULE_CLOSE_DATE )=trunc(gp.END_DATE)
) y
where c.PERIOD_ID(+)=y.PERIOD_ID and c.INVENTORY_ITEM_ID(+)=y.INVENTORY_ITEM_ID and c.ORGANIZATION_ID(+) =y.TRANSFER_ORGANIZATION_ID
and y.TRANSACTION_ID=t.TRANSACTION_ID)
============================
update mtl_material_transactions t
set t.TRANSFER_PRICE=
(select nvl(ACCTG_COST,0) glcost
from gl_item_cst c,(
select b.ORGANIZATION_CODE,b.ORGANIZATION_NAME,gp.PERIOD_ID, PERIOD_YEAR, p.PERIOD_NAME,PERIOD_START_DATE,SCHEDULE_CLOSE_DATE,PERIOD_CLOSE_DATE,gp.START_DATE, gp.END_DATE,
a.transaction_id,a.organization_id,a.subinventory_code,a.inventory_item_id,a.transaction_date,a.transaction_type_id,a.transaction_quantity,
a.transfer_organization_id--, a.TRANSFER_ORGANIZATION_ID
from mtl_material_transactions a,org_organization_definitions b, org_acct_periods p,gmf_period_statuses gp--,
where a.costed_flag = 'N' and a.TRANSFER_ORGANIZATION_ID = b.ORGANIZATION_ID
and a.ACCT_PERIOD_ID=p.ACCT_PERIOD_ID
and trunc(p.PERIOD_START_DATE)=trunc(gp.START_DATE) and trunc(p.SCHEDULE_CLOSE_DATE )=trunc(gp.END_DATE)
) y
where c.PERIOD_ID(+)=y.PERIOD_ID and c.INVENTORY_ITEM_ID(+)=y.INVENTORY_ITEM_ID and c.ORGANIZATION_ID(+) =y.TRANSFER_ORGANIZATION_ID
and y.TRANSACTION_ID=t.TRANSACTION_ID --and t.TRANSACTION_ID=31073262
)
where exists (
select TRANSACTION_ID,y.INVENTORY_ITEM_ID,TRANSFER_ORGANIZATION_ID,TRANSACTION_TYPE_ID, nvl(ACCTG_COST,0) glcost, y.TRANSFER_PRICE
from gl_item_cst c,(
select b.ORGANIZATION_CODE,b.ORGANIZATION_NAME,gp.PERIOD_ID, PERIOD_YEAR, p.PERIOD_NAME,PERIOD_START_DATE,SCHEDULE_CLOSE_DATE,PERIOD_CLOSE_DATE,gp.START_DATE, gp.END_DATE,
a.transaction_id,a.organization_id,a.subinventory_code,a.inventory_item_id,a.transaction_date,a.transaction_type_id,a.transaction_quantity,
a.transfer_organization_id,a.TRANSFER_PRICE--, a.TRANSFER_ORGANIZATION_ID
from mtl_material_transactions a,org_organization_definitions b, org_acct_periods p,gmf_period_statuses gp--,
where a.costed_flag = 'N' and a.TRANSFER_ORGANIZATION_ID = b.ORGANIZATION_ID
and a.ACCT_PERIOD_ID=p.ACCT_PERIOD_ID
and trunc(p.PERIOD_START_DATE)=trunc(gp.START_DATE) and trunc(p.SCHEDULE_CLOSE_DATE )=trunc(gp.END_DATE)
) y
where c.PERIOD_ID(+)=y.PERIOD_ID and c.INVENTORY_ITEM_ID(+)=y.INVENTORY_ITEM_ID and c.ORGANIZATION_ID(+) =y.TRANSFER_ORGANIZATION_ID
and y.TRANSACTION_ID=t.TRANSACTION_ID)
No comments:
Post a Comment