0% found this document useful (0 votes)
65 views22 pages

Exadata Pricelist 070598

1. The document provides SQL code to generate a report from transaction data in tables like mtl_material_transactions and mtl_system_items. 2. The code includes SELECT statements that retrieve and format fields like transaction details, item codes and names, quantities, and dates. 3. The FROM and WHERE clauses join various tables, filter for specific transaction types and periods, and include parameters like branch ID and month.

Uploaded by

Francisco Sotelo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views22 pages

Exadata Pricelist 070598

1. The document provides SQL code to generate a report from transaction data in tables like mtl_material_transactions and mtl_system_items. 2. The code includes SELECT statements that retrieve and format fields like transaction details, item codes and names, quantities, and dates. 3. The FROM and WHERE clauses join various tables, filter for specific transaction types and periods, and include parameters like branch ID and month.

Uploaded by

Francisco Sotelo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 22

1.

DO POOLING (00)
SELECT NVL(DECODE(MIVAHA.TYPE,NULL,'H',MIVAHA.TYPE),' ') CD_JENIS --1
,RPAD(NVL(DECODE(MIVAHA.ATTRIBUTE3,NULL,'LAIN-LAIN',MIVAHA.ATTRIBUTE3),' '),30,' ') NM_JENIS --2
,NVL(RPAD(nvl(MMT.SHIPMENT_NUMBER,MMT.TRANSACTION_REFERENCE),9,' '),' ') NODOKJDI --3
,RPAD(' ',17,' ') NOFAK --4
,NVL(TO_CHAR(mmt.transaction_date,'dd/mm/rr'),' ') TGLDOKJDI --5
,TO_CHAR(TO_DATE(mmt.transaction_date,'DD-MON-RRRR'),'DD') HRDOK --6
,RPAD(NVL(kddev.kodelang,' '),4,' ') KODELANG --7
,SUBSTR(RPAD(NVL(msi.SEGMENT1,' '),6,' '),2,5) KODEPROD --8
,RPAD(NVL(msi.DESCRIPTION,' '),25,' ') NAMAPROD --9
,TO_CHAR(ABS(NVL(mmt.PRIMARY_QUANTITY,0)),'9999999990.99') BANYAK --10
,LPAD(LTRIM(TO_CHAR(NVL((select qll.OPERAND from qp_list_headers qlh, qp_list_lines_v qll
where qlh.LIST_HEADER_ID = qll.LIST_HEADER_ID
and sysdate between qll.START_DATE_ACTIVE and nvl( qll.END_DATE_ACTIVE,'31-DEC-4000' )
and UPPER(qlh.name) not like '%OPBAL%'
and UPPER(qlh.name) not like '%DOSP%'
and qll.PRODUCT_ATTR_VALUE = to_char(MSI.INVENTORY_ITEM_ID)
AND ROWNUM = 1),0),'999999999990.90')),15,' ')
hna --11
,LPAD(LTRIM(TO_CHAR(NVL((select qll.OPERAND*ABS(mmt.primary_quantity) from qp_list_headers qlh,
qp_list_lines_v qll
where qlh.LIST_HEADER_ID = qll.LIST_HEADER_ID
and sysdate between qll.START_DATE_ACTIVE and nvl( qll.END_DATE_ACTIVE,'31-DEC-4000' )
and UPPER(qlh.name) not like '%OPBAL%'
and UPPER(qlh.name) not like '%DOSP%'
and qll.PRODUCT_ATTR_VALUE = to_char(MSI.INVENTORY_ITEM_ID)
AND ROWNUM = 1),0),'999999999990.90')),15,' ')
thna --12
,LPAD(LTRIM(TO_CHAR(NVL(ABS((SELECT DECODE(NVL(pllv.price_discount,0),0,0,(NVL(pllv.price_discount,0)-4))
FROM po_line_locations_v pllv
WHERE PLLV.item_id = MMT.INVENTORY_ITEM_ID
AND (end_date >= SYSDATE OR end_date IS NULL)
AND ROWNUM = 1
AND start_date IN (SELECT MAX (start_date)
FROM po_line_locations_v PLVV2
WHERE PLVV2.item_id = MMT.INVENTORY_ITEM_ID AND (end_date >= SYSDATE OR end_date IS
NULL)))),0)
,'999999999990.99')),15,' ')
PRSNPOT --13
,LPAD('0.00',15,' ') NILPPN --14
,RPAD(NVL(MIVAHA.DESCRIPTION,' '),12,' ') NODO --15
,RPAD(NVL(TO_CHAR(NVL(mivaha.ALOCATE_DATE,mmt.TRANSACTION_DATE),'dd/mm/rr'),' '),8,' ') TGLDO --16??
,RPAD(NVL((SELECT DESCRIPTION FROM MPI_INV_NOTA_ALOKASI_DTL_ALL MIVADA
WHERE MIVADA.HEADER_ID = MIVAHA.HEADER_ID
AND MIVADA.ITEM_ID = MSI.INVENTORY_ITEM_ID AND ROWNUM =1),
NVL(mmt.TRANSACTION_REFERENCE,' '))
,50,' ') KET --17??
FROM mtl_system_items msi,
hr_organization_units hou,
mtl_transaction_lot_val_v mtlvv,
mtl_material_transactions mmt,
mtl_item_categories_v micv,
mtl_transaction_types mtt,
mpi_branch_code_dev_data mbcda,
MPI_INV_NOTA_ALOKASI_HDR_ALL MIVAHA
,(SELECT LPAD(dev.kodelang,4,' ') kodelang, dev.PRIMARY_INVENTORY_CODE --, dev.*
FROM mpi_branch_code_dev_data dev
WHERE dev.kodelang IS NOT NULL
-- AND dev.branch_id = :v_branchid
) kddev
WHERE msi.inventory_item_id = mmt.inventory_item_id
--AND hou.NAME = 'MPI - Master Item'
AND hou.organization_id = msi.organization_id
AND mtlvv.transaction_id = mmt.transaction_id
AND micv.inventory_item_id = msi.inventory_item_id
AND micv.organization_id = msi.organization_id
AND UPPER (micv.category_set_name) = 'SALES AND MARKETING'
and kddev.PRIMARY_INVENTORY_CODE = mtt.ATTRIBUTE1
--AND mtt.attribute1 = mbcda.PRIMARY_INVENTORY_CODE
AND HOU.ORGANIZATION_ID = mbcda.WAREHOUSE_ID
AND MIVAHA.DO_NUMBER(+) = mmt.SHIPMENT_NUMBER
AND MMT.TRANSACTION_TYPE_ID = MTT.TRANSACTION_TYPE_ID
AND mbcda.branch_id = :v_poolid
AND UPPER(mtt.TRANSACTION_TYPE_NAME) LIKE '%TRANSFER TO%' AND UPPER(MTT.DESCRIPTION) LIKE
'%PENGIRIMAN%'
AND TO_CHAR (TO_DATE (mmt.transaction_date, 'DD-MON-YYYY'), 'MM') = :v_month
AND TO_CHAR (TO_DATE (mmt.transaction_date, 'DD-MON-RRRR'), 'RR') = TO_CHAR(SYSDATE,'RR');

2. FO - POOLING BANDUNG

