Query problem  in viewobject wizard

I have problem to viewobject creation
In the sql Query of viewobject wizard, I can not use build-in sql function like trunc, nvl to the attribute
if I use function, there is no problem with query test(query is valid). However when I click ok or apply button
it popup message like this:
"the following attributes will be set as transients. Derived expression will be lost"
Does this mean I can not use any build-in fuction in select list in view obect wizard?
Another question is how can I nest sql in the select list?
for instance:
in my select list in Query(viewobject wizard)
I have Query:
select Customer.CUSTOMER_ID,
Customer.BANK_NUMBER,
Customer.TRANS_AMOUNT,
from CUSTOMER Customer
where Customer.CUSTOMER_ID =:0
it works without problem
But if add nested select query:
select Customer.CUSTOMER_ID,
Customer.BANK_NUMBER,
(select sum(c.TRANS_AMOUNT)
from CUSTOMER c
where......
) as "Amount"
Account.FILE_NAME,
from CUSTOMER Customer, ACCOUNT Account
where Customer.CUSTOMER_ID =:0
It did not work.
Can somebody tell me how to solve this problem?
Or is there another way to achieve this?
thanks

sory i wrote the wrong one
function CF_ITEMFormula return number is
v_item number(30);
begin
IF :P_state  ALL then
        IF :P_STATE = 'SMALL' THEN
        SELECT aa.item
        INTO v_item
        FROM tableA aa,
                 tableb bb
        WHERE aa.code = bb.code
        AND aa.date = :P_date
        AND aa.name = :P_name
        AND bb.state LIKE '%et%''
        AND (case :P_DIV
                when ('west') then aa.division = 1
                when ('east') then aa.division = 2
                when ('south') then aa.division = 3
                when ('south & west) then aa.division in (1,3)
                else aa.division in (1,2,3)
                end);
        end if;
       IF :P_STATE = 'BIG' THEN
        SELECT aa.item
        INTO v_item
        FROM tableA aa,
                 tableb bb
        WHERE aa.code = bb.code
        AND aa.date = :P_date
        AND aa.name = :P_name
        AND bb.state LIKE '%wa%''
        AND (case :P_DIV
                when ('west') then aa.division = 1
                when ('east') then aa.division = 2
                when ('south') then aa.division = 3
                when ('south & west) then aa.division in (1,3)
                else aa.division in (1,2,3)
                end);
        end if;
end if;
EXCEPTION
WHEN NO_DATA_FOUND THEN RETURN (0)
end;

Similar Messages

  • Problem using ViewObject with bc4j:table

    Hello !!
    This is the query of my ViewObject:
    select * from speiseplan order by jahr desc, kw desc;
    and everything works fine in the BC4J tester:
    jahr kw
    2003 52
    2003 7
    2003 3
    2002 51
    But in my uix page the rows are not correctly sorted:
    jahr kw
    2003 3
    2003 7
    2003 52
    2002 51
    What's going wrong here?
    Thanks for your help.
    Regards,
    Mareike

    Duplicate post.
    Original problem using ViewObject with <bc4j:table>

  • Designing LOV Query Problem

    Hello APEX people,
    I posted my problem here:
    Designing LOV Query Problem
    What I have is a sequence like this:
    CREATE SEQUENCE
    DR_SEQ_FIRST_SCHEDULE_GROUP
    MINVALUE 1 MAXVALUE 7 INCREMENT BY 1 START WITH 1
    CACHE 6 ORDER CYCLE ;
    What I need would be a SQL query returning all possible values oft my sequence like:
    1
    2
    3
    4
    5
    6
    7
    I want to use it as a source for a LOV...
    The reason why I use the cycling sequence is: My app uses it to cycle scheduling priorities every month to groups identified by this number (1-7).
    In the Admin Form, I want to restrict the assignment in a user friendly way - a LOV.
    Thanks
    Johann

    Here ist the solution (posted by michales in the PL/SQL forum):
    SQL> CREATE SEQUENCE
    dr_seq_first_schedule_group
    MINVALUE 1 MAXVALUE 7 INCREMENT BY 1 START WITH 1
    CACHE 6 ORDER CYCLE
    Sequence created.
    SQL> SELECT LEVEL sn
    FROM DUAL
    CONNECT BY LEVEL <= (SELECT max_value
    FROM user_sequences
    WHERE sequence_name = 'DR_SEQ_FIRST_SCHEDULE_GROUP')
    SN
    1
    2
    3
    4
    5
    6
    7
    7 rows selected.

  • SQL+-MULTI TABLE QUERY PROBLEM

    HAI ALL,
    ANY SUGGESTION PLEASE?
    SUB: SQL+-MULTI TABLE QUERY PROBLEM
    SQL+ QUERY GIVEN:
    SELECT PATIENT_NUM, PATIENT_NAME, HMTLY_TEST_NAME, HMTLY_RBC_VALUE,
    HMTLY_RBC_NORMAL_VALUE, DLC_TEST_NAME, DLC_POLYMORPHS_VALUE,
    DLC_POLYMORPHS_NORMAL_VALUE FROM PATIENTS_MASTER1, HAEMATOLOGY1,
    DIFFERENTIAL_LEUCOCYTE_COUNT1
    WHERE PATIENT_NUM = HMTLY_PATIENT_NUM AND PATIENT_NUM = DLC_PATIENT_NUM AND PATIENT_NUM
    = &PATIENT_NUM;
    RESULT GOT:
    &PATIENT_NUM =1
    no rows selected
    &PATIENT_NUM=2
    no rows selected
    &PATIENT_NUM=3
    PATIENT_NUM 3
    PATIENT_NAME KKKK
    HMTLY_TEST_NAME HAEMATOLOGY
    HMTLY_RBC_VALUE 4
    HMTLY_RBC_NORMAL 4.6-6.0
    DLC_TEST_NAME DIFFERENTIAL LEUCOCYTE COUNT
    DLC_POLYMORPHS_VALUE     60
    DLC_POLYMORPHS_NORMAL_VALUE     40-65
    ACTUAL WILL BE:
    &PATIENT_NUM=1
    PATIENT_NUM 1
    PATIENT_NAME BBBB
    HMTLY_TEST_NAME HAEMATOLOGY
    HMTLY_RBC_VALUE 5
    HMTLY_RBC_NORMAL 4.6-6.0
    &PATIENT_NUM=2
    PATIENT_NUM 2
    PATIENT_NAME GGGG
    DLC_TEST_NAME DIFFERENTIAL LEUCOCYTE COUNT
    DLC_POLYMORPHS_VALUE     42
    DLC_POLYMORPHS_NORMAL_VALUE     40-65
    &PATIENT_NUM=3
    PATIENT_NUM 3
    PATIENT_NAME KKKK
    HMTLY_TEST_NAME HAEMATOLOGY
    HMTLY_RBC_VALUE 4
    HMTLY_RBC_NORMAL 4.6-6.0
    DLC_TEST_NAME DIFFERENTIAL LEUCOCYTE COUNT
    DLC_POLYMORPHS_VALUE     60
    DLC_POLYMORPHS_NORMAL_VALUE     40-65
    4 TABLES FOR CLINICAL LAB FOR INPUT DATA AND GET REPORT ONLY FOR TESTS MADE FOR PARTICULAR
    PATIENT.
    TABLE1:PATIENTS_MASTER1
    COLUMNS:PATIENT_NUM, PATIENT_NAME,
    VALUES:
    PATIENT_NUM
    1
    2
    3
    4
    PATIENT_NAME
    BBBB
    GGGG
    KKKK
    PPPP
    TABLE2:TESTS_MASTER1
    COLUMNS:TEST_NUM, TEST_NAME
    VALUES:
    TEST_NUM
    1
    2
    TEST_NAME
    HAEMATOLOGY
    DIFFERENTIAL LEUCOCYTE COUNT
    TABLE3:HAEMATOLOGY1
    COLUMNS:
    HMTLY_NUM,HMTLY_PATIENT_NUM,HMTLY_TEST_NAME,HMTLY_RBC_VALUE,HMTLY_RBC_NORMAL_VALUE     
    VALUES:
    HMTLY_NUM
    1
    2
    HMTLY_PATIENT_NUM
    1
    3
    MTLY_TEST_NAME
    HAEMATOLOGY
    HAEMATOLOGY
    HMTLY_RBC_VALUE
    5
    4
    HMTLY_RBC_NORMAL_VALUE
    4.6-6.0
    4.6-6.0
    TABLE4:DIFFERENTIAL_LEUCOCYTE_COUNT1
    COLUMNS:DLC_NUM,DLC_PATIENT_NUM,DLC_TEST_NAME,DLC_POLYMORPHS_VALUE,DLC_POLYMORPHS_
    NORMAL_VALUE,
    VALUES:
    DLC_NUM
    1
    2
    DLC_PATIENT_NUM
    2
    3
    DLC_TEST_NAME
    DIFFERENTIAL LEUCOCYTE COUNT
    DIFFERENTIAL LEUCOCYTE COUNT
    DLC_POLYMORPHS_VALUE
    42
    60
    DLC_POLYMORPHS_NORMAL_VALUE
    40-65
    40-65
    THANKS
    RCS
    E-MAIL:[email protected]
    --------

    I think you want an OUTER JOIN
    SELECT PATIENT_NUM, PATIENT_NAME, HMTLY_TEST_NAME, HMTLY_RBC_VALUE,
    HMTLY_RBC_NORMAL_VALUE, DLC_TEST_NAME, DLC_POLYMORPHS_VALUE,
    DLC_POLYMORPHS_NORMAL_VALUE
    FROM PATIENTS_MASTER1, HAEMATOLOGY1,  DIFFERENTIAL_LEUCOCYTE_COUNT1
    WHERE PATIENT_NUM = HMTLY_PATIENT_NUM (+)
    AND PATIENT_NUM = DLC_PATIENT_NUM (+)
    AND PATIENT_NUM = &PATIENT_NUM;Edited by: shoblock on Nov 5, 2008 12:17 PM
    outer join marks became stupid emoticons or something. attempting to fix

  • ADF 10.1.2/10.1.3: Preventing eagerly querying of detail viewobjects

    Ever since we started developer ADF applications we had issues with database queries being performed when we didn't expect it. It turned out that this is the default behavior of the master-detail synchronization in ADF 10.1.2 and 10.1.3 (haven't tested 11 yet). I've come up with a solution of our own, which I want to share with you all. I also want to check if anybody here sees any drawbacks in this approach.
    First some background info: Whenever the master view object is requeried or navigates to another row it requeries all detail view objects that have been queried previously. Detail view objects that are in their initial/clean state are not touched.
    So, on the very first page of your application you might need DEPT and EMP, and they are automatically queried (since the ADF bindings are refreshed). However, when you navigate to the next page it might only use the DEPT ViewObject. If you navigate to another DEPT, the EMP query is also re-executed even if this next page doesn't have a binding for EMP.
    Steve Muench described a possible workaround (number 74) at
    http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html
    Although his solution works, we didn't really like it. Here's a summary of his approach:
    <ul>
    <li> add a method <tt>enableDetailsForViewInstances()</tt> to the ADF BC Application Module. This accepts an array of view instance names representing the views used on the current page. It then enabled/disables the master-detail synchronization for each viewlink based so that only the viewlinks relevant to the current page are enabled.</li>
    <li> add a custom <tt>JSFPageLifecycle</tt> class that overrides the <tt>prepareModel()</tt> method.
    This methods assembles a list of all view instances used by the iterator bindings of the current page. It then calls the method on the ADF BC Application Module to enable/disable the viewlinks</li>
    </ul>
    The Application Module disables master-detail synchronization by calling <tt>removeMasterRowSetIterator()</tt> on the detail viewobject. This removes the master-RowSetIterator from the default RowSetIterator of the detail VO, effectively breaking the link. The old master-RowSetIterator is kept in a HashMap. Later, when both the master and detail VO are used on the same page the link is restored by calling <tt>setMasterRowSetIterator()</tt> on the detail with the master-RowSetIterator stored in the HashMap.
    The main objection we had to this approach is that you are pushing the relevant viewobjects from the View layer to the Model layer. We would like the Model not to be too knowledgable about the View layer. Also, this means things break if you get a hold of a detail viewobject some other way, for instance by calling findViewObject on the AppModule or by having an old reference to the detail VO. If you get hold of such a VO instance without calling <tt>enableDetailsForViewInstances()</tt> it would not have a master-rowsetiterator and an exception is thrown about the bind parameter from the viewlink being null.
    I tried to find a solution that is transparent to the View layer or other client. I wanted a solution where the eager master-detail navigation is disabled and the detail would only be requeried/refreshed when explicitely called for. This could either be your custom code calling the ViewObject or the JSF View layer having an ADF binding to the ViewObject. Basically I want to try to reset the detail ViewObject to its initial/clean state as the master VO won't requery the detail VO's that are in the initial stage. It only requeries the detail VOs that have a default RowSet and RowSetIterator.
    After quite some digging around I came up with:
    <ul>
    <li>clear/close the <tt>RowSetIterator</tt> on the detail <tt>ViewObject</tt> when navigating to another row in the master <tt>ViewObject</tt>. To do this, we use a <tt>DetailClearingListener</tt> class that implements the <tt>RowSetListener</tt> interface.</li>
    <li>The <tt>DetailClearingListener</tt> class implements the <tt>navigated(NavigationEvent event)</tt> method. This gets executed when the (master) ViewObject navigates to another row. In this <tt>navigate()</tt> method I iterate over <tt>ViewObject.getViewLinks()</tt> to find all the links where the navigating ViewObject is the source (=master). Then I look at the ViewObject from the destination (=detail) part of the link.
    For each detail ViewObject I get the RowSetIterators by calling <tt>ViewObject.getRowSetIterators()</tt>. Then I close all these RowSetIterators by calling <tt>closeRowSetIterator()</tt> on them</li>
    <li>The tricky part was to properly register this listener with the master ViewObject. As it turns out, you can call <tt>addListener()</tt> on the ViewObject, but in fact it is just relaying this to the default RowSetIterator of the ViewObject. It's the RowSetIterator that registers the listeners and calls them when required. This proved to be a problem, when a ViewObject is both the detail in a master-detail relationship and also the master in (another) master-detail relationship.
    With the DetailClearingListeners in place, the first (highest) master-detail relationship will close the default RowSetIterator on it's detail VO when navigating the master. Unfortunately this also destroys the registered listeners on this default RowSetIterator that need to managed the lower master-detail relationship.
    The only workable solution we could find is to override the <tt>getDefaultRowSet()</tt> method in the ViewObject and register the listener there. This means that whenever the default rowset (and rowsetiterator) is requested, we make sure we register the DetailClearingListener before returning the rowset. Since we can't test if the listener is already registered it does mean we frequently register the listener even when it is not necessary. Luckily enough the internal implemention does prevent duplicates and will ignore any new listeners that are already registered. This is why we are creating only a single instance of the DetailClearingListener and store it in a private member variable of the ViewObject. That way, we use the same DetailClearingListener instance each time and duplicates are prevented.</li>
    <li>The big benefit of this approach is that only relies on changes to the ViewObject. This can easily be implemented by giving all your ViewObjects a common superclass that implements this solution. In most cases, you already have an application- or enterprise-wide ViewObjectImpl class that is the basis for all your ViewObjects. In that case, you can just implement the solution in that global class.</li>
    </ul>
    We've tested this solution in ADF 10.1.2 and 10.1.3 applications and found dramatic performance gains. We had one application were page requests took 10-15 seconds once you visited all pages in the application (thereby activating each ViewObject at least once). It was not uncommon for a navigation to another row in the master ViewObject to trigger 70-100 queries, since all the detail (and detail-detail, etc) ViewObject where eagerly requeried. With this new approach, page response times have dropped below 1 second.
    So, at least in our situaton, this solution seems to work. I'm just wondering what the downside of closing the RowSetIterator is. There must be some drawbacks to this approach, but it seems I can't find any so far. Hopefully some of you can suggest what the danger/drawback is in closing a RowSetIterator.

    Shay's question about experience is a good one. If you're not already proficient at UIX then I would choose JSF. If you've done very little J2EE/Java/JSP/HTML development work, you've got a couple of months of ramping up to be able to accomplish much tangible.
    I've been working on a project for a couple of months using ADF BC on the backend and JSF/ADF Faces for the View. The enticement was built on the expectation that 10.1.3. would be going into production very soon, and it seems that this is true, from what little hints and clues I can pick up from these tight-mouthed Oracle guys. ;-)
    The disadvantage of going that way is that the documentation sucks for doing anything but the most basic, declarative user interface development, especially if you want to use ADF Faces (there's some decent resource out in the world for JSF development, although even that is pretty thin). This is promised to be much improved with the production release.
    For the business services development, unless you already know ADF Business Components I strongly recommend grabbing a copy of the Oracle JDeveloper 10g Handbook. It fills in many of the gaps that otherwise leave you at a loss for how to tie the backend pieces together.
    Good luck!
    Johnny Lee

  • Post Query Problem

    Hellow
    I have a master-detail blocks.
    Now I want to run the detail block according to certain query that returns MORE than onw row a time.
    I used a cursor to resolve this prob.
    Still having problem in quering the detail when I query the Master.
    Any comment??
    Note: I can populate the detail using a Stored procedure. But this SP needs an input(Bind Variable in Master block) to be passed as a parameter.
    Can it work like this? How?
    Regards
    Tariq

    The data block wizard is capable of creating two data blocks with the master/detail relationship. Create the master block first, then create the detail block and set up the relationship in the wizard. When you make the layout for the detail block, specify how many rows you want to see in the detail, and tell it to display a scroll bar in case the query returns more than that number of rows. You should not need to create a cursor or do any specific programming to implement a master/detail form.
    null

  • Reg: Query Problem for New Posting Period

    Hi Xperts,
    While I try to Map the A/P Invoices with their respective Outgoing Payment,
    I used the following Query and it's Query Printlayout
    SELECT T0.DocNum [Payment#], T0.DocDate [Payment Date],
    T0.CardCode, T0.CardName, T1.InvoiceId, T2.DocNum [AP Inv#],
    T2.NumatCard [Bill No.], T2.DocDate [Bill Date], T1.selfInv,
    T1.SumApplied, T1.WtAppld, T0.NoDocsum 
    FROM  [dbo].[OVPM] T0  INNER  JOIN
    [dbo].[VPM2] T1  ON  T1.[DocNum] = T0.DocNum
    INNER  JOIN [dbo].[OPCH] T2  ON  T2.[DocEntry] = T1.DocEntry
    WHERE T0.Cardname='[%0]' and T0.DocDate='[%1]' and
    T0.DocNum='[%2]'
    I got the above query from our Expert Mr.Sambath only.
    Now what is the problem is the query is retrieving the payment details of old Posting Period only and not the current posting period.
    In detail, I used 'Primary' Series for FY08-09, Period indicator 'Default'
    Now I'm using 'Primary1' Series for FY09-10, Period indicator '0910'
    Thanx in adv.
    Regards,
    Bala

    Hi Bala,
    Looking at your query, it is not query issue ,it is your data issue.
    Please check if you have data in  VPM2  table  which is bank transfer payment method
    Thank you
    Bishal
    Edited by: Bishal Adhikari on Apr 9, 2009 8:48 AM

  • PI 7.11 problem with configuration wizard

    hello guys,
    during the configuration wizard to use PI functionalty of my PI system I receive a massage regarding the not correct registration of my system into SLD
    ABAP technical system 'SID on HOSTNAME\SID' not found . But it's correctly in the abap technical systems.
    What could be wrong? Is it related to the fact I performed a NAMED INSTANCE installation with MSSQL ?
    anyone of us had the same problem?

    Hello Bruno,
    Please follow the MANUAL wizard from the link below:
    http://help.sap.com/saphelp_nwpi71/helpdata/EN/a0/40084136b5f423e10000000a155106/frameset.htm
    Perhaps the automatic wizard could lead to a lot of problems.
    It should solve the issue with the wizard.
    Regards,
    Caio Cagnani

  • VIEW Query Problem

    Hi Greg,
    I had created a view on a table which doesn't have Primary Key, but it has Unique and Not Null constraints on required columns.
    I had wrote a procedure to query the data on VIEW. I have experienced strange problem, very first call to procedure will take more time than succeeding requests. For example from second request onwards, it returns data in < 2 Sec, but first transaction is taking 12 Sec to 30 Sec.
    I thought that very first time VIEW is taking time to refresh it self. So, I added FORCE keyword in CREATE VIEW stattement. However, that doesn't helped out.
    In my further investigation I came to know that base table on which VIEW created, has to be loaded in to memory before querying on VIEW.
    So, I had executed a simple select statement on base table, before I execute VIEW query in procedure.
    With this change I got results consistently < 2 Sec all the times.
    My question is instead of executing the select statement on base table is there a way to load base tables data in memory before querying on VIEW?
    Thanks,
    Subbarao

    Hi,
    A view is nothing but parsed SQL statements stored in the database, a view may or may not run faster. If you execute the SQL used to define the view how much time is it taking. If you want try looking at MATERIALIZED VIEW , that may help you.
    thanks

  • Date range query  problem  in report

    Hi all,
    I have created a report based on query and i want to put date range selection but query giving problem.
    If i am creating select list selection then it is working fine means it will display all records on the particular date.
    But what i need is that user will enter date range as creation_date1,creation_date2 and query should return all the records between these date range. i want to pass it by creating items, i created two items and passing creation_date range to display all records but not displaying and if not passing date then should take null as default and display all records
    Here is the query:
    /* Formatted on 2006/12/10 20:01 (Formatter Plus v4.8.0) */
    SELECT tsh."SR_HEADER_ID", tsh."SALES_DEPT_NUMBER", tsh."COUNTRY",
    tsh."LOCAL_REPORT_NUMBER", tsh."ISSUE_DATE", tsh."SUBJECT",
    tsh."MACHINE_SERIAL_NUMBER", tsh."MACHINE_TYPE", tsh."MACHINE_HOURS",
    tsh."STATUS"
    FROM "TRX_SR_HEADERS" tsh, "TRX_SR_PARTS" tsp
    WHERE (tsh.status LIKE :p23_status_sp OR tsh.status IS NULL)
    AND (tsh.machine_type LIKE :p23_machine_type_sp)
    AND ( tsh.machine_serial_number LIKE
    TO_CHAR (:p23_machine_serial_number_sp)
    OR tsh.machine_serial_number IS NULL
    AND ( TO_CHAR (tsh.failure_date, 'DD-MON-YY') LIKE
    TO_CHAR (:p23_failure_date_sp)
    OR TO_CHAR (tsh.failure_date, 'DD-MON-YY') IS NULL
    AND ( TO_CHAR (tsh.creation_date, 'DD-MON-YY')
    BETWEEN TO_CHAR (:p23_creation_date_sp)
    AND TO_CHAR (:p23_creation_date_sp1)
    OR TO_CHAR (tsh.creation_date, 'DD-MON-YY') IS NULL
    AND (tsh.issue_date LIKE :p23_date_of_issue_sp OR tsh.issue_date IS NULL)
    AND (tsh.country LIKE :p23_country_sp OR tsh.country IS NULL)
    AND ( tsh.local_report_number LIKE TO_CHAR (:p23_local_rep_num_sp)
    OR tsh.local_report_number IS NULL
    AND ( tsp.part_number LIKE TO_CHAR (:p23_part_number_sp)
    OR tsp.part_number IS NULL
    AND tsh.machine_type IN (
    SELECT DISTINCT machine_type
    FROM trx_sales_dept_machine_list
    WHERE sales_department_id IN (
    SELECT DISTINCT sales_department_id
    FROM trx_user_sales_department
    WHERE UPPER (user_name) =
    UPPER ('&APP_USER.'))
    AND SYSDATE >= valid_from)
    AND tsh.sr_header_id = tsp.sr_header_id
    can any one tell me wat is wroung in this query.
    Any other way to write this?
    Thank You,
    Amit

    Hi User....
    Here is some date range SQL that my teams uses with some success:
    For date columns that do not contain NULL values, try this (note the TRUNC, it might help with your "today" problem).
    The hard coded dates allow users to leave the FROM and TO dates blank and still get sensible results (ie a blank TO date field asks for all dates in the future.
    AND TRUNC(DATE_IN_DATABASE)
    BETWEEN
    decode( :P1_DATE_FROM,
    TO_DATE('01-JAN-1900'),
    :P1_DATE_FROM)
    AND
    decode( :P1_DATE_TO,
    TO_DATE('31-DEC-3000'),:
    :P1_DATE_TO)
    For date columns that contain NULL values, try this (a little bit trickier):
    AND nvl(TRUNC(DATE_IN_DATABASE),
    decode( :P1_DATE_FROM,
    decode( :P1_DATE_TO,
    TO_DATE('30-DEC-3000'),
    NULL),
    NULL)
    BETWEEN
    decode( :P1_DATE_FROM,
    TO_DATE('01-JAN-1900'),
    :P1_DATE_FROM)
    AND
    decode( :P1_DATE_TO,
    TO_DATE('31-DEC-3000'),
    :P1_DATE_TO)
    Note the 30-DEC-3000 versus 31-DEC-3000. This trick returns the NULL dates when the FROM and TO date range items are both blank.
    I hope this helps.
    By the way, does anyone have a better way of doing this? The requirement is given a date column in a database and a FROM and a TO date item on a page,
    find all of the dates in the database between the FROM and TO dates. If the FROM date is blank, assume the user want all dates in the past (excluding NULL dates). If the TO date is blank, assume that the user wants all of the dates in the future (excluding NULL dates). If both FROM and TO dates are blank, return all of the dates in the databse (including NULL dates).
    Cheers,
    Patrick

  • Multiprovider Query Problem

    Hi Gurus,
    The scenario is that there are 2 inficubes, one with order data and other with delivery data. The cube with order data has the requested delivery date and the delivery cube has the actual delivery date. The problem is that I have a query on a multiprovider (on top of the 2 cubes). So when I output the query data by the sales order number, the result is fine, but when I drill down on any of the dates mentioned above ( they are free characteristics in the query), the result splits up into 2 records. For Eg.
    Sales Order     Req Del Date  Act Del Date  Order Qty  Shipped Qty
    12345               03/03/08         -                    5                 -
                                   -           06/03/08            -                5
    What can I do to get the result in one row?
    I will reward points for any help.
    Thanks

    This is the behavior of the multiprovider, since the actual goods issue date is not part of the orders cube, then it will create a second record. There are a couple solutions you could get around to this:
    1. You could merge the data in one DSO before you actually load it to the data target. To do this, you could update fields you need to the orders ods from the delivery ods.
    2. You could create an infoset between the two cubes if you are in 7.0, otherwise, you could create infoset using the underlying ods and create a query from the infoset: performance wise this is not recommended.
    3. If you want to solve the issue report level, there is what is called constant selection and you can make the actual goods issue date as a constant selection and you can get one line.
    /people/prakash.darji/blog/2006/09/19/the-hidden-secret-of-constant-selection
    I would recommend the last option,
    thanks.
    Wond

  • Out standing MIS Report query problem.

    Hi,
    We designed MIS Report for outstanding mis through Crystal report.here we are facing probleme.ex:AR invoice raised on 01 Jan 09 bill amount 1000 and for this client is received full amount against that bill on 04 march09.in this report we provided parameters for from date and to date. When user selected in parameter from date 010109 to 050309 it will show pending amount is 0.but users are asking if they select from date upto 030309 means it will show pending amount should be show 1000.in this query we are retrieving based on document status when open. How we can show report for this requirements. Please guide me.if we give docstatus='O' or docstatus= 'C' it's showing but pending amount =Bill amount - paid amount here it's showing 0 i think here also we need to pass incoming payment docdate.how wen do please guide me.
    below this is the query.
    set @FromYear=case when month(@ToDate)>=1 and month(@ToDate)<=3 then Year(@ToDate)-1 else Year(@ToDate) end
    set @ToYear=case when month(@ToDate)>=1 and month(@ToDate)<=3 then Year(@ToDate) else Year(@ToDate)+1 end
    --select @fromYear,@toyear,@todate,@ProjCode,@Cardcode,@VoucherType,@GroupName
    select a.u_category,a.docdate,g.name,d.CardCode,d.cardname,e.GroupName,SUBSTRING(CONVERT(VARCHAR(11), a.docdate, 113), 4, 8)as Month of invoiceraised,
    b.seriesname,a.docnum,a.Project,0,a.doctotal,
    paidamount= case when a.paidtodate is NULL then 0 else a.paidtodate end,
    pendingamount= case when isnull(a.doctotal,0)-isnull(a.paidtodate,0) is null then 0 else isnull(a.doctotal,0)-isnull(a.paidtodate,0) end,
    case when year(a.docdate) = @ToYear and month(a.docdate) = 3 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as March ,
    case when year(a.docdate) = @ToYear and month(a.docdate) = 2 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as Feb,
    case when year(a.docdate) = @ToYear and month(a.docdate) = 1 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as Jan,
    case when year(a.docdate) = @FromYear and month(a.docdate) = 12 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as Dec,
    case when year(a.docdate) = @FromYear and month(a.docdate) = 11 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as Nov,
    case when year(a.docdate) = @FromYear and month(a.docdate) = 10 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as Oct,
    case when year(a.docdate) = @FromYear and month(a.docdate) = 9 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as Sept,
    case when year(a.docdate) = @FromYear and month(a.docdate) = 8 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as Aug,
    case when year(a.docdate) = @FromYear and month(a.docdate) = 7 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as July,
    case when year(a.docdate) = @FromYear and month(a.docdate) = 6 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as June,
    case when year(a.docdate) = @FromYear and month(a.docdate) = 5 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as May,
    case when year(a.docdate) = @FromYear and month(a.docdate) = 4 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as April,
    --case when a.docdate = (select f_refdate from ofpr where year(f_refdate)=year(a.refdate) then a.doctotal-c.paidtodate else 0 end as Pre-Yr
    nodocsum=isnull(f.nodocsum,0),0 as PreviousFY
    from oinv a
    left join nnm1 b on a.series=b.series
    inner join INV1 c ON a.DocEntry = c.DocEntry
    inner join OCRD d ON d.CardCode=a.CardCode
    left join ocpr g on g.cardcode=d.cardcode
    Inner join OCRG e on e.GroupCode=d.GroupCode and e.grouptype='c'
    LEFT JOIN ORCT f ON a.DocEntry = f.DocEntry
    where
    a.docstatus='O' and
    case when a.doctotal-a.paidtodate is null then 0 else a.doctotal-a.paidtodate end >= 0
    Reds,
    Sampath kumar devunuri.

    Hi,Gordon Du ,
    We are designing through Crystal reports 2008 only. Based on SQL query how we can maintain History of Document status and date in table. Please give me your advise how we can rectify this problem. Kindly find above query.
    Regds,
    Sampath Kumar.

  • Problem with Dunning wizard

    After the excution of Dunning wizard, I get the following error :
    18/03/2009  19:06:51: Could not commit transaction '' (DWZ2)
    Now,
    I don't see the register dunning transaction, but all the business partner has been signed has dunned.
    I need know to understand what is my problem and this error, and to restore back the situation to the time before the error.
    Giuseppe

    HI,
    The error message is typically caused by approval procedures. Could you
    please ask the customer to try the following:
    1. Check the approval templates.
    2. Log on with the approver user (designed approver in the template).
    3. Go to the Approval Templates Setup window, Terms tab.
    4. If the radio button 'when the following applies' is checked, please
    check if any box was checked on the 'Choose' column and if the Ratio
    'Undefined type' is selected. If so, either select a ratio and define
    a value, or uncheck the box.
    5. Check the last line in the Terms tab ('Undefined type') and make sure
    it is not checked.
    6. Click on Update.
    If the above does not solve the issue, then this may be related to Note
    1258519 which is an application error fixed in 2007A, P44.
    Also there is a workaround on the Note 1258519.
    Regards
    Vikas
    SAP Business One Forums Team

  • Query problem with accumulated key figures

    Hi BI Gurus!
    I have a report problem that I hope you can help me with!
    In my report I have 2 key figures. One for accumulated revenue previous year (KF1) and one for accumulated revenue current year (KF2). Both key figures should be presented in a graph in monthly buckets.
    January figures from both the key figures shoule be presented in the same bucket. Therfore I can't use 0CALYEAR since we have the "year" information in there. Instead I'm using 0CALMONTH2 which is only two digits, 01 for January. That way I can map figures from both previous year and current year in the same bucket.
    I need the figures to be accumulated and this is what I have problem with. When I run the report today in February 2010 it looks like this:
    Month   KF1   KF2
    01        10     15
    02        10     20
    03        15    
    04        10    
    05        20    
    06        10    
    07        10    
    08        15    
    09        15    
    10        20    
    11        20    
    12        10    
    This is how I would like the report to look like:
    Month   KF1   KF2
    01        10     15
    02        20     35
    03        35    
    04        45    
    05        65    
    06        75    
    07        85    
    08        100    
    09        115    
    10        135    
    11        155    
    12        165
    I have tried to use the setting "accumulated" for the key figures but then I get this result:
    Month   KF1   KF2
    01        10     15
    02        20     35
    03        35     35
    04        45     35
    05        65     35
    06        75     35
    07        85     35
    08        100   35
    09        115   35
    10        135   35
    11        155   35
    12        165   35
    Since the KF2 is revenue for current year and I run the report in February I don't want any figures to be displayed in Mars...
    I have tried to restrict the key figures by 0CALMONTH2 and 0CALYEAR. The KF1 is havein a restriction to only show values for 0CALYEAR - 1 and an interval for 0CALMONTH2 from JAN - DEC.
    The KF2 is having a restriction to only show values in the interval "first month in year - current month" (in this example JAN - FEB) for 0CALMONTH2. And current year for 0CALYEAR.
    Despite my restrictions for KF2 the numpers repeats itself for every month...
    Any suggestion how I can resolve this?
    Best regards
    Anders Florin

    Hi Khaled and thank you for trying to help me!
    I agree with you and think the users should accept the report as it is. But they are claiming that top management will not accept this and they would really want this to be fixed the whay that they want. I have tried to push back on this and said that I'm not sure that it can be resoleved and that it could cost them a lot of money if I try.
    But I will try to resolve it for them if I have spare time in the end of the project. I have not promised them anything but it would really be nice if I could fix it.
    So when you say I need to use a structure and a calculated key figure. How should the calculated key figure and the structure be configured?
    If I use a structure in the rows I guess I can't use same object in calc.key.figure right? Like if I use 0CALMONTH2 in the structure I'm not able to restrict the key figure with the same object? If that is correct I also have a ZMONTH object, different story why I have that... , that I can use in the same way as 0CALMONTH2. Or is this only a problem when I use "local" formulas within the query and not using a "global" calculated key figure? Cause I have only used the "loacal" formula calculated key figure in this report....
    Br
    Anders

  • Abap select query problem

    This report will take delivery document number and delivery date from user and fetches details from delivery table and fetches
    corresponding sales order details and billing details  and displays sales order details with ALV list.
    << Please only post the relevant portions of your code >>
    i just want to know that is this way of fetching the data into internal table okay ?are there any better ways of fetching the data into the internal table ? why  is it looping in work area of lips, why not in likp?
    (plz dont use field-symbols or oo abap or macros) I WANT TO USE PLAIN AND SIMPLE ABAP STATEMENTS LIKE ABOVE..
    By using "vbeln type lips-vbeln" are we refering to the field or data element? plz suggest.
    P.S.           [my approach was to inner join likp and lips into itab(my internal table).
    select data from kna1, vbak,vbap,vbrp into respective internal tables like it_kna1,it_vbak etc.
    then using individual loops into the tables, i would use read table to insert data into itab(my final internal table) plz suggest which method wud be more efficient? ]
    Edited by: Rob Burbank on Jun 8, 2009 11:54 AM

    ok i am posting the select queries once again.
    i want to know why are we looping in t_lips and why not t_likp? bcoz tlikp is the header table, if we loop thru it and then read the rest tables then what will be the problem? plz clarify with examples._
    [my idea was to loop at t_likp then read t_lips.append the lips data into t_order(main internal table).then do read table on t_kna1,t_vbap etc indexing t_order. so plz suggest whether my approach was write or wrong?if wrong why?plz site any other ways of doing this query.
    types: begin of ty_vbap,
           vbeln type vbap-vbeln,
           posnr type vbap-posnr, .....
    does the declaration statement in types refer to tables or data elements? what is the difference if we declare it like:
       types: begin of ty_vbap,
           vbeln type vbeln,
           posnr type posnr, .....
    select-options:
    s_deldoc FOR likp-vbeln, " Delivery
    s_dldate FOR likp-lfdat. " Delivery Date
    Get delivery document number,delivery date,customer number from
    delivery header table
    SELECT vbeln " Delivery
    lfdat " Delivery Date
    kunnr " Customer Number 1
    FROM likp
    INTO TABLE t_likp
    WHERE vbeln IN s_deldoc
    AND lfdat IN s_dldate.
    IF sy-subrc EQ 0.
    Get Customer name for customer numbers from Customer master table
    SELECT kunnr " Customer Number 1
    name1 " Name 1
    FROM kna1
    INTO TABLE t_kna1
    FOR ALL ENTRIES IN t_likp
    WHERE kunnr EQ t_likp-kunnr.
    IF sy-subrc EQ 0.
    Get delivery item number,sales document number,sales item number,
    delivery quantity from delivery item table
    SELECT vbeln " Delivery
    posnr " Delivery Item
    vgbel " Document number of
    " reference document
    vgpos " Item number of reference item
    lfimg " Actual quantity delivered
    vrkme " Sales unit
    FROM lips
    INTO TABLE t_lips
    FOR ALL ENTRIES IN t_likp
    WHERE vbeln EQ t_likp-vbeln.
    IF sy-subrc EQ 0.
    Get sales document number,item number,material,material description,
    ordered quantity from sales item table
    SELECT vbeln " Sales Document
    posnr " Sales Document Item
    matnr " Material Number
    arktx " Short text for sales order
    " item
    kwmeng " Cumulative Order Quantity
    vrkme " Sales unit
    FROM vbap
    INTO TABLE t_vbap
    FOR ALL ENTRIES IN t_lips
    WHERE vbeln EQ t_lips-vgbel
    AND posnr EQ t_lips-vgpos.
    IF sy-subrc EQ 0.
    Get sales document number ,created date,purchase order number from
    sales header table
    SELECT vbeln " Sales Document
    erdat " Date on Which Record Was" Created
    aufnr " Order Number
    FROM vbak
    INTO TABLE t_vbak
    FOR ALL ENTRIES IN t_lips
    WHERE vbeln EQ t_lips-vgbel.
    IF sy-subrc EQ 0.* Get billing document number,billing item,reference delivery document
    number,delivery item number,billing item from billing item table
    SELECT vbeln " Billing Document
    posnr " Billing item
    vgbel " Document number of the
    " reference document
    vgpos " Item number of the" reference" item
    fklmg " Billing quantity in" stockkeeping unit
    vrkme " Sales unit
    FROM vbrp
    INTO TABLE t_vbrp
    FOR ALL ENTRIES IN t_lips
    WHERE vgbel EQ t_lips-vbeln
    AND vgpos EQ t_lips-posnr.
    ENDIF. " IF SY-SUBRC EQ 0
    ENDIF. " IF SY-SUBRC EQ 0
    ENDIF. " IF SY-SUBRC EQ 0
    ENDIF. " IF SY-SUBRC EQ 0
    ELSE.
    Display message if records are not found for entered values
    MESSAGE S000.
    EXIT.
    ENDIF. " IF SY-SUBRC EQ 0
    Looping Delivery item internal table to assign values to order
    internal table
    LOOP AT t_lips INTO fs_lips.
    Get delivery date and customer number for delivery document number
    from delivery header internal table
    READ TABLE t_likp WITH KEY vbeln = fs_lips-vbeln
    INTO fs_likp.
    Get customer name for customer number from customer master internal
    table
    IF sy-subrc EQ 0.
    READ TABLE t_kna1 WITH KEY kunnr = fs_likp-kunnr
    INTO fs_kna1.
    Get sales document number,item number,ordered quantity for delivery
    document number,item number from sales item internal table
    IF sy-subrc EQ 0.
    READ TABLE t_vbap WITH KEY vbeln = fs_lips-vgbel
    posnr = fs_lips-vgpos INTO fs_vbap.
    Get goods issue date and purchase order number for sales document
    number from sales header internal table
    IF sy-subrc EQ 0.
    READ TABLE t_vbak WITH KEY vbeln = fs_vbap-vbeln INTO fs_vbak.
    IF sy-subrc EQ 0.
    Get billing document number,billing item,billing quantity for delivery
    document number,delivery item number from billing item internal table
    READ TABLE t_vbrp WITH KEY vgbel = fs_lips-vbeln
    vgpos = fs_lips-posnr INTO fs_vbrp.
    Assign sales,delivery,billing fields into respective fields of sales
    order internal table
    IF sy-subrc EQ 0.
    fs_order-vbeln = fs_vbap-vbeln.
    fs_order-posnr = fs_vbap-posnr.
    fs_order-erdat = fs_vbak-erdat.
    fs_order-kunnr = fs_likp-kunnr.
    fs_order-name1 = fs_kna1-name1.
    fs_order-aufnr = fs_vbak-aufnr.
    fs_order-matnr = fs_vbap-matnr.
    fs_order-arktx = fs_vbap-arktx.
    fs_order-kwmeng = fs_vbap-kwmeng.
    fs_order-vrkme = fs_vbap-vrkme.
    fs_order-vbeln1 = fs_lips-vbeln.
    fs_order-posnr1 = fs_lips-posnr.
    fs_order-lfimg = fs_lips-lfimg.
    fs_order-vrkme1 = fs_lips-vrkme.
    fs_order-vbeln2 = fs_vbrp-vbeln.
    fs_order-posnr2 = fs_vbrp-posnr.
    fs_order-fklmg = fs_vbrp-fklmg.
    fs_order-vrkme2 = fs_vbrp-vrkme.
    APPEND fs_order TO t_order.
    CLEAR fs_order.
    ENDIF. " IF SY-SUBRC EQ 0
    ENDIF. " IF SY-SUBRC EQ 0
    ENDIF. " IF SY-SUBRC EQ 0
    ENDIF. " IF SY-SUBRC EQ 0
    ENDIF. " IF SY-SUBRC EQ 0
    ENDLOOP. " LOOP AT T_LIPS INTO FS_LIPS

Maybe you are looking for