select mmt.SHIPMENT_NUMBER,to_char(mmt.TRANSACTION_DATE,'YYYY/MM/DD') TDATE, mmt.INVENTORY_ITEM_ID,msib.SEGMENT1 ITEM,msib.DESCRIPTION,
mmt.ORGANIZATION_ID SORGID, ood.ORGANIZATION_CODE SORGCODE,ood.ORGANIZATION_NAME SORGNAME,
mmt.TRANSACTION_QUANTITY,cc.CONCATENATED_SEGMENTS,
mmt.TRANSFER_ORGANIZATION_ID RORGID,ood1.ORGANIZATION_CODE RORGCODE,ood1.ORGANIZATION_NAME RORGNAME,
sum(nvl(xal.ACCOUNTED_DR,0)) ACCOUNTED_DR,sum(nvl(xal.ACCOUNTED_CR,0)) ACCOUNTED_CR
from gl_je_headers gjh, gl_je_lines gjl,gl_code_combinations_kfv CC,gl_import_references gir,xla_ae_lines xal,xla.xla_transaction_entities xte
,mtl_material_transactions mmt, mtl_system_items_b msib, org_organization_definitions ood, org_organization_definitions ood1
where gjh.STATUS = 'P' and gjh.PERIOD_NAME = :P_PERIOD_NAME -- 'Aug-21-22'
and gjh.JE_SOURCE = 'Inventory' and gjh.JE_CATEGORY = 'INTE'
and gjh.JE_HEADER_ID = gjl.JE_HEADER_ID --and gjl.CODE_COMBINATION_ID = 605635
and gjl.CODE_COMBINATION_ID = CC.CODE_COMBINATION_ID and cc.SEGMENT1 =:p_OU_CODE ---'10211 '
and cc.segment6 = '12190411'-- in('10411','14711) and cc.segment6 in('12190611','12190711')
--and trunc(mmt.TRANSACTION_DATE) >= (select distinct trunc(START_DATE) from gl_period_statuses where PERIOD_NAME=:p_PERIOD_NAME)
---and trunc(mmt.TRANSACTION_DATE) <= (select distinct trunc(END_DATE) from gl_period_statuses where PERIOD_NAME=:p_PERIOD_NAME)
and gjl.JE_HEADER_ID = gir.JE_HEADER_ID and gjl.JE_LINE_NUM = gir.JE_LINE_NUM and gir.GL_SL_LINK_ID = xal.GL_SL_LINK_ID
and gir.REFERENCE_5 = xte.ENTITY_ID and xte.SOURCE_ID_INT_1 = mmt.TRANSACTION_ID and mmt.TRANSACTION_TYPE_ID = 62
and mmt.INVENTORY_ITEM_ID = msib.INVENTORY_ITEM_ID and mmt.ORGANIZATION_ID = msib.ORGANIZATION_ID and mmt.ORGANIZATION_ID = ood.ORGANIZATION_ID
and mmt.TRANSFER_ORGANIZATION_ID = ood1.ORGANIZATION_ID
---and mmt.SHIPMENT_NUMBER= '1442448211' ---'1441524611'
and mmt.TRANSACTION_ID not in(
select x.TRANSFER_TRANSACTION_ID from mtl_material_transactions x where x.transaction_type_id = 61 ---and x.SHIPMENT_NUMBER='14424482'
and x.TRANSACTION_DATE BETWEEN to_date('2021/09/01 00:00:00', 'YYYY/MM/DD HH24:MI:SS') AND to_date('2021/09/30 23:59:59', 'YYYY/MM/DD HH24:MI:SS')
)
group by mmt.SHIPMENT_NUMBER,to_char(mmt.TRANSACTION_DATE,'YYYY/MM/DD'),mmt.INVENTORY_ITEM_ID,msib.SEGMENT1,msib.DESCRIPTION,
mmt.ORGANIZATION_ID,ood.ORGANIZATION_CODE,ood.ORGANIZATION_NAME,
mmt.TRANSACTION_QUANTITY,cc.CONCATENATED_SEGMENTS,
mmt.TRANSFER_ORGANIZATION_ID,ood1.ORGANIZATION_CODE,ood1.ORGANIZATION_NAME
order by mmt.SHIPMENT_NUMBER
No comments:
Post a Comment
Text Message