SELECT --mmt.organization_id,mtt.transaction_type_id,
-- RPAD(NVL(DECODE(mtt.transaction_type_id,12,'G'),' '),1,' ') CD_JENIS --1
CASE WHEN upper(transaction_type_name) like '%INTRANSIT%RECEIPT%' THEN 'G'
WHEN upper(transaction_type_name) like '%ED%INTER-ORG%TRANSFER%' THEN 'B'
WHEN upper(transaction_type_name) like '%NDK%INTER-ORG%TRANSFER%' THEN 'D'
WHEN upper(transaction_type_name) like '%RECEIPT%FROM%' THEN '0'
ELSE ' '
END CD_JENIS --1
-- ,RPAD(DECODE(NVL(mtt.transaction_type_id,0),12,'Lain-lain'),30,' ') NM_JENIS --2
,CASE WHEN upper(transaction_type_name) like '%INTRANSIT%RECEIPT%' THEN RPAD('Lain-lain',30,' ')
WHEN upper(transaction_type_name) like '%ED%INTER-ORG%TRANSFER%' THEN RPAD('Klaim ED',30,' ')
WHEN upper(transaction_type_name) like '%NDK%INTER-ORG%TRANSFER%' THEN RPAD('Klaim Barang Rusak',30,' ')
WHEN upper(transaction_type_name) like '%RECEIPT%FROM%' THEN RPAD('Realokasi Barang',30,' ')
ELSE RPAD(' ',30,' ')
END NM_JENIS --2
,RPAD(nvl(MMT.SHIPMENT_NUMBER,MMT.TRANSACTION_REFERENCE),5,' ') nodokjdi --3
,RPAD(' ',17,' ') NOFAK --4
,LPAD(TO_CHAR(mmt.transaction_date,'mm/dd/rr'),8,' ') AS TGLDOKJDI --5
,RPAD(EXTRACT (DAY FROM mmt.TRANSACTION_DATE),2,' ') HRDOK --6
,RPAD(NVL(nvl((select kodelang from mpi_branch_code_dev_data mbcdd where mtt.attribute1 =
mbcdd.PRIMARY_INVENTORY_CODE),(select kodelang from mpi_branch_code_dev_data mbcdd where
mbcdd.WAREHOUSE_ID = mmt.TRANSFER_ORGANIZATION_ID)),' '),4,' ') KODELANG --7
,SUBSTR(RPAD(NVL(msi.SEGMENT1,' '),6,' '),2,5) KODEPROD --8
,RPAD(NVL(msi.DESCRIPTION,' '),25,' ') NAMAPROD --9
,(LPAD(LTRIM(TO_CHAR(ABS(NVL(mmt.PRIMARY_QUANTITY,0)),'99999999990.99')),14,' ')) BANYAK --10
,LPAD(LTRIM(TO_CHAR(ABS(NVL(unit.unit_price,0)),'999999999990.99')),15,' ') HNA --11
,(LPAD(LTRIM(TO_CHAR(ABS(NVL(mmt.PRIMARY_QUANTITY*unit.unit_price,0)),'999999999990.99')),15,' ')) THNA --12
,LPAD(LTRIM(TO_CHAR(NVL(ABS((SELECT CASE WHEN pllv.price_discount - 4 <= 0
THEN 0
ELSE pllv.price_discount - 4
END
FROM po_line_locations_v pllv
WHERE item_id = mmt.inventory_item_id
AND (end_date >= SYSDATE OR end_date IS NULL)
AND ROWNUM = 1
AND start_date IN (SELECT MAX (start_date)
FROM po_line_locations_v
WHERE item_id = mmt.inventory_item_id
AND ((end_date >= SYSDATE) OR (end_date IS NULL))))
),0),'999999999990.99')),15,' ')
PRSNPOT --13
,LPAD('0.00',15,' ') NILPPN --14
,RPAD(mmt.shipment_number,12,' ') nodo --15
,RPAD(NVL(TO_CHAR(mmt.TRANSACTION_DATE ,'mm/dd/rr'),0),8,' ') tgldo --16
,RPAD(NVL(mmt.TRANSACTION_REFERENCE,' '),50,' ') KET --17
FROM (SELECT * FROM mtl_transaction_types
WHERE DISABLE_DATE IS NULL AND (upper(transaction_type_name) like '%INTRANSIT%RECEIPT%'
or upper(transaction_type_name) like '%ED%INTER-ORG%TRANSFER%'
or upper(transaction_type_name) like '%NDK%INTER-ORG%TRANSFER%'
or upper(transaction_type_name) like '%RECEIPT%FROM%') --IN (132, 133, 174, 21)
and upper(transaction_type_name) not like '%RECEIPT%FROM%POOLING%'
) mtt,
mtl_material_transactions mmt,
(SELECT * FROM mtl_system_items WHERE ORGANIZATION_ID=104) msi,
(SELECT * FROM mtl_item_categories WHERE CATEGORY_SET_ID=1) mic,
mtl_categories_b mcb,
hr_all_organization_units hao,
(SELECT * FROM mtl_transaction_lot_numbers WHERE TRANSACTION_QUANTITY > 0) mtln,
(SELECT DISTINCT A.ITEM_ID,A.UNIT_PRICE,B.LAST_UPDATE_DATE
FROM PO_LINES_ALL A,
(SELECT * FROM PO_HEADERS_ALL
WHERE type_lookup_code = 'QUOTATION'
AND status_lookup_code = 'A'
AND (end_date > SYSDATE OR end_date IS NULL)
)B
WHERE A.PO_HEADER_ID = B.PO_HEADER_ID
AND (A.ITEM_ID,B.LAST_UPDATE_DATE)
IN (
SELECT T.ITEM_ID,MAX(T1.LAST_UPDATE_DATE) LAST_UPDATE_DATE
FROM PO_LINES_ALL T,
(SELECT * FROM PO_HEADERS_ALL
WHERE type_lookup_code = 'QUOTATION'
AND status_lookup_code = 'A'
AND (end_date > SYSDATE OR end_date IS NULL)
) T1
WHERE T.PO_HEADER_ID = T1.PO_HEADER_ID
GROUP BY T.ITEM_ID)
) unit
WHERE mtt.TRANSACTION_TYPE_ID = mmt.TRANSACTION_TYPE_ID
AND mtln.TRANSACTION_ID = mmt.TRANSACTION_ID
AND mtln.INVENTORY_ITEM_ID = mmt.INVENTORY_ITEM_ID
AND msi.INVENTORY_ITEM_ID = mmt.INVENTORY_ITEM_ID
AND mmt.ORGANIZATION_ID = hao.ORGANIZATION_ID
AND msi.INVENTORY_ITEM_ID=mic.INVENTORY_ITEM_ID
AND msi.ORGANIZATION_ID=mic.ORGANIZATION_ID
AND mic.CATEGORY_ID=mcb.CATEGORY_ID
AND mmt.inventory_item_id = unit.item_id(+)
AND TO_CHAR(mmt.transaction_date,'mm') = :v_month
AND EXISTS (
SELECT t1.organization_id kd_wh
FROM hr_organization_information t1
WHERE t1.org_information_context = 'Accounting Information'
AND mmt.organization_id = t1.organization_id
AND EXISTS (
SELECT t2.organization_id
FROM hr_organization_units t2
WHERE t1.org_information3 = t2.organization_id
AND EXISTS (
SELECT 1
FROM mpi.mpi_branch_code_dev_data t3
WHERE t2.attribute1 = t3.branch_code
AND branch_id = :v_poolid)))
ORDER BY MMT.INVENTORY_ITEM_ID
3. FO POOLING – JKT
-- FO POOLING (00)

SELECT --mmt.organization_id,mtt.transaction_type_id,
-- RPAD(NVL(DECODE(mtt.transaction_type_id,12,'G'),' '),1,' ') CD_JENIS --1
CASE WHEN upper(transaction_type_name) like '%INTRANSIT%RECEIPT%' THEN 'G'
WHEN upper(transaction_type_name) like '%ED%INTER-ORG%TRANSFER%' THEN 'B'
WHEN upper(transaction_type_name) like '%NDK%INTER-ORG%TRANSFER%' THEN 'D'
WHEN upper(transaction_type_name) like '%RECEIPT%FROM%' THEN '0'
ELSE ' '
END CD_JENIS --1
-- ,RPAD(DECODE(NVL(mtt.transaction_type_id,0),12,'Lain-lain'),30,' ') NM_JENIS --2
,CASE WHEN upper(transaction_type_name) like '%INTRANSIT%RECEIPT%' THEN RPAD('Lain-lain',30,' ')
WHEN upper(transaction_type_name) like '%ED%INTER-ORG%TRANSFER%' THEN RPAD('Klaim ED',30,' ')
WHEN upper(transaction_type_name) like '%NDK%INTER-ORG%TRANSFER%' THEN RPAD('Klaim Barang Rusak',30,' ')
WHEN upper(transaction_type_name) like '%RECEIPT%FROM%' THEN RPAD('Realokasi Barang',30,' ')
ELSE RPAD(' ',30,' ')
END NM_JENIS --2
,RPAD(nvl(MMT.SHIPMENT_NUMBER,MMT.TRANSACTION_REFERENCE),9,' ') nodokjdi --3
,RPAD(' ',17,' ') NOFAK --4
,LPAD(TO_CHAR(mmt.transaction_date,'mm/dd/rr'),8,' ') AS TGLDOKJDI --5
,RPAD(EXTRACT (DAY FROM mmt.TRANSACTION_DATE),2,' ') HRDOK --6
,RPAD(NVL(' ',' '),4,' ') KODELANG --7
,SUBSTR(RPAD(NVL(msi.SEGMENT1,' '),6,' '),2,5) KODEPROD --8
,RPAD(NVL(msi.DESCRIPTION,' '),25,' ') NAMAPROD --9
,(LPAD(LTRIM(TO_CHAR(ABS(NVL(mmt.PRIMARY_QUANTITY,0)),'99999999990.99')),14,' ')) BANYAK --10
,LPAD(LTRIM(TO_CHAR(ABS(NVL(unit.unit_price,0)),'999999999990.99')),15,' ') HNA --11
,(LPAD(LTRIM(TO_CHAR(ABS(NVL(mmt.PRIMARY_QUANTITY*unit.unit_price,0)),'999999999990.99')),15,' ')) THNA --12
,LPAD(LTRIM(TO_CHAR(NVL(ABS((SELECT CASE WHEN pllv.price_discount - 4 <= 0
THEN 0
ELSE pllv.price_discount - 4
END
FROM po_line_locations_v pllv
WHERE item_id = mmt.inventory_item_id
AND (end_date >= SYSDATE OR end_date IS NULL)
AND ROWNUM = 1
AND start_date IN (SELECT MAX (start_date)
FROM po_line_locations_v
WHERE item_id = mmt.inventory_item_id
AND ((end_date >= SYSDATE) OR (end_date IS NULL))))
),0),'999999999990.99')),15,' ')
PRSNPOT --13
,LPAD('0.00',15,' ') NILPPN --14
,RPAD(mmt.shipment_number,12,' ') nodo --15
,RPAD(NVL(TO_CHAR(mmt.TRANSACTION_DATE ,'mm/dd/rr'),0),8,' ') tgldo --16
,RPAD(NVL(mmt.TRANSACTION_REFERENCE,' '),50,' ') KET --17
FROM (SELECT * FROM mtl_transaction_types
WHERE DISABLE_DATE IS NULL AND (upper(transaction_type_name) like '%INTRANSIT%RECEIPT%'
or upper(transaction_type_name) like '%ED%INTER-ORG%TRANSFER%'
or upper(transaction_type_name) like '%NDK%INTER-ORG%TRANSFER%'
or upper(transaction_type_name) like '%RECEIPT%FROM%') --IN (132, 133, 174, 21)
and upper(transaction_type_name) not like '%RECEIPT%FROM%POOLING%'
) mtt,
mtl_material_transactions mmt,
(SELECT * FROM mtl_system_items WHERE ORGANIZATION_ID=104) msi,
(SELECT * FROM mtl_item_categories WHERE CATEGORY_SET_ID=1) mic,
mtl_categories_b mcb,
hr_all_organization_units hao,
(SELECT * FROM mtl_transaction_lot_numbers WHERE TRANSACTION_QUANTITY > 0) mtln,
(SELECT DISTINCT A.ITEM_ID,A.UNIT_PRICE,B.LAST_UPDATE_DATE
FROM PO_LINES_ALL A,
(SELECT * FROM PO_HEADERS_ALL
WHERE type_lookup_code = 'QUOTATION'
AND status_lookup_code = 'A'
AND (end_date > SYSDATE OR end_date IS NULL)
)B
WHERE A.PO_HEADER_ID = B.PO_HEADER_ID
AND (A.ITEM_ID,B.LAST_UPDATE_DATE)
IN (
SELECT T.ITEM_ID,MAX(T1.LAST_UPDATE_DATE) LAST_UPDATE_DATE
FROM PO_LINES_ALL T,
(SELECT * FROM PO_HEADERS_ALL
WHERE type_lookup_code = 'QUOTATION'
AND status_lookup_code = 'A'
AND (end_date > SYSDATE OR end_date IS NULL)
) T1
WHERE T.PO_HEADER_ID = T1.PO_HEADER_ID
GROUP BY T.ITEM_ID)
) unit
WHERE mtt.TRANSACTION_TYPE_ID = mmt.TRANSACTION_TYPE_ID
AND mtln.TRANSACTION_ID = mmt.TRANSACTION_ID
AND mtln.INVENTORY_ITEM_ID = mmt.INVENTORY_ITEM_ID
AND msi.INVENTORY_ITEM_ID = mmt.INVENTORY_ITEM_ID
AND mmt.ORGANIZATION_ID = hao.ORGANIZATION_ID
AND msi.INVENTORY_ITEM_ID=mic.INVENTORY_ITEM_ID
AND msi.ORGANIZATION_ID=mic.ORGANIZATION_ID
AND mic.CATEGORY_ID=mcb.CATEGORY_ID
AND mmt.inventory_item_id = unit.item_id(+)
AND TO_CHAR(mmt.transaction_date,'mm') = :v_month
AND EXISTS (
SELECT t1.organization_id kd_wh
FROM hr_organization_information t1
WHERE t1.org_information_context = 'Accounting Information'
AND mmt.organization_id = t1.organization_id
AND EXISTS (
SELECT t2.organization_id
FROM hr_organization_units t2
WHERE t1.org_information3 = t2.organization_id
AND EXISTS (
SELECT 1
FROM mpi.mpi_branch_code_dev_data t3
WHERE t2.attribute1 = t3.branch_code
AND branch_id = :v_poolid))) ORDER BY MMT.INVENTORY_ITEM_ID;

