18
Query to find GL to AR Receiving Transactions  Query to find GL to AR Receiving Transactions. ----------------------------------------------------------------------------- -- -- Query to find GL to AR Receiving Transactions ----------------------------------------------------------------------------- -- SELECT b.NAME je_batch_name,  b.description je_batch_description,  b.running_total_accounted_dr je_batch_total_dr,  b.running_total_accounted_cr je_batch_total_cr,  b.status je_batch_status,  b.default_effective_date je_batch_effective_date,  b.default_period_name je_batch_period_name,  b.creation_date je_batch_creation_date,  u.user_name je_batch_created_by,  h.je_category je_header_category, h.je_source je_header_source,  h.period_name je_header_period_name,  h.NAME je_header_journal_name,  h.status je_header_journal_status,  h.creation_date je_header_created_date,  u1.user_name je_header_created_by,  h.description je_header_description,  h.running_total_accounted_dr je_header_total_acctd_dr,  

Very Impotant Queries

Embed Size (px)

Citation preview

7/22/2019 Very Impotant Queries

http://slidepdf.com/reader/full/very-impotant-queries 1/18

Query to find GL to AR Receiving

Transactions 

Query to find GL to AR Receiving Transactions.

-----------------------------------------------------------------------------

-- 

-- Query to find GL to AR Receiving Transactions 

-----------------------------------------------------------------------------

-- 

SELECT 

b.NAME je_batch_name, 

b.description je_batch_description, 

b.running_total_accounted_dr je_batch_total_dr, 

b.running_total_accounted_cr je_batch_total_cr, 

b.status je_batch_status, 

b.default_effective_date je_batch_effective_date, 

b.default_period_name je_batch_period_name, 

b.creation_date je_batch_creation_date, 

u.user_name je_batch_created_by, 

h.je_category je_header_category, 

h.je_source je_header_source, 

h.period_name je_header_period_name, 

h.NAME je_header_journal_name, 

h.status je_header_journal_status, 

h.creation_date je_header_created_date, 

u1.user_name je_header_created_by, 

h.description je_header_description, 

h.running_total_accounted_dr je_header_total_acctd_dr, 

7/22/2019 Very Impotant Queries

http://slidepdf.com/reader/full/very-impotant-queries 2/18

h.running_total_accounted_cr je_header_total_acctd_cr, 

l.je_line_num je_lines_line_number, 

l.ledger_id je_lines_ledger_id, 

glcc.concatenated_segments je_lines_ACCOUNT, 

l.entered_dr je_lines_entered_dr, 

l.entered_cr je_lines_entered_cr, 

l.accounted_dr je_lines_accounted_dr, 

l.accounted_cr je_lines_accounted_cr, 

l.description je_lines_description, 

glcc1.concatenated_segments xla_lines_account, 

xlal.accounting_class_code xla_lines_acct_class_code, 

xlal.accounted_dr xla_lines_accounted_dr, 

xlal.accounted_cr xla_lines_accounted_cr, 

xlal.description xla_lines_description, 

xlal.accounting_date xla_lines_accounting_date, 

xlate.entity_code xla_trx_entity_code, 

xlate.source_id_int_1 xla_trx_source_id_int_1, 

xlate.source_id_int_2 xla_trx_source_id_int_2, 

xlate.source_id_int_3 xla_trx_source_id_int_3, 

xlate.security_id_int_1 xla_trx_security_id_int_1, 

xlate.security_id_int_2 xla_trx_security_id_int_2, 

xlate.transaction_number xla_trx_transaction_number, 

rcvt.transaction_type rcv_trx_transaction_type, 

rcvt.transaction_date rcv_trx_transaction_date, 

rcvt.quantity rcv_trx_quantity, 

rcvt.shipment_header_id rcv_trx_shipment_header_id, 

rcvt.shipment_line_id rcv_trx_shipment_line_id, 

rcvt.destination_type_code rcv_trx_destination_type_code, 

7/22/2019 Very Impotant Queries

http://slidepdf.com/reader/full/very-impotant-queries 3/18

rcvt.po_header_id rcv_trx_po_header_id, 

rcvt.po_line_id rcv_trx_po_line_id, 

rcvt.po_line_location_id rcv_trx_po_line_location_id, 

rcvt.po_distribution_id rcv_trx_po_distribution_id, 

rcvt.vendor_id rcv_trx_vendor_id, 

