Using 'Greater than/less than' in dynamic where condition

Hi Guys,
I am trying to use a logical expression with GT/LT condition in dynamic where, butits giving dump  "expression worngly parenthesised' . My query runs perfectly fine when the logical expression does not have 'GT/LT' . Is there a different way of using GT/LT in dynamic where or is it not posiible at all?? Please find my query below -
IF vendor IS NOT INITIAL.
      i_where_clause = 'a~lifnr = vendor'.
      APPEND i_where_clause.
      CLEAR i_where_clause.
    ENDIF.
    IF to_date IS NOT INITIAL.
      i_where_clause = 'a~zzearliestdep LT to_date'.
      APPEND i_where_clause.
      CLEAR i_where_clause.
    ENDIF.
    IF from_date IS NOT INITIAL.
      i_where_clause = 'a~zzlatestdep GT from_date'.
      APPEND i_where_clause.
      CLEAR i_where_clause.
    ENDIF.
  SELECT aebeln alifnr azzearliestdep azzlatestdep
            bebelp belikz b~kzabs
       INTO CORRESPONDING FIELDS OF TABLE i_podetails
       UP TO max_hits ROWS
       FROM ( ekko AS a INNER JOIN ekpo AS b
               ON aebeln = bebeln )
       WHERE a~ebeln = ebeln AND
            (i_where_clause).

Hi,
Try this -
IF vendor IS NOT INITIAL.
  i_where_clause = 'a~lifnr = vendor'.
  APPEND i_where_clause.
ENDIF.
IF to_date IS NOT INITIAL.
  if i_where_cause[] is not initial.
    i_where_clause = 'AND'
    append i_where_cause.
  endif.
  i_where_clause = 'a~zzearliestdep LT to_date'.
  APPEND i_where_clause.
ENDIF.
IF from_date IS NOT INITIAL.
  if i_where_cause[] is not initial.
    i_where_clause = 'AND'
    append i_where_cause.
  endif.
  i_where_clause = 'a~zzlatestdep GT from_date'.
  APPEND i_where_clause.
  CLEAR i_where_clause.
ENDIF.
Cheers.
\[removed by moderator\]
Edited by: Jan Stallkamp on Jun 26, 2008 1:08 PM

