Wednesday, 27 April 2011

AP-SLA-GL LINK QUERY


AP-SLA-GL QUERY

SELECT
   aia.INVOICE_ID "Invoice Id",
   aia.INVOICE_NUM "Invoice Number",
   aia.INVOICE_DATE "Invoice Date",
   aia.INVOICE_AMOUNT "Amount",
   xal.ENTERED_DR "Entered DR in SLA",
   xal.ENTERED_CR "Entered CR in SLA",
   xal.ACCOUNTED_DR "Accounted DR in SLA",
   xal.ACCOUNTED_CR "Accounted CR in SLA",
      gjh.je_source ,
   gjl.ENTERED_DR "Entered DR in GL",
   gjl.ACCOUNTED_DR "Accounted DR in GL",
   xal.ACCOUNTING_CLASS_CODE "Accounting Class",
   gcc.SEGMENT1||'.'||gcc.SEGMENT2||'.'
       ||gcc.SEGMENT3||'.'||gcc.SEGMENT4||'.'
       ||gcc.SEGMENT5||'.'||gcc.SEGMENT6||'.'
       ||gcc.SEGMENT7 "Code Combination",
   aia.INVOICE_CURRENCY_CODE "Inv Curr Code",
   aia.PAYMENT_CURRENCY_CODE "Pay Curr Code",
   aia.GL_DATE "GL Date",
   xah.PERIOD_NAME "Period",
   aia.PAYMENT_METHOD_CODE "Payment Method",
   aia.VENDOR_ID "Vendor Id",
   aps.VENDOR_NAME "Vendor Name",
   xah.JE_CATEGORY_NAME "JE Category Name"
FROM
   apps.ap_invoices_all aia,
   xla.xla_transaction_entities XTE,
   apps.xla_events xev,
   apps.xla_ae_headers XAH,
   apps.xla_ae_lines XAL,
   apps.GL_IMPORT_REFERENCES gir,
   apps.gl_je_headers gjh,
   apps.gl_je_lines  gjl,
   apps.gl_code_combinations gcc,
   apps.ap_suppliers aps,
   (select aid1.invoice_id,
           pa.project_id,
           nvl(pa.segment1,'NO PROJECT') Project
   from    apps.ap_invoice_distributions_all aid1,
           apps.PA_PROJECTS_ALL pa
   where aid1.rowid in
       (select MAx(rowid)
       from apps.ap_invoice_distributions_all aid2
       where aid1.INvoice_ID=aid2.INvoice_ID
       group by aid1.invoice_id)
   and aid1.project_id=pa.project_id(+)) sql1,
   (select aid1.invoice_id,
           pt.task_id,
           nvl(pt.task_number,'NO TASK') Task
   from    apps.ap_invoice_distributions_all aid1,
           apps.PA_TASKS pt
   where aid1.rowid in
       (select MAx(rowid)
       from apps.ap_invoice_distributions_all aid2
       where aid1.INvoice_ID=aid2.INvoice_ID
       group by aid1.invoice_id)
   and aid1.task_id=pt.task_id(+)) sql2
WHERE
   aia.INVOICE_ID = xte.source_id_int_1
   and aia.INVOICE_ID=sql1.Invoice_ID
   and aia.INVOICE_ID=sql2.Invoice_ID
   and xev.entity_id= xte.entity_id
   and xah.entity_id= xte.entity_id
   and xah.event_id= xev.event_id
   and XAH.ae_header_id = XAL.ae_header_id
  -- and XAH.je_category_name = 'Purchase Invoices'
   and XAH.gl_transfer_status_code= 'Y'
   and XAL.GL_SL_LINK_ID=gir.GL_SL_LINK_ID
   and gir.GL_SL_LINK_TABLE = xal.GL_SL_LINK_TABLE
   and gjl.JE_HEADER_ID=gjh.JE_HEADER_ID
   and gjh.JE_HEADER_ID=gir.JE_HEADER_ID
   and gjl.JE_HEADER_ID=gir.JE_HEADER_ID
   and gir.JE_LINE_NUM=gjl.JE_LINE_NUM
   and gcc.CODE_COMBINATION_ID=XAL.CODE_COMBINATION_ID
   and gcc.CODE_COMBINATION_ID=gjl.CODE_COMBINATION_ID
   and aia.VENDOR_ID=aps.VENDOR_ID
   and gjh.STATUS='P'
   and gjh.Actual_flag='A'
   and gjh.CURRENCY_CODE='USD'
   and aia.Invoice_id=&Invoice_Id;