rcvt.vendor_site_id rcv_trx_vendor_site_id 

FROM 

gl_je_batches b, 

gl_je_headers h, 

gl_je_lines l, 

fnd_user u, 

fnd_user u1, 

gl_code_combinations_kfv glcc, 

gl_code_combinations_kfv glcc1, 

gl_import_references gir, 

xla_ae_lines xlal, 

xla_ae_headers xlah, 

xla_events xlae, 

xla.xla_transaction_entities xlate, 

rcv_transactions rcvt 

WHERE 

1=1 

AND b.created_by = u.user_id 

AND h.created_by = u1.user_id 

AND b.je_batch_id = h.je_batch_id 

AND h.je_header_id = l.je_header_id 

AND l.code_combination_id = glcc.code_combination_id  

AND l.je_header_id = gir.je_header_id 

7/22/2019 Very Impotant Queries

http://slidepdf.com/reader/full/very-impotant-queries 4/18

  AND l.je_line_num = gir.je_line_num 

AND gir.gl_sl_link_table = xlal.gl_sl_link_table 

AND gir.gl_sl_link_id = xlal.gl_sl_link_id 

AND xlal.application_id = xlah.application_id 

AND xlal.ae_header_id = xlah.ae_header_id 

AND xlal.code_combination_id = glcc1.code_combination_id 

AND xlah.application_id = xlae.application_id 

AND xlah.event_id = xlae.event_id 

AND xlae.application_id = xlate.application_id 

AND xlae.entity_id = xlate.entity_id 

AND xlate.source_id_int_1 = rcvt.transaction_id 

AND h.je_category = 'Receiving' 

AND b.default_period_name = 'DEC-12' 

ORDER BY h.je_category; 

  Query to find GL Period-wise Transaction

Summary 

Query to find GL Period-wise Transaction Summary.

------------------------------------------------------------------------------- 

-- Query to find GL Period-wise Transaction Summary  

-----------------------------------------------------------------------------

-- 

SELECT 

7/22/2019 Very Impotant Queries

http://slidepdf.com/reader/full/very-impotant-queries 5/18

b.name batch_name, 

b.description batch_description, 

b.running_total_accounted_dr batch_total_dr, 

b.running_total_accounted_cr batch_total_cr, 

b.status batch_status, 

b.default_effective_date effective_date, 

b.default_period_name batch_period_name, 

b.creation_date, 

u.user_name batch_created_by, 

h.je_category, 

h.je_source, 

h.period_name je_period_name, 

h.name journal_name, 

h.status journal_status, 

h.creation_date je_created_date, 

u1.user_name je_created_by, 

h.description je_description, 

h.running_total_accounted_dr je_total_dr, 

h.running_total_accounted_cr je_total_cr, 

l.je_line_num line_number, 

l.ledger_id, 

glcc.concatenated_segments account, 

l.entered_dr, 

l.entered_cr, 

l.accounted_dr, 

l.accounted_cr, 

xlal.unrounded_accounted_dr xla_unrounded_accounted_dr, 

xlal.unrounded_accounted_cr xla_unrounded_accounted_cr, 

7/22/2019 Very Impotant Queries

http://slidepdf.com/reader/full/very-impotant-queries 6/18

l.description, 

xlal.code_combination_id, 

xlal.accounting_class_code,  

xlal.accounted_dr xlal_accounted_dr, 

xlal.accounted_cr xlal_accounted_cr, 

xlal.description xlal_description, 

xlal.accounting_date xlal_accounting_date, 

xlate.entity_code xlate_entity_code, 

xlate.source_id_int_1 xlate_source_id_int_1, 

xlate.source_id_int_2 xlate_source_id_int_2, 

xlate.source_id_int_3 xlate_source_id_int_3, 

xlate.security_id_int_1 xlate_security_id_int_1, 

xlate.security_id_int_2 xlate_security_id_int_2, 

xlate.transaction_number xlate_transaction_number 

FROM 

gl_je_batches b, 

gl_je_headers h, 

gl_je_lines l, 

fnd_user u, 

fnd_user u1, 

gl_code_combinations_kfv glcc, 

gl_import_references gir, 

xla_ae_lines xlal, 

xla_ae_headers xlah, 

xla_events xlae, 

xla.xla_transaction_entities xlate 

WHERE 

1=1 

AND b.created_by = u.user_id 

7/22/2019 Very Impotant Queries

