Tuesday, 17 July 2018

PLSQL Query for Payables Subledger Account Analysis Report - Oracle EBS R12

https://aporaclepayables.blogspot.com/2018/07/p.html


Subledger Account Analysis Report PLSQL Query for Payables


---Begning Balance 

   select sum(b.ACCOUNTED_DR) , sum(b.ACCOUNTED_CR) ,  sum(b.ACCOUNTED_DR) - sum(b.ACCOUNTED_CR) from xla_ae_headers a, xla_ae_lines b, gl_code_combinations c
    where a.AE_HEADER_ID=b.AE_HEADER_ID
    and a.LEDGER_ID=b.LEDGER_ID
    and a.APPLICATION_ID=b.APPLICATION_ID
    and b.CODE_COMBINATION_ID=c.CODE_COMBINATION_ID
    and a.JE_CATEGORY_NAME in ('Purchase Invoices' , 'Reconciled Payments')
    and a.APPLICATION_ID = 200
    and a.LEDGER_ID = 2031
    and b.ACCOUNTING_DATE < = '30-JUN-2017'
    and c.SEGMENT1 = '02'
    and c.SEGMENT2 = '002'
    and c.SEGMENT3 = '000'
    and c.SEGMENT4 = '248111100'
 

 --Period Debit Credit  ----   Depends on the Accounting date you provide   

    select a.DOC_SEQUENCE_VALUE , a.JE_CATEGORY_NAME , b.ACCOUNTING_DATE, b.ACCOUNTED_DR , b.ACCOUNTED_CR from xla_ae_headers a, xla_ae_lines b, gl_code_combinations c
    where a.AE_HEADER_ID=b.AE_HEADER_ID
    and a.LEDGER_ID=b.LEDGER_ID
    and a.APPLICATION_ID=b.APPLICATION_ID
    and b.CODE_COMBINATION_ID=c.CODE_COMBINATION_ID
    and a.JE_CATEGORY_NAME in ('Purchase Invoices' , 'Reconciled Payments')
    and a.APPLICATION_ID = 200
    and a.LEDGER_ID = 2031
    and b.ACCOUNTING_DATE between '01-JUL-17' and '31-JUL-17'
    and c.SEGMENT1 = '02'
    and c.SEGMENT2 = '002'
    and c.SEGMENT3 = '000'
    and c.SEGMENT4 = '248111100'

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

Summary Report


select    BR.PERIOD_NAME, BEG  , DR , CR  , sum(BEG-CR+DR) END   from  

 
( select  /*a.DOC_SEQUENCE_VALUE DOC1 , a.JE_CATEGORY_NAME  J1, b.ACCOUNTING_DATE A1, */ c.SEGMENT4, c.SEGMENT2,c.SEGMENT1,c.SEGMENT3, a.LEDGER_ID ,sum(b.ACCOUNTED_DR) - sum( b.ACCOUNTED_CR) BEG
from xla_ae_headers a, xla_ae_lines b, gl_code_combinations c
where a.AE_HEADER_ID=b.AE_HEADER_ID
and a.LEDGER_ID=b.LEDGER_ID
and a.APPLICATION_ID=b.APPLICATION_ID
and b.CODE_COMBINATION_ID=c.CODE_COMBINATION_ID
and a.JE_CATEGORY_NAME in ('Purchase Invoices' , 'Reconciled Payments')
and a.APPLICATION_ID = 200
and a.LEDGER_ID = 2031
and b.ACCOUNTING_DATE < = '30-SEP-2017'
and c.SEGMENT1 = '02'
and c.SEGMENT2 = '002'
and c.SEGMENT3 = '000'
and c.SEGMENT4 = '248111100'
group by c.SEGMENT4, c.SEGMENT2,c.SEGMENT1,c.SEGMENT3, a.LEDGER_ID 
)  AR
,
    
( select/* a.DOC_SEQUENCE_VALUE DOC2 , a.JE_CATEGORY_NAME  J2, b.ACCOUNTING_DATE A2,*/ a.PERIOD_NAME,c.SEGMENT4, c.SEGMENT2,c.SEGMENT1,c.SEGMENT3, a.LEDGER_ID ,sum(b.ACCOUNTED_DR) DR , sum( b.ACCOUNTED_CR )  CR 
from xla_ae_headers a, xla_ae_lines b, gl_code_combinations c
where a.AE_HEADER_ID=b.AE_HEADER_ID
and a.LEDGER_ID=b.LEDGER_ID
and a.APPLICATION_ID=b.APPLICATION_ID
and b.CODE_COMBINATION_ID=c.CODE_COMBINATION_ID
and a.JE_CATEGORY_NAME in ('Purchase Invoices' , 'Reconciled Payments')
and a.APPLICATION_ID = 200
and a.LEDGER_ID = 2031
and b.ACCOUNTING_DATE between '01-OCT-17' and '31-OCT-17'
and c.SEGMENT1 = '02'
and c.SEGMENT2 = '002'
and c.SEGMENT3 = '000'
and c.SEGMENT4 = '248111100'
group by a.PERIOD_NAME,c.SEGMENT4, c.SEGMENT2,c.SEGMENT1,c.SEGMENT3, a.LEDGER_ID 
)  BR
where AR.SEGMENT4 = BR.SEGMENT4
and AR.SEGMENT2 = BR.SEGMENT2
and AR.SEGMENT1 = BR.SEGMENT1
and AR.SEGMENT3 = BR.SEGMENT3
and AR.LEDGER_ID = BR.LEDGER_ID
group by  BR.PERIOD_NAME,BEG  , DR , CR 