SELECT * FROM MTL_MATERIAL_TRANSACTIONS MMT, MTL_TRANSACTION_TYPES MTT WHERE


MMT.TRANSACTION_TYPE_ID = MTT.TRANSACTION_TYPE_ID AND (upper(transaction_type_name) like
'%INTRANSIT%RECEIPT%'
or upper(transaction_type_name) like '%ED%INTER-ORG%TRANSFER%'
or upper(transaction_type_name) like '%NDK%INTER-ORG%TRANSFER%'
or upper(transaction_type_name) like '%RECEIPT%FROM%')
AND MMT.ORGANIZATION_ID = 105
AND TO_CHAR(mmt.transaction_date,'mm') = :v_month

4. PENERIMAAN JKT1 DARI POOLING NON ORACLE

--Penerimaan JKT1 dari POOLING NON ORACLE (Bandung & Surabaya)

SELECT DISTINCT msi.INVENTORY_ITEM_ID, RPAD(NVL(mmt.TRANSACTION_REFERENCE,' '),11,' ') nodo, --1


NVL(DECODE (UPPER(mtt.TRANSACTION_TYPE_NAME),
'RECEIPT FROM POOLING BDG', '21',
'RECEIPT FROM POOLING SBY', '31'
),' ') kodesup --2
,NVL(RPAD(mmt.TRANSACTION_REFERENCE,6,' '),' ') nodok --3
,RPAD(NVL(REPLACE(micv.category_concat_segs,'.',''),' '),5,' ') klasprod --4
,SUBSTR(RPAD(NVL(msi.segment1,' '),6,' '),2,5) kodeprod --5
,RPAD(NVL(msi.description,' '),25,' ') namaprod --6
,LPAD(LTRIM(TO_CHAR(NVL((select qll.OPERAND from qp_list_headers qlh, qp_list_lines_v qll
where qlh.LIST_HEADER_ID = qll.LIST_HEADER_ID
and sysdate between qll.START_DATE_ACTIVE and nvl( qll.END_DATE_ACTIVE,'31-DEC-4000' )
and UPPER(qlh.name) not like '%OPBAL%'
and UPPER(qlh.name) not like '%DOSP%'
and qll.PRODUCT_ATTR_VALUE = to_char(MSI.INVENTORY_ITEM_ID)
AND ROWNUM = 1),0),'999999999990.90')),15,' ')
hna --7
,LPAD(LTRIM(TO_CHAR(NVL((select qll.OPERAND*0.1 from qp_list_headers qlh, qp_list_lines_v qll
where qlh.LIST_HEADER_ID = qll.LIST_HEADER_ID
and sysdate between qll.START_DATE_ACTIVE and nvl( qll.END_DATE_ACTIVE,'31-DEC-4000' )
and UPPER(qlh.name) not like '%OPBAL%'
and UPPER(qlh.name) not like '%DOSP%'
and qll.PRODUCT_ATTR_VALUE = to_char(MSI.INVENTORY_ITEM_ID)
AND ROWNUM = 1),0),'999999999990.90')),15,' ')
ppn --8
,LPAD(LTRIM(TO_CHAR(NVL((select qll.OPERAND from qp_list_headers qlh, qp_list_lines_v qll
where qlh.LIST_HEADER_ID = qll.LIST_HEADER_ID
and sysdate between qll.START_DATE_ACTIVE and nvl( qll.END_DATE_ACTIVE,'31-DEC-4000' )
and UPPER(qlh.name) not like '%OPBAL%'
and UPPER(qlh.name) not like '%DOSP%'
and qll.PRODUCT_ATTR_VALUE = to_char(MSI.INVENTORY_ITEM_ID)
AND ROWNUM = 1),0),'999999999990.90')),15,' ')
hpc --9
,LPAD(NVL(mmt.TRANSACTION_QUANTITY,0),10,' ') kirim --10
,LPAD(NVL(mmt.TRANSACTION_QUANTITY,0),10,' ') terima --11
,NVL(msi.attribute3,' ') kodeotc --12
,RPAD(' ',12,' ') kunci_a --13
,TO_CHAR(SYSDATE,'mm/dd/rr') tglsys --14
,RPAD(NVL(mtlvv.lot_number,' '),8,' ') nobatch --15
,mmt.TRANSACTION_DATE Tgl_Terima
FROM mtl_system_items msi,
hr_organization_units hou,
mtl_transaction_lot_val_v mtlvv,
mtl_material_transactions mmt,
mtl_item_categories_v micv,
hr_organization_information hoi,
hr_organization_units hou2,
mpi_branch_code_dev_data mbcda,
MTL_TRANSACTION_TYPES mtt
WHERE msi.inventory_item_id = mmt.inventory_item_id
AND hou.NAME = 'MPI - Master Item'
AND hou.organization_id = msi.organization_id
AND mtlvv.transaction_id = mmt.transaction_id
AND micv.inventory_item_id = msi.inventory_item_id
AND micv.organization_id = msi.organization_id
AND micv.CATEGORY_SET_ID = 1
AND mmt.owning_organization_id = hoi.organization_id
AND hoi.org_information1 <> 'INV'
AND hoi.org_information3 = to_char(hou2.organization_id)
AND hou2.attribute1 = mbcda.branch_code
AND mbcda.branch_id = :p_branchid
AND mmt.TRANSACTION_TYPE_ID = mtt.TRANSACTION_TYPE_ID
AND (UPPER(mtt.TRANSACTION_TYPE_NAME) = 'RECEIPT FROM POOLING SBY' OR
UPPER(mtt.TRANSACTION_TYPE_NAME) = 'RECEIPT FROM POOLING BDG')
AND TO_CHAR (TO_DATE (mmt.transaction_date, 'DD-MON-RRRR'), 'MM') = :v_month
AND TO_CHAR (TO_DATE (mmt.transaction_date, 'DD-MON-RRRR'), 'RR') = TO_CHAR(SYSDATE,'RR');
5. ASR CABANG
exec dbms_application_info.SET_CLIENT_INFO(102)

select * from PO_REQUISITION_HEADERS_INQ_V

select * from PO_REQUISITION_LINES_INQ_V

select * from MTL_SYSTEM_ITEMS

/* Formatted on 2009/03/25 15:28 (Formatter Plus v4.8.8) */


SELECT a.requisition_num, a.line_num, c.segment1, a.item_description,
a.quantity, unit_meas_lookup_code, a.unit_price,
a.authorization_status, a.need_by_date, a.creation_date,
a.suggested_vendor_name, b.description
FROM po_requisition_lines_inq_v a,
po_requisition_headers_inq_v b,
mtl_system_items c
WHERE a.requisition_header_id = b.requisition_header_id
AND c.inventory_item_id = a.item_id
AND c.organization_id = 104

