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

Similar Messages

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

  • 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

  • Using select-option in webdynpro for ABAP where I have two separate pages

    Hi Experts,
             I have a requirement where I have two pages. The first page is a selection screen that contains 2 select-options to select carrid and connid. There is also a button 'Submit'. The second page contains a ALV grid output based on the selection screen criteria.
    Second page is opened on the clicking the 'Submit' button in first page.
    How to design a ABAP webdynpro component for this scenario?
    How to pass select-option values to the next page?
    What nodes/attributes should I have to create in component controller?
    Please provide me the step by step info.
    I have seen the weblog by Rich Heilman at /people/rich.heilman2/blog/2005/12/20/using-select-options-in-a-web-dynproabap-application
    But it has only one page. So I am not able to recreate my scenario based on this.
    Thanks
    Gopal

    Hi Experts,
             I have a requirement where I have two pages. The first page is a selection screen that contains 2 select-options to select carrid and connid. There is also a button 'Submit'. The second page contains a ALV grid output based on the selection screen criteria.
    Second page is opened on the clicking the 'Submit' button in first page.
    How to design a ABAP webdynpro component for this scenario?
    How to pass select-option values to the next page?
    What nodes/attributes should I have to create in component controller?
    Please provide me the step by step info.
    I have seen the weblog by Rich Heilman at /people/rich.heilman2/blog/2005/12/20/using-select-options-in-a-web-dynproabap-application
    But it has only one page. So I am not able to recreate my scenario based on this.
    Thanks
    Gopal

  • Using Select option in Native SQL

    Hi,
    Can any one tell me, how to use select option value in native SQL.
    ie.,
    I want to use select option in where condition. Need to select all the records from table(non-SAP) where date in given range.
    Please suggest.
    Thanks,
    Amal

    Hi
    No!
    U need to find a way to convert a range of select-option to a range for Native SQL, probably it should be better doesn't use a select-option for the date but two parameters: one for date from and one for date to.
    Max

  • How will use Select-Options in Read table Concept.

    Hi All,
                  How will use Select-Options in Read table. For  example,
          Select-Options : test for bseg-prctr.
           Select * from bseg into table ITAB.
    Read table ITAB with key prctr in test.
    Last line is showing error. If any way to read ITAB as conditions given per select options.
    Thankx Advance,,,

    HI,
    you cannot use " IN " with read statement , read statement is used as:
    READ TABLE it_collect  ASSIGNING <fs_collect>
                      WITH KEY   rbpl = <fs_wkdet>-arbpl
                                 ufnr = <fs_wkdet>-aufnr.
    anyways you can use  loop at statement before read to use  " into "  statement as:
    LOOP AT it_master INTO l_master
                                           WHERE werks       = l_werks
    hope it will help you
    regards
    rahul
    Edited by: RAHUL SHARMA on Dec 30, 2008 9:14 AM

  • 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

  • How to use select-options in the function module of import parameter ?

    Hi ...
       I have created a BAPI and tested in SWO1 tcode , by giving the single value for an company code ( BUKRS ) , it executed properly .
    Same thing is working after implementing in a program .
    so now it is working for fetching a single company code details .
    My requirement is : I want to use select-options in program as well as in function module IN IMPORT PARAMETER.
    Program :
    REPORT  ZTEST.
    TABLES : T001 , ZBAPI_STR .
    TYPES : BEGIN OF TY_ITEM  .
              INCLUDE STRUCTURE ZBAPI_STR .
    TYPES : END OF TY_ITEM .
    DATA :WA_ITEM TYPE TY_ITEM ,
          ITEM LIKE STANDARD TABLE OF WA_ITEM INITIAL SIZE 0 .
    PARAMETER : BUKRS TYPE ZBAPI_STR-BUKRS.
    call function 'ZBAPI_FMT001'
      exporting
        bukrs         =  BUKRS
    IMPORTING
      RETURN        =
      tables
        itemtab       = ITEM
    IF ITEM IS NOT INITIAL .
      LOOP AT ITEM INTO WA_ITEM .
        WRITE : / WA_ITEM-BUKRS , WA_ITEM-BUTXT , WA_ITEM-ORT01 , WA_ITEM-LAND1 .
      ENDLOOP.
    ENDIF.
    FUNCTION MODULE :
    FUNCTION ZBAPI_FMT001.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(BUKRS) TYPE  EFG_TAB_RANGES
    *"  EXPORTING
    *"     VALUE(RETURN) TYPE  BAPIRET2
    *"  TABLES
    *"      ITEMTAB STRUCTURE  ZBAPI_STR
    SELECT BUKRS BUTXT ORT01 LAND1 FROM T001 INTO TABLE ITEMTAB WHERE BUKRS = BUKRS .
    ENDFUNCTION.
    Regards
    Deepa.

    I have given a similiar example which i did
    Declare a
    Table type:Z_TT_PONUM             
    Short text  :  Select options  PO Number
    in SE11 tcode with row type eg: Z_ST_PONUM
    create a structure (this will be the row type)
    Structure          Z_ST_PONUM            
    Short text         Select Options Field PO number
    Compenent  Compent type
    SIGN       BAPISIGN      Inclusion/exclusion criterion SIGN for range tables
    OPTION       BAPIOPTION      Selection operator OPTION for range tables
    LOW       EBELN                      Purchasing Document Number
    HIGH       EBELN                      Purchasing Document Number
    In the function module import
    give as
    I_PO_NUM     TYPE     Z_TT_PONUM     opt  pass value Select options  PO Number
    Hope this is exactly what you want to know.
    So you create a structure simliar to mine but the low an high whould be your component
    then a table type  and then include that in the BAPI.
    Then pass your select-option value to this BAPI when you call this BAPI in the program

  • Problem with table-indexes when using select-options in select

    Hello experts,
    is it right that table-indexes will not be used if you take select-options to select data from the database?
    in detail:
    i have build up an table-index for one of our db-tables and test it via an test-programm. The first test with '=' comparisons worked fine. Every key of the index was used; checked via ST05!
    e.g.:    SELECT * FROM TABLEA INTO ITAB WHERE keya = '1' AND keyb = '2' AND keyc = '3'.
    Now i startet the test with select-options
    e.g.:   SELECT * FROM TABLEA INTO ITAB WHERE keya IN seltabA  AND keyb IN seltabB AND keyc IN seltabC.
    First of all i just filled the seltabs with only 1 value:    eg:  seltabA=      SIGN = 'I'   OPTION = 'EQ'   LOW = '1'     etc.
    Everything worked fine. Every key of the index was used.
    But now, I putted more than one entries in the seltabs e.g.
    seltabA:      SIGN = 'I'   OPTION = 'EQ'   LOW = '1'
                       SIGN = 'I'   OPTION = 'EQ'   LOW = '2'   
                       SIGN = 'I'   OPTION = 'EQ'   LOW = '3'
    From now on, the indexed was not used completely (with all keys).
    Isn't that strange? How can i use select-options or sel-ranges with using the complete table-indexes?
    Thanks a lot,
    Marcel

    Hi Hermann,
    i hope this helps:
    this is the first one, which uses the complete index:
    SELECT                                                                     
      "KOWID" , "LIFNR" , "KLPOS" , "ORGID" , "KOART" , "MATNR" , "GLTVON" ,   
      "GLTBIS" , "WERT" , "ABLIF" , "FAKIV" , "AENAM" , "AEDAT" , "AFORM" ,    
      "HERSTELLER" , "ARTGRP" , "OE_FREITXT" , "ARTFREITEXT" , "STATUS" ,      
      "TERDAT"                                                                 
    FROM                                                                       
      "/dbcon/01_con"                                                       
    WHERE                                                                      
      "MANDT" = ? AND "LIFNR" = ? AND "ORGID" = ? AND "KOART_BASIS" = ? AND    
      "STATUS" = ? AND "GEWAEHR_KOWID" < ? AND ( "STATUS" = ? OR "STATUS" = ? OR
      "STATUS" = ? )  WITH UR                 
    RESULT: 5 IXSCAN /dbcon/01_con05 #key columns:  4
    And the second one, which does not use the complete index! The 3 ranges are filled each with 2 values. Remember; when i fill them each with only one value, the result is the same as you can see above(/dbcon/01_con05 #key columns:  4):
    SELECT                                                                     
      "KOWID" , "LIFNR" , "KLPOS" , "ORGID" , "KOART" , "MATNR" , "GLTVON" ,   
      "GLTBIS" , "WERT" , "ABLIF" , "FAKIV" , "AENAM" , "AEDAT" , "AFORM" ,    
      "HERSTELLER" , "ARTGRP" , "OE_FREITXT" , "ARTFREITEXT" , "STATUS" ,      
      "TERDAT"                                                                 
    FROM                                                                       
      "/dbcon/01_con"                                                       
    WHERE                                                                      
      "MANDT" = ? AND "LIFNR" IN ( ? , ? ) AND "ORGID" IN ( ? , ? ) AND        
      "KOART_BASIS" IN ( ? , ? ) AND "GEWAEHR_KOWID" < ? AND ( "STATUS" = ? OR 
      "STATUS" = ? OR "STATUS" = ? )  WITH UR                                  
    and here the access-plan
       0 SELECT STATEMENT ( Estimated Costs =  5,139E+01 [timerons] )                                                                               
    5     1 RETURN                                                                               
    5     2 NLJOIN                                                                               
    5     3 [O] TBSCAN                                                                               
    5     4 SORT                                                                               
    5 TBSCAN GENROW                                                                               
    5     6 <i> FETCH /dbcon/01_con                                                                               
    7 IXSCAN /dbcon/01_con05 #key columns:  2   
    As you can see, only 2 keys were taken for indexed selection!
    Any idea?
    Kind regards,
    MArcel
    Edited by: Marcel Ebert on Jul 28, 2009 5:25 PM

  • How to use select options whitout ranges ie like parameter

    how to use select options whitout ranges ie like parameter and pls send me the code on that
    thanks
    raja.

    hi,
    SELECT-OPTIONS : s_kunnr for kna1-kunnr <b>no intervels.</b>
    eg: code
    <b>SELECT-OPTIONS : s_kunnr for kna1-kunnr <b>no intervels.</b></b>
    data: itab type table of kna1 with header line.
    select * from kna1 into table itab where kunnr IN s_kunnr.
    rgds
    Anver

  • ABAP WD application using Select Options  & Adobe form :Don't see form data

    Hi,
    I am trying to get multiple PDF forms by passing multiple order numbers.I was able to get one PDF form successfully and now I am enhancing this application.
    For doing this I have created nested WD Context .
    1) Created a Node for Selections. ND_SELECT  ,
    Cardinality: 1..n ,
    Selection: 1..n ,
    Intialization lead Selection : Checked ,
    Singleton : Checked
    2) Created a Node for Output Structures ADOBE_DATA
    Properties same as above
    3) As we need Nesting Under ADOBE_DATA node I have created a subnode for Header: HEADER
    Properties same as above
    4) Under HEADER node I have created a items Node : ITEM
    Properties same as above
    As I have used Select-options and I am getting both header and Item data in to button search method .
    DATA lo_nd_adobe_data TYPE REF TO if_wd_context_node.
      DATA lo_nd_header TYPE REF TO if_wd_context_node.
      DATA lo_el_header TYPE REF TO if_wd_context_element.
      DATA ls_header TYPE wd_this->element_header.
    * navigate from <CONTEXT> to <ADOBE_DATA> via lead selection
      lo_nd_adobe_data = wd_context->get_child_node( name = wd_this->wdctx_adobe_data ).
    * navigate from <ADOBE_DATA> to <HEADER> via lead selection
      lo_nd_header = lo_nd_adobe_data->get_child_node( name = wd_this->wdctx_header ).
      lo_nd_header->bind_table( new_items = it_header  set_initial_elements = abap_true ).
      DATA lo_nd_item TYPE REF TO if_wd_context_node.
      DATA lo_el_item TYPE REF TO if_wd_context_element.
      DATA ls_item TYPE wd_this->element_item.
    * navigate from <CONTEXT> to <ADOBE_DATA> via lead selection
      lo_nd_adobe_data = wd_context->get_child_node( name = wd_this->wdctx_adobe_data ).
    * navigate from <ADOBE_DATA> to <HEADER> via lead selection
      lo_nd_header = lo_nd_adobe_data->get_child_node( name = wd_this->wdctx_header ).
    * navigate from <HEADER> to <ITEM> via lead selection
      lo_nd_item = lo_nd_header->get_child_node( name = wd_this->wdctx_item ).
    lo_nd_item->bind_table( new_items = it_item  set_initial_elements = abap_true ).
    Could you please tell me where I am doing wrong?
    In adobe form
    Created one MainForm  and its properties are
    Binding : $record.HEADER.DATA[*]
    Repeat subform for each data item Checked , Min Count: 1
    Subform Content : Flowed ,Western Text , Allow page breaks withing Content Checked
    Accessibility /Subform Role: None
    Inside this Mainform I have created a small table ITEMTABLE  with 3 fields and mapped it item data.
    Itemtable properties
    Binding : ITEM
    Uncheck Repeat table for Each Data item.
    I have Itemtablerow inside Itemtable  and its properties are:
    Binding : DATA[*]
    Repeat row for each data item Checked ,Min count: 1
    Accesibility:/Subform Role: Body row
    Row: body row, Check Allow page breaks within content
    Still donu2019t see data on form.here is what i have in Hierarchy tab.
    ADOBE_DATA (no Caption)
    - (Master pages)(no caption)
             Page1
                      Untitled Content Area(no caption)
    - Mainform(no Caption)
                       PSPID {PSPID}
              -ItemTable (No caption)
                      - ItemtableRow (no Caption)
                                   PSPID(no Caption)
                                    CJTDAT(no Caption)
                                    CPERCO(no Caption)
    What could be going wrong ?
    Rgds
    Vara

    Hi John,
    In the WD4A view, there is a button "Show/Hide Layout Preview".
    Click on that button to be able to see the Layout.
    Note that this button is next to the Pretty Print button.
    regards,
    Reema.

  • "WHERE field IN select-options" alternative

    I currently have a report that uses
    SELECT-OPTIONS so_num FOR qmih-qmnum.
    SELECT * FROM qmih INTO TABLE t_qmih
       WHERE qmnum IN so_num.
    Now, this works fine unless the user selects a large number of individual items in the select options, e.g. 7,000 individual qmnums, in which case I get an ABAP error.
    The dump contains the following helpful information:
    How to correct the error                                                                               
    The SAP Open SQL statement must be divided into several smaller units.
    If the problem occurred due to the use of an excessively large table  
    in an IN itab construct, you can use the addition FOR ALL ENTRIES     
    instead.                                                              
    When you use this addition, the statement is split into smaller units 
    according to the restrictions of the database system used.                                                                               
    You may able to find an interim solution to the problem               
    in the SAP note system. If you have access to the note system yourself,
    use the following search criteria:                                    
    Could anyone give me an idea of how I could fix this?

    Hi Chandrasekhar,
    very interesting statement but not necessarily correct.
    Select-options declares a range-type internal table with header line. The number of table rows is limited by the system memory storage available.
    Oracle database has a fixed limit of 32KB for the length of the select statement. The open SQL database interface will resolve the range table resulting in the right number of comparison expressions.
    If the user puts too many values into select-options, he will probably copy single values which are represented by SIGN = 'I' and OPTION = 'EQ'.
    Try this (example):
    select-options:
      s_matnr for mara-matnr.
    data:
      lt_value like hashed table of s_matnr-low with unique key table_line. "avoid duplicates
    fiels-symbols:
      <any> type any,
      <value> type any.
    loop at s_matnr assigning <any>
      where sign = 'I' and option = 'EQ'.
      assign component 'LOW' of structure <any> to <field>.
      insert <field> into table t_value.
      delete s_matnr.
    endloop.
    select ...
      into table ...
      from ...
      for all entries in lt_value
      where matnr = lt_value-table_line.
    if lines( s_matnr ) > 0.
    select ...
      appending table ...
      from ...
      where matnr in s_matnr.
    endif.
    Now you've got them all.
    Regards,
    Clemens

  • 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

  • Can we use select options in smartform

    can we use select options in smartform if so can any one send me a sample code...
    Thanks
    bhaskhar

    Hi ,
    Can u explain why u want to use select options in smartforms . U can try it in program lines .
    Its better to use select options in the driver program and fetch data accordingly in the driver program or passing the selected values from select options to the smatfrom and fdetching the data there in smartform .
    Regards

