Need help troubleshooting Report Query/BI Publisher

Hi All --
I need some help with an odd issue I'm having with a report query and BI Publisher. The users run this report by inputting a date range, usually by week. Oddly enough, if we input a date range of 06/01/2008 through 06/07/2008, the report runs and BI Publisher renders the document correctly, but if we input a date range of 06/08/2008 through 06/14/2008, the report shows correctly on the screen, but BI Publisher returns an empty document. I thought perhaps it was an issue with the data, but inputting the date range of 06/01/2008 through 06/14/2008 works correctly and the document is rendered with all the data as shown in the report.
I'm really at a loss and don't know how to proceed in troubleshooting the issue. Does anyone know of any log files or anything else to look at to try and figure out why the report isn't being rendered correctly for that one week?
Thanks!
Leigh Johnson

Thanks Marc --
The OC4J logs don't show any errors at the time I tried running the report. I did change the output format to XML and saved it for the date range that doesn't work as well as a date range that does work. As foar as I can tell, the only differences is the data within the tags, but I'm no XML expert so I may have missed something. I opened my report template and loaded the xml data first from the date range that produces a rendered report properly and used preview...as expected it worked. When I did the same thing for the "bad" date range, I get the following set of errors, should I move my issue to the BI Publisher forum do you think?
ConfFile: C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\Template Builder for Word\config\xdoconfig.xml
Font Dir: C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\Template Builder for Word\fonts
Run XDO Start
Template: D:\BiPublisher\on_time_delivery.rtf
RTFProcessor setLocale: en-us
FOProcessor setData: D:\BiPublisher\ontimedelivery.xml
FOProcessor setLocale: en-us
Output type: MHTML
java.lang.reflect.InvocationTargetException
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
     at java.lang.reflect.Method.invoke(Unknown Source)
     at oracle.apps.xdo.common.xml.XSLT10gR1.invokeProcessXSL(XSLT10gR1.java:721)
     at oracle.apps.xdo.common.xml.XSLT10gR1.transform(XSLT10gR1.java:504)
     at oracle.apps.xdo.common.xml.XSLT10gR1.transform(XSLT10gR1.java:253)
     at oracle.apps.xdo.common.xml.XSLTWrapper.transform(XSLTWrapper.java:181)
     at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:1151)
     at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:275)
     at oracle.apps.xdo.template.FOProcessor.createFO(FOProcessor.java:1809)
     at oracle.apps.xdo.template.FOProcessor.generate(FOProcessor.java:1027)
     at RTF2PDF.runRTFto(RTF2PDF.java:708)
     at RTF2PDF.runXDO(RTF2PDF.java:548)
     at RTF2PDF.main(RTF2PDF.java:305)
Caused by: oracle.xdo.parser.v2.XPathException: An internal error condition occurred.
     at oracle.xdo.parser.v2.XSLStylesheet.flushErrors(XSLStylesheet.java:1534)
     at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:521)
     at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:489)
     at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:271)
     at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:155)
     at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:192)
     ... 15 more