6. MATERIAL TRANSACTION DILUAR SALES ORDER

/* Formatted on 2009/03/20 13:56 (Formatter Plus v4.8.8) */


SELECT msi.segment1, msi.DESCRIPTION , mmt.subinventory_code,mmt.SHIPMENT_NUMBER,
mmt.TRANSACTION_QUANTITY ,mmt.TRANSACTION_REFERENCE, mmt.TRANSACTION_DATE ,
mtt.TRANSACTION_TYPE_NAME
--SUM (mmt.transaction_quantity)
FROM mtl_material_transactions mmt,
mtl_transaction_types mtt,
mtl_system_items msi
WHERE msi.inventory_item_id = mmt.inventory_item_id
AND msi.organization_id = 104 -- 104 =Nama Organisasi master item
AND mmt.organization_id = 106 /* 106=JKT1 (hr_oraganization_units) ; 105=pooling*/
AND upper(mtt.transaction_type_name) not like '%ORDER%'
AND mmt.transaction_type_id = mtt.transaction_type_id
AND TO_DATE (mmt.transaction_date) BETWEEN '01-mar-2009' AND '30-MAR-2009'

GROUP BY msi.segment1, mmt.subinventory_code , msi.DESCRIPTION

7. PENERIMAAN DAN PENGELUARAN BARANG

/* Formatted on 2009/03/30 17:28 (Formatter Plus v4.8.8) */


SELECT mmt.SHIPMENT_NUMBER, mmt.CREATION_DATE,msi.segment1, msi.DESCRIPTION, mmt.subinventory_code,
SUM (mmt.transaction_quantity)
FROM mtl_material_transactions mmt,
mtl_transaction_types mtt,
mtl_system_items msi
WHERE msi.inventory_item_id = mmt.inventory_item_id
AND msi.organization_id = 104
AND mmt.organization_id = 105 /*pengiriman inter-org dari pooling*/
AND mtt.transaction_type_name = 'Intransit Shipment'
AND mmt.transaction_type_id = mtt.transaction_type_id
-- AND mmt.transaction_type_id = 12
AND TO_DATE (mmt.transaction_date) BETWEEN '01-mar-2009' AND '31-MAR-2009'
GROUP BY mmt.SHIPMENT_NUMBER,msi.segment1, mmt.CREATION_DATE,msi.DESCRIPTION,mmt.subinventory_code
/* Formatted on 2009/03/30 17:28 (Formatter Plus v4.8.8) */
SELECT mmt.SHIPMENT_NUMBER,mmt.CREATION_DATE, msi.segment1,msi.DESCRIPTION, mmt.subinventory_code, SUM
(mmt.transaction_quantity)
FROM mtl_material_transactions mmt,
mtl_transaction_types mtt,
mtl_system_items msi
WHERE msi.inventory_item_id = mmt.inventory_item_id
AND msi.organization_id = 104
AND mmt.organization_id = 106 /*penerimaan JK1 dari pooling*/
AND mtt.transaction_type_name = 'Intransit Receipt'
AND mmt.transaction_type_id = mtt.transaction_type_id
AND TO_DATE (mmt.transaction_date) BETWEEN '01-mar-2009' AND '31-MAR-2009'
GROUP BY mmt.SHIPMENT_NUMBER,mmt.CREATION_DATE, msi.segment1,msi.DESCRIPTION, mmt.subinventory_code

RRCV_VRC_HDS_V RVHV,
RCV_TRANSACTIONS RT,
where
AND RT.SHIPMENT_HEADER_ID = RVHV.SHIPMENT_HEADER_ID
AND RT.TRANSACTION_TYPE = 'DELIVER'
AND MMT.RCV_TRANSACTION_ID = RT.TRANSACTION_ID

8. SI (PENERIMAAN DARI CABANG BANDUNG & SURABAYA)


SELECT DISTINCT msi.INVENTORY_ITEM_ID, RPAD(NVL(mmt.TRANSACTION_REFERENCE,' '),11,' ') nodo, --1
NVL(DECODE (UPPER(mtt.TRANSACTION_TYPE_NAME),
'RECEIPT FROM POOLING BDG', '21',
'RECEIPT FROM POOLING SBY', '31'
),' ') kodesup --2
,NVL(RPAD(mmt.TRANSACTION_REFERENCE,6,' '),' ') nodok --3
,RPAD(NVL(REPLACE(micv.category_concat_segs,'.',''),' '),5,' ') klasprod --4
,SUBSTR(RPAD(NVL(msi.segment1,' '),6,' '),2,5) kodeprod --5
,RPAD(NVL(msi.description,' '),25,' ') namaprod --6
,LPAD(LTRIM(TO_CHAR(NVL((select qll.OPERAND from qp_list_headers qlh, qp_list_lines_v qll
where qlh.LIST_HEADER_ID = qll.LIST_HEADER_ID
and sysdate between qll.START_DATE_ACTIVE and nvl( qll.END_DATE_ACTIVE,'31-DEC-4000' )
and UPPER(qlh.name) not like '%OPBAL%'
and UPPER(qlh.name) not like '%DOSP%'
and qll.PRODUCT_ATTR_VALUE = to_char(MSI.INVENTORY_ITEM_ID)
AND ROWNUM = 1),0),'999999999990.90')),15,' ')
hna --7
,LPAD(LTRIM(TO_CHAR(NVL((select qll.OPERAND*0.1 from qp_list_headers qlh, qp_list_lines_v qll
where qlh.LIST_HEADER_ID = qll.LIST_HEADER_ID
and sysdate between qll.START_DATE_ACTIVE and nvl( qll.END_DATE_ACTIVE,'31-DEC-4000' )
and UPPER(qlh.name) not like '%OPBAL%'
and UPPER(qlh.name) not like '%DOSP%'
and qll.PRODUCT_ATTR_VALUE = to_char(MSI.INVENTORY_ITEM_ID)
AND ROWNUM = 1),0),'999999999990.90')),15,' ')
ppn --8
,LPAD(LTRIM(TO_CHAR(NVL((select qll.OPERAND from qp_list_headers qlh, qp_list_lines_v qll
where qlh.LIST_HEADER_ID = qll.LIST_HEADER_ID
and sysdate between qll.START_DATE_ACTIVE and nvl( qll.END_DATE_ACTIVE,'31-DEC-4000' )
and UPPER(qlh.name) not like '%OPBAL%'
and UPPER(qlh.name) not like '%DOSP%'
and qll.PRODUCT_ATTR_VALUE = to_char(MSI.INVENTORY_ITEM_ID)
AND ROWNUM = 1),0),'999999999990.90')),15,' ')
hpc --9
,LPAD(NVL(mmt.TRANSACTION_QUANTITY,0),10,' ') kirim --10
,LPAD(NVL(mmt.TRANSACTION_QUANTITY,0),10,' ') terima --11
,NVL(msi.attribute3,' ') kodeotc --12
,RPAD(' ',12,' ') kunci_a --13
,TO_CHAR(SYSDATE,'mm/dd/rr') tglsys --14
,RPAD(NVL(mtlvv.lot_number,' '),8,' ') nobatch --15
FROM mtl_system_items msi,
hr_organization_units hou,
mtl_transaction_lot_val_v mtlvv,
mtl_material_transactions mmt,
mtl_item_categories_v micv,
hr_organization_information hoi,
hr_organization_units hou2,
mpi_branch_code_dev_data mbcda,
MTL_TRANSACTION_TYPES mtt
WHERE msi.inventory_item_id = mmt.inventory_item_id
AND hou.NAME = 'MPI - Master Item'
AND hou.organization_id = msi.organization_id
AND mtlvv.transaction_id = mmt.transaction_id
AND micv.inventory_item_id = msi.inventory_item_id
AND micv.organization_id = msi.organization_id
AND micv.CATEGORY_SET_ID = 1
AND mmt.owning_organization_id = hoi.organization_id
AND hoi.org_information1 <> 'INV'
AND hoi.org_information3 = to_char(hou2.organization_id)
AND hou2.attribute1 = mbcda.branch_code
AND mbcda.branch_id = :p_branchid
AND mmt.TRANSACTION_TYPE_ID = mtt.TRANSACTION_TYPE_ID
AND (UPPER(mtt.TRANSACTION_TYPE_NAME) = 'RECEIPT FROM POOLING SBY' OR
UPPER(mtt.TRANSACTION_TYPE_NAME) = 'RECEIPT FROM POOLING BDG')
AND TO_CHAR (TO_DATE (mmt.transaction_date, 'DD-MON-RRRR'), 'MM') = :v_month
AND TO_CHAR (TO_DATE (mmt.transaction_date, 'DD-MON-RRRR'), 'RR') = TO_CHAR(SYSDATE,'RR');

9. STOK OPNAME CABANG