18 comments:

Unknown said...

Hi Prashant,

My requirement is to get inventory aging report by buckets 31-60 days,61-90....by using transaction date as parameter
I am getting only total data correct remaing buckets data wrong .

can u pls help

Thanks in advance
sunil

Anonymous said...

What's up to all, how is everything, I think every one is getting more from this site, and your views are nice in support of new viewers.

my webpage free wordpress templates

Anonymous said...

Hello! Do you know if they make any plugins to
help with SEO? I'm trying to get my blog to rank for some targeted keywords but I'm not seeing very good gains.
If you know of any please share. Many thanks!

Feel free to surf to my web blog: alli zum abnehmen

Anonymous said...

My brother recommended I would possibly like this blog.
He was totally right. This put up truly made my day. You
cann't believe just how a lot time I had spent for this information! Thank you!

Look at my blog: joomla 1.6

Anonymous said...

This piece of writing is truly a fastidious one it assists new the web
people, who are wishing for blogging.

Also visit my blog wordpress grundlagenkurse
My website - seo wordpress

Anonymous said...

Good response in return of this difficulty with real arguments and describing everything
concerning that.

my website: Deutschland

Anonymous said...

Keep this going please, great job!

Also visit my page Wellness-Massage

Anonymous said...

What i don't understood is in fact how you are no longer really a lot more well-liked than you might be right now. You are so intelligent. You realize thus significantly with regards to this subject, produced me in my opinion believe it from numerous varied angles. Its like women and men aren't interested unless it is one thing to accomplish with Lady gaga!
Your individual stuffs nice. All the time maintain it up!


Feel free to surf to my homepage geld geld

Anonymous said...

Wow, wonderful blog layout! How long have you been blogging for?
you make blogging look easy. The overall look of your
web site is excellent, as well as the content!

Visit my web blog ... arbeit suchen

Anonymous said...

Hey there! Do you know if they make any plugins to safeguard
against hackers? I'm kinda paranoid about losing everything I've worked hard on.
Any recommendations?

Take a look at my web-site ... marketing unternehmensberatung

Anonymous said...

Hello! Someone in my Myspace group shared this website with us so I
came to check it out. I'm definitely enjoying the information. I'm bookmarking and will be tweeting
this to my followers! Superb blog and wonderful style
and design.

my web blog ... wordpress travel themes

Anonymous said...

That is very fascinating, You're an overly skilled blogger. I've joined your feed and look
ahead to searching for extra of your great post.
Additionally, I've shared your website in my social networks

Feel free to surf to my weblog wordpress fortbildung berlin

Anonymous said...

Yes! Finally someone writes about payments.


Also visit my webpage; wordpress requirements
Also see my web page - wordpress seminar

Anonymous said...

I like the valuable info you provide in your articles.
I will bookmark your blog and check again here
frequently. I am quite certain I'll learn lots of new stuff right here! Best of luck for the next!

Also visit my web blog - rezepte für paleo diät

Anonymous said...

Hey very nice blog!

My homepage ... wordpress kommentare abschalten
Also see my webpage :: ebay kunde zahlt nicht

Anonymous said...

Attractive section of content. I just stumbled upon your site and in accession capital to
assert that I get in fact enjoyed account your blog posts.

Any way I'll be subscribing to your feeds and even I achievement you access consistently quickly.

My webpage :: paleo bananen

Anonymous said...

Its like you read my mind! You seem to know a
lot about this, like you wrote the book in it or something.

I think that you could do with some pics to drive the message home a bit, but instead of that,
this is magnificent blog. A fantastic read. I'll definitely be back.

Also visit my site paläodiät

Anonymous said...

It's wonderful that you are getting thoughts from this piece of writing as well as from our dialogue made at this place.

my weblog - low carb bbq sauce
my page: Low Carb Rezepte