http://slidepdf.com/reader/full/very-impotant-queries 7/18

  AND h.created_by = u1.user_id 

AND b.je_batch_id = h.je_batch_id 

AND h.je_header_id = l.je_header_id 

AND xlal.code_combination_id = glcc.code_combination_id 

AND l.je_header_id = gir.je_header_id 

AND l.je_line_num = gir.je_line_num 

AND gir.gl_sl_link_table = xlal.gl_sl_link_table 

AND gir.gl_sl_link_id = xlal.gl_sl_link_id 

AND xlal.ae_header_id = xlah.ae_header_id 

AND xlah.event_id = xlae.event_id 

AND xlae.entity_id = xlate.entity_id 

AND xlae.application_id = xlate.application_id 

-- AND XLATE.SOURCE_ID_INT_1 = RCVT.TRANSACTION_ID  

AND h.je_source = 'Receivables' 

AND h.period_name = 'NOV-12' --'&PERIOD_NAME' 

Query to find Bank information 

Bank, Bank Account, and Bank Branches information from R12.

-----------------------------------------------------------------------------

-- 

-- Query to find Bank, Bank Account, and Bank Branches information 

-----------------------------------------------------------------------------

-- 

7/22/2019 Very Impotant Queries

http://slidepdf.com/reader/full/very-impotant-queries 8/18

SELECT cba.bank_account_name "Bank Account Name", 

cba.bank_account_num "Bank Account Number", 

cba.multi_currency_allowed_flag "Multi Currency Flag", 

cba.zero_amount_allowed "Zero Amount Flag", 

cba.account_classification "Account Classification", 

bb.bank_name "Bank Name", 

bb.bank_branch_type "Bank Branch Type", 

bb.bank_branch_name "Bank Branch Name", 

bb.bank_branch_number "Bank Branch Number", 

bb.eft_swift_code "Swift Code", 

-- bb.description "Description", 

ou.name "Operating Unit", 

gcf.concatenated_segments "GL Code Combination" 

FROM ce_bank_accounts cba, 

ce_bank_acct_uses_all bau, 

cefv_bank_branches bb, 

hr_operating_units ou, 

gl_code_combinations_kfv gcf 

WHERE cba.bank_account_id = bau.bank_account_id 

AND cba.bank_branch_id = bb.bank_branch_id 

AND ou.organization_id = bau.org_id 

AND cba.asset_code_combination_id = gcf.code_combination_id 

AND (cba.end_date IS NULL OR cba.end_date > TRUNC(SYSDATE)) 

ORDER BY TO_NUMBER(cba.bank_account_num);  

7/22/2019 Very Impotant Queries

http://slidepdf.com/reader/full/very-impotant-queries 9/18

Query to list Customer (Party), Account, Site

data 

As my client was going through its customer related data clean up in its Oracle R12 applications, I wrote

the following query to retrieve all the information that were needed to provide a list of its customer

(party), account, site, address, collector, and other related information.

--

=============================================================================  

-- Filename : Customer Data Query  

-- Programmer : Abul Mohsin 

-- Date : 29-Oct-2012 

-- Language : SQL 

-- Module : AR 

-- Purpose : Lists Customer (Party), Customer Account, and Customer Site

-- related information. 

--

=============================================================================  

SELECT 

----------------------------------------------------------  

-- Party Information 

----------------------------------------------------------  

hp.party_number "Registry ID", 

hp.party_name "Party Name", 

hp.party_type "Party Type", 

DECODE(hp.status, 

'A', 'Active', 

'I', 'Inactive', 

hp.status) "Party Status", 

----------------------------------------------------------  

7/22/2019 Very Impotant Queries

http://slidepdf.com/reader/full/very-impotant-queries 10/18

  -- Account Information 

----------------------------------------------------------  

hca.account_number "Account Number", 

DECODE(hca.status, 

'A', 'Active', 

'I', 'Inactive', 

hca.status) "Account Status", 

hca.account_name "Account Description", 

hca.customer_class_code "Classification", 

DECODE(hca.customer_type, 

'R', 'External', 

'I', 'Internal', 

hca.customer_type) "Account Type", 

----------------------------------------------------------  

-- Site Information 

----------------------------------------------------------  

hps.party_site_number "Customer Site Number", 

DECODE(hcas.status,

'A', 'Active',

'Inactive') "Site Status", 

DECODE(hcas.bill_to_flag, 

'P', 'Primary', 

'Y', 'Yes', 

hcas.bill_to_flag) "Bill To Flag", 