/* Formatted on 2009/04/05 12:21 (Formatter Plus v4.8.8) */
SELECT a.segment1 KOBAR, a.description,
z.qty_all, '|', b.qty qty_non_staging,
c.qty qty_staging, d.qty qty_ed, g.qty_GIT,
e.qty qty_selisih, '|', f.qty_proforma, '|', NULL STOCK1, NULL STOCK2
FROM (SELECT a.inventory_item_id, a.segment1, a.description
FROM mtl_system_items_b a
WHERE a.organization_id = :id_gudang) a,
(SELECT b.inventory_item_id, SUM (b.transaction_quantity) qty
FROM mtl_onhand_quantities b
WHERE b.organization_id = :id_gudang
AND b.subinventory_code NOT IN ('Staging', 'ED', 'SELISIH', 'GIT')
GROUP BY b.inventory_item_id) b,
(SELECT b.inventory_item_id, SUM (b.transaction_quantity) qty
FROM mtl_onhand_quantities b
WHERE b.organization_id = :id_gudang
AND b.subinventory_code = 'Staging'
GROUP BY b.inventory_item_id) c,
(SELECT b.inventory_item_id, SUM (b.transaction_quantity) qty
FROM mtl_onhand_quantities b
WHERE b.organization_id = :id_gudang
AND b.subinventory_code = 'ED'
GROUP BY b.inventory_item_id) d,
(SELECT b.inventory_item_id, SUM (b.transaction_quantity) qty
FROM mtl_onhand_quantities b
WHERE b.organization_id = :id_gudang
AND b.subinventory_code = 'SELISIH'
GROUP BY b.inventory_item_id) e,
(SELECT inventory_item_id,
SUM (primary_reservation_quantity) qty_proforma
FROM mtl_reservations
WHERE organization_id = :id_gudang
AND subinventory_code = 'Staging'
GROUP BY inventory_item_id) f,
(SELECT b.inventory_item_id, SUM (b.transaction_quantity) qty_all
FROM mtl_onhand_quantities b
WHERE b.organization_id = :id_gudang
GROUP BY b.inventory_item_id) z,
(SELECT b.inventory_item_id, SUM (b.transaction_quantity) qty_GIT
FROM mtl_onhand_quantities b
WHERE b.organization_id = :id_gudang
AND b.subinventory_code = 'GIT'
GROUP BY b.inventory_item_id) g
WHERE a.inventory_item_id = b.inventory_item_id(+)
AND a.inventory_item_id = c.inventory_item_id(+)
AND a.inventory_item_id = d.inventory_item_id(+)
AND a.inventory_item_id = e.inventory_item_id(+)
AND a.inventory_item_id = f.inventory_item_id(+)
AND a.inventory_item_id = z.inventory_item_id(+)
AND a.inventory_item_id = g.inventory_item_id(+)
ORDER BY SUBSTR (a.segment1, 1, 2), a.description

10. BACKORDER REPORT


select
-- wdd.currency_code currency_code,
wdd.date_requested Tgl_Transaksi,
-- nvl(wdd.source_line_set_id,wdd.source_line_id) source_line_set_id,
-- decode( :p_sort_by,
-- 'CUSTOMER',
-- substrb(party.party_name,1,50),
-- 'WAREHOUSE',
-- ood.organization_name,
-- 'ORDER',
-- wdd.source_header_number,
-- null) sort_by,
-- wdd.source_header_number order_number,
-- wdd.source_header_id source_header_id, --3455286
substrb(party.party_name,1,50) customer_name,
cust_acct.account_number customer_number,
-- wdd.source_line_id,
wdd.src_requested_quantity ordered_qty,
wdd.src_requested_quantity_uom order_UOM,
wdd.source_line_number line_number,
--nvl(wdd.top_model_line_id,wdd.source_line_number) option_number,
-- wdd.top_model_line_id option_number,
-- &rp_item_flex_all_seg item_code,
-- wdd.inventory_item_id,
wdd.item_description,
-- wdd.source_code,
-- wdd.shipment_priority_code,
-- wdd.requested_quantity_uom,
sum(nvl(wdd.requested_quantity,0)) backordered_quantity,
wdd.date_scheduled,
wdd.organization_id,
ood.organization_name,
wdd.unit_price -- BugFix #3738248
from org_organization_definitions ood,
hz_parties party,
hz_cust_accounts cust_acct,
-- &lp_item_from
-- &lp_country_from
wsh_delivery_details wdd,
mtl_system_items_vl si --Bug# 3306781
where wdd.inventory_item_id = si.inventory_item_id (+) --Bug# 3306781
and wdd.organization_id = si.organization_id
and wdd.released_status = 'B'
and cust_acct.party_id = party.party_id
and wdd.customer_id = cust_acct.cust_account_id
and wdd.organization_id = ood.organization_id
--and wdd.source_code = :P_SOURCE_SYSTEM
--&lp_item_id
--&lp_item_where
--&lp_inventory
--&lp_header_number
--&lp_order_type
--&lp_customer
--&lp_warehouse
--&lp_created_by
--&lp_country_where
--&lp_source_code
group by
wdd.currency_code,
wdd.inventory_item_id,
wdd.date_requested,
substrb(party.party_name,1,50),
ood.organization_name,
wdd.source_header_number,
wdd.source_header_id, --Bug#3455286
cust_acct.account_number,
wdd.source_line_id,
wdd.src_requested_quantity,
wdd.src_requested_quantity_uom,
wdd.source_line_number,
wdd.top_model_line_id,
wdd.inventory_item_id,
wdd.item_description,
wdd.source_code,
wdd.shipment_priority_code,
wdd.requested_quantity_uom,
wdd.date_scheduled,
wdd.organization_id,
wdd.source_line_set_id,
wdd.unit_price -- BugFix#3738248
-- &rp_item_flex_all_seg
----order by
-- wdd.currency_code,
-- decode( :p_sort_by,
-- 'CUSTOMER',
-- substrb(party.party_name,1,50),
-- 'WAREHOUSE',
-- ood.organization_name,
-- 'ORDER',
-- wdd.source_header_number,
-- null)
11. CANCEL ORDER BY REASON
exec dbms_application_info.set_client_info(103)

SELECT
lh.LINE_ID ,
org.name custumer,
org.customer_number cust_no,
h.order_number order_number,
-- h.transactional_curr_code currency1,
h.ordered_date order_date,
lh.ordered_item Kodeprod,
-- nvl(lh.cancelled_quantity,0)*nvl(lh.unit_selling_price,0) amount,
-- lh.line_id lineid,
SI.description Nama_Produk,
-- lh.inventory_item_id iid,
-- lh.line_number ||'.'||lh.shipment_number||'.'||lh.option_number linenum,
DECODE(l.ITEM_TYPE_CODE,'SERVICE',L.LINE_NUMBER ||'.'|| L.SHIPMENT_NUMBER||'.'|| L.OPTION_NUMBER
||'.'||L.COMPONENT_NUMBER || decode(L.SERVICE_NUMBER,null,null,'.'||L.SERVICE_NUMBER),
'INCLUDED',L.LINE_NUMBER ||'.'|| L.SHIPMENT_NUMBER||'.'|| L.OPTION_NUMBER ||'.'||L.COMPONENT_NUMBER
||decode(L.SERVICE_NUMBER,null,null,'.'||L.SERVICE_NUMBER),
L.LINE_NUMBER || '.' || L.SHIPMENT_NUMBER || decode(L.OPTION_NUMBER,null,null,'.'||L.OPTION_NUMBER))
linenum,
-- lh.shipment_number shipnum,
-- lh.option_number optionnum,
lh.ordered_quantity ordered_qty,
lh.order_quantity_uom unit1,
lh2.CANCELLED_QUANTITY ,
lh2.UNIT_LIST_PRICE HNA,
-- lh.cancelled_quantity cancelled_qty,
-- lh.cancelled_quantity2 cancelled_qty2,
-- lh.ordered_quantity_uom2 unit2,
lu.meaning cancel_reason ,
-- h.salesrep_id hsalesrep_id,
-- lh.salesrep_id lsalesrep_id,
-- sr2.name lsalesrep,
-- sr.name salesrep,
lh.hist_creation_date tgl_cancel,
fnd_user.user_name username,
--lh.item_identifier_type,
--lh.ordered_item_id,
--&rp_item_flex_all_seg item_flex,
/*
decode (substr(upper(:p_print_description),1,1),
'P', si.description ,
'D', decode(lh.item_identifier_type, 'INT', si.description, 'CUST', nvl(ci.customer_item_desc, si.description),
oi.item_description),
'O', decode (lh.item_identifier_type, 'INT', &rp_item_flex_all_seg, 'CUST', ci.customer_item_number,
lh.ordered_item),
'C', decode(lh.item_identifier_type, 'INT', &rp_item_flex_all_seg , 'CUST', ci.customer_item_number || ' '||
nvl(ci.customer_item_desc, si.description),
lh.ordered_item || ' '|| nvl(oi.item_description, si.description)),
&rp_item_flex_all_seg) Item,
*/
-- h.conversion_rate conversion_rate,
-- h.conversion_type_code conversion_type_code,
-- h.transactional_curr_code currency_code,
-- lh.line_category_code cat_code,
NULL
FROM
oe_order_lines_history lh,
OE_ORDER_LINES_ALL LH2,
oe_order_lines_all l,
oe_order_headers_all h,
oe_reasons r,
mtl_system_items_vl SI,
ra_salesreps sr,
ra_salesreps sr2,
oe_lookups lu,
oe_sold_to_orgs_v org,
fnd_user
/*
mtl_customer_items ci,
oe_items_v oi*/
WHERE lh.header_id = h.header_id
and l.header_id = h.header_id
and l.line_id = lh.line_id
-- AND lh.hist_type_code='CANCELLATION'
AND h.salesrep_id=sr.salesrep_id(+)
AND lh.salesrep_id=sr2.salesrep_id(+)
AND r.reason_id=lh.reason_id
AND r.reason_code = lu.lookup_code
AND LH2.LINE_ID = LH.LINE_ID
and lh2.CANCELLED_QUANTITY <> 0
AND lu.lookup_type = 'CANCEL_CODE'
AND nvl(SI.organization_id,0) = nvl(oe_sys_parameters.value('MASTER_ORGANIZATION_ID'),0)
AND lh.inventory_item_id=SI.inventory_item_id
/* and lh.ordered_item_id = ci.customer_item_id(+)
and lh.ordered_item = oi.item(+)*/
AND org.organization_id=lh.sold_to_org_id
AND lh.hist_created_by=fnd_user.user_id
-- and nvl(h.org_id,0)= nvl(:p_organization_id,0)
----&lp_order_num
--&lp_salesrep
--&lp_customer_name
--&lp_order_date
--&lp_item_flex_all_seg
--&lp_cancelled_by
--&lp_cancel_date
--&lp_cancel_reason
--&lp_order_category
--&lp_line_category
And h.ordered_date between :tgl_mulai and :tgl_akhir
ORDER BY order_date,tgl_cancel

