Sunday, October 04, 2015

Query for PLA Register in India Localization

SELECT
pl.organization_id,
(select distinct organization_name from org_organization_definitions
where organization_id=pl.organization_id) Org_name,
(select distinct organization_code from org_organization_definitions
where organization_id=pl.organization_id) Org_code,
pl.register_id,
pl.fin_year,
pl.slno,
pl.charge_account_id,
pl.ref_document_id,
trunc(pl.ref_document_date),
nvl(pl.dr_invoice_date,pl.tr6_challan_date) Invoice_Date,
nvl(pl.dr_invoice_no,pl.tr6_challan_no) Invoice_num,
pl.location_id,
trunc(pl.entry_date),
pl.inventory_item_id,
pl.vendor_cust_flag,
pl.vendor_id,
decode (pl.vendor_cust_flag,'C',(select party_name from hz_parties where party_id=
                                (select party_id from hz_cust_accounts where cust_account_id =pl.vendor_id))
                           ,'V',(select vendor_name from po_vendors where vendor_id=pl.vendor_id)) Customer_Vendor_name,
decode (pl.vendor_cust_flag,'C',(select address3 || ' - ' || city from hz_locations where location_id =
                                (select location_id from hz_party_sites  where party_site_id=
                                (select party_site_id from hz_cust_acct_sites_all  where cust_acct_site_id =
                                (select cust_acct_site_id from hz_cust_site_uses_all where site_use_id=14474))))
                           ,'V',(select vendor_site_code || ' - ' || state from ap_supplier_sites_all
                                 where vendor_id=pl.vendor_id
                                 and vendor_site_id=pl.vendor_site_id)) Site_Name,
pl.vendor_site_id,
pl.excise_invoice_no,
trunc(pl.transaction_date),
pl.transaction_source_num,
(pl.cr_basic_ed + pl.cr_other_ed) cr_Bed,
pl.cr_additional_ed,
 (SELECT sum(credit)
                       FROM jai_cmn_rg_others jac                                                
                      WHERE jac.source_register_id = pl.register_id                                                                  
                        AND jac.tax_type in( 'EXCISE_EDUCATION_CESS','CVD_EDUCATION_CESS')
                       ) cr_edu,
(SELECT sum(credit)
              FROM jai_cmn_rg_others jac                                                
             WHERE jac.source_register_id = pl.register_id                                                                  
               AND jac.tax_type in ('EXCISE_SH_EDU_CESS','CVD_SH_EDU_CESS')
                       )   cr_she_cess ,
(pl.dr_basic_ed + dr_other_ed) Dr_Bed,
pl.dr_additional_ed,
 (SELECT sum(debit)
                       FROM jai_cmn_rg_others jac                                                
                      WHERE jac.source_register_id = pl.register_id                                                                  
                        AND jac.tax_type in( 'EXCISE_EDUCATION_CESS','CVD_EDUCATION_CESS')
                       ) dr_edu,
 (SELECT sum(debit)
                       FROM jai_cmn_rg_others jac                                                
                      WHERE jac.source_register_id = pl.register_id                                                                  
                        AND jac.tax_type in ('EXCISE_SH_EDU_CESS','CVD_SH_EDU_CESS')
                       )   dr_she_cess ,
pl.other_tax_credit,
pl.other_tax_debit,
wda.delivery_id,
wda.delivery_detail_id,
wdd.item_description,
(select concatenated_segments from mtl_system_items_kfv
where inventory_item_id=wdd.inventory_item_id
and organization_id=pl.organization_id) item_code,
wdd.shipped_quantity,
wdd.unit_price,
wdd.source_header_number,
wdd.requested_quantity_uom,
 (select distinct doc_sequence_value from  GL_JE_HEADERS
          where je_header_id in  (select distinct je_header_id FROM gl_je_lines
                                  where reference_5=to_char(wda.delivery_id)
                                  and CODE_COMBINATION_ID=pl.CHARGE_ACCOUNT_ID)) GL_DOC_SEQ,
         (select distinct default_effective_date from  GL_JE_HEADERS
          where je_header_id in (select distinct je_header_id FROM gl_je_lines
                                  where reference_5=to_char(wda.delivery_id)
                                  and CODE_COMBINATION_ID=pl.CHARGE_ACCOUNT_ID)) GL_Date
from jai_cmn_rg_pla_trxs pl,
wsh_delivery_assignments wda,
wsh_delivery_details wdd
where  pl.ref_document_id=wda.delivery_detail_id(+)
and wdd.delivery_detail_id(+)=wda.delivery_detail_id
and pl.organization_id =:organizaion_id
and pl.location_id=nvl(:location_id,pl.location_id)
and TRUNC (pl.transaction_date) BETWEEN TRUNC (NVL (TO_DATE (:p_from_date),
                                                       pl.transaction_date
                                                      )
                                                 )
                                       AND TRUNC (NVL (TO_DATE (:p_to_date),
                                                       pl.transaction_date
                                                      ))
ORDER BY pl.slno

No comments:

Post a Comment

Clear BNE Cache for WebADI Changes

It Sometime happens that WebAdi Changes doesn't reflect once migrated in controlled instances. Here are the quick steps(Generally perfor...