Monday, 9 December 2013

Data Find Query from Account_Code_Ori

select
item_code,
item_description,
nvl(sum(accounted_dr),0) Total_Dr,
nvl(sum(accounted_cr),0) Total_Cr,
nvl(sum(accounted_dr),0)-
nvl(sum(accounted_cr),0) Total_value,
sum(transaction_quantity) Total_quantity
from
( SELECT
gjh.je_category,
gjh.je_source,
gjh.period_name,
gjh.name jv_name,
gjh.status ,
gjh.description jv_header_description,
gjh.doc_sequence_value,
gjl.je_line_num,
gjl.accounted_cr,
gjl.accounted_dr,
gjl.description jv_line_description,
gir.reference_2 inv_org,
gir.reference_3 mtl_transaction_id,
GJL.REFERENCE_5 AP_INVOICE_NUM,
msib.segment1||'-'||msib.segment2||'-'||msib.segment3||'-'||msib.segment4||'-'||msib.segment5||'-'||msib.segment6 item_code,
msib.description item_description,
mmt.subinventory_code,
mtt.transaction_type_name,
mmt.transaction_quantity,
mmt.SHIPMENT_NUMBER,
mtt.TRANSACTION_TYPE_NAME,
mtst.TRANSACTION_SOURCE_TYPE_NAME ,rsh.RECEIPT_NUM
FROM
gl_je_lines gjl,
gl_import_references gir,
gl_je_headers gjh,
gl_code_combinations gcc,
mtl_material_transactions mmt,
mtl_system_items_b msib,
mtl_transaction_types mtt,
MTL_TXN_SOURCE_TYPES mtst,
RCV_TRANSACTIONS RT,
RCV_SHIPMENT_HEADERS RSH
WHERE
gjl.je_line_num = gir.je_line_num and
gjl.je_header_id = gir.je_header_id and
gjl.je_header_id=gjh.je_header_id and
gjl.code_combination_id=gcc.code_combination_id and
  --gcc.segment4 in (1,4,5) and
  gcc.segment4 = '1' and
gcc.segment2='02' and
gjh.default_effective_date between '01-Apr-2012' and
'31-Mar-2013' and
gjh.status='P' and
mmt.transaction_id=gir.reference_3 and
msib.inventory_item_id=mmt.inventory_item_id and
msib.organization_id=mmt.organization_id and
mtt.transaction_type_id=mmt.transaction_type_id and
mtt.TRANSACTION_SOURCE_TYPE_ID = mtst.TRANSACTION_SOURCE_TYPE_ID and
rt.TRANSACTION_ID(+) = mmt.RCV_TRANSACTION_ID and
rsh.SHIPMENT_HEADER_ID(+) = rt.SHIPMENT_HEADER_ID and
mmt.TRANSACTION_QUANTITY > 0

)
group by item_code,item_description



No comments:

Post a Comment