12. SALES PER PRINSIPLE PER RAYON


select sum(JUMLAH_HARGA) from (
SELECT OOHA.ORDERED_DATE,RCTA.TRX_DATE, RCTA.TRX_NUMBER,ffvt.description principal,hps.party_site_number,
hl.address_lines_phonetic ,ooha.order_number,ooha.CUST_PO_NUMBER,hca.account_number,
to_char(RCTA.TRX_DATE ,'Month') ordered_date,
(ooha.ordered_date + rtl.due_days) due_date, hp.party_name,
hps.attribute3 address, hps.attribute4 npwp, hl.city,
hcsua.territory_id, jrs.salesrep_number,
-- decode(:P_SALPER,null,'Semua Sales Person',jrs.NAME,0,0) NAME_salper,
jrs.NAME,
jrs.segment1,
jrs.segment2,
otta.ORDER_CATEGORY_CODE,
oola.CUST_PO_NUMBER,
oola.ordered_item,rcta.INTERFACE_HEADER_ATTRIBUTE1 noso,
--oola.ordered_quantity,
oola.unit_list_price, ooha.ORG_ID,
-- (oola.ordered_quantity * oola.unit_list_price) jumlah_harga,
nvl((DECODE(OTTA.ORDER_CATEGORY_CODE,'RETURN',(oola.ordered_quantity*-1),oola.ordered_quantity) *
oola.unit_list_price),0) jumlah_harga,
DECODE(OTTA.ORDER_CATEGORY_CODE,'RETURN',(oola.ordered_quantity*-1),oola.ordered_quantity)
ordered_quantity
FROM oe_transaction_types_all otta,
oe_order_headers_all ooha,
oe_order_lines_all oola,
-- mtl_material_transactions mtt,
-- mtl_transaction_lot_val_v mtlvv,
mtl_system_items_b msib,
hz_parties hp,
hz_party_sites hps,
hz_party_site_uses hpsu,
hz_locations hl,
hz_cust_accounts hca,
hz_cust_acct_sites_all hcasl,
hz_cust_site_uses_all hcsua,
hz_customer_profiles hcp,
ra_terms_lines rtl,
--ra_territories rt,
--ra_salesrep_territories rst,
--jtf_rs_salesreps jrs,
--ar_collectors ac,
ra_customer_trx_all rcta,
ra_customer_trx_lines_all rctla,
so_order_types_all sota,
fnd_flex_value_sets ffvs, -- value set principal
fnd_flex_values ffv, -- value set principal
fnd_flex_values_tl ffvt,
mtl_item_categories_v micv,
-- (SELECT mttp.transaction_type_name,
-- mttp.transaction_type_id
-- FROM mtl_txn_source_types mtst,
-- mtl_transaction_types mttp
-- WHERE transaction_source_type_name = 'Sales order'
-- AND mtst.transaction_source_type_id = mttp.transaction_source_type_id
-- AND mttp.transaction_type_name = 'Sales order issue') mttp
(select rst.territory_id,
jrs.salesrep_number,
jrs.NAME,
rt.segment1,
rt.segment2
from jtf_rs_salesreps jrs,
ra_salesrep_territories rst,
ra_territories rt
where jrs.salesrep_id = rst.salesrep_id
AND rt.territory_id = rst.territory_id
AND SYSDATE BETWEEN rst.start_date_active AND NVL(rst.end_date_active, '31-DEC-4712')) jrs
WHERE otta.transaction_type_id = ooha.order_type_id
AND oola.inventory_item_id = msib.inventory_item_id
AND hca.party_id = hp.party_id
AND hca.cust_account_id = ooha.sold_to_org_id
and ooha.invoice_to_org_id = hcsua.site_use_id
AND hps.party_id = hp.party_id
AND hpsu.party_site_id = hps.party_site_id
AND hl.location_id = hps.location_id
AND hcasl.cust_account_id = hca.cust_account_id
AND hcsua.cust_acct_site_id = hcasl.cust_acct_site_id
and hps.party_site_id = hcasl.party_site_id
AND hcp.site_use_id = hcsua.site_use_id
AND hcp.standard_terms = rtl.term_id
-- AND rt.territory_id = hcsua.territory_id
AND jrs.territory_id(+) = hcsua.territory_id
-- AND jrs.salesrep_id = rst.salesrep_id
--AND ac.collector_id = hcp.collector_id
AND rcta.interface_header_attribute1 = to_char(ooha.order_number)
AND sota.NAME = rcta.interface_header_attribute2
AND rcta.customer_trx_id = rctla.customer_trx_id
AND rctla.interface_line_attribute6 = oola.line_id
AND sota.order_type_id = ooha.order_type_id
AND hcp.status = 'A'
and hp.status = 'A'
and hpsu.status = 'A'
--AND ac.status ='A'
AND hpsu.site_use_type = 'SHIP_TO'
AND oola.flow_status_code = 'CLOSED'
AND rcta.complete_flag = 'Y'
-- AND SYSDATE BETWEEN rst.start_date_active AND NVL(rst.end_date_active, '31-DEC-4712')
--AND otta.attribute2 <> 'Y'
-- AND mtt.trx_source_line_id = oola.line_id
-- AND mtt.source_code = 'ORDER ENTRY'
-- AND mtt.transaction_id = mtlvv.transaction_id
-- AND mttp.transaction_type_id = mtt.transaction_type_id
AND rctla.inventory_item_id = msib.inventory_item_id
AND rctla.line_type = 'LINE'
AND rctla.interface_line_attribute11 = '0'
-- AND to_char(rcta.trx_date,'YYYY') = 2009
and to_date(RCTA.TRX_DATE) between to_date(to_char(:P_TGL_AWAL,'DD-MON-RRRR'),'DD-MON-RRRR') AND
to_date(TO_CHAR(:P_TGL_AKHIR,'DD-MON-RRRR'),'DD-MON-RRRR')
-- --AND rcta.trx_number BETWEEN :P_from_trx_number AND :P_to_trx_number
-- &p_where_trx_number
-- &p_where_trx_date
-- &p_where_acc_num
-- &p_where_site_num
AND ffvs.flex_value_set_name = 'MPI_INV_ITEM_CATEGORIES_PRINCIPAL'
AND ffvs.flex_value_set_id = ffv.flex_value_set_id
AND ffv.enabled_flag = 'Y'
AND ffvt.flex_value_id = ffv.flex_value_id
AND ffvt.flex_value_meaning = micv.segment1
and micv.inventory_item_id = msib.inventory_item_id
AND micv.organization_id = msib.organization_id
AND micv.category_set_name = 'Inventory'
AND ooha.org_id = :P_org_id
and substr(oola.ordered_item,2,1) = :kode
AND EXISTS (SELECT 'X'
FROM hr_organization_units
WHERE UPPER(NAME) = 'MPI - MASTER ITEM'
AND organization_id = msib.organization_id)
AND ooha.ship_from_org_id IN (
SELECT organization_id
FROM hr_organization_units)
--AND EXISTS (SELECT 'X'
-- FROM hr_organization_units
-- WHERE organization_id = ooha.ship_from_org_id)
-- ORDER BY rcta.trx_number, oola.line_number
ORDER BY RCTA.TRX_DATE )
--order by ooha.ORDER_NUMBER desc

13. CEK MODIFIER