Monday, 9 July 2018

PLSQL Query for Supplier Exemption Certificate Active/InActive - Oracle EBS R12

https://aporaclepayables.blogspot.com/2018/07/plsql-query-for-supplier-exemption.html

Supplier Exemption Certificate Active/InActive

select

 d.name,
 b.VENDOR_NAME,
 b.VENDOR_ID,
 b.SEGMENT1 "Supplier Number",
 c.VENDOR_SITE_CODE,
 a.TAX_NAME,
 a.CERTIFICATE_NUMBER,
 a.RATE_TYPE,
 a.PRIORITY,
 a.TAX_RATE,
 /* nvl(a.START_DATE,sysdate - 365000) st,
 nvl(a.END_DATE,sysdate + 365000) ed,*/
 case
   when trunc(nvl(a.END_DATE, sysdate + 365000)) < trunc(sysdate) then
    'N'
   when trunc(nvl(a.START_DATE, sysdate - 365000)) > trunc(sysdate) then
    'N'
   else
    'Y'
 end Status,
 to_char(a.START_DATE, 'DD-MON-YYYY') "FROM",
 a.START_DATE,
 to_char(a.END_DATE, 'DD-MON-YYYY') "TO",
 a.END_DATE,
 a.COMMENTS,
 a.ATTRIBUTE1 "Issuing Autority"

  from AP_AWT_TAX_RATES_all  a,
       ap_suppliers          b,
       ap_supplier_sites_all c,
       hr_operating_units    d
 where b.VENDOR_ID = c.VENDOR_ID
   and a.RATE_TYPE = 'CERTIFICATE'
   and b.VENDOR_ID = a.VENDOR_ID
   and a.VENDOR_SITE_ID = c.VENDOR_SITE_ID
   and a.ORG_ID = c.ORG_ID
   and a.ORG_ID = d.organization_id
   and a.ORG_ID = NVL(:P_ORG_ID, a.ORG_ID)
   and b.segment1 = NVL(:SEGMENT1, b.SEGMENT1)
   and c.VENDOR_SITE_CODE = NVL(:VENDOR_SITE_CODE, c.VENDOR_SITE_CODE)
   
      /*
      and ((( nvl(a.START_DATE,sysdate - 365000) between
      to_date(nvl(:P_FROM_DATE,
      to_char(sysdate - 365000, 'DD-MON-YYYY')   ),
      'DD-MON-YYYY') AND
      to_date(nvl(:P_TO_DATE,
      to_char(sysdate + 365000, 'DD-MON-YYYY')),
      'DD-MON-YYYY')) or
      (nvl(a.END_DATE,sysdate + 365000) between
      to_date(nvl(:P_FROM_DATE,
      to_char(sysdate - 365000, 'DD-MON-YYYY')),
      'DD-MON-YYYY') and
      to_date(nvl(:P_TO_DATE,
      to_char(sysdate + 365000, 'DD-MON-YYYY')),
      'DD-MON-YYYY'))) OR
      ((to_date(nvl(:P_FROM_DATE,
      to_char(sysdate - 365000, 'DD-MON-YYYY')),
      'DD-MON-YYYY') between nvl(a.START_DATE,sysdate - 365000) AND nvl(a.END_DATE,sysdate + 365000)) or
      (to_date(nvl(:P_TO_DATE,
      to_char(sysdate + 365000, 'DD-MON-YYYY')),
      'DD-MON-YYYY') between nvl(a.START_DATE,sysdate - 365000) and nvl(a.END_DATE,sysdate + 365000)))) 
      */
   
   and (
     
        ((nvl(a.START_DATE, sysdate - 365000) between
        nvl(:P_FROM_DATE, sysdate - 365000) AND
        nvl(:P_TO_DATE, sysdate + 365000)) or
        (nvl(a.END_DATE, sysdate + 365000) between
        nvl(:P_FROM_DATE, sysdate - 365000) and
        nvl(:P_TO_DATE, sysdate + 365000))) OR
        ((nvl(:P_FROM_DATE, sysdate - 365000) between
        nvl(a.START_DATE, sysdate - 365000) AND
        nvl(a.END_DATE, sysdate + 365000)) or
        (nvl(:P_TO_DATE, sysdate + 365000) between
        nvl(a.START_DATE, sysdate - 365000) and
        nvl(a.END_DATE, sysdate + 365000)))
     
       )
   
   and NVL(case
             when trunc(nvl(a.END_DATE, sysdate + 365000)) < trunc(sysdate) then
              'N'
             when trunc(nvl(a.START_DATE, sysdate - 365000)) > trunc(sysdate) then
              'N'
             else
              'Y'
           end,
           'NA') = NVL(:P_STATUS,
                       NVL(case
                             when trunc(nvl(a.END_DATE, sysdate + 365000)) < trunc(sysdate) then
                              'N'
                             when trunc(nvl(a.START_DATE, sysdate - 365000)) > trunc(sysdate) then
                              'N'
                             else
                              'Y'
                           end,
                           'NA'))
--  and a.START_DATE is null

 order by a.ORG_ID, b.VENDOR_NAME, c.VENDOR_SITE_CODE, a.START_DATE