Important apps queries important apps queries om advance pricing query
SELECT qpseg.segment_mapping_column,
qpsour.user_sourcing_type,
qpsour.user_value_string,
qpcon.prc_context_code,
qpsour.attribute_sourcing_level,
qpsour.request_type_code,
qpreq.pte_code,
qpcon.prc_context_type,
qpseg.segment_code,
qpcon.seeded_flag context_seeded_flag,
qpseg.seeded_flag attribute_seeded_flag
FROM qp_segments_b QPSEG,
qp_attribute_sourcing QPSOUR,
qp_prc_contexts_b QPCON,
qp_pte_request_types_b QPREQ,
qp_pte_segments QPPSEG
WHERE qpsour.segment_id = qpseg.segment_id
AND qppseg.user_sourcing_method = ‘attribute mapping’
AND qpsour.request_type_code = ‘ont’
AND qpseg.prc_context_id = qpcon.prc_context_id
AND qpreq.request_type_code = qpsour.request_type_code
AND qppseg.pte_code = qpreq.pte_code
AND qppseg.segment_id = qpsour.segment_id
AND qppseg.sourcing_enabled = ‘y’
AND qpcon.prc_context_type IN (‘pricing_attribute’,
‘product’,
‘qualifier’)
OM sales ORDER report
SELECT oha.header_id,
bill_ca.cust_account_id,
oha.order_number,
oha.ordered_date,
oha.cust_po_number customer_po,
oha.org_id,
ott.NAME order_type,
ola.line_number,
msi.segment1 item_code,
msi.description item_desc,
ola.ordered_quantity,
ola.order_quantity_uom,
oha.transactional_curr_code trx_curr,
ola.unit_selling_price,
(ola.ordered_quantity*ola.unit_selling_price) line_amt,
ola.shipping_quantity,
ola.shipping_quantity_uom,
(Nvl(ola.shipping_quantity,0)*ola.unit_selling_price) shipped_amt,
ola.schedule_ship_date,
--oha.flow_status_code order_status,
ol.meaning order_status,
bill_p.party_name,
bill_su.location invoice_to_location,
bill_loc.address1 invoice_to_address1,
bill_loc.address2 invoice_to_address2,
bill_loc.address3 invoice_to_address3,
bill_loc.address4 invoice_to_address4,
Decode (bill_loc.city, NULL, NULL, bill_loc.city
|| ', ' )
|| Decode (bill_loc.state, NULL, bill_loc.province
|| ', ', bill_loc.state
|| ', ' )
|| Decode (bill_loc.postal_code, NULL, NULL, bill_loc.postal_code
|| ', ' )
|| Decode (bill_loc.country, NULL, NULL, bill_loc.country) invoice_to_address5,
ship_loc.city ship_city,
ship_loc.country ship_country_code,
ft.territory_short_name ship_country,
(
SELECT NAME
FROM ra_salesreps_all
WHERE salesrep_id = oha.salesrep_id
AND org_id = oha.org_id) sales_person,
--wd.date_scheduled,
oha.conversion_type_code
FROM oe_order_headers_all oha,
oe_order_lines_all ola,
oe_transaction_types_tl ott,
mtl_system_items_b msi,
hz_cust_site_uses_all bill_su,
hz_party_sites bill_ps,
hz_locations bill_loc,
hz_cust_acct_sites_all bill_cas,
hz_cust_accounts bill_ca,
hz_parties bill_p,
hz_cust_site_uses_all ship_su,
hz_party_sites ship_ps,
hz_locations ship_loc,
hz_cust_acct_sites_all ship_cas,
-- wsh_deliverables_v wd
fnd_territories_tl ft,
oe_lookups ol
WHERE oha.org_id = Nvl(:p_org_id,oha.org_id)
AND Trunc(oha.ordered_date) BETWEEN Nvl(:p_order_date_from,Trunc(oha.ordered_date)) AND Nvl(:p_order_date_to,Trunc(oha.ordered_date))
AND bill_ca.cust_account_id BETWEEN Nvl(:p_cust_acc_id_from,Trunc(bill_ca.cust_account_id)) AND Nvl(:p_cust_acc_id_to,Trunc(bill_ca.cust_account_id))
AND Trunc(Nvl(ola.schedule_ship_date,sysdate)) BETWEEN Nvl(:p_delvry_date_from,Trunc(Nvl(ola.schedule_ship_date,sysdate))) AND Nvl(:p_delvry_date_to,Trunc(Nvl(ola.schedule_ship_date,sysdate)))
--and oha.flow_status_code between nvl(:p_order_status_from,oha.flow_status_code)
--and nvl(:p_order_status_to,oha.flow_status_code)
AND ol.meaning BETWEEN Nvl(:p_order_status_from,ol.meaning) AND Nvl(:p_order_status_to,ol.meaning)
AND msi.inventory_item_id BETWEEN Nvl(:p_prod_desc_from,msi.inventory_item_id) AND Nvl(:p_prod_desc_to,msi.inventory_item_id)
/*and msi.description between nvl(:p_prod_desc_from,msi.description)
and nvl(:p_prod_desc_to,msi.description) */
AND ship_loc.country BETWEEN Nvl(:p_ship_country_from,ship_loc.country) AND Nvl(:p_ship_country_to,ship_loc.country)
AND oha.salesrep_id BETWEEN Nvl(:p_salesrep_id_from,oha.salesrep_id) AND Nvl(:p_salesrep_id_to,oha.salesrep_id)
AND oha.header_id = ola.header_id
AND oha.order_type_id = ott.transaction_type_id
AND ott.language = Userenv('LANG')
AND ola.inventory_item_id = msi.inventory_item_id
AND ola.ship_from_org_id = msi.organization_id
AND oha.invoice_to_org_id = bill_su.site_use_id(+)
AND bill_su.cust_acct_site_id = bill_cas.cust_acct_site_id(+)
AND bill_cas.party_site_id = bill_ps.party_site_id(+)
AND bill_loc.location_id(+) = bill_ps.location_id
AND bill_cas.cust_account_id = bill_ca.cust_account_id
AND bill_ca.party_id = bill_p.party_id
AND oha.ship_to_org_id = ship_su.site_use_id(+)
AND ship_su.cust_acct_site_id = ship_cas.cust_acct_site_id(+)
AND ship_cas.party_site_id = ship_ps.party_site_id(+)
AND ship_loc.location_id(+) = ship_ps.location_id
-- and oha.header_id = wd.source_header_id(+)
-- and ola.line_id = wd.source_line_id(+)
AND ship_loc.country = ft.territory_code
AND ft.language = userenv('LANG')
AND ol.lookup_type = 'FLOW_STATUS'
AND ol.lookup_code = oha.flow_status_code
--and oha.order_number = 21019
inv orgin reportSELECT msib.inventory_item_id ,
msib.organization_id "Warehouse_Code" ,
msib.segment1 "Item" ,
msib.description "Item_Desc" ,
mtln.lot_number ,
msib.primary_uom_code "UOM" ,
msib.primary_unit_of_measure ,
msib.inventory_item_status_code ,
msib.item_type ,
msib.default_so_source_type ,
mmt.transaction_id ,
mmt.subinventory_code ,
mmt.transfer_subinventory ,
mmt.attribute1 "Ship_to_warehouse_id" ,
(
SELECT od.organization_name
FROM org_organization_definitions od
WHERE od.organization_id=mmt.attribute1 ) ship_to_warehouse ,
mmt.attribute2 shipment_reference ,
ood.organization_code ,
ood.organization_name warehouse ,
To_char(To_date(mmt.attribute3 ,'YYYY/MM/DD HH24:MI:SS'),'DD-MON-YYYY') shipment_date ,
Abs(mmt.transaction_quantity) quantity ,
mmt.transaction_uom
--,mmt.actual_cost
--,mmt.prior_cost
--,mmt.new_cost
,
( hou.address_line_1
||''
|| address_line_2
||''
|| address_line_3
||''
|| region_1
||''
|| region_2
||''
|| region_3
||''
|| telephone_number_1
||''
|| telephone_number_2
||''
|| telephone_number_3
||''
|| postal_code
||''
|| town_or_city
||''
|| country)ship_to_adderss
--,mmt.locator_id
,
mmt.currency_code
FROM mtl_system_items_b msib ,
mtl_material_transactions mmt ,
mtl_transaction_lot_numbers mtln ,
hr_organization_units_v hou ,
org_organization_definitions ood
WHERE msib.inventory_item_id=mmt.inventory_item_id
AND msib.organization_id=mmt.organization_id
AND msib.organization_id=ood.organization_id
AND mmt.attribute1=hou.organization_id(+)
--AND mmt.transaction_id=185011--162022--178029
AND ood.organization_code=:inventory_org--parametors
--AND mmt.attribute3 BETWEEN :from_date AND :to_date--parametors
AND to_char(to_date(mmt.attribute3 ,'YYYY/MM/DD HH24:MI:SS'),'DD-MON-YYYY') BETWEEN nvl(:from_date,to_char(to_date(mmt.attribute3 ,'YYYY/MM/DD HH24:MI:SS'),'DD-MON-YYYY') ) AND nvl(:to_date,to_char(to_date(mmt.attribute3 ,'YYYY/MM/DD HH24:MI:SS'),'DD-MON-YYYY') )
AND mmt.transaction_id=mtln.transaction_id
AND mmt.subinventory_code LIKE 'IWM'
AP checks status information
SELECT PVS.attribute6 "SUPPLIER SITE TYPE" ,
GSOB.NAME "SET OF BOOKS NAME" ,
AC.check_number ,
AC.check_date ,
Trunc(sysdate-AC.check_date) "AGE OF CHECK" ,
AI.payment_currency_code "PAYMENT CURRENCY CODE" ,
AC.amount "CHECK AMOUNT" ,
AIA.invoice_num "INVOICE NUMBER" ,
AI.invoice_currency_code "INVOICE CURRENCY CODE" ,
AI.amount_paid "INVOICE AMOUNT PAID" ,
PV.vendor_name "SUPPLIER NAME" ,
PVS.vendor_site_code "SUPPLIER SITE CODE" ,
AID.description "DESCRIPTION" ,
PVS.address_line1 "ADDRESS LINE1" ,
PVS.address_line2 "ADDRESS LINE2" ,
PVS.address_line3 "ADDRESS LINE3" ,
PVS.city "CITY" ,
PVS.state "STATE" ,
PVS.zip "ZIP"
FROM po_vendor_sites PVS ,
gl_sets_of_books GSOB ,
ap_checks AC ,
ap_invoices AI ,
ap_invoices_all AIA ,
po_vendors PV ,
ap_invoice_distributions AIDSELECT tax JOURNALSSELECT GLJH.je_header_id "HID",
GLJH.tax_status_code "TC",
GLJL.tax_code_id "ID",
To_char(GLJH.last_update_date,'DD-MON-YYYY') "UPDATE_DATE"
FROM gl_je_headers GLJH,
gl_je_lines GLJL,
gl_code_combinations GLCC,
gl_je_batches GLJB
WHERE GLJH.je_header_id=GLJL.je_header_id
AND GLJL.code_combination_id=GLCC.code_combination_id
AND GLJH.je_batch_id=GLJB.je_batch_id
AND GLJH.tax_status_code='T'
ORDER BY GLJH.je_header_id;
INVOICE payment CHECK
SELECT --PVSA.ADDRESS_LINE1 "SUPPLIER SITE TYPE"
gsoba.NAME "SET OF BOOKS NAME" ,
aca.check_number "CHECK NUMBER" ,
aca.check_date "CHECK DATE" ,
Trunc(sysdate-aca.check_date) "AGE OF CHECK" ,
aia.payment_currency_code "PAYMENT CURRENCY CODE" ,
aca.amount "CHECK AMOUNT" ,
aia.invoice_num "INVOICE NUMBER" ,
aia.invoice_currency_code "INVOICE CURRENCY CODE" ,
aia.amount_paid "INVOICE AMOUNT PAID" ,
pv.vendor_name "SUPPLIER NAME" ,
pvsa.vendor_site_code "SUPPLIER SITE CODE" ,
aida.description "DESCRIPTION" ,
pvsa.address_line1 "ADDRESS LINE1" ,
pvsa.address_line2 "ADDRESS LINE2" ,
pvsa.address_line3 "ADDRESS LINE3" ,
pvsa.city "CITY" ,
pvsa.state "STATE" ,
pvsa.zip "ZIP"
FROM ap_invoices_all AIA ,
ap_checks_all ACA ,
ap_invoice_payments_all AIPA ,
ap_invoice_distributions_all AIDA ,
po_distributions_all PDA ,
po_vendor_sites_all PVSA ,
po_vendors PV ,
gl_sets_of_books GSOBA
WHERE aipa.check_id=aca.check_id
AND aia.invoice_id=aipa.invoice_id
AND aia.invoice_id=aida.invoice_id
AND pv.vendor_id=pvsa.vendor_id
AND aia.vendor_id=pv.vendor_id
AND aida.po_distribution_id=pda.po_distribution_id
AND aia.set_of_books_id=gsoba.set_of_books_id
Sales invoice
SELECT hou.NAME operating_unit_name,
rct.trx_number sales_invoice_number,
ooh.order_number,
rc.customer_name,
rsa.NAME sales_person_name,
msi.segment1 item_number,
mln.lot_number,
msi.primary_unit_of_measure primary_uom,
ool.ordered_quantity primary_quantity,
msi.secondary_uom_code secondary_uom,
ool.ordered_quantity2 secondary_quantity,
msi.organization_id inventory_org_id,
ool.org_id,
rctl.extended_amount amount
FROM oe_order_headers_all ooh,
oe_order_lines_all ool,
hr_operating_units hou,
ra_customer_trx_all rct,
ra_customer_trx_lines_all rctl,
ra_customers rc,
ra_salesreps_all rsa,
mtl_system_items_b msi,
mtl_lot_numbers mln
WHERE ooh.header_id = ool.header_id
AND hou.organization_id = ool.org_id
AND ool.reference_customer_trx_line_id = rctl.customer_trx_line_id
AND rct.sold_to_customer_id = rc.customer_id
AND ooh.salesrep_id = rsa.salesrep_id
AND mln.inventory_item_id = msi.inventory_item_id
AND mln.organization_id = msi.organization_id
Receipt
SELECT acr.receipt_number ,
arm.NAME receipt_method ,
acr.receipt_date ,
acrh.gl_date ,
abb.bank_name ,
aba.bank_account_num ,
hp.party_name customer_name
FROM ar_receipt_methods ARM ,
ar_cash_receipts_all ACR ,
ar_cash_receipt_history_all ACRH ,
ap_bank_accounts ABA ,
ap_bank_branches ABB ,
hz_parties HP ,
hz_cust_accounts HCA
WHERE arm.receipt_method_id=acr.receipt_method_id
AND acr.cash_receipt_id=acrh.cash_receipt_id
AND acr.remittance_bank_account_id=aba.bank_account_id(+)
AND aba.bank_account_id=abb.bank_branch_id(+)
AND acr.pay_from_customer=hca.cust_account_id
AND hca.party_id=hp.party_id
AR invoice
SELECT rcta.trx_number invoice_num,
--sales_order_reference,
rct.gl_date,
rctl.inventory_item_id,
rct.amount,
rcta.trx_date invoice_date,
rctl.taxable_amount tax_amount
-- revenue_account_id,
--receivables_account_id,
FROM ra_customer_trx_lines_all rctl,
ra_cust_trx_line_gl_dist_all rct,
ra_customer_trx_all rcta
WHERE rctcl.customer_trx_line_id=rct.customer_trx_line_id
AND rctl.customer_trx_id=rcta.customer_trx_id
AND rcta.customer_trx_id=rct.customer_trx_id ap internal item querySELECT DISTINCT To_char(api.invoice_date,'MM/DD/YYYY') document_date,
(
SELECT segment7
FROM gl_code_combinations gc
WHERE gc.code_combination_id = aid.dist_code_combination_id ) document_type,
(
SELECT segment5
FROM gl_code_combinations gc
WHERE gc.code_combination_id = aid.dist_code_combination_id ) company_code, -- <>
NULL posting_date,
NULL fiscal_period,
api.invoice_currency_code currency_key,
Decode(api.invoice_currency_code, sob.currency_code,NULL, Substr(api.exchange_rate,1, Instr(api.exchange_rate,'.',1)-1)
|| Rpad(Substr(api.exchange_rate, Instr(api.exchange_rate,'.',1), Length(api.exchange_rate)),6,0)) exchange_rate,
api.invoice_num document_num,
NULL header_text,
Decode(Sign(api.invoice_amount), 1,31,-1,21,0,31,NULL) posting_key1,
pv.segment1 account_or_matchcode1,
Abs(api.invoice_amount) amount1,
apt.NAME payment_terms,
(
SELECT To_char(Max(due_date),'MM/DD/YYYY')
FROM ap_payment_schedules_all
WHERE invoice_id = api.invoice_id) baseline_date, -- As per option2 in Mapping doc.
Substr(pv.segment1,1,18) assignment_number1,
(
SELECT segment2
FROM gl_code_combinations gc
WHERE gc.code_combination_id = aid.dist_code_combination_id ) item_text1,
Decode(Sign(api.invoice_amount), 1,40,-1,50,0,40,NULL) posting_key2,
NULL account_or_matchcode2,
Abs(Nvl(
(
SELECT Sum(apd.amount)
FROM ap_invoice_distributions_all apd
WHERE apd.invoice_id=api.invoice_id),NULL)) amount2,
NULL assignment_number2,
NULL item_text2, --Can concatenate PO#s and populate this if business needs it.
(
SELECT segment4
FROM gl_code_combinations gc
WHERE gc.code_combination_id = aid.dist_code_combination_id ) profit_center, --To be mapped by Finance. For now, leave blank
Decode (
(
SELECT Count(1)
FROM ap_payment_schedules_all
WHERE invoice_id = api.invoice_id
AND Nvl(hold_flag,'N') = 'Y'),0,'N','Y' ) payment_hold,
api.vendor_site_id vendor_site_id
FROM ap_invoices_all api,
ap_accounting_events_all apae,
ap_ae_headers_all apaeh,
gl_sets_of_books sob,
po_vendors pv,
gl_code_combinations gcc,
ap_invoice_distributions_all aid,
ap_terms_tl apt
WHERE apae.source_table='AP_INVOICES'
AND apae.event_status_code = 'ACCOUNTED'
AND apaeh.gl_transfer_flag = 'Y'
AND apaeh.gl_transfer_error_code IS NULL
AND Nvl(api.payment_status_flag,'N')<>'Y'
AND api.cancelled_date IS NULL
AND api.cancelled_by IS NULL
AND api.cancelled_amount IS NULL
--AND api.invoice_id=apae.source_id
AND aid.accounting_event_id = apae.accounting_event_id
AND apae.accounting_event_id = apaeh.accounting_event_id
AND sob.set_of_books_id=api.set_of_books_id
AND api.accts_pay_code_combination_id = gcc.code_combination_id
AND api.vendor_id=pv.vendor_id
AND apt.term_id= api.terms_id
AND api.org_id = 403
AND gcc.segment1 = '547L'
AND gcc.segment2 LIKE '191%'
AND aid.invoice_id = api.invoice_id
AND aid.line_type_lookup_code NOT IN ('TAX')
AND Abs(api.invoice_amount) !='0'
AND api.invoice_id NOT IN
(
SELECT vouchno
FROM ap_expense_report_headers_all)
Purchase ORDER query
SELECT msi.segment1 Product ,
msi.description Description ,
hl.description Ship_to_location
-- Modified deliver_to_subinv to display Subinventory Name as part of CCD# 2010-04-1701
--, mse.description deliver_to_subinv
,
mse.secondary_inventory_name deliver_to_subinv ,
decodeSELECT Decode(d.reservation_type, 1, 'On Demand', 2, 'Reserved') res_type,
Substr(u.user_name, 1, 20) user_name,
Substr(i.segment1, 1, 10) item,
c.customer_name cust_name,
c.customer_number cust_number,
h.order_number ord_no,
Substr(l.shipment_priority_code, 1, 10) ship_code,
h.date_ordered date_ordered,
r.organization_code org,
d.line_item_quantity demand_qty
FROM so_headers_all h,
mtl_demand d,
mtl_sales_orders s,
mtl_system_items i,
org_organization_definitions r,
fnd_user u,
ra_customers c,
so_lines_all l
WHERE h.created_by = u.user_id
AND d.inventory_item_id = i.inventory_item_id
AND d.organization_id = i.organization_id
AND h.order_number = s.segment1
AND r.organization_id = d.organization_id
AND c.customer_id = h.customer_id
AND d.demand_source_line = l.line_id
AND l.header_id = h.header_id
AND d.line_item_quantity > 0
AND i.segment1 BETWEEN '&&item_from' AND '&&item_to'
AND d.demand_id IN
(
SELECT Max(d1.demand_id)
FROM mtl_demand d1
WHERE d1.line_item_quantity > 0
AND d1.demand_source_type IN (2,
8)
AND d1.parent_demand_id IS NOT NULL
GROUP BY d1.reservation_type,
d1.parent_demand_id)
ORDER BY Decode(d.reservation_type, 1, 'Demand', 2, 'Reserved'),
Substr(u.user_name, 1, 20),
Substr(i.segment1, 1, 10) /
SELECT l.transaction_reason_code reason_code,
c.customer_name cust_name,
Substr(s.segment1, 1, 10) item,
h.order_number ord_no,
t.trx_number inv_no,
0 - Nvl(l.ordered_quantity, 0) - Nvl(l.cancelled_quantity, 0) rma_quantity,
Nvl(tl.quantity_credited, 0) qty_credited,
Nvl(tl.quantity_credited, 0) * Nvl(unit_selling_price, 0) total_cr,
u.user_name creator_name,
h.creation_date creation_date
FROM fnd_user u,
mtl_system_items s,
ra_customers c,
ra_customer_trx_all t,
ra_customer_trx_lines_all tl,
so_headers_all h,
so_lines_all l
WHERE h.order_category = 'RMA'
AND h.cancelled_flag IS NULL
AND tl.customer_trx_id = t.customer_trx_id(+)
AND tl.interface_line_attribute6(+) = l.line_id
AND c.customer_id = h.customer_id
AND u.user_id = h.created_by
AND l.inventory_item_id = s.inventory_item_id
AND l.warehouse_id = s.organization_id
AND h.header_id = l.header_id
AND h.creation_date BETWEEN to_date('&&from_date', 'DD-MON-RRRR') AND to_date('&&to_date', 'DD-MON-RRRR')
ORDER BY 1,
2 /
SELECT o.organization_code org_name,
Substr(msi.segment1, 1, 10) item,
Substr(msi.description, 1, 45) item_desc,
sh.order_number order_number,
sh.date_ordered date_ordered,
Substr(fu.user_name, 1, 12) created_by,
Nvl(sl.ordered_quantity, 0) - Nvl(sl.cancelled_quantity, 0) qty_ordered,
sl.selling_price *sl.ordered_quantity ext_amount
FROM so_headers_all sh,
mtl_system_items msi,
so_lines_all sl,
fnd_user fu,
org_organization_definitions o
WHERE sh.header_id = sl.header_id
AND o.organization_id = msi.organization_id
AND sh.order_category IN ('R',
'RMA')
AND sl.inventory_item_id = msi.inventory_item_id
AND sl.warehouse_id = msi.organization_id
AND sh.created_by = fu.user_id
AND (
sh.s1 = 5
OR sh.s1 = 15)
AND sh.cancelled_flag IS NULL
AND sh.creation_date BETWEEN to_date('&&from_date, 'dd-mon-rr') AND TO_DATE('&&to_date', 'dd-mon-rr') ORDER BY o.organization_code, SUBSTR(msi.segment1, 1, 10), SUBSTR(msi.description, 1, 45), sh.order_number
No comments:
Post a Comment