/* Formatted on 2009/03/25 11:55 (Formatter Plus v4.8.8) */
SELECT qlh.description, qll.list_line_no, qll.product_precedence
FROM qp_list_headers_tl qlh, qp_list_lines qll
WHERE qll.list_header_id = qlh.list_header_id
AND qlh.description = 'Askes On Principal JKT1'
AND qll.product_precedence <> 240
UNION
SELECT qlh.description, qll.list_line_no, qll.product_precedence
FROM qp_list_headers_tl qlh, qp_list_lines qll
WHERE qll.list_header_id = qlh.list_header_id
AND qlh.description = 'Askeskin On Principal JKT1'
AND qll.product_precedence <> 210
UNION
SELECT qlh.description, qll.list_line_no, qll.product_precedence
FROM qp_list_headers_tl qlh, qp_list_lines qll
WHERE qll.list_header_id = qlh.list_header_id
AND qlh.description = 'CN On MPI JKT1'
AND qll.product_precedence <> 220
UNION
SELECT qlh.description, qll.list_line_no, qll.product_precedence
FROM qp_list_headers_tl qlh, qp_list_lines qll
WHERE qll.list_header_id = qlh.list_header_id
AND qlh.description = 'CN Tarik Off JKT1'
AND qll.product_precedence <> 290
UNION
SELECT qlh.description, qll.list_line_no, qll.product_precedence
FROM qp_list_headers_tl qlh, qp_list_lines qll
WHERE qll.list_header_id = qlh.list_header_id
AND qlh.description = 'Discount Off MPI JKT1'
AND qll.product_precedence <> 260
UNION
SELECT qlh.description, qll.list_line_no, qll.product_precedence
FROM qp_list_headers_tl qlh, qp_list_lines qll
WHERE qll.list_header_id = qlh.list_header_id
AND qlh.description = 'Discount ON JKT 1'
AND qll.product_precedence <> 220
UNION
SELECT qlh.description, qll.list_line_no, qll.product_precedence
FROM qp_list_headers_tl qlh, qp_list_lines qll
WHERE qll.list_header_id = qlh.list_header_id
AND qlh.description = 'HC On Principal JKT1'
AND qll.product_precedence <> 210
UNION
SELECT qlh.description, qll.list_line_no, qll.product_precedence
FROM qp_list_headers_tl qlh, qp_list_lines qll
WHERE qll.list_header_id = qlh.list_header_id
AND qlh.description = 'Pertamina On Principal JKT1'
AND qll.product_precedence <> 210
UNION
SELECT qlh.description, qll.list_line_no, qll.product_precedence
FROM qp_list_headers_tl qlh, qp_list_lines qll
WHERE qll.list_header_id = qlh.list_header_id
AND qlh.description = 'Regular Off Principal JKT1'
AND qll.product_precedence <> 250
UNION
SELECT qlh.description, qll.list_line_no, qll.product_precedence
FROM qp_list_headers_tl qlh, qp_list_lines qll
WHERE qll.list_header_id = qlh.list_header_id
AND qlh.description = 'Regular On Principal JKT1'
AND qll.product_precedence <> 210
UNION
SELECT qlh.description, qll.list_line_no, qll.product_precedence
FROM qp_list_headers_tl qlh, qp_list_lines qll
WHERE qll.list_header_id = qlh.list_header_id
AND qlh.description = 'Discount Bonus JKT1'
AND qll.product_precedence <> 230
14. RAYONISASI SALESMAN / TABEL CUSTOMER

SELECT hps.party_site_number kode_cust,


hl.address_lines_phonetic nama_cust,
hl.ADDRESS3 Alamat,
hl.CITY KOTA,
jrs.salesrep_number kode_salesman,
jrs.NAME nama_salesman,
rt.segment2 rayon_sales,
rt.SEGMENT1 Keterangan,
ffvt.description,
-- ffvt.FLEX_VALUE_MEANING ,
substr(ac.NAME,1,3) kode_kolektor,
ac.DESCRIPTION Nama_Kolektor -- ac.attribute2 cabang_kolektor
FROM hz_parties hp,
fnd_flex_value_sets ffvs,
fnd_flex_values ffv,
fnd_flex_values_tl ffvt ,
hz_party_sites hps,
hz_party_site_uses hpsu,
hz_locations hl,
hz_cust_accounts hca,
hz_cust_acct_sites_all hcasl,
hz_cust_site_uses_all hcsua,
hz_customer_profiles hcp,
ra_terms_lines rtl,
ra_territories rt,
ra_salesrep_territories rst,
jtf_rs_salesreps jrs,
ar_collectors ac
WHERE hca.party_id = hp.party_id
AND hps.party_id = hp.party_id
AND hpsu.party_site_id = hps.party_site_id
AND hl.location_id = hps.location_id
AND hcasl.cust_account_id = hca.cust_account_id
AND hcsua.cust_acct_site_id = hcasl.cust_acct_site_id
and hps.party_site_id = hcasl.party_site_id
AND hcp.site_use_id = hcsua.site_use_id
AND hcp.standard_terms = rtl.term_id
AND rt.territory_id = hcsua.territory_id
AND rst.territory_id = hcsua.territory_id
AND jrs.salesrep_id = rst.salesrep_id
AND ac.collector_id = hcp.collector_id
AND hcsua.ORG_ID = 103 --kodecabang JKT1
AND hcp.status = 'A'
and hp.status = 'A'
and hpsu.status = 'A'
AND ac.status ='A'
AND hpsu.site_use_type = 'SHIP_TO'
and ffvs.flex_value_set_name = 'MPI_RAYON'
and ffvs.flex_value_set_id = ffv.flex_value_set_id
AND ffvt.flex_value_id = ffv.flex_value_id
AND ffv.enabled_flag = 'Y'
and rt.SEGMENT2 = ffvt.FLEX_VALUE_MEANING
AND SYSDATE BETWEEN rst.start_date_active
AND NVL (rst.end_date_active, '31-DEC-4712')
order by NAMA_CUST
-- and hps.PARTY_SITE_NUMBER = 10046

SELECT ffvt.description, ffvt.FLEX_VALUE_MEANING


--INTO v_desc
FROM fnd_flex_value_sets ffvs, fnd_flex_values ffv, fnd_flex_values_tl ffvt
WHERE (ffvs.flex_value_set_name = 'MPI_RAYON' or ffvs.FLEX_VALUE_SET_NAME = 'MPI_WILAYAH')
and ffvs.flex_value_set_id = ffv.flex_value_set_id
AND ffvt.flex_value_id = ffv.flex_value_id
AND ffv.enabled_flag = 'Y'
-- AND ffvt.flex_value_meaning = :attribute3;

select * from FND_FLEX_VALUES_VL

15. PRICE LIST


select qll.LIST_HEADER_ID, qll.LIST_LINE_ID, qll.PRODUCT_ATTR_VAL_DISP, qll.PRODUCT_UOM_CODE, qll.OPERAND,
qll.START_DATE_ACTIVE, qll.END_DATE_ACTIVE , qht.NAME
from qp_list_lines_v qll , qp_list_headers_tl qht
where qll.LIST_HEADER_ID = qht.LIST_HEADER_ID
and (qll.END_DATE_ACTIVE > '28-apr-09' or qll.END_DATE_ACTIVE is null)
order by qll.LIST_HEADER_ID
---yg dipakai = 6032 , 6033 ,6034,6037

select * from qp_list_headers_tl

select * from qp_list_lines_v

-- Cek QUATATION
SELECT a.segment1 no_dok,
DECODE (a.status_lookup_code,
'I', 'Incomplete',
'A', 'Active',
'Closed'
) status_quo,
b.vendor_name, c.vendor_site_code, f.INVENTORY_ITEM_ID, f.segment1 ko_bar, f.attribute2 kode_foxpro,
d.item_description, f.PRIMARY_UOM_CODE, d.unit_price hna, e.quantity, e.price_override hjp,
e.price_discount marjin, g.category_concat_segs kls_prod,
h.ATTRIBUTE4 PHB, f.HAZARD_CLASS_ID OKT, i.LOCATION_CODE
FROM po_headers_all a,
po_vendors b,
po_vendor_sites_all c,
po_lines_all d,
po_line_locations_all e,
mtl_system_items_b f,
mtl_item_categories_v g,
mtl_system_items_b h,
hr_locations_all i
WHERE a.type_lookup_code = 'QUOTATION'
AND a.vendor_id = b.vendor_id
AND a.vendor_site_id = c.vendor_site_id
AND a.status_lookup_code <> 'C'
AND a.closed_date IS NULL
AND a.po_header_id = d.po_header_id
AND a.po_header_id = e.po_header_id
AND d.po_line_id = e.po_line_id
AND d.item_id = f.inventory_item_id
AND d.item_id = g.inventory_item_id
AND f.inventory_item_id = g.inventory_item_id
AND f.organization_id = '105'
and h.INVENTORY_ITEM_ID = f.INVENTORY_ITEM_ID
and h.ORGANIZATION_ID = '104'
AND f.organization_id = g.organization_id
and i.LOCATION_ID = e.SHIP_TO_LOCATION_ID
AND g.category_set_id = 1
AND d.po_line_id IN (
SELECT z.po_line_id
FROM (SELECT b.vendor_name, c.vendor_site_code,
MAX (d.po_line_id) po_line_id, f.segment1,
d.item_description
FROM po_headers_all a,
po_vendors b,
po_vendor_sites_all c,
po_lines_all d,
po_line_locations_all e,
mtl_system_items_b f
WHERE a.type_lookup_code = 'QUOTATION'
AND a.vendor_id = b.vendor_id
AND a.vendor_site_id = c.vendor_site_id
AND a.status_lookup_code <> 'C'
AND a.closed_date IS NULL
AND a.po_header_id = d.po_header_id
AND a.po_header_id = e.po_header_id
AND d.po_line_id = e.po_line_id
AND d.item_id = f.inventory_item_id
AND f.organization_id = '105'
GROUP BY b.vendor_name,
c.vendor_site_code,
f.segment1,
d.item_description) z)

16.REKAP PRODUK/FAKTUR
mpi_interface_to_legacy_pkg