Similar Messages

  • Partition by range using greater than or in between statment?

    Can you partition by range using greater than or in between statment? If so, can someone please post the syntax?

    ji**** wrote:
    Can you partition by range using greater than or in between statment? If so, can someone please post the syntax?http://download.oracle.com/docs/cd/B10500_01/server.920/a96524/c12parti.htm
    CREATE TABLE sales_range
    (salesman_id  NUMBER(5),
    salesman_name VARCHAR2(30),
    sales_amount  NUMBER(10),
    sales_date    DATE)
    PARTITION BY RANGE(sales_date)
    PARTITION sales_jan2000 VALUES LESS THAN(TO_DATE('02/01/2000','DD/MM/YYYY')),
    PARTITION sales_feb2000 VALUES LESS THAN(TO_DATE('03/01/2000','DD/MM/YYYY')),
    PARTITION sales_mar2000 VALUES LESS THAN(TO_DATE('04/01/2000','DD/MM/YYYY')),
    PARTITION sales_apr2000 VALUES LESS THAN(TO_DATE('05/01/2000','DD/MM/YYYY'))
    );

  • Single quote in dynamic where condition

    BAPI_STUDENT_IDENTIFIC_ADD has a field called IDENTIFICATIONNUMBER.  This field is later used in a dynamic where condition and causes a short dump when it contains a single quote.  I will change the program that calls the BAPI to check for single quotes, but is there anything else I need to check for to ensure a correct where condition?
    Thanks,
    Dan

    Hi Dan,
    The best way to ensure correctness of syntax of a dynamic where condition is:
    Run the program in debugging mode, Get the Query that is generated dynamically and write it to some other ABAP program and perform syntax check.
    This will help you to remove all the syntax errors.
    Regards,
    Darshil

  • Dynamic select query with dynamic where condition

    Hi all,
    I want to use the dynamic select query with dynamic where condition. For that I used the below code but I am getting dump when using this code.
    Please advice, if there is any other way to achieve this requirement.
    Thanks,
    Sanket Sethi
    Code***************
    PARAMETERS: p_tabnam      TYPE tabname,
                p_selfl1      TYPE edpline,
                p_value       TYPE edpline,
                p_where1      TYPE edpline .
    DATA: lt_where    TYPE TABLE OF edpline,
          lt_sel_list TYPE TABLE OF edpline,
          l_wa_name   TYPE string,
          ls_where    TYPE edpline,
          l_having    TYPE string,
          dref        TYPE REF TO data,
          itab_type   TYPE REF TO cl_abap_tabledescr,
          struct_type TYPE REF TO cl_abap_structdescr,
          elem_type   TYPE REF TO cl_abap_elemdescr,
          comp_tab    TYPE cl_abap_structdescr=>component_table,
          comp_fld    TYPE cl_abap_structdescr=>component.
    TYPES: f_count TYPE i.
    FIELD-SYMBOLS : <lt_outtab> TYPE ANY TABLE,
    *                <ls_outtab> TYPE ANY,
                    <l_fld> TYPE ANY.
    struct_type ?= cl_abap_typedescr=>describe_by_name( p_tabnam ).
    elem_type   ?= cl_abap_elemdescr=>describe_by_name( 'F_COUNT' ).
    comp_tab = struct_type->get_components( ).
    comp_fld-name = 'F_COUNT'.
    comp_fld-type = elem_type.
    APPEND comp_fld TO comp_tab.
    struct_type = cl_abap_structdescr=>create( comp_tab ).
    itab_type   = cl_abap_tabledescr=>create( struct_type ).
    l_wa_name = 'l_WA'.
    CREATE DATA dref TYPE HANDLE itab_type.
    ASSIGN dref->* TO <lt_outtab>.
    *CREATE DATA dref TYPE HANDLE struct_type.
    *ASSIGN dref->* TO <ls_outtab>.
    * Creation of the selection fields
    APPEND p_selfl1 TO lt_sel_list.
    APPEND 'COUNT(*) AS F_COUNT' TO lt_sel_list.
    ** Creation of the "where" clause
    *CONCATENATE p_selfl1 '= '' p_value ''.'
    *            INTO ls_where
    *            SEPARATED BY space.
    *APPEND ls_where TO lt_where.
    * Creation of the "where" clause
    APPEND p_where1 TO lt_where.
    * Creation of the "having" clause
    l_having = 'count(*) >= 1'.
    * THE dynamic select
    SELECT          (lt_sel_list)
           FROM     (p_tabnam)
           INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>.
    *       WHERE    (lt_where).

    Hi Sanket,
    The above given logic of mine works for you, put the code in the If condition and try-
    just like below:
    IF NOT P_EBELN IS INITIAL.
    lt_where = '& = ''&'' '.
    REPLACE '&' WITH p_ebeln INTO lt_where.
    REPLACE '&' WITH field_value INTO lt_where.
    SELECT (lt_sel_list) INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>
    FROM (p_tabnam)
    WHERE (lt_where).
    ENDIF.
    thanks\
    Mahesh

  • Dynamic where condition

    Hi, I'm building a procedure with 4 parameters το pass in input and I ask if it's possible to build a select inside the procedure with a dynamic where condition.
    The query with 2 conditions is the following:
    SELECT count(incident_number) FROM cs.cs_incidents_all_b
    1st condition
    WHERE (TO_DATE(incident_attribute_6,'dd-mm-yyyy hh24:mi') BETWEEN TO_DATE(p_create_date_ll,'dd-mm-yyyy hh24:mi') AND TO_DATE(p_create_date_ul,'dd-mm-yyyy hh24:mi'))
    2nd condition
    AND external_attribute_4 BETWEEN p_resolv_time_ll AND p_resolv_time_ul;
    The first condition has to be always valid, but the second one, depending on the parameters has to be satisfied or not.
    The first 2 parameters (p_create_date_ll and p_create_date_ul) are always written as a string (so the first condition always works).
    The second pair of paramenters (p_resolv_time_ll and p_resolv_time_ul) can be written as numbers (from a form), or written both as '*'
    So, If the parameters p_resolv_time_ll and p_resolv_time_ul are numbers, I should retrieve a small set of data (all the 2 where condition have to work),
    while if they are both '*' ONLY the first condition has to work. Practically, in this last case the 2nd condition is how it was commented.
    Is it possible to build something that satisfy my request ?
    Thanks in advance
    Alex

    Yes I know....
    If I use an IF THEN ELSE statement I can write 2 different queries with 2 different where conditions....but I want to avoid this solution because I have 4 pair of these parameters which can assume differents values and depending on their values I have to use different where conditions
    If I use an IF THEN ELSE statement, this means to write 16 different queries....
    I already used DECODE or CASE but they not satisfy my request....
    Anybody has others ideas ?
    Thanks

  • Issue with Dynamic WHERE condition in Cursor in FUNCTION.

    Hi All,
    I am facing an issue with cursor having dynamic WHERE condition in a function.
    Below is the FUNCTION:
    CREATE OR REPLACE FUNCTION EXCEPTION_MERGE(TABLE_NAME IN VARCHAR2, TAB_NAME IN VARCHAR2)
    RETURN VARCHAr2
    IS
    stmt_tabcols VARCHAR2(32767);
    v_columnname VARCHAR2(32767);
    CURSOR C1 IS
    SELECT 'A.'||A.COLUMN_NAME ||' = '|| 'B.'||B.COLUMN_NAME COLUMN_NAME
    FROM
    SELECT COLUMN_ID, COLUMN_NAME
    FROM USER_TAB_COLUMNS
    WHERE TABLE_NAME  = TABLE_NAME
    AND COLUMN_NAME NOT IN ('ERROR_TAB_ID','ERROR_LOAD_DATE')
    ) A,
    SELECT COLUMN_ID, COLUMN_NAME
    FROM USER_TAB_COLUMNS
    WHERE TABLE_NAME = TAB_NAME
    ) B
    WHERE A.COLUMN_ID = B.COLUMN_ID;
    BEGIN
    FOR TABCOL IN C1
    LOOP
        stmt_tabcols := stmt_tabcols ||TABCOL.COLUMN_NAME||',';
    END LOOP;
        stmt_tabcols := RTRIM(stmt_tabcols, ',');
        RETURN stmt_tabcols;
    END;
    SELECT EXCEPTION_MERGE('WC_W_TEST_FS','WC_W_TEST_FS_GBL') FROM DUAL;It throws, below error:
    ORA-06502 : PL/SQL : Numeric or value error : character string buffer too smallIf I REPLACE TABLE_NAME and TAB_NAME with hard coded values , it works fine. Can somebody look at the code and let me know the issue.
    Edited by: ace_friends22 on Sep 9, 2012 1:08 PM

    Etbin neatly demonstrating the value of posting code in a manner which makes it easy to read.
    It's obviously an naming/scoping issue. Faced with a join like this:
    where table_name = table_namethe engine looks for something called table_name in the current scope. It finds it, a column on USER_TAB_COLUMNS and applies it to both sides of the filter. It has no way of knowing that there is also a parameter called TABLE_NAME, because that is outside its current scope. Consequently the query will join every table in your schema regardless of what values you pass, and that's why you blow the buffer.
    Takw etbin's advice and name your parameter with a prefix:
    where table_name = p_table_nameThis isn't a column in USER_TAB_COLUMNS which will force the engine to look in the next scope up, which in your case is the function, where it will find your parameter and so generate a query for the passed values only.
    Cheers, APC
    Edited by: APC on Sep 9, 2012 8:03 AM

  • Xpath query using greater than operator

    I'm trying to evaluate some xml to determine if it matches some criterium.
    MyXmlColumns contains the following kind of data "<Values><Value>data1</Value><Value>data2</Value><Values>"
    When I execute the following query I get zero rows returned when it should match some rows containing this data.
    select * from mydata
    where existsNode(MyXmlColumn, '/Values/Value[. > "data1"]') = 1
    The question is why greter than, lesser than, does not work, and if there is any alternative.
    If I use equals operator, or greater than but using a number it works.
    I know that I can use XmlExists function but I'm using Oracle 9i r2 so it's not an option.
    Thanks in advance for any suggestion.

    but I'm using Oracle 9i r2
    The question is why greter than, lesser than, does not workWorks on 9.2.0.8:
    SQL> select * from v$version where rownum = 1
    BANNER                                                         
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    1 row selected.
    SQL> with mydata as
       select xmltype('<Values><Value>data1</Value><Value>data2</Value></Values>') MyXmlColumn from dual
    select * from mydata t where existsNode(t.MyXmlColumn, '/Values/Value') < 3
    MYXMLCOLUMN                                                              
    <Values>                                                                 
      <Value>data1</Value>                                                   
      <Value>data2</Value>                                                   
    </Values>                                                                
    1 row selected.

  • How to use (greater than) in web services call

    Hello, I am trying to query a set of assets where the external unique ID is greater than 400,000. My existing code looks like
    qryIn.ListOfAsset(0).ExternalSystemId = ">'400000'"
    However, using this will return any asset record starting with a 5 or above as far as I can tell, I assume b/c it is comparing string data due to the single quotes infering data of type text (string). Is it possible to use comparison operators with numeric data correctly?
    I posed this question to support and received the below answer:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <AssetWS_AssetQueryPage_Input xmlns="urn:crmondemand/ws/asset/"> <ListOfAsset xmlns="urn:/crmondemand/xml/asset"> <Asset> <AssetId /> <PurchaseDate/> <OwnerAccountId /> <ExternalSystemId>&gt; '400000'</ExternalSystemId> </Asset> </ListOfAsset> </AssetWS_AssetQueryPage_Input> </soap:Body> </soap:Envelope>
    Basically, instructing me to use &gt. I'm doing coding in .NET visual studio and not using the XML as above. However, I did try the following:
    qryIn.ListOfAsset(0).ExternalSystemId = "&gt;'400000'" which returned an error in the compiler.
    Any help would be appreciated. Thanks.

    Thanks for the reply. I would assume "external system id" is an integer, but, I will test on a custom field that I now is of type integer.
    Could you take your same code and use a non-zero value for the operand? For example, could you try
    objAccQryParam.ListOfAccount[0].CustomInteger0 = ">= '10'"; and let me know if that returns values that are greater than or equal to 10. Using a two digit number is important. Assuming you have data greater than 10.
    Thanks!

  • Problem with Filtering Data by Using "Greater Than" in APD

    Dear Experts,
      First of all, I am a novice of SAP Data Mining. I try to filter data in APD by using the 'Restrict Amont of Data (the Filter Icon).' My problem is really simple. I don't know how to filter data which have value greater than a constant.
    For example, I try to keep only records which have a quantity greater than 1000.
      At the selection option in the single value tab, I found only the '=' option. The options like '>', '<', '>=', etc are not found. Could anyone suggest me please?

    I do appreciate your prompt response.
    Seemingly, using the interval is our best solution, though it is not best for our customers.
    Having already gone through the note you gave me, in fact, it is really pertinent. Unfortunately, our support package is now 13, and it is extremely difficult to retest our system if we decide to apply the support package 16.
    Are there any other solution?
    By the way, you deserve my point.

  • KQL query using "Greater Than" fails

    I have developed a CSOM app that does a KQL query against several managed properties. One of these properties is numeric (mapped to RefinableDouble01), so I have a greater than (>) comparison in the query string:
         RefinableDouble01>41.12345
    I developed the app in Office 365 and when I run the query there, it works fine (no errors).  However, when I run it to our internal SharePoint 2013 site, it fails with the error:
         "We didn't understand your search terms. Make sure they're using proper syntax."
    As far as I can tell, the configuration of the internal site matches the Office 365 site.
    If I use a query on a text property, so that I don't use the greater than comparison, that query works. The query results from that query also show that the managed property RefinableDouble01 is properly mapped and returns the expected numeric value.
    Does anyone know what the problem is? I'm wondering if the KQL query functionality is not properly set up in our internal site, but that is not an area that I am familiar with.
    Bob Feldman

    Here is more information, from the ULS Log file, regarding the error:
    06/27/2014 11:05:13.47  NodeRunnerQuery1-d8a6a564-7b37- (0x0BA4) 0x0DC4 Search                         Query Processing             
     aizc0 High     Microsoft.Office.Server.Search.Query.Ims.ImsQueryInternal : New request: Query text 'RefinableDouble01>41.12345', Query template ''; HiddenConstraints: ; SiteSubscriptionId: 00000000-0000-0000-0000-000000000000 fa039f9c-0884-60df-c11a-64f9b09837c4
    06/27/2014 11:05:13.48  NodeRunnerQuery1-d8a6a564-7b37- (0x0BA4) 0x0DC4 Search                         Query Processing             
     aizgn Medium   Microsoft.Office.Server.Search.Query.Pipeline.Executors.QueryPipelineHardWiredFlowExecutor : (FlowExecutor)eventSearchFlowDone: d8a6a564-7b37-4815-a35f-f97acc0d6cba, RefinableDouble01>41.12345, Microsoft.ProductivitySearchFlow,
    0, SPWFEAPP, Error=Exception occurred due to some other exception fa039f9c-0884-60df-c11a-64f9b09837c4 fa039f9c-0884-60df-c11a-64f9b09837c4
    06/27/2014 11:05:13.48  NodeRunner.exe (0x0BA4)                  0x0DC4 SharePoint Server Search       Query                        
     aisyt High     ExecuteFlowInternal FlowExecutor:Microsoft.ProductivitySearchFlow Exception: Microsoft.Ceres.Evaluation.DataModel.CommonEvaluationException: Exception occurred due to some other exception ---> Microsoft.Office.Server.Search.Query.QueryMalformedException:
    Query 'RefinableDouble01>41.12345' failed: syntax error at position 0, The operation is illegal for the given property, property expression: RefinableDouble01>41.8882213637562     --- End of inner exception stack trace ---    
    at Microsoft.Office.Server.Search.Query.Pipeline.Processing.KeywordQueryParserEvaluator.KeywordQueryParserProducer.ParseKeywordQuery(String queryText, ParsingContext parsingContext, Boolean debugMode, String& searchTerms)     at Microsoft.Office.Server.Search.Query.Pipeline.Processing.KeywordQueryParserEvalua... fa039f9c-0884-60df-c11a-64f9b09837c4
    06/27/2014 11:05:13.48  w3wp.exe (0x196C)                        0x41B0 SharePoint Server Search       Query                        
     dk68 High     SearchServiceApplication::Execute--Exception: Microsoft.Office.Server.Search.Query.QueryMalformedException: We didn't understand your search terms. Make sure they're using proper syntax. ---> System.ServiceModel.FaultException`1[Microsoft.Office.Server.Search.Administration.SearchServiceApplicationFault]:
    Query 'RefinableDouble01>41.12345' failed: syntax error at position 0, The operation is illegal for the given property, property expression: RefinableDouble01>41.8882213637562    Server stack trace:      at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime
    operation, ProxyRpc& rpc)     at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)     at ... fa039f9c-0884-60df-c11a-64f9b09837c4

  • Dynamis where Condition using select-options

    Hi All,
    I am trying to form a dynamic where clause using values entered on a selection screen. I want that if a new entry is added in the selection screen the where clause can also be modified dynamically without any change in coding. The only change required should be addition of select-option statement in the selection screen declaration.
    Thanks in advance.
    Anju

    refer below example
    L_COND_SYNTAX = 'd2ext_status = l_status and d2ext_date ne c_intdate and '
    & 'd2~ext_uploaded = space'.
    SELECT D1TKNUM D1SHTYP D1TPLST D1ERNAM D1ERDAT D1BFART
    D1VSART D1ROUTE D1SIGNI D1EXTI1 D1~TPBEZ
    D1DATBG D1UATBG D1TDLNR D2VBELN D2~POSNR
    D2EXT_FAILED D2EXT_COUNT D2EXT_DATE D2EXT_TIME
    D2EXT_REP_DATE D2EXT_REP_TIME
    D2EXT_RES_DATE D2EXT_RES_TIME D2~EXT_ERR_TYPE
    INTO TABLE PA_GT_SHIP_HEADER
    FROM VTTK AS D1 INNER JOIN RIOZTM_DELSTAT AS D2
    ON D1TKNUM = D2TKNUM
    WHERE
    D1~TKNUM IN S_TKNUM AND
    D1~SHTYP IN S_SHTYP AND
    AND
    <b>(L_COND_SYNTAX).</b>
    Plz note the backet in L_COND_SYNTAX.
    Reward points if helpful

  • Dump using Dynamic WHERE condition (EXISTS + subquery)

    Hi experts,
    I want to use dynamic WHERE here, but I got a problem when using EXISTS + subuery.
    Here is my code snippet:
    And the actual SQL sentence should be like this:
    When I execute this program, an exception CX_SY_DYNAMIC_OSQL_SEMANTICS is raised and the program dumps.
    Dump Information:
    Short text
       A dynamically specified column name is unknown.
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SEMANTICS', was
         not caught in
        procedure "FRM_GET_ALL_PROD_ORDERS" "(FORM)", nor was it propagated by a
         RAISING clause.
        Since the caller of the procedure could not have anticipated that the
        exception would occur, the current program is terminated.
        The reason for the exception is:
        An Open SQL clause was specified dynamically. The contained field name
        "EXISTS" does not exist in any of the database tables from the FROM clause.
    I'm confused because the plain text of my WHERE condition looks good. Could you tell me why I encountered this problem?
    Many thanks,
    Shelwin

    Hi Shelwin !
    Testing your code i dont have dump, using this:
    REPORT z_test MESSAGE-ID z_test_msgs.
    DATA: lt_where_tab1 TYPE STANDARD TABLE OF edpline WITH HEADER LINE,
          lt_where_tab2 TYPE STANDARD TABLE OF edpline WITH HEADER LINE,
          gt_detail     TYPE STANDARD TABLE OF caufv WITH HEADER LINE.
    CONCATENATE 'EXISTS (SELECT J_1~STAT FROM JEST AS J_1 INNER JOIN TJ02T AS T_1'
                'ON J_1~STAT EQ T_1~ISTAT'
                'WHERE J_1~OBJNR EQ CAUFV~OBJNR'
                'AND J_1~INACT EQ '' '''
                'AND T_1~SPRAS EQ ''E'''
                'AND T_1~TXT04 EQ ''CRTD'')'
                INTO lt_where_tab1.
    CONCATENATE 'NOT EXISTS (SELECT J_2~STAT FROM JEST AS J_2 INNER JOIN TJ02T AS T_2'
                'ON J_2~STAT EQ T_2~ISTAT'
                'WHERE J_2~OBJNR EQ CAUFV~OBJNR'
                'AND J_2~INACT EQ '' '''
                'AND T_2~SPRAS EQ ''E'''
                'AND T_1~TXT04 IN (''TECO'' , ''DLFL'', ''DLV'', ''CLSD''))'
                INTO lt_where_tab2.
    SELECT aufnr ftrms gltrs
      FROM caufv
      INTO CORRESPONDING FIELDS OF TABLE gt_detail
    WHERE (lt_where_tab1)
       AND (lt_where_tab2).
    BREAK-POINT.
    Regards,
    Edited for error on image.

  • Dynamic where condition - Problem

    Hi All,
    I have a problem in a select statement where I use a dynamic condition.It gives me a dump
    SAPSQL_WHERE_PARENTHESES
    CX_SY_DYNAMIC_OSQL_SYNTAX.
    Please find the below code which I implemented.
      *SELECT * FROM ZXR5*
               WHERE (SOURCE).
    The value of SOURCE is 'MATNR EQ '000000000000200066'.
    When I checked the help, it is advised to use a CATCH exception which I did as below:
    TRY.
      *SELECT * FROM ZXR5*
               WHERE (SOURCE).
      CATCH cx_sy_dynamic_osql_error.
        MESSAGE `Wrong WHERE condition!` TYPE 'I'.
    ENDTRY.
    Now, the select statement gives an exception and is not executing to fetch the values.
    I need some input on the above issue. Any help on this would be greatly appreciated.
    Regards,
    Rajmohamed.M

    Hi Vijay,
    I tried the same and all the time, the select statement gives me an exception and wont proceed.
      TRY.
        SELECT * FROM ZXR5
                 INTO TABLE <L_ZXR5>
                 WHERE (SOURCE).
        CATCH cx_sy_dynamic_osql_error.
        MESSAGE `Wrong WHERE condition!` TYPE 'I'.
      ENDTRY.
    Regards,
    Raj

  • How to execute procedure with dynamic where condition.

    Hi All,
    I am facing a probelem
    Issue :
    I am having a parameter p_id in my procedure based on the value of this parameter i want to change the where condition.
    How to do so?
    Code:---------
    create or replace procedure p_1
    ( p_id in emp_dummy.empno%type)
    is
    parameter_1 varchar2(2000);
    v_sal number;
    begin
    if p_id = 1 then
    parameter_1 := 'where empno = 1';
    else
    parameter_1 := 'where 1=1';
    end if;
    select salary into v_sal from emp_dummy||' '||parameter_1;
    end;

    Dynamic SQL is not the best of ideas, but if you must...
    EXECUTE IMMEDIATE 'select salary from emp_dummy where empno=nvl(:x,empno)' into v_sal using p_id;Then if you pass in the p_id to the procedure it will select the salary for that employee and if null is passed in then it will select the salary for all employees. Now here's a problem because you are trying to return a single value and if you don't specify the employee then it will try and return multiple values from that select, so you probably want to do something like give the sum of the salaries...
    EXECUTE IMMEDIATE 'select sum(salary) from emp_dummy where empno=nvl(:x,empno)' into v_sal using p_id;

  • Dynamic where condition in Select statement

    Hi,
    I have 10 fields on selection-screeen. In which ever field the user enters single values or ranges,i should pick that field dynamically and pass that field along with value range to Where condition of Select statement.How can i achieve this? Please help.
    Regards
    K Srinivas

    see the following example:
    data : begin of itab occurs 0,
             matnr like mara-matnr,
    end of itab.
    ypes: begin of ty_s_clause.
    types:   line(72)  type c.
    types: end of ty_s_clause.
    data : begin of gt_condtab occurs 0.
            include structure hrcond.
    data : end   of gt_condtab.
    FIELD-SYMBOLS <fs_wherecond> TYPE ty_s_clause.
    data:
      gt_where_clauses  type standard table of ty_s_clause
                        with default key.
    gt_condtab-field = 'MATNR'.
    gt_condtab-opera = 'EQ'.
    gt_condtab-low = '000000000000000111'.
    append  gt_condtab.
    clear  gt_condtab.
    call function 'RH_DYNAMIC_WHERE_BUILD'
      exporting
        dbtable         = space " can be empty
      tables
        condtab         = gt_condtab
        where_clause    = gt_where_clauses
      exceptions
        empty_condtab   = 01
        no_db_field     = 02
        unknown_db      = 03
        wrong_condition = 04.
    select matnr from mara into table itab where (gt_where_clauses).

Maybe you are looking for

  • Entity Attribute Validation via XML

    We have an Entity object with 2 attributes. I'm trying to setup a new validation rule for attribute B that forces it to be GREATER THAN attribute A. It seems that the only way to accomplish this is by using a MethodValidator. The most obvious choice,

  • BPC for Excel selection screens trouble

    Hi, all! In our BPC network there are some client machines which have strange trouble in BPC for Excel. When we try login to Excel, Run DM package and select members from CV and run others menu where exists selection screen we see black rectangle whe

  • Since installing Mavericks Photoshop CS6 is freezing all keyboard communication every 3 or 4 minutes

    Hi, a couple of days ago I installed Mavericks onto an imac running 16gb ram, 3.4ghz HD. I'm running Photoshop CS6 version 13.0.5 & using a wacom with the latest drivers 6.3.7-3.  I've had no issues previously but since installing Mavericks every 3 o

  • Is my ADS configured ??

    I installed Developer Workplace and ADS has come along with it (atleast I think so). I went to http://localhost:50004/AdobeDocumentServices/Config and this is what is displayed. I know the format is all gone but bear with me please. AdobeDocumentServ

  • EPMA Essbase Application Validation - A internal server error

    I have created an essbase application "TEST". In Epma i have uploaded the dimensions for the application and tried to Validate the application. But during validation I am getting the following error "A internal server error occured communicating with