Maybe you are looking for

  • Error #1009: Cannot access a property or method of a null object reference.

    Well I'm stumped. I have researched the issue for 5 hours now and can't seem to come any closer to understand what the issue is. I receive an error occurs while the program is adding elements to an Object. After 10 elements are added it goes into the

  • Oracle database Connectivity using OCI driver

    I am getting the error only when ever I am using oci driver oracle.url=jdbc:oracle:oci:@(description=(address=(host=url.name.com)(protocol=tcp)(port=1521))(connect_data=(sid=user))) 04:52:55,093 ERROR [STDERR] java.sql.SQLException: ???S???Y??x?? 04:

  • Permenant error in bpm inbound processing error in inbound queue of pi7.1

    Hi Experts,              In  E filling scenario in SAPPI7.1, iam facing a problem. i.e In sxmb_moni message monitoring, the  message was schedule at outbound side.when i extend that, the message was stuck in smq2 with "permenant error in bpm inbound

  • Lightroom tether issues.

    I shoot events where lots of folks line up to get photographed and I use LR to aid in getting the best shots and allow the clients to select their favorites. I own a Nikon D700 and tether it to my recently purchased a Dell Inspiron Laptop with WIn7,

  • Sale Orders not to be released through VKM4

    Hi ,       I have a problem I dont want users to release sale orders through VKM4, how can i hide the SAle Orders tick Box. ? Regrds, Binayak