DECODE(hcas.ship_to_flag, 

'P', 'Primary', 

'Y', 'Yes', 

hcas.ship_to_flag) "Ship To Flag", 

7/22/2019 Very Impotant Queries

http://slidepdf.com/reader/full/very-impotant-queries 11/18

hcas.cust_acct_site_id "Customer Acct Site ID", 

----------------------------------------------------------  

-- Address Information 

----------------------------------------------------------  

hl.address1 "Address1", 

hl.address2 "Address2", 

hl.address3 "Address3", 

hl.address4 "Address4", 

hl.city "City", 

hl.state "State", 

hl.postal_code "Zip Code", 

ter.name "Territory", 

----------------------------------------------------------  

-- DFF Information (specific to client) 

----------------------------------------------------------  

hcas.attribute4 "SMG Key", 

hcas.attribute8 "GLN Key", 

hca.attribute3 "Credit Approval Date", 

hca.attribute7 "Credit Approved By", 

hca.attribute4 "Acct Opened Date", 

hca.attribute5 "Credit Collection Status", 

hca.attribute1 "BPCS Last Trx Date", 

hca.attribute2 "BPCS Avg Pay Days", 

hca.attribute6 "BPCS RCM Reference", 

----------------------------------------------------------  

-- Collector Information 

----------------------------------------------------------  

col.name "Collector Name", 

7/22/2019 Very Impotant Queries

http://slidepdf.com/reader/full/very-impotant-queries 12/18

  ----------------------------------------------------------  

-- Account Profile Information 

----------------------------------------------------------  

hcp.credit_checking "Credit Check Flag", 

hcp.credit_hold "Credit Hold Flag", 

hcpa.auto_rec_min_receipt_amount "Min Receipt Amount", 

hcpa.overall_credit_limit "Credit Limit", 

hcpa.trx_credit_limit "Order Credit Limit", 

----------------------------------------------------------  

-- Attachment Flag  

----------------------------------------------------------  

NVL((SELECT 'Y' 

FROM fnd_documents_vl doc,

fnd_lobs blo,

fnd_attached_documents att 

WHERE doc.media_id = blo.file_id 

AND doc.document_id = att.document_id 

AND att.entity_name = 'AR_CUSTOMERS' 

AND att.pk1_value = hca.cust_account_id 

AND ROWNUM = 1), 'N' 

) "Attachment Flag", 

----------------------------------------------------------  

-- Party Relationship Flag  

----------------------------------------------------------  

NVL((SELECT 'Y' 

FROM hz_cust_acct_relate_all hzcar 

WHERE hzcar.cust_account_id = hca.cust_account_id 

AND hzcar.relationship_type = 'ALL' 

7/22/2019 Very Impotant Queries

http://slidepdf.com/reader/full/very-impotant-queries 13/18

  AND ROWNUM = 1), 'N' 

) "Party Relationship Flag", 

----------------------------------------------------------  

-- Account Relationship Flag  

----------------------------------------------------------  

NVL((SELECT 'Y' 

FROM hz_cust_acct_relate_all hzcar 

WHERE hzcar.cust_account_id = hca.cust_account_id 

AND ROWNUM = 1), 'N' 

) "Account Relationship Flag", 

----------------------------------------------------------  

-- Party Contact Flag  

----------------------------------------------------------  