Similar Messages

  • Need help with SQL Query with Inline View + Group by

    Hello Gurus,
    I would really appreciate your time and effort regarding this query. I have the following data set.
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
    1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
    Please Ignore '----', added it for clarity
    I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number. When there are no multiple records I want to display the respective Description.
    The query should return the following data set
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
    The following is my query. I am kind of lost.
    select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    from (
    select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
    from INVOICE
    group by sequence_id,check_date, check_number, invoice_number, vendor_number
    ) A, INVOICE B
    where A.sequence_id = B.sequence_id
    Thanks,
    Nick

    It looks like it is a duplicate thread - correct me if i'm wrong in this case ->
    Need help with SQL Query with Inline View + Group by
    Regards.
    Satyaki De.

  • Need Help on below Query.

    Hi All,
    Need Help on below Query.
    Consider,
    "test9" Table Data in COLUMN "Name" AS
    Name
    =====
    'a'
    'b'
    'c'
    'd'
    'e'
    I am writing a query as :
    SELECT * FROM test9 WHERE Name IN ('a','b','c','d','e','f','g')
    I want result set as , It should show data as -
    'f'
    'g'
    i.e. data which does not exists in the table and which is give in in clause
    Is it possible in a single query.

    You can put the data that is to be checked for into a table instead or an inline view, for example:
    with t as
    (select 'a' as c1 from dual
    union all
    select 'b' from dual
    union all
    select 'c' from dual
    union all
    select 'd' from dual
    union all
    select 'e' from dual)
    select c1 from (select 'a' as c1 from dual
    union all
    select 'b' from dual
    union all
    select 'c' from dual
    union all
    select 'd' from dual
    union all
    select 'e' from dual
    union all
    select 'f' from dual
    union all
    select 'g' from dual)
    minus
    select c1 from t
    C
    f
    g
    2 rows selected.

  • Please, need help with a query

    Hi !
    Please need help with this query:
    Needs to show (in cases of more than 1 loan offer) the latest create_date one time.
    Meaning, In cases the USER_ID, LOAN_ID, CREATE_DATE are the same need to show only the latest, Thanks!!!
    select distinct a.id,
    create_date,
    a.loanid,
    a.rate,
    a.pays,
    a.gracetime,
    a.emailtosend,
    d.first_name,
    d.last_name,
    a.user_id
    from CLAL_LOANCALC_DET a,
    loan_Calculator b,
    bv_user_profile c,
    bv_mr_user_profile d
    where b.loanid = a.loanid
    and c.NET_USER_NO = a.resp_id
    and d.user_id = c.user_id
    and a.is_partner is null
    and a.create_date between
    TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
    TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
    order by a.create_date

    Take a look on the syntax :
    max(...) keep (dense_rank last order by ...)
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions056.htm#i1000901
    Nicolas.

  • Please need help with this query

    Hi !
    Please need help with this query:
    Needs to show (in cases of more than 1 loan offer) the latest create_date one time.
    Meaning, In cases the USER_ID, LOAN_ID, CREATE_DATE are the same need to show only the latest, Thanks!!!
    select distinct a.id,
    create_date,
    a.loanid,
    a.rate,
    a.pays,
    a.gracetime,
    a.emailtosend,
    d.first_name,
    d.last_name,
    a.user_id
    from CLAL_LOANCALC_DET a,
    loan_Calculator b,
    bv_user_profile c,
    bv_mr_user_profile d
    where b.loanid = a.loanid
    and c.NET_USER_NO = a.resp_id
    and d.user_id = c.user_id
    and a.is_partner is null
    and a.create_date between
    TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
    TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
    order by a.create_date

    Perhaps something like this...
    select id, create_date, loanid, rate, pays, gracetime, emailtosend, first_name, last_name, user_id
    from (
          select distinct a.id,
                          create_date,
                          a.loanid,
                          a.rate,
                          a.pays,
                          a.gracetime,
                          a.emailtosend,
                          d.first_name,
                          d.last_name,
                          a.user_id,
                          max(create_date) over (partition by a.user_id, a.loadid) as max_create_date
          from CLAL_LOANCALC_DET a,
               loan_Calculator b,
               bv_user_profile c,
               bv_mr_user_profile d
          where b.loanid = a.loanid
          and   c.NET_USER_NO = a.resp_id
          and   d.user_id = c.user_id
          and   a.is_partner is null
          and   a.create_date between
                TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
                TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
    where create_date = max_create_date
    order by create_date

  • Need help defining a query

    Hi everyone...
    I need help with this query. The table 'cobros' has a primary key defined by id_cliente + id_cobro. I pretend to classify rows by COUNT(id_cobro) which are between a date range.
    A client could have 1 or 2 or 3 rows per day, no more for a specific date. I would like to get first, all clients with COUNT(id_cobro) = 1, all clients with COUNT(id_cobro) = 2, and finally all clients with COUNT(id_cobro) = 3.
    Something similar to:
    1 SELECT id_cliente, COUNT(id_cobro) FROM cobros
    2 WHERE fecha_proximo_cobro >= '2011-05-30 00:00'
    3 AND fecha_proximo_cobro <= '2011-05-30 23:59'
    4 AND COUNT(id_cobro) = 1
    5 GROUP BY id_cliente
    The fourth line is the problem. It doesn't work.
    Thanks in advance!!!
    Mario

    Maybe you are looking for something like this?
    SELECT id_cliente
         , COUNT(*)   AS cnt
    FROM   cobros
    WHERE  fecha_promixo_cobro BETWEEN TO_DATE('2011-05-30 00:00','YYYY-MM-DD HH24:MI') AND TO_DATE('2011-05-30 23:59','YYYY-MM-DD HH24:MI')
    GROUP BY id_cliente
    ORDER BY 2
           , 1Also, NEVER rely on implicit data type conversion as you have (you provide a STRING not a DATE).
    Edited by: Centinul on Jun 2, 2011 12:36 PM
    Fixed syntax error.

  • Complete novice needs help getting SQL Query into Crystal Reports XI

    Post Author: MissMarnie
    CA Forum: Data Connectivity and SQL
    So I was given an intro level web course and a monster reference guide in prep to format a report. One of our developers wrote me everything I need for the report into a SQL Query and now I'm supposed to format it in CR XII literally do not know what to do from here. I'm able to set up the correct server as a datasource, if that's useful, but I don't know how to make the querey into a bunch of formattable fields in  CR. If anyone can walk me through this, I'd be so grateful. I've attempted to look up SQL query in both the help and the book but I keep hitting a wall. The help dialog says things like "press this button" with no reference to what "this button" is. I'm sure it's obvious to the knowledgeable but I'm in a complete fog. Thanks in advance   

    Post Author: synapsevampire
    CA Forum: Data Connectivity and SQL
    IF you're trying to get assistance with setting up a query as the source for a report, try posting your Crystal version and the database type.
    Different software works differently.
    In CR 9 and above, under the connection to the database you'll see Add Command. Select that and you can paste the query in.
    As for not knowing how to generate a report, that requires experience, there's no generic solution of course..
    -k

  • Need to create report query to get latest open and last closed period for given application

    Hi All,
    I need to create a report query to get below result displayed in report output.
    1)   -   Application name
    2)   -    Ledger name
    -o/  -Operating Unit
    3)   -  Last Closed Period
    4)   -  Current Open Period
    5)   -  Date Closed – Last Closed Period
    6)   -  Date Open – Current Open Period
    I tr I tried to create the query below is the same. Please let me know if it looks fine.
    SELECT *
      FROM (SELECT fav.application_name ,
                   hou.name Operating_Unit_Name,
                   gl.name Ledger_name,
                   gl.latest_opened_period_name,
                   gps.period_name Period_Name,
                   DECODE(gps.closing_status, 'O', 'Open', 'C', 'Closed') status,
                   gps.last_update_date Last_status_modified_date
              FROM gl_period_statuses gps,
                   gl_sets_of_books   gsob,
                   fnd_application_vl fav,
                   hr_operating_units hou,
                   gl_ledgers         gl
             WHERE gps.period_name = gps.period_name
               AND gps.closing_status ='C'
               AND fav.application_short_name =
                   NVL('&p_application_short_name', fav.application_short_name)
               AND gps.application_id = fav.application_id
               AND gsob.set_of_books_id = gps.set_of_books_id
               AND hou.set_of_books_id = gps.set_of_books_id
               AND gl.ledger_id = gsob.set_of_books_id
               AND hou.organization_id=NVL('&p_operating_unit',hou.organization_id)
               AND gl.ledger_id=NVL('&p_ledger_id',gl.ledger_id) 
             ORDER BY gps.last_update_date desc )WHERE ROWNUM = 1 
    UNION ALL
    SELECT *
      FROM (SELECT fav.application_name Application_Name,
                   hou.name Operating_Unit_Name,
                   gl.name Ledger_name,
                   gl.latest_opened_period_name,
                   gps.period_name Period_Name,
                   DECODE(gps.closing_status, 'O', 'Open', 'C', 'Closed') status,
                   gps.last_update_date Last_status_modified_date
              FROM gl_period_statuses gps,
                   gl_sets_of_books   gsob,
                   fnd_application_vl fav,
                   hr_operating_units hou,
                   gl_ledgers         gl
             WHERE gps.period_name = gps.period_name
               AND gps.closing_status = 'O'
               AND fav.application_short_name =
                   NVL('&p_application_short_name', fav.application_short_name)
               AND gps.application_id = fav.application_id
               AND gsob.set_of_books_id = gps.set_of_books_id
               AND hou.set_of_books_id = gps.set_of_books_id
               AND gl.ledger_id = gsob.set_of_books_id
               AND hou.organization_id=NVL('&p_operating_unit',hou.organization_id)
               AND gl.ledger_id=NVL('&p_ledger_id',gl.ledger_id) 
             ORDER BY gps.last_update_date desc)
             WHERE ROWNUM = 1

    It is within the table I believe (I'm not a DBA or a developer) since I created a BLOB column and then used the file browse feature to allow users to attach a resume to the table in order to be able to perform a search of the attached documents.
    I'm just having a hard time pointing the link in the search results report to the document in the blob column.
    The information on that page is great if you're trying to create a link to the document on the initial report.
    But I created a query using Oracle Text to run a report that does a boolean search of the attached word documents in the table.
    When it displays the search results, it doesn't create a link to the document and I can't figure out how to do it.
    Here's a link the the instructions I used to create the initial search report with Oracle Text, mind you I only created the index and query, I didn't add in all the link data since they're using documents on websites and I'm using documents in a table.
    http://www.oracle.com/technology/products/database/application_express/pdf/apex_text_application_v1.6.pdf
    If you can help me with this I'd really appreciate it.
    Thanks again.
    Greg
    Edited by: gjones77 on Dec 2, 2008 8:14 AM

  • Recurring problem - need to touch report query to make page to work again

    Hello
    In my APEX 3.0 (Oracle 10.2.0.3.0) application I have a main menu which is a very simple page with one report that selects from a local table (no dblink) what pages the logged user has access to.
    The problem is that now and then (around once a week) users get "page not found" after they log in to the application but before the main menu is displayed. After some testing I found out that, to fix it, I need to touch the report query (let's say, adding an extra space somewhere) and apply changes. After that, the page works fine...
    I have other much more complex pages in the application that don't have such problem.
    Any advice? Where should I start investigating to fix this?
    Thanks
    Luis
    PS: From the error_log file:
    [Mon Aug 20 10:12:54 2007] [error] [client 10.0.10.87] [ecid: 11877561:10.0.24.16:14092:0:37471,0] mod_plsql: /pls/apex/f HTTP-404 ORA-03113: end-of-file o
    n communication channel\n
    [Mon Aug 20 10:12:54 2007] [alert] [client 10.0.10.87] [ecid: 11877561:10.0.24.16:14092:0:37471,0] mod_plsql: Unable to reset state for mode 0: Err 3114 url=>/pls/apex/f

    i have this exact same problem in our production environment
    i really need help to fix it or we'll lose our major client
    they're fed up with it
    anyone?

  • I need help with reporting as soon as possible!

    How can I do reporting in JDeveloper like in Crystal reports. Is there any extention or tool that can be of help.
    Thanks
    Edited by: Fenoch on Mar 12, 2010 6:34 AM
    Edited by: Fenoch on Mar 12, 2010 6:36 AM

    @Fenoch,
    I'm also new to the JDeveloper world and I haven't gotten into reporting yet, but a couple I've heard about are
    Oracle BI Publisher - http://www.oracle.com/technology/products/xml-publisher/index.html
    Jasper Reports - http://www.jaspersoft.com/
    BIRT - http://www.eclipse.org/birt/phoenix/ (more of an eclipse thing I think)
    I hope that helps, I'd like to hear what you find out about any of these.
    Don't let elitist responses run you out of the community.
    @John,
    John Stegeman wrote:
    If you need help as soon as possible, why didn't you try searching the forums?
    JDeveloper doesn't have reporting capability, per se, but there are a number of Java-based reporting tools out there, which you could find [url http://www.lmgtfy.com/?q=java+reports]here
    John
    Way to be an ass to a newbie. It is posts like this (from an Oracle "Ace" Director no less) that push people away from the platform.
    Maybe you could post a link to a reporting tool you know about, instead of sounding off like an elitists jerk and belittling a new guy. I'm sure you popped into the world full of knowledge and ego, never received any help or asked any "newb" questions.
    I also find it very interesting that your "helpful" search link sends us to GOOGLE and not on a search of these forums. Could it be that the forum search is unreliable and returns garbage results most of the time?
    You could have linked a forum search -
    http://forums.oracle.com/forums/search.jspa?objID=f83&q=java+reports (Typical unhelpful results set)
    http://forums.oracle.com/forums/search.jspa?objID=f83&q=reports (Slightly better, at least has a couple posts talking about Jasper)
    Re: Report Facility
    Or if you just gotta use google at least narrow it to the forum you are suggesting we search in -
    http://www.google.com/search?hl=en&as_q=java+reports&as_epq=&as_oq=&as_eq=&num=100&lr=&as_filetype=&ft=i&as_sitesearch=http%3A%2F%2Fforums.oracle.com%2Fforums%2Fforum.jspa%3FforumID%3D83&as_qdr=all&as_rights=&as_occt=any&cr=&as_nlo=&as_nhi=&safe=images
    It is actually the low quality of the forum search tool that forces people to re-post the same questions as others have. I know I do it all the time after I've attempted multiple searches.
    TL;DR version
    Be helpful or be silent.
    Bullying the new people pushes them away and hurts the community. No new people -> no more JDeveloper.

  • Need help with conditional query

    guys this is just an extension of this post that Frank was helping me with. im reposting because my requirements have changes slightly and im having a hell of a time trying to modify the query.
    here is the previous post.
    need help with query that can look data back please help.
    CREATE TABLE "FGL"
        "FGL_GRNT_CODE" VARCHAR2(60),
        "FGL_FUND_CODE" VARCHAR2(60),
        "FGL_ACCT_CODE" VARCHAR2(60),
        "FGL_ORGN_CODE" VARCHAR2(60),
        "FGL_PROG_CODE" VARCHAR2(60),
        "FGL_GRNT_YEAR" VARCHAR2(60),
        "FGL_PERIOD"    VARCHAR2(60),
        "FGL_BUDGET"    VARCHAR2(60)
      )data
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','11','00','400');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','1','100');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','1','0');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','11','1','400');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('360055','360055','7200','4730','02','10','1','400');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('360055','360055','7600','4730','02','10','1','400');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','14','200');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','10','14','100');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','14','200');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','2','100');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','11','2','600');
    I need to find the greatest grant year for the grant by a period parameter.
    once i find the greatest year i need to check the value of period 14 for that grant for the previous year and add it to the budget amount for that grant. however if their is an entry in the greatest year for period 00 then i need to ignore the period 14 of previous year and do this calculation current period +(current period - greatest year 00)
    hope that makes sense so in other words with the new data above. if i was querying period two of grant year 11. i would end up with $800
    because the greatest year is 11 it contains a period 0 with amount of $400 so my total should be
    period 2 amount $ 600
    period 0 amount $ 400 - period 2 amount of $600 = 200
    600+200 = $800
    if i query period 1 of grant 360055 i would just end up with 800 of grnt year 10.
    i have tried to modify that query you supplied to me with no luck. I have tried for several day but im embarrased to say i just can get it to do what im trying to do .
    can you please help me out.
    here is the query supplied by frank kulash who gracefully put this together for me.
    WITH     got_greatest_year     AS
         SELECT     fgl.*     -- or whatever columns are needed
         ,     MAX ( CASE
                     WHEN  fgl_period = :given_period
                     THEN  fgl_grnt_year
                    END
                  ) OVER ()     AS greatest_year
         FROM     fgl
    SELECT     SUM (fgl_budget)     AS total_budget     -- or SELECT *
    FROM     got_greatest_year
    WHERE     (     fgl_grnt_year     = greatest_year
         AND     fgl_period     = :given_period
    OR     (     fgl_grnt_year     = greatest_year - 1
         AND     fgl_period     = 14
    ;Miguel

    Hi, Miguel,
    Are you waying that, when the greatest year that has :given_period also has period='00' (or '0', or whatever you want to use), then you want to double the budget from the given_period (as well as subtract the budget from the '00', and not count the pevious year's '14')? If so, add another condition to the CASE statement which decides what you're SUMming:
    WITH     got_greatest_year     AS
         SELECT       TO_NUMBER (fgl_grnt_year)     AS grnt_year
         ,       fgl_period
         ,       TO_NUMBER (fgl_budget)     AS budget
         ,       MAX ( CASE
                       WHEN  fgl_period = :given_period
                       THEN  TO_NUMBER (fgl_grnt_year)
                      END
                    ) OVER ()     AS greatest_year
         FROM       fgl
    ,     got_cnt_00     AS
         SELECT     grnt_year
         ,     fgl_period
         ,     budget
         ,     greatest_year
         ,     COUNT ( CASE
                       WHEN  grnt_year     = greatest_year
                       AND       fgl_period     = '00'
                       THEN  1
                         END
                    ) OVER ()          AS cnt_00
         FROM    got_greatest_year
    SELECT       SUM ( CASE
                        WHEN  grnt_year     = greatest_year                    -- New
                  AND       fgl_period     = :given_period                    -- New
                  AND       cnt_00     > 0            THEN  budget * 2     -- New
                        WHEN  grnt_year     = greatest_year
                  AND       fgl_period     = :given_period       THEN  budget
                        WHEN  grnt_year     = greatest_year
                  AND       fgl_period     = '00'            THEN -budget
                        WHEN  grnt_year     = greatest_year - 1
                  AND       fgl_period     = '14'     
                  AND       cnt_00     = 0            THEN  budget
                    END
               )          AS total_budget
    FROM       got_cnt_00
    ;You'll notice this is the same as the previous query I posted, except for 3 lines maked "New".

  • Urgent........need help in report

    hi all,
    i need help in a report.
    the requirement is ,
    i need to create a report that will display the SO number in alv grid with check box.
    from the list, if i select the check box, it should
    •     Perform VA02, go to the item detail (Sales) (RECORDING)
    •     Update the SO line item’s Pricing Date to PGI Date
    HOW TO DO THIS.
    PLEASE HELP ME
    •     Interactive Report
    o     Report will generate a list of SO based on selection parameters
    o     User is able to choose all or partial records from the list of SO
    o     For the selected SO, user is able to perform one of the two functions:
    &#61607;     New Pricing based on Batch ID from Production Order
    &#61607;     New Pricing based on PGI Date
    o     The result of the updating is displayed on the screen
    &#61607;     SO updated with success
    &#61607;     SO not updated due to error

    Hi,
    Check this SD MODULE alv intereactive report.
    Hope it may helps u.
    REPORT  YMS_ALVINTER.
    *& tables declaration
    TABLES: VBRK,VBRP.
    *& type-pools declaration
    TYPE-POOLS: SLIS.
    *& data declaration
    DATA: G_REPID TYPE SY-REPID.
    DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV, "mara
    WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
    WA_LAYOUT TYPE SLIS_LAYOUT_ALV,
    WA_EVENT TYPE SLIS_ALV_EVENT,
    T_EVENT TYPE SLIS_T_EVENT.
    DATA: V_VBELN LIKE VBRK-VBELN,
    V_MATNR LIKE VBRP-MATNR.
    DATA: BEGIN OF IT_VBRK OCCURS 0,
    VBELN LIKE VBRK-VBELN,
    WAERK LIKE VBRK-WAERK,
    VKORG LIKE VBRK-VKORG,
    FKDAT LIKE VBRK-FKDAT,
    BUKRS LIKE VBRK-BUKRS,
    NETWR LIKE VBRK-NETWR,
    END OF IT_VBRK.
    DATA: BEGIN OF IT_VBRP OCCURS 0,
    VBELN LIKE VBRP-VBELN,
    POSNR LIKE VBRP-POSNR,
    FKIMG LIKE VBRP-FKIMG,
    VRKME LIKE VBRP-VRKME,
    NETWR LIKE VBRP-NETWR,
    MATNR LIKE VBRP-MATNR,
    ARKTX LIKE VBRP-ARKTX,
    END OF IT_VBRP.
    *& selection screen
    SELECTION-SCREEN BEGIN OF BLOCK B WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS: S_VBELN FOR VBRK-VBELN,
    S_FKDAT FOR VBRK-FKDAT,
    S_MATNR FOR VBRP-MATNR.
    SELECTION-SCREEN END OF BLOCK B.
    **INITIALIZATION.
    INITIALIZATION.
      G_REPID = SY-REPID.
      S_FKDAT-LOW = SY-DATUM - 200.
      S_FKDAT-HIGH = SY-DATUM.
      APPEND S_FKDAT.
    ***AT SELECTION-SCREEN.
    AT SELECTION-SCREEN.
      IF NOT S_VBELN IS INITIAL.
        SELECT SINGLE VBELN FROM VBRK
        INTO V_VBELN
        WHERE VBELN IN S_VBELN.
        IF SY-SUBRC <> 0.
          MESSAGE E001(ZZ2).
        ENDIF.
      ENDIF.
      IF NOT S_MATNR IS INITIAL.
        SELECT SINGLE MATNR FROM MARA
        INTO V_MATNR
        WHERE MATNR IN S_MATNR.
        IF SY-SUBRC <> 0.
          MESSAGE E001(ZZ2).
        ENDIF.
      ENDIF.
    ***START-OF-SELECTION.
    START-OF-SELECTION.
      PERFORM GET_DATA_VBRK.
    *& Form GET_DATA_VBRK
    text
    --> p1 text
    <-- p2 text
    FORM GET_DATA_VBRK .
      SELECT VBELN
      WAERK
      VKORG
      FKDAT
      BUKRS
      NETWR
      INTO TABLE IT_VBRK
      FROM VBRK
      WHERE VBELN IN S_VBELN
      AND FKDAT IN S_FKDAT.
    ENDFORM. " GET_DATA_VBRK
    *& Form GET_DATA_VBRP
    text
    --> p1 text
    <-- p2 text
    FORM GET_DATA_VBRP .
      SELECT VBELN
      POSNR
      FKIMG
      VRKME
      NETWR
      MATNR
      ARKTX
      FROM VBRP
      INTO TABLE IT_VBRP
      WHERE VBELN = IT_VBRK-VBELN.
    ENDFORM. " GET_DATA_VBRP
    ***END-OF-SELECTION.
    END-OF-SELECTION.
      PERFORM EVENT_LIST.
      PERFORM GET_FIELD_CATALOG.
      PERFORM LIST_DISP .
    *&      Form  list_disp
          text
    FORM LIST_DISP .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER = ' '
    I_BUFFER_ACTIVE = ' '
      I_CALLBACK_PROGRAM = G_REPID
    I_CALLBACK_PF_STATUS_SET = 'POPUP'
      I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
    I_CALLBACK_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_END_OF_LIST = ' '
    I_STRUCTURE_NAME =
    I_BACKGROUND_ID = ' '
    I_GRID_TITLE =
    I_GRID_SETTINGS =
    IS_LAYOUT = WA_LAYOUT
      IT_FIELDCAT = IT_FIELDCAT
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
    IT_EVENTS =
    IT_EVENT_EXIT =
    IS_PRINT =
    IS_REPREP_ID =
    I_SCREEN_START_COLUMN = 0
    I_SCREEN_START_LINE = 0
    I_SCREEN_END_COLUMN = 0
    I_SCREEN_END_LINE = 0
    IT_ALV_GRAPHICS =
    IT_HYPERLINK =
    IT_ADD_FIELDCAT =
    IT_EXCEPT_QINFO =
    I_HTML_HEIGHT_TOP =
    I_HTML_HEIGHT_END =
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
      TABLES
      T_OUTTAB = IT_VBRK
      EXCEPTIONS
      PROGRAM_ERROR = 1
      OTHERS = 2
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM. " LIST_DISP
    *& Form GET_FIELD_CATALOG
    text
    --> p1 text
    <-- p2 text
    FORM GET_FIELD_CATALOG .
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
      EXPORTING
      I_PROGRAM_NAME = G_REPID
      I_INTERNAL_TABNAME = 'IT_VBRK'
    I_STRUCTURE_NAME =
    I_CLIENT_NEVER_DISPLAY = 'X'
      I_INCLNAME = G_REPID
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE =
      CHANGING
      CT_FIELDCAT = IT_FIELDCAT
      EXCEPTIONS
      INCONSISTENT_INTERFACE = 1
      PROGRAM_ERROR = 2
      OTHERS = 3
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM. " GET_FIELD_CATALOG
    *& Form event_list
    text
    --> p1 text
    <-- p2 text
    FORM EVENT_LIST .
      CLEAR WA_EVENT.
      WA_EVENT-NAME = 'USER_COMMAND'.
      WA_EVENT-FORM = 'USER_COMMAND'.
      APPEND WA_EVENT TO T_EVENT.
      CLEAR WA_EVENT.
    ENDFORM. " event_list
    *&      Form  user_command
          text
         -->R_UCOMM    text
         -->RS_SELFIELDtext
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
    RS_SELFIELD TYPE SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN '&IC1'.
          READ TABLE IT_VBRK INDEX RS_SELFIELD-TABINDEX.
          PERFORM GET_DATA_VBRP.
          PERFORM BUILD_FIELDCATALOG_VBRP .
          PERFORM DISPLAY_ALV_VBRP.
      ENDCASE.
    ENDFORM.                    "user_command
    *& Form BUILD_FIELDCATALOG_VBRP
    text
    --> p1 text
    <-- p2 text
    FORM BUILD_FIELDCATALOG_VBRP .
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
      EXPORTING
      I_PROGRAM_NAME = G_REPID
      I_INTERNAL_TABNAME = 'IT_VBRP'
    I_STRUCTURE_NAME =
    I_CLIENT_NEVER_DISPLAY = 'X'
      I_INCLNAME = G_REPID
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE =
      CHANGING
      CT_FIELDCAT = IT_FIELDCAT
      EXCEPTIONS
      INCONSISTENT_INTERFACE = 1
      PROGRAM_ERROR = 2
      OTHERS = 3
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM. " BUILD_FIELDCATALOG_VBRP
    *& Form DISPLAY_ALV_VBRP
    text
    --> p1 text
    <-- p2 text
    FORM DISPLAY_ALV_VBRP .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER = ' '
    I_BUFFER_ACTIVE = ' '
      I_CALLBACK_PROGRAM = G_REPID
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = ' '
    I_CALLBACK_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_END_OF_LIST = ' '
    I_STRUCTURE_NAME =
    I_BACKGROUND_ID = ' '
    I_GRID_TITLE =
    I_GRID_SETTINGS =
    IS_LAYOUT =
      IT_FIELDCAT = IT_FIELDCAT
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
    IT_EVENTS =
    IT_EVENT_EXIT =
    IS_PRINT =
    IS_REPREP_ID =
    I_SCREEN_START_COLUMN = 0
    I_SCREEN_START_LINE = 0
    I_SCREEN_END_COLUMN = 0
    I_SCREEN_END_LINE = 0
    IT_ALV_GRAPHICS =
    IT_HYPERLINK =
    IT_ADD_FIELDCAT =
    IT_EXCEPT_QINFO =
    I_HTML_HEIGHT_TOP =
    I_HTML_HEIGHT_END =
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
      TABLES
      T_OUTTAB = IT_VBRP
      EXCEPTIONS
      PROGRAM_ERROR = 1
      OTHERS = 2
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM. " DISPLAY_ALV_VBRP
    Thanks,
    Shankar

  • Need Help - Jasper Report

    i need a report in my application. i was able to make a report using Jasper Report. but i need help on how to connect from SJSC to jasper. how do i call the report created?
    i have read all the post regarding jasper but none give me any idea on how do i call the report from SJSC. help me please!! :-(

    pleeease help me

  • Need help with a query

    Hi,
    I need help with the following query. I want the balance (bal) with the latest exchange rate available.
    Sample table & data
    with
    FX_RATE as
    select 11 as id_date, 1 as id_curr, 47 as EXCH_rate from dual union
    select 12, 1, 48 from dual union
    select 13, 2, 54 from dual union
    select 14, 2, 55 from dual union
    select 15, 3, 56 from dual union
    select 15, 2, 49 from dual),
    TBL_NM as
    select 13 as p_date, 2 as p_curr, 200 as bal from dual union
    select 14, 2, 200 from dual union
    select 15, 2, 200 from dual union
    select 16, 2, 200 from dual union
    select 17, 2, 200 from dual union
    select 11, 5, 100 from dual
    select p_date, p_curr, bal * nvl(exch_rate,1) from TBL_NM T LEFT OUTER JOIN FX_RATE F1 on (id_curr = p_curr and F1.id_date = T.p_Date)In the above query for p_date 16 & 17 and p_curr 2 it returns just balance multiplied by exchange rate 1"default". But i want the balance to have data as per latest exchange rate which is of exchange rate 15.
    I tried this but returns error ORA-01799: a column may not be outer joined to a subquery ..
    with
    FX_RATE as
    select 11 as id_date, 1 as id_curr, 47 as EXCH_rate from dual union
    select 12, 1, 48 from dual union
    select 13, 2, 54 from dual union
    select 14, 2, 55 from dual union
    select 15, 3, 56 from dual union
    select 15, 2, 49 from dual),
    TBL_NM as
    select 13 as p_date, 2 as p_curr, 200 as bal from dual union
    select 14, 2, 200 from dual union
    select 15, 2, 200 from dual union
    select 16, 2, 200 from dual union
    select 17, 2, 200 from dual union
    select 11, 5, 100 from dual
    select p_date, p_curr, bal * nvl(exch_rate,1) from TBL_NM T LEFT OUTER JOIN FX_RATE F1
    on (id_curr = p_curr and F1.id_date = (select max(F2.id_date) from FX_RATE F2 where F2.id_curr = T.p_curr and F2.id_Date <=  T.p_date))Please advice on how i can achieve this ..

    The entire query wud be like this .. I've to incorporate in here
    CREATE MATERIALIZED VIEW MV_DUMMY
    BUILD IMMEDIATE
    REFRESH FORCE ON DEMAND
    AS
        SELECT T.ID_TSACTION_RELEASED                                                                                
        BAL.ID_CONTRACT_BALANCE                                                                                                                                                                                                                                                                           AS ID_CONTRACT_BALANCE,   
        T.N_REFERENCE_NUMBER                                                                                          
        T.INSTRUMENT_N_REFERENCE                                                                                      
        T.ITEM_NUMBER                                                                                                   
        T.EXTERNAL_SYSTEM_ID                                                                                            
        T.SEQUENCE_NUMBER                                                                                               
        T.ID_RELEASED_DATE                                                                                              
       ROUND(BAL.LC_AVAILABLE_BALANCE * NVL(FX1.EXCHANGE_RATE,1) / NVL(FX2.EXCHANGE_RATE,1) , 4)                           
        BAL.LIABILITY_BALANCE                                                                                              
        BAL.LIABILITY_BALANCE * NVL(FX3.EXCHANGE_RATE,1)                                                                   
        BAL.LIABILITY_CHANGE_USD                                                                                           
        BAL.MEMO_LIABILITY_BALANCE                                                                                         
        BAL.MEMO_LIABILITY_BALANCE * NVL(FX3.EXCHANGE_RATE,1)                                                              
        BAL.MEMO_LIABILITY_CHANGE_USD                                                                                      
        BAL.ORIGINAL_FACE_AMOUNT                                                                                           
        decode(T.TENOR_CODE,'Time','T','Sight','S','Split Sight Time','SST','Split Multiple Time','SMT',T.TENOR_CODE)
        CASE
          WHEN GTSPROD.PRODUCT_CATEGORY IN ('ILC','IB','AIR','STG','NLC','NP')
          THEN T.ID_LIABILITY_CIF
          WHEN GTSPROD.PRODUCT_CATEGORY IN ('ELC','EB','XLC','XP','EC','LN','SCF-AR')
          THEN T.Id_Beneficiary
          WHEN GTSPROD.PRODUCT_CATEGORY IN ('TLC','IC','OA','SCF-AP')
          THEN T.ID_Applicant
        END PRIMARY_CUSTOMER_ID,
        CASE
          WHEN GTSPROD.PRODUCT_CATEGORY IN ('ILC','IB','AIR','STG','NLC','NP')
          THEN plbcif.EXTERNAL_SYSTEM_ID
          WHEN GTSPROD.PRODUCT_CATEGORY IN ('ELC','EB','XLC','XP','EC','LN','SCF-AR')
          THEN PBCIF.EXTERNAL_SYSTEM_ID
          WHEN GTSPROD.PRODUCT_CATEGORY IN ('TLC','IC','OA','SCF-AP')
          THEN pappcif.EXTERNAL_SYSTEM_ID
        END PRIMARY_CUSTOMER_EXT_SYS_ID,
        CASE
          WHEN GTSPROD.PRODUCT_CATEGORY IN ('ILC','IB','AIR','STG','NLC','NP')
          THEN plbcif.CIF_NAME
          WHEN GTSPROD.PRODUCT_CATEGORY IN ('ELC','EB','XLC','XP','EC','LN','SCF-AR')
          THEN PBCIF.CIF_NAME
          WHEN GTSPROD.PRODUCT_CATEGORY IN ('TLC','IC','OA','SCF-AP')
          THEN pappcif.CIF_NAME
        END PRIMARY_CUSTOMER_NAME,
        CASE
          WHEN GTSPROD.PRODUCT_CATEGORY IN ('ILC','IB','AIR','STG','NLC','NP')
          THEN plbbac.BAC
          WHEN GTSPROD.PRODUCT_CATEGORY IN ('ELC','EB','XLC','XP','EC','LN','SCF-AR')
          THEN pbbac.BAC
          WHEN GTSPROD.PRODUCT_CATEGORY IN ('TLC','IC','OA','SCF-AP')
          THEN pappbac.BAC
        END PRIMARY_CUST_BAC_CODE,
        CASE
          WHEN GTSPROD.PRODUCT_CATEGORY IN ('ILC','IB','AIR','STG','NLC','NP')
          THEN nvl(plbmg.MARKET,'NOT APPLICABLE')
          WHEN GTSPROD.PRODUCT_CATEGORY IN ('ELC','EB','XLC','XP','EC','LN','SCF-AR')
          THEN nvl(pbmg.MARKET,'NOT APPLICABLE')
          WHEN GTSPROD.PRODUCT_CATEGORY IN ('TLC','IC','OA','SCF-AP')
          THEN nvl(pappmg.MARKET,'NOT APPLICABLE')
        END PRIMARY_CUST_MARKET,
        CASE
          WHEN GTSPROD.PRODUCT_CATEGORY IN ('ILC','IB','AIR','STG','NLC','NP')
          THEN nvl(plbmg.SUB_MARKET,'NOT APPLICABLE')
          WHEN GTSPROD.PRODUCT_CATEGORY IN ('ELC','EB','XLC','XP','EC','LN','SCF-AR')
          THEN nvl(pbmg.SUB_MARKET,'NOT APPLICABLE')
          WHEN GTSPROD.PRODUCT_CATEGORY IN ('TLC','IC','OA','SCF-AP')
          THEN nvl(pappmg.SUB_MARKET,'NOT APPLICABLE')
        END PRIMARY_CUST_SUB_MARKET
      FROM F_TSACTION_RELEASED T
      LEFT OUTER JOIN D_BAC_CODE BAC
      ON (T.BAC_CODE_LIABILITY = BAC.BAC_CODE)
      LEFT OUTER JOIN REF_BAC_SORT_CODE REF_BAC
      ON (T.BAC_CODE_LIABILITY = REF_BAC.BAC)
      LEFT OUTER JOIN F_CONTRACT_BALANCE BAL
      ON (T.ID_TSACTION_RELEASED = BAL.ID_TSACTION_RELEASED)
      LEFT OUTER JOIN D_MARKET_SEGMENT MG
      ON (T.ID_MARKET_SEGMENT = MG.ID_MARKET_SEGMENT)
      LEFT OUTER JOIN D_DATE DT
      ON (DT.ID_DATE = T.ID_RELEASED_DATE)
      LEFT OUTER JOIN D_DATE DB
      ON (DB.ID_DATE = BAL.ID_RELEASED_DATE)
      LEFT OUTER JOIN D_PROCESSING_UNIT PU
      ON (PU.ID_PROCESSING_UNIT = T.ID_PROCESSING_UNIT)
      LEFT OUTER JOIN D_BIR_PRODUCT BIRPROD
      ON (BIRPROD.ID_BIR_PRODUCT=T.ID_BIR_PRODUCT)
      LEFT OUTER JOIN D_GTS_PRODUCT_TYPE GTSPROD
      ON (GTSPROD.ID_GTS_PRODUCT_TYPE= T.ID_GTS_PRODUCT_TYPE)
      LEFT OUTER JOIN D_GTS_TSACTION_TYPE GTST
      ON (GTST.ID_GTS_TSACTION_TYPE = T.ID_GTS_TSACTION_TYPE)
      LEFT OUTER JOIN D_CURRENCY CCYT
      ON (CCYT.ID_CURRENCY = T.ID_TSACTION_CURRENCY)
      LEFT OUTER JOIN d_cif lcif
      ON (lcif.id_cif = T.id_liability_cif)
      LEFT OUTER JOIN d_cif lbcif
      ON (lbcif.id_cif = bal.id_liability_cif)
      LEFT OUTER JOIN d_cif bcif
      ON (bcif.id_cif = T.id_BENEFICIARY)
      LEFT OUTER JOIN d_cif icif
      ON (icif.id_cif = T.id_ISSUING_BANK)
      LEFT OUTER JOIN d_cif acif
      ON (acif.id_cif = T.id_ADVISING_BANK)
      LEFT OUTER JOIN d_cif appcif
      ON (appcif.id_cif = T.id_applicant)
      LEFT OUTER JOIN d_state astate
      ON (astate.id_state = acif.id_state)
      LEFT OUTER JOIN d_state bstate
      ON (bstate.id_state = bcif.id_state)
      LEFT OUTER JOIN d_state lstate
      ON (lstate.id_state = lcif.id_state)
      LEFT OUTER JOIN d_state lbstate
      ON (lbstate.id_state = lbcif.id_state)
      LEFT OUTER JOIN d_state istate
      ON (istate.id_state = icif.id_state)
      LEFT OUTER JOIN d_state appstate
      ON (appstate.id_state = appcif.id_state)
      LEFT OUTER JOIN D_TSACTION_SOURCE TSrc
      ON (T.ID_TSACTION_SOURCE = TSrc.ID_TSACTION_SOURCE)
      LEFT OUTER JOIN D_COUNTRY LCTRY
      ON (LCTRY.ID_COUNTRY = lcif.ID_COUNTRY)
      LEFT OUTER JOIN D_COUNTRY LBCTRY
      ON (LBCTRY.ID_COUNTRY = lbcif.ID_COUNTRY)
      LEFT OUTER JOIN D_COUNTRY BCTRY
      ON (BCTRY.ID_COUNTRY = bcif.ID_COUNTRY)
      LEFT OUTER JOIN D_COUNTRY ICTRY
      ON (ICTRY.ID_COUNTRY = icif.ID_COUNTRY)
      LEFT OUTER JOIN D_COUNTRY ACTRY
      ON (ACTRY.ID_COUNTRY = acif.ID_COUNTRY)
      LEFT OUTER JOIN D_COUNTRY APPCTRY
      ON (APPCTRY.ID_COUNTRY = appcif.ID_COUNTRY)
      LEFT OUTER JOIN D_COUNTRY PCTRY
      ON (PCTRY.ID_COUNTRY = T.ID_PRESENTER_COUNTRY)
      LEFT OUTER JOIN D_LOCATION LOC
      ON (LOC.ID_LOCATION = T.ID_PROCESSING_LOCATION)
      LEFT OUTER JOIN D_CURRENCY BCCYT
      ON (BCCYT.ID_CURRENCY = BAL.ID_LIABILITY_CURRENCY)
      LEFT OUTER JOIN D_CURRENCY BALCYT
      ON (BALCYT.ID_CURRENCY = BAL.ID_BALANCE_CURRENCY)
      LEFT OUTER JOIN d_liability_type li
      ON (li.id_liability_type = BAL.id_liability_type)
      LEFT OUTER JOIN d_cif plbcif
      ON (plbcif.id_cif = T.id_liability_cif)
      LEFT OUTER JOIN REF_BAC_SORT_CODE plbbac
      ON (plbcif.bac_code=plbbac.bac)
      LEFT OUTER JOIN D_MARKET_SEGMENT plbmg
      ON (plbbac.SORT_CODE=plbmg.MARKET_SEGMENT)
      LEFT OUTER JOIN d_cif pbcif
      ON (pbcif.id_cif = T.id_BENEFICIARY)
      LEFT OUTER JOIN REF_BAC_SORT_CODE pbbac
      ON (pbcif.bac_code=pbbac.bac)
      LEFT OUTER JOIN D_MARKET_SEGMENT pbmg
      ON (pbbac.SORT_CODE=pbmg.MARKET_SEGMENT)
      LEFT OUTER JOIN d_cif pappcif
      ON (pappcif.id_cif = T.id_applicant)
      LEFT OUTER JOIN REF_BAC_SORT_CODE pappbac
      ON (pappcif.bac_code=pappbac.bac)
      LEFT OUTER JOIN D_MARKET_SEGMENT pappmg
      ON (pappbac.SORT_CODE=pappmg.MARKET_SEGMENT)
      LEFT OUTER JOIN D_CURRENCY LOCALCYT
      ON (LOCALCYT.alpha_code = PU.local_ccy)
      LEFT OUTER JOIN D_BRANCH Branch              
      ON (T.ID_BRANCH  = Branch.ID_BRANCH )
      LEFT OUTER JOIN F_USD_FX_RATE_HISTORY FX1
      ON (BAL.ID_BALANCE_CURRENCY = FX1.ID_CURRENCY and FX1.ID_DATE = (select max(FX11.ID_DATE) from F_USD_FX_RATE_HISTORY FX11 where BAL.ID_BALANCE_CURRENCY = FX11.ID_CURRENCY and FX11.ID_DATE <= BAL.id_released_date))
      LEFT OUTER JOIN F_USD_FX_RATE_HISTORY FX2
      ON (LOCALCYT.ID_CURRENCY = FX2.ID_CURRENCY and FX2.ID_DATE = (select max(FX22.ID_DATE) from F_USD_FX_RATE_HISTORY FX22 where LOCALCYT.ID_CURRENCY = FX22.ID_CURRENCY and FX22.ID_DATE <= BAL.id_released_date))
      LEFT OUTER JOIN F_USD_FX_RATE_HISTORY FX3
      ON (BAL.ID_LIABILITY_CURRENCY = FX3.ID_CURRENCY and FX3.ID_DATE = (select max(FX33.ID_DATE) from F_USD_FX_RATE_HISTORY FX33 where BAL.ID_LIABILITY_CURRENCY = FX33.ID_CURRENCY and FX33.ID_DATE <= BAL.id_released_date))Note the lines
    ROUND(BAL.MN_AVAILABLE_BALANCE * NVL(FX1.EXCHANGE_RATE,1) / NVL(FX2.EXCHANGE_RATE,1) , 4)                           
    BAL.LIABILITY_BALANCE * NVL(FX3.EXCHANGE_RATE,1)                                                                   
    BAL.MEMO_LIABILITY_BALANCE * NVL(FX3.EXCHANGE_RATE,1)                 
    And
    LEFT OUTER JOIN F_USD_FX_RATE_HISTORY FX1
      ON (BAL.ID_BALANCE_CURRENCY = FX1.ID_CURRENCY and FX1.ID_DATE = (select max(FX11.ID_DATE) from F_USD_FX_RATE_HISTORY FX11 where BAL.ID_BALANCE_CURRENCY = FX11.ID_CURRENCY and FX11.ID_DATE <= BAL.id_released_date))
      LEFT OUTER JOIN F_USD_FX_RATE_HISTORY FX2
      ON (LOCAMNYT.ID_CURRENCY = FX2.ID_CURRENCY and FX2.ID_DATE = (select max(FX22.ID_DATE) from F_USD_FX_RATE_HISTORY FX22 where LOCAMNYT.ID_CURRENCY = FX22.ID_CURRENCY and FX22.ID_DATE <= BAL.id_released_date))
      LEFT OUTER JOIN F_USD_FX_RATE_HISTORY FX3
      ON (BAL.ID_LIABILITY_CURRENCY = FX3.ID_CURRENCY and FX3.ID_DATE = (select max(FX33.ID_DATE) from F_USD_FX_RATE_HISTORY FX33 where BAL.ID_LIABILITY_CURRENCY = FX33.ID_CURRENCY and FX33.ID_DATE <= BAL.id_released_date))Thsi is where I need to incorporate the change

  • Need help with SQL Query

    I am trying to build a query that sums up 12 columns depending on some accounting variables.
    example:
    SELECT gbmcu, gbco, gbfy,'',SUM(gban01 gban02 gban03 gban04 gban05+gban06+gban07+gban08+gban09+gban10+gban11+gban12) AS Oil_Volumes
    FROM PRODDTA.F0902
    WHERE GBCO = '00099'
    AND GBFY = 5
    AND GBLT = 'QU' AND GBOBJ = 5015 AND GBSUB = '105'
    GROUP BY gbmcu, gbco, gbfy
    The condition that changes is :AND GBLT = 'QU' AND GBOBJ = 5015 AND GBSUB = '105'
    I need to do this for 17 different conditions - I need to make the query as optimized as possible.
    I tried using a case statement but that takes forever (the table is over 4 million records to scan through).
    Please let me know if anyone has any suggestions on how to create something to perform these calculations.
    thanks,
    Pam

    I think I would tend to write that query as:
    SELECT gbmcu, gbco, gbfy,
           SUM(CASE WHEN gblt = 'QA' AND gbobj = 5015 AND gbsub = '105' THEN
                    gban01+gban02+gban03+gban04+gban05+gban06+gban07+gban08+gban09+gban10+gban11+gban12 END) Oil_Sales
           SUM(CASE WHEN gblt = 'QU' AND gbobj = 5015 AND gbsub = '105' THEN
                    gban01+gban02+gban03+gban04+gban05+gban06+gban07+gban08+gban09+gban10+gban11+gban12 END) Oil_Volumes
    FROM proddta.f0902
    WHERE gbco = '00099' and
          gbfy = 5 and
          gblt IN ('QA', 'QU') and
          gbpbj = 5015 and
          gbsub = '105'
    GROUP BY gbmcu, gbco, gbfySUM the CASE rather than CASE SUM. Also, as written, your query will look at all of the records in f0902 whether or not they meet one of the Case criteria, so I would put the required values in the WHERE clause as well. Your samples only show gblt changing, so you may need to make the gbpbj and gbsub predicates IN lists as well.
    If the query runs in 1.5 hours calculating one value, I would expect it to be about the same calculating 17 values, since I would bet that most of the run time is accessing the table rather than doing the math. It would almost certainly be faster than running essentially the same query 17 times.
    Indexes on some or all of the columns in the WHERE clause may help, depending on how selective the columns are. At a guess, I would suggest that gbco and gbfy would be good candidates.
    Finally, are you sure that gbsub is a character field? The only example we have is a number.
    HTH
    John

Maybe you are looking for

  • Purchase Price Variation related issue

    Hi Xperts In GRPO and AP Invoice Quantity and Unit Price is same.  In Invoice CST Included CST is Defined as nondeductible 100%. But in Journal Entry Purchase Price Variation is Affected . Please Clarify Me why this was affected in this account Thank

  • .Class file not updating

    Hi all, I am working on an applet that requires the use of a .class file. So, when I make changes to test.java, I want the changes to move over to test.class, however they are not moving over there. In a sense, my .class file is outdated and is not u

  • Unable to update iPhoto 9.2.3

    I recently purchased a Macbook Air 11" (July 2011 model) which came preinstalled with Lion (can't remember the version) and iLife 11. On my first boot I noticed that the Mac App Store popped up a few updates and one of the updates was iPhoto 9.2.3. W

  • How do you stop adjustments to the image when importing pictures?

    When I import pictures into Lightroom 1.1 they all automatically get adjusted to be much brighter. How do I stop this? The DEVELOP SETTINGS DIALOG in the IMPORT PHOTOS pop up box is set to NONE. I don't think it's a color management issue as the imag

  • BI instance question

    Folks, Can we discuss the pros and cons of the below A. Multiple BW instance world wide with a corporate consolidated instance B. 1 single BW instance for world wide operation Can the above be considered independent of ECC instance architecture ?. Th