SELECT
SUM (SUBSTR(LPAD(NVL(ABS(mtlvv.PRIMARY_QUANTITY),''),6,' '),1,6)) --- perbaikan
AS BANYAK --14
FROM oe_transaction_types_all otta,
oe_order_headers_all ooha,
oe_order_lines_all oola,
mtl_material_transactions mtt,
mtl_transaction_lot_val_v mtlvv,
mtl_system_items_b msib,
hz_parties hp,
hz_party_sites hps,
hz_party_site_uses hpsu,
hz_locations hl,
hz_cust_accounts hca,
hz_cust_acct_sites_all hcasl,
hz_cust_site_uses_all hcsua,
hz_customer_profiles hcp,
ra_terms_lines rtl,
ra_territories rt,
ra_salesrep_territories rst,
jtf_rs_salesreps jrs,
ra_customer_trx_all rcta,
--ra_customer_trx_lines_all rctla,
so_order_types_all sota,
mtl_item_categories mic,
ra_customer_trx_lines_all rctla,
mtl_categories_b mcb,
--ar_customers ac,
HR_ALL_ORGANIZATION_UNITS HAOU,
(SELECT T.organizAtion_id FROM HR_ALL_ORGANIZATION_UNITS T
WHERE EXISTS (SELECT 1 FROM mpi_branch_code_dev_data t1 WHERE t1.branch_id = :v_branchid AND T.attribute1 =
t1.branch_code)
) HAOU2
,(SELECT mttp.transaction_type_name,
mttp.transaction_type_id
FROM mtl_txn_source_types mtst,
mtl_transaction_types mttp
WHERE transaction_source_type_name = 'Sales order'
AND mtst.transaction_source_type_id = mttp.transaction_source_type_id
AND mttp.transaction_type_name = 'Sales order issue') mttp
WHERE otta.transaction_type_id = ooha.order_type_id
AND ooha.header_id = oola.header_id
AND oola.inventory_item_id = msib.inventory_item_id
--and msib.ORGANIZATION_ID = ooha.SHIP_FROM_ORG_ID -- ship dari gudang mana
--
AND msib.INVENTORY_ITEM_ID=mic.INVENTORY_ITEM_ID
AND msib.ORGANIZATION_ID=mic.ORGANIZATION_ID
AND mic.CATEGORY_ID = mcb.CATEGORY_ID
AND mic.CATEGORY_SET_ID=1
--
AND hca.party_id = hp.party_id
AND hca.cust_account_id = ooha.sold_to_org_id
AND hps.party_id = hp.party_id
AND hpsu.party_site_id = hps.party_site_id
AND hl.location_id = hps.location_id
AND hcasl.cust_account_id = hca.cust_account_id
AND hcsua.cust_acct_site_id = hcasl.cust_acct_site_id
AND hps.party_site_id = hcasl.party_site_id
AND hcp.site_use_id = hcsua.site_use_id
AND hcp.standard_terms = rtl.term_id
AND rt.territory_id = hcsua.territory_id
AND rst.territory_id = hcsua.territory_id
AND jrs.salesrep_id = rst.salesrep_id
AND rcta.interface_header_attribute1 = TO_CHAR(ooha.order_number)
AND sota.NAME = rcta.interface_header_attribute2
AND sota.order_type_id = ooha.order_type_id
AND hcp.status = 'A'
AND hp.status = 'A'
AND hpsu.status = 'A'
AND hpsu.site_use_type = 'SHIP_TO'
AND oola.flow_status_code = 'CLOSED'
AND rcta.complete_flag = 'Y'
AND SYSDATE BETWEEN rst.start_date_active AND NVL(rst.end_date_active, '31-DEC-4712')
--AND otta.attribute2 <> 'Y'
AND mtt.trx_source_line_id = oola.line_id --- perbaikan
AND hcasl.party_site_id = hps.party_site_id --- perbaikan
AND ooha.INVOICE_TO_ORG_ID = hcsua.SITE_USE_ID ---- perbaikan
--AND mtt.source_code = 'ORDER ENTRY'
AND mtt.transaction_id = mtlvv.transaction_id
AND mttp.transaction_type_id = mtt.transaction_type_id
--AND ac.orig_system_reference = hps.party_site_number
AND HAOU.ORGANIZATION_ID = ooha.ORG_ID
AND HAOU.ORGANIZATION_ID = HAOU2.organization_id
and rctla.interface_line_attribute11 ='0'
AND rctla.line_type = 'LINE'
and msib.SEGMENT1 = :id
AND rctla.customer_trx_id =rcta.CUSTOMER_TRX_ID
and to_char(oola.line_id) = rctla.interface_line_attribute6
AND EXISTS (SELECT 'X'
FROM hr_organization_units
WHERE UPPER(NAME) = 'MPI - MASTER ITEM'
AND organization_id = msib.organization_id)
AND EXISTS (SELECT 'X'
FROM hr_organization_units
WHERE organization_id = ooha.ship_from_org_id)
--AND TO_CHAR(RCTA.trx_date,'MM') = :v_month
and to_date(rcta.TRX_DATE) between :tgl_awal and :tgl_akhir
AND rcta.CUST_TRX_TYPE_ID = DECODE(:v_trantype,'Faktur',1000,'Retur',1001)
union all
SELECT ------
distinct
SUM (SUBSTR(LPAD(NVL(ABS(mr.reservation_quantity),''),6,' '),1,6)) --- perbaikan
AS BANYAK --14
FROM oe_transaction_types_all otta,
oe_order_headers_all ooha,
oe_order_lines_all oola,
--mtl_material_transactions mtt,************
--mtl_transaction_lot_val_v mtlvv, ***********
mpi_branch_code_dev_data mbcdd,
mtl_reservations mr,
mtl_lot_numbers mln,
mtl_system_items_b msib,
hz_parties hp,
hz_party_sites hps,
hz_party_site_uses hpsu,
hz_locations hl,
hz_cust_accounts hca,
hz_cust_acct_sites_all hcasl,
hz_cust_site_uses_all hcsua,
hz_customer_profiles hcp,
ra_terms_lines rtl,
ra_territories rt,
ra_salesrep_territories rst,
jtf_rs_salesreps jrs,
ra_customer_trx_all rcta,
ra_customer_trx_lines_all rctla,
so_order_types_all sota,
mtl_item_categories mic,
mtl_categories_b mcb,
--ar_customers ac,
HR_ALL_ORGANIZATION_UNITS HAOU,
(SELECT T.organizAtion_id FROM HR_ALL_ORGANIZATION_UNITS T
WHERE EXISTS (SELECT 1 FROM mpi_branch_code_dev_data t1 WHERE t1.branch_id = :v_branchid AND T.attribute1 =
t1.branch_code)
) HAOU2
WHERE otta.transaction_type_id = ooha.order_type_id
AND ooha.header_id = oola.header_id
AND oola.inventory_item_id = msib.inventory_item_id
AND msib.INVENTORY_ITEM_ID=mic.INVENTORY_ITEM_ID
AND msib.ORGANIZATION_ID=mic.ORGANIZATION_ID
AND mic.CATEGORY_ID = mcb.CATEGORY_ID
AND mic.CATEGORY_SET_ID=1
AND hca.party_id = hp.party_id
AND hca.cust_account_id = ooha.sold_to_org_id
AND hps.party_id = hp.party_id
AND hpsu.party_site_id = hps.party_site_id
AND hl.location_id = hps.location_id
AND hcasl.cust_account_id = hca.cust_account_id
AND hcsua.cust_acct_site_id = hcasl.cust_acct_site_id
AND hps.party_site_id = hcasl.party_site_id
AND hcp.site_use_id = hcsua.site_use_id
AND hcp.standard_terms = rtl.term_id
AND rt.territory_id = hcsua.territory_id
AND rst.territory_id = hcsua.territory_id
AND jrs.salesrep_id = rst.salesrep_id
AND rcta.interface_header_attribute1 = TO_CHAR(ooha.order_number)
AND sota.NAME = rcta.interface_header_attribute2
AND sota.order_type_id = ooha.order_type_id
AND hcp.status = 'A'
AND hp.status = 'A'
AND hpsu.status = 'A'
AND hpsu.site_use_type = 'SHIP_TO'
and mbcdd.ORGANIZATION_ID = HAOU.ORGANIZATION_ID ----
and mr.DEMAND_SOURCE_LINE_ID = oola.LINE_ID
and mln.LOT_NUMBER = mr.LOT_NUMBER
and mln.INVENTORY_ITEM_ID = oola.INVENTORY_ITEM_ID
and mr.ORGANIZATION_ID = mbcdd.WAREHOUSE_ID
and mln.ORGANIZATION_ID = mbcdd.WAREHOUSE_ID ----ubah
AND oola.flow_status_code = 'CLOSED'
AND rcta.complete_flag = 'Y'
AND SYSDATE BETWEEN rst.start_date_active AND NVL(rst.end_date_active, '31-DEC-4712')
AND otta.attribute2 = 'Y'
AND hcasl.party_site_id = hps.party_site_id --- perbaikan
AND ooha.INVOICE_TO_ORG_ID = hcsua.SITE_USE_ID ---- perbaikan
AND HAOU.ORGANIZATION_ID = ooha.ORG_ID
AND HAOU.ORGANIZATION_ID = HAOU2.organization_id
and rctla.interface_line_attribute11 ='0'
AND rctla.line_type = 'LINE'
AND rctla.customer_trx_id =rcta.CUSTOMER_TRX_ID
and to_char(oola.line_id) = rctla.interface_line_attribute6
AND EXISTS (SELECT 'X'
FROM hr_organization_units
WHERE UPPER(NAME) = 'MPI - MASTER ITEM'
AND organization_id = msib.organization_id)
AND EXISTS (SELECT 'X'
FROM hr_organization_units
WHERE organization_id = ooha.ship_from_org_id)
--AND TO_CHAR(RCTA.trx_date,'MM') = :v_month
and to_date(rcta.TRX_DATE) between :tgl_awal and :tgl_akhir
and msib.SEGMENT1 = :id
--and rcta.TRX_NUMBER = '10908'
AND rcta.CUST_TRX_TYPE_ID = DECODE(:v_trantype,'Faktur',1000,'Retur',1001);

You might also like