NVL((SELECT 'Y' 

FROM hz_parties hp2 

WHERE 1=1 

AND hp2.party_id = hp.party_id 

AND ( 

hp2.url IS NOT NULL OR 

-- LENGTH(TRIM(hp.email_address)) > 5 

INSTR(hp2.email_address, '@') > 0 OR 

hp2.primary_phone_purpose IS NOT NULL 

), 'N' 

) "Party Contact Flag", 

----------------------------------------------------------  

-- Account Contact Flag  

----------------------------------------------------------  

7/22/2019 Very Impotant Queries

http://slidepdf.com/reader/full/very-impotant-queries 14/18

  NVL((SELECT 'Y' 

FROM hz_contact_points 

WHERE status = 'A' 

AND owner_table_id = 

(SELECT hcar.party_id 

FROM hz_cust_account_roles hcar,

ar_contacts_v acv 

WHERE hcar.cust_account_id = hca.cust_account_id 

AND hcar.cust_account_role_id = acv.contact_id

AND hcar.cust_acct_site_id IS NULL  -- look for 

account level only  

AND ROWNUM = 1 -- add this row to show inactive sites

(i.e. with no site id) 

AND ROWNUM = 1), 'N' 

) "Account Contact Flag", 

----------------------------------------------------------  

-- Site Contact Flag  

----------------------------------------------------------  

NVL((SELECT 'Y' 

FROM hz_contact_points 

WHERE status = 'A' 

AND owner_table_id = 

SELECT hcar.party_id 

FROM hz_cust_account_roles hcar, 

ar_contacts_v acv 

WHERE 

hcar.cust_acct_site_id = hcas.cust_acct_site_id 

7/22/2019 Very Impotant Queries

http://slidepdf.com/reader/full/very-impotant-queries 15/18

  AND hcar.cust_account_role_id = acv.contact_id 

AND ROWNUM = 1  -- add this row to show inactive

sites (i.e. with no site id) 

AND ROWNUM = 1), 'N'  -- any contact (email, phone, fax)

would suffice this condition 

) "Site Contact Flag" 

FROM 

hz_parties hp, 

hz_party_sites hps, 

hz_cust_accounts_all hca, 

hz_cust_acct_sites_all hcas, 

hz_customer_profiles hcp, 

hz_cust_profile_amts hcpa, 

hz_locations hl, 

ra_territories ter, 

ar_collectors col 

WHERE 

1=1 

AND hp.party_id = hca.party_id 

AND hca.cust_account_id = hcas.cust_account_id(+) 

AND hps.party_site_id(+) = hcas.party_site_id 

AND hp.party_id = hcp.party_id

AND hca.cust_account_id = hcp.cust_account_id 

AND hps.location_id = hl.location_id(+) 

AND col.collector_id = hcp.collector_id 

AND hcas.territory_id = ter.territory_id(+) 

AND hcp.cust_account_profile_id = hcpa.cust_account_profile_id 

---- 

7/22/2019 Very Impotant Queries

http://slidepdf.com/reader/full/very-impotant-queries 16/18

  AND hp.party_type = 'ORGANIZATION'  -- only ORGANIZATION Party 

types 

AND hp.status = 'A'  -- only Active

Parties/Customers 

---- 

-- following conditions are for testing purpose only  

-- comment/uncomment as needed  

---- 

-- AND hp.party_number = 11530 

-- AND hca.account_number = 32253 --32396 --31753 --32253 --31038 

ORDER BY TO_NUMBER(hp.party_number), hp.party_name, hca.account_number; 

Query to find Request Group for concurrent

program 

Following query finds the associated request group and the application module name (Payables,

Receivables, etc.) for a concurrent program.

In this example, I used "TAMS Send Email Process (UNIGROUP)" as concurrent program name. With a

little modification to the query, you should be able to find concurrent request set name also.

-----------------------------------------------------------------------------

-- 

-- Query to find request group and application name for a concurrent program 

-----------------------------------------------------------------------------

-- 

SELECT cpt.user_concurrent_program_name "Concurrent Program Name", 

7/22/2019 Very Impotant Queries

http://slidepdf.com/reader/full/very-impotant-queries 17/18

  DECODE(rgu.request_unit_type, 

'P', 'Program', 

'S', 'Set', 

rgu.request_unit_type) "Unit Type", 

cp.concurrent_program_name "Concurrent Program Short Name", 

rg.application_id "Application ID", 

rg.request_group_name "Request Group Name", 

fat.application_name "Application Name", 

fa.application_short_name "Application Short Name", 

fa.basepath "Basepath" 

FROM  fnd_request_groups rg, 

fnd_request_group_units rgu, 

fnd_concurrent_programs cp, 

fnd_concurrent_programs_tl cpt, 

fnd_application fa, 

fnd_application_tl fat 

 WHERE rg.request_group_id = rgu.request_group_id 

 AND rgu.request_unit_id = cp.concurrent_program_id  

 AND cp.concurrent_program_id = cpt.concurrent_program_id 

 AND rg.application_id = fat.application_id 

 AND fa.application_id = fat.application_id 

 AND cpt.language = USERENV ('LANG') 

 AND fat.language = USERENV ('LANG') 

 ANDcpt.user_concurrent_program_name = 'TAMS Send Email Process

(UNIGROUP)'; 

7/22/2019 Very Impotant Queries

http://slidepdf.com/reader/full/very-impotant-queries 18/18