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

Similar Messages

  • 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

  • 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;

  • Loop with dynamic where clause

    hi,
        In a program we need to use a loop into an internal table with a where condition is decided on run time.
    "Select" from database table is using dynamic where clause and it is working fine.
    For the loop part does any one have any idea on this? if we can have dynamic where clause in a loop into internal tab?
    Thanks

    Hi,
    You can't use 'loop where' dynamically  .
    Have you already tried to use Ranges and CHECK statement?
    Like:
    First mount range options;
    Loop at <table>.
    Check using the range.
    endloop.
    Maybe it's works for you !!
    Marcelo Ramos

  • 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

  • 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

  • Issue with Dynamic Link with Premiere CC and After Effects

    I'm having a strange and annoying issue with Dynamic linked clips in Premiere CC:
    When I render or export my timeline the progress will stall when it hits a dynamic linked clip.  It will stay stalled until I click the After Effects application and make it the active window.  Once that happens the render/export resumes at normal speed. 
    This is annoying as I can't start a render and walk away or work on different windows, I have to babysit all the renders to make sure they go through.
    Has anybody experienced this and know of any solutions? 
    I'm running the latest version of Premiere (7.2.1) and After Effects 12.2.0.52 on Mavericks 10.9.1 with a GTX 770 Video Card.

    Does it still pause if AE is closed completely? I often experience slower AME renders from Premiere over dynamic link material when AE is open. Closing AE speeds things up. Go figure.

  • Select three tables data with Same where condition

    Hi i want sum data in three tables with same where condition. how can i do this code very simple.
    SELECT SUM(SIGNA) FROM dbo.tblPLAG 
    WHERE   VERSION='ACTUAL' AND STATS='ST_Z010'
    AND FACILITY='FA_2003'
    AND  TD IN  ( SELECT TIMEID FROM Time   WHERE   ID BETWEEN 
     @YEAR+'.'+(SELECT RIGHT ('000'+ CAST (@PERIOD-6 AS varchar), 3)) 
     AND   
    @YEAR +'.'+(SELECT RIGHT ('000'+ CAST (@PERIOD AS varchar), 3)))
       

    Try following
    SELECT SUM(t1.SIGNA) + sum(t2.SIGNA) + sum(t3.SIGNA) and you query, it will add the SUMs of each table.. hopefully it will work

  • REPORT with dynamic WHERE CLAUSE (run RDF or REP) ?

    Hi:
    When running a REPORT (myreport.rep) with dynamic where clause using a lexical parameter, I got this error:
    REP-1439: Cannot compile .REP or .PLX file as it does not have source
    If i run the report specifiying RDF extension (myreport.rdf) the report run successfully! Is this normal ?
    If I specify RDF extension will Report Server COMPILE the report everytime I execute it ?
    When using dynamic WHERE CLAUSE I will have to run RDF files instead of REP ?
    I'm running Reports 9i under Linux, with IDS under Windows.
    Waiting Help
    Joao Oliveira

    It sounds like you are building the .rep files on one platform (windows) and running them on another (linux). The reason that the .rdf file continues to work is that Reports recompiles the PL/SQL within the report when you move from one platform to another or change schemas. .rep files can't be re-compiled in this way so you need to ensure they are compiled successfully when converting them.
    You need to convert from .rdf to .rep on the platform that you are intending to run on. Try running rwconverter on the linux platform with "compile_all=yes" to produce the .rep file and running that .rep file.

  • Are there any issues with itunes where as certain windows looks like a PC in safe mode?

    are there any issues with itunes where as certain windows looks like a PC in safe mode?

    Check your trash. I had some old uninstalled files in there. Deleted and restated itunes. seems to work.

  • Issue with dynamically setting where clause in OAF

    Hi All,
    I have a View object having the query below:
    SELECT  rownum LINENUM,
            B.line_id LINE_ID,
            B.INVENTORY_ITEM_ID INVITMID ,
            B.QUANTITY_DELIVERED PICKQTY         
    from   MTL_TXN_REQUEST_HEADERS A,
            MTL_TXN_REQUEST_LINES  B
      WHERE A.HEADER_ID=B.HEADER_ID
       AND A.MOVE_ORDER_TYPE=2 
       AND 'on'=:1
       AND B.TO_SUBINVENTORY_CODE=NVL(:4,B.TO_SUBINVENTORY_CODE)
       AND A.request_number=NVL(:5,A.REQUEST_NUMBER) 
    UNION ALL
    SELECT  rownum LINENUM,
            a.wip_entity_id LINE_ID,
            a.INVENTORY_ITEM_ID INVITMID,
            a.QUANTITY_ISSUED PICKQTY      
      FROM  WIP_REQUIREMENT_OPERATIONS a,
            eam_work_orders_v b
      WHERE a.wip_entity_id=b.wip_entity_id
         AND 'on'=:2
        AND a.ATTRIBUTE2=NVL(:4,a.ATTRIBUTE2)
      and b.wip_entity_name=NVL(:6,b.wip_entity_name)
    I need to pass dynamically a condition to my where clause that i can handle it by defining two bind parameters in the vo query and can pass it but the problem is the bind variable contains a string like 1311,13112,14445 that i need to pass for a field such as B.line_id in the first query and b.wip_entity_id in the second query so when i am trying by passing the string as one value it is working fine but for value separetd by comma it is giving prob.
    so i tried by passing dynamic where clause but it is everytime executing for first clause only how i can pass dynamically both the queries.
    vo.setWhereClause("LINE_ID in "+wherclause);
    please help me out
    Thnaks
    Deb

    Hi Gaurav,
    Thnaks for the reply i tried belwo way u suggested but the query is executing multiple times and i am not getting the correct data as expected.
    public void processPOData (String wherclause)
                 OAViewObject vo = this.getXXDPECONTAINLINESVO1();
                    String query =vo.getQuery();
                    String newwhereclause ="LINE_ID = "+wherclause;
                    StringBuffer stringbuffer = new StringBuffer();  
                stringbuffer.append("SELECT * FROM (");
                stringbuffer.append(query);
                stringbuffer.append(") where ");
                stringbuffer.append(newwhereclause);          
        ViewDefImpl viewdefimpl = getXXDPECONTAINLINESVO1().getViewDefinition();
                viewdefimpl.setQuery(stringbuffer.toString());
                 vo.reset();
                 vo.clearCache();
                vo.executeQuery();
                    System.out.println("where clause:"+wherclause);
    in my log file the query is forming like below:
    SELECT * FROM (SELECT * FROM (SELECT * FROM (SELECT * FROM ( SELECT * FROM ( SELECT  rownum LINENUM,
            B.line_id LINE_ID,
            B.INVENTORY_ITEM_ID INVITMID ,
            B.QUANTITY_DELIVERED PICKQTY ,
            B.TO_SUBINVENTORY_CODE UNLOADINGPNT,
            A.REQUEST_NUMBER RRNUM,
            NULL WORKORDNUM,
            NULL DTRNUM,
            A.description,
            A.FROM_SUBINVENTORY_CODE FROM_SUB,
            A.TO_SUBINVENTORY_CODE  TO_SUB,
            NULL SOURCE       
    from   MTL_TXN_REQUEST_HEADERS A,
            MTL_TXN_REQUEST_LINES  B
      WHERE A.HEADER_ID=B.HEADER_ID
       AND A.MOVE_ORDER_TYPE=2  
    UNION ALL
    SELECT  rownum LINENUM,
            a.wip_entity_id LINE_ID,
            a.INVENTORY_ITEM_ID INVITMID,
            a.QUANTITY_ISSUED PICKQTY,
            a.ATTRIBUTE2 UNLOADINGPNT,
            NULL RRNUM,
            b.WIP_ENTITY_NAME WORKORDNUM,
            NULL DTRNUM,
            b.description,
            NULL FROM_SUB,
            NULL TO_SUB,      
            b.source SOURCE
      FROM  WIP_REQUIREMENT_OPERATIONS a,
            eam_work_orders_v b
      WHERE a.wip_entity_id=b.wip_entity_id ) )) where LINE_ID = 30026) where LINE_ID = 30026) where LINE_ID = 30026
    But in my page i am getting all the data instead of only for line 30026, please help me out

  • Xcelsius Engage: Issue with dynamic visibilty of data in dashboard

    Hi,
    We have a requirement for a dashboard where data for 5 Sites need to be displayed as per 17 KPIs and 12 different rolling months.
    Raw sample data looks like below-
    SITE  KPI        ActYTD  Act(Pre Month) PlanYTD  Plan(Prev Month)  VarianceYTD Variance(Pre Month)
    A       On-Time   76.7         82.92                  111.50       109.50             -1                    -1
    B       Delay       73.70       80.00                   79.75        77.75             -1                     1
    There are 5 different Sites and 17 different KPIs.
    Based on the raw data that we get from BI (7.0 query output), we manipulate it in MS excel, using some lookups and formulae to obtain certain values, store them in designated sheets and then Xcelsius (different components) use these sheets as source.
    We are having three levels of navigation-
    1. Main screen listing all KPIs site wise and months ( the site and months could be selected from Combo boxes at the top). The KPIs are bind to a list view, each row is a selectable KPI leading to level two navigation.
    2. Level two contains the details for each KPI ( values and trend chart). Selection in the chart for a Site leads to level 3 navigation.
    3. Level 3 screen contains data by KPI and by Site for 12 rolling months ( The sites could be changed from a drop-down).
    There are custom navigation buttons (home/back) to enable navigations between the screens.
    We are using 3 panel containers, 2 list views, 4-5 combo boxes and some hidden button ( with dynamic visibilty).
    The workbook has 8-9 different sheets, though the Xcelsius componets are bound to only 3 sheets.
    Things work fine till we select 14th KPI , but Xcelsius starts behaving awkwardly when we select 15th KPI and further.For the selected KPI, the level two screen would load for a flash of a second and then the control comes back to level 1 screen. We do not face this issue till 14th KPI.
    In-order to eliminate possibiltes we did the following-
    1. Changed the order of KPIs - issue persists
    2. Changed the Excel option " Max. no of Rows" to 4000- issue persists
    3. Decreased the amount of data to be loaded - issue persists ( though at max we are loading data for 2000 rows)
    4. Decreased the no. of KPIs to 14 in level 1 list view - all works fine.
    We have not noticed any gradual decrease in performance/load time till 14th KPI but everything goes for a toss when the 15th KPI is displayed.
    We are on the latest Xcelsius patch ( patch 3).
    We would appreciate any pointers/help to resolve this issue.
    Thanks in advance for your time.
    Best Regards,
    Bansi.

    How many total rows are you dealing with in your spreadsheet?
    -Dell

  • Performance issues with dynamic action (PL/SQL)

    Hi!
    I'm having perfomance issues with a dynamic action that is triggered on a button click.
    I have 5 drop down lists to select columns which the users want to filter, 5 drop down lists to select an operation and 5 boxes to input values.
    After that, there is a filter button that just submits the page based on the selected filters.
    This part works fine, the data is filtered almost instantaneously.
    After this, I have 3 column selectors and 3 boxes where users put values they wish to update the filtered rows to,
    There is an update button that calls the dynamic action (procedure that is written below).
    It should be straight out, the only performance issue could be the decode section, because I need to cover cases when user wants to set a value to null (@) and when he doesn't want update 3 columns, but less (he leaves '').
    Hence P99_X_UC1 || ' = decode('  || P99_X_UV1 ||','''','|| P99_X_UC1  ||',''@'',null,'|| P99_X_UV1  ||')
    However when I finally click the update button, my browser freezes and nothing happens on the table.
    Can anyone help me solve this and improve the speed of the update?
    Regards,
    Ivan
    P.S. The code for the procedure is below:
    create or replace
    PROCEDURE DWP.PROC_UPD
    (P99_X_UC1 in VARCHAR2,
    P99_X_UV1 in VARCHAR2,
    P99_X_UC2 in VARCHAR2,
    P99_X_UV2 in VARCHAR2,
    P99_X_UC3 in VARCHAR2,
    P99_X_UV3 in VARCHAR2,
    P99_X_COL in VARCHAR2,
    P99_X_O in VARCHAR2,
    P99_X_V in VARCHAR2,
    P99_X_COL2 in VARCHAR2,
    P99_X_O2 in VARCHAR2,
    P99_X_V2 in VARCHAR2,
    P99_X_COL3 in VARCHAR2,
    P99_X_O3 in VARCHAR2,
    P99_X_V3 in VARCHAR2,
    P99_X_COL4 in VARCHAR2,
    P99_X_O4 in VARCHAR2,
    P99_X_V4 in VARCHAR2,
    P99_X_COL5 in VARCHAR2,
    P99_X_O5 in VARCHAR2,
    P99_X_V5 in VARCHAR2,
    P99_X_CD in VARCHAR2,
    P99_X_VD in VARCHAR2
    ) IS
    l_sql_stmt varchar2(32600);
    p_table_name varchar2(30) := 'DWP.IZV_SLOG_DET'; 
    BEGIN
    l_sql_stmt := 'update ' || p_table_name || ' set '
    || P99_X_UC1 || ' = decode('  || P99_X_UV1 ||','''','|| P99_X_UC1  ||',''@'',null,'|| P99_X_UV1  ||'),'
    || P99_X_UC2 || ' = decode('  || P99_X_UV2 ||','''','|| P99_X_UC2  ||',''@'',null,'|| P99_X_UV2  ||'),'
    || P99_X_UC3 || ' = decode('  || P99_X_UV3 ||','''','|| P99_X_UC3  ||',''@'',null,'|| P99_X_UV3  ||') where '||
    P99_X_COL  ||' '|| P99_X_O  ||' ' || P99_X_V  || ' and ' ||
    P99_X_COL2 ||' '|| P99_X_O2 ||' ' || P99_X_V2 || ' and ' ||
    P99_X_COL3 ||' '|| P99_X_O3 ||' ' || P99_X_V3 || ' and ' ||
    P99_X_COL4 ||' '|| P99_X_O4 ||' ' || P99_X_V4 || ' and ' ||
    P99_X_COL5 ||' '|| P99_X_O5 ||' ' || P99_X_V5 || ' and ' ||
    P99_X_CD   ||       ' = '         || P99_X_VD ;
    --dbms_output.put_line(l_sql_stmt); 
    EXECUTE IMMEDIATE l_sql_stmt;
    END;

    Hi Ivan,
    I do not think that the decode is performance relevant. Maybe the update hangs because some other transaction has uncommitted changes to one of the affected rows or the where clause is not selective enough and needs to update a huge amount of records.
    Besides that - and I might be wrong, because I only know some part of your app - the code here looks like you have a huge sql injection vulnerability here. Maybe you should consider re-writing your logic in static sql. If that is not possible, you should make sure that the user input only contains allowed values, e.g. by white-listing P99_X_On (i.e. make sure they only contain known values like '=', '<', ...), and by using dbms_assert.enquote_name/enquote_literal on the other P99_X_nnn parameters.
    Regards,
    Christian

  • 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).

  • 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

Maybe you are looking for

  • XP Pro license key on sticker is not valid

    Hi, I have a HP desktop machine with window XP Pro license sticker on it. System hard disk is not working anymore and i need to reinstall the xp pro on new hard disk. I don't have any xp installation cd with me, i have tried the xp pro installation c

  • Downloading failed on Nokia 6790 slider

    I had a Nokia E71 and never had any issues with the Ovi store.  I traded it in for a Nokia 6790 slider which I got it set up and going, I downloaded the Ovi Store and went to download the youtube and it gets to about half done before it says Download

  • I NEED help capturing... ANYONE

    Sorry to sound desperate but i have been trying to fix this for 4 days and have a project coming due. FCP 5.1 Quicktime 7.2 Mac OS X 10.4.11 When i try to capture i can control my Canon XL1. I see the time code and can start and stop. VT OK. No Pictu

  • Forms became so slowely

    Hi All, I am using the JDK instead of the JINITIATOR it was working good but I dont know why it became very slowely, I tried to remove the OS and reinstall it again but the problem still exist. I am using internet explorer 7 I dont know if it cause a

  • Very Slow Imports

    Rec'd the 60G video Ipod for Christmas, just intalled ITunes 6 last weekend. I started importing cd's at a rate of 18x, which was awesome. Started importing more cd's today, down to a rate of 4x, which is taking forever (I've got about 400 cd's to im