Dynamic Where Clause - How To?

I need help building a dynamic where clause in 1.6
I have three fields:
p1_col_where which is a static list of 8 columns
p1_condition which is a static list of the 9 possible conditions(=,<,>...)
p1_condition_value is a text field that the user enters the literal they want to use
The lov select I thought would be:
SELECT Description, positem
FROM v_item
WHERE :P1_COL_WHERE :P1_CONDITION :P1_CONDITION_VALUE
I was hoping that this would be resolved to: WHERE item = 123
but of course I get a big NASTY error.
Can someone help me out?
Thanks,
Joe

Mike,
Thanks for the help.
There's a problem in the docs for creating this popup on step 5. The docs say:
Step 5 - Add the LOV report to the popup page
select ename, job, sal , 'placeholder' the_link
from emp
where ename like '%'||:P2_ENAME||'%'
and (job = :P2_JOB or :P2_JOB is null)
and (sal = :P2_SAL or :P2_SAL is null)
Note that the last column in this query is just a placeholder. once the region is created, turn that placeholder into a link by doing the following:
1.     Navigate to the Page Definition for page 2
2.     Next to the name of the report region created in step 5, Click Q
3.     Next to the column THE_LINK, click the edit icon
4.     In the "Link Text" field enter the string "select"
5.     In the URL field enter: javascript:passBack('#ENAME#','#JOB#','#SAL#');
6.     Click the "Apply Changes" button
The problem is in number 5. There is NO URL field to enter that code. Where does it go?
Also, your alternative method:
IF :P1_COL_WHERE is null then
RETURN 'SELECT Description, positem FROM v_item';
ELSE
RETURN 'SELECT Description, positem FROM v_item '||
' WHERE '||:P1_COL_WHERE||' '||:P1_CONDITION||' '||:P1_CONDITION_VALUE;
END IF;
With a 'GO' button is the method that I was trying. That's what gave me the error when the page loaded.
Any assistance is greatly appreciated.
Thanks,
Joe

Similar Messages

  • How to set dynamic WHERE clause to VO from backingBean?

    Hi,
    Can any one let me know the best way to add the dynamic WHERE clause in to VO query.
    I have created AM (with AMImpl.java) & VO (with VOImpl.java & VORowImpl.java) in my model project. I suppose to set the WHERE condition at runtime while the user click the search button. I am handling the user button click at UI layer backingBean. From the backing bean I could able to get the objct of the VO and set the where clause by below code.
            ValueExpression valueExp = elFactory.createValueExpression(elContext, "#{bindings.UserSearchVO1Iterator}", Object.class);
            DCIteratorBinding dcIter = (DCIteratorBinding)valueExp.getValue(elContext);
            ViewObject userSearchVO = dcIter.getViewObject();
            userSearchVO.setWhereClause("lower(usr_login) LIKE ':1' and usr_udf_suid like ':2' ");
            userSearchVO.executeQuery();But as I fear this is not the right way to do it. So I am creating the cutom method inside the VOImpl.java and triggring that method by creating one more cutom method in AMImpl.java. But I dont know how to invoke this AM method from backingBean.
    AMImpl method
    public void initDetails()
            UserSearchVOImpl vo = getUserSearchVO1();
            vo.initQuery();
    VOImpl method
        public void initQuery()
            setWhereClause("lower(usr_login) LIKE 'a%' and usr_udf_suid like '%1144%'");
            executeQuery();
        }Can any one guide me which is the best way to set the where clause to VO? How to call the AM method from backingBean?
    Thanks
    kln

    i am new to oracle 11g i writing a stored procedure in which i have made use of case in where clause to pass my parameter value v_toStoreID
    i have googled a lot regarding that i found that to use case in where clause it should be like this
    where
    case  column_value
    when 0
    then value1
    else
    value2
    end
    this my query
    SELECT ITMID as ItemId,
    NVL(OrderDtl.PackageID, 0) PackageId,
    OrderDtl.OrdDtlID,
    (CASE NVL(OrderDtl.PackageID, 0)
    WHEN 0
    THEN 1
    ELSE 0
    END) as PackageFlag,
    ivitem.Code ItemCode,
    ivitem.ITMNAME AS itemName,
    IvPatientIssueMst.IssueNo Issue_No,
    to_char(Issuedate, 'DD/MM/YYYY') IssueDate,
    OrderDtl.OrdQty,
    NVL(OrderDtl.AllocationID, 0) Package,
    OrderDtl.ServiceAmount MRP
    FROM IvPatientIssueMst
    JOIN OrderMst
    ON IvPatientIssueMst.OrderId = OrderMst.OrdId
    JOIN OrderDtl
    ON OrderDtl.OrdID = OrderMst.OrdId
    JOIN ivitem
    ON ivitem.ITMID = OrderDtl.DrugId
    LEFT JOIN IVPatientIndentMst
    ON IVPatientIndentMst.IndentID = IvPatientIssueMst.IndentId
    WHERE OrderMst.OrdVisitID = 395899
    AND
    *(CASE IvPatientIssueMst.StoreId*
    when NVL(IvPatientIssueMst.StoreId, 0)=0
    THEN v_toStoreID
    ELSE  IVPatientIndentMst.ToStoreID
    END)
    ORDER BY ivitem.ITMNAME;
    it is not working please someone help

  • How to add a dynamic where clause for a sql based VO with group by query?

    Hi,
    Here is my case, I have a sql query based VO with the query like "select status, count(*) StatusCount from my_table group by status". Now I used the following java code trying to dynamically add the where clause to my VO to filter the rows based the type attribute in my DB table.
    vo.setWhereClause("type='MyType1' ");
    vo.executeQuery();
    Then I got the sql syntax error. Looks like the ADF has added the where clause to the end of my sql so my sql becomes "select status, count(*) StatusCount from my_table group by status where type='MyType1' ". But what I expected was the correct syntax "select status, count(*) StatusCount from my_table where type='MyType1' group by status".
    Does anyone know if this is an ADF bug? Or is there any other way to achieve my goal?
    Thanks,
    Chunyang
    Edited by: Chunyang on Dec 13, 2012 9:09 PM

    Hi,
    When you use setWhereClause on the VO, it is applied on top of the VO query. I.e, assume your VO has the following query.
    select empno, ename from empNow, if you apply the where clause programatically, only the two attributes that you are using in the select statement could be used. I.e
    select * from (select empno, ename from emp) where ename='KING' - VALID
    select * from (select empno, ename from emp) where deptno=10  - INVALID (because the inner query - the one you've defined as query for your vo does not have deptno attribute selected)If you would need to set a dynamic where clause, you need to make them available in your select statement / use bind variables.
    -Arun

  • How to create VO with multiple dynamic where clauses on select with UNION?

    I am trying to implement the View Object for the UNION query that looks like this:
         select a,b,c...
              from t1,t2,...
              where dynamic_where_clause1     
         union all
         select a,b,c,...
              from t11,t12, ...
              where dynamic_where_clause2
    There are up to 60 input parameters that are used to generate dynamic where clauses. They are actually created by calling PL SQL function.
    So far, I was not able to assign both where clauses to the view object. Is there a workable solution for this problem, besides resorting to programmatic View Object?
    I understand that recommended way with UNIONs is to wrap both queries into a parent select:
    select * from (
         select a,b,c...
              from t1,t2,...
              where ... -- table relationship joints
         union all
         select a,b,c,...
              from t11,t12, ...
              where ... -- table relationship joints
    ) QRSLT
         where dynamic_where_clause
    Unfortunately this approach doesn't work here, since individual selects are producing unmanageable amount of data and resulting query takes forever to complete.

    I afraid I would not have any real benefits from using VO if I replace the entire query with every request. Actually, the performance may suffer.
    I solved the problem by creating a POJO Data Control and invoking the custom select query from java. Not sure if it is the best approach to the problem, but implementation time is limited and it works.
    Actually, this is not the first time I see the need to implement VO with complicated SQL like select with unions and dynamic pieces. It would be nice to find a solution and not resort to workarounds.
    Edited by: viksicom on Aug 2, 2012 8:48 AM

  • How to create dynamic where clause instead of pragmatically

    Hi,
    I'm using Jdev 11.1.2.2.0 and my requirement to create a two fields with search button to fetch data as adf table. User need to enter either of the field value and click search button to see his data.
    So I created a sql query based view object with 2 bind variables (which are input params) & 2 view criteria (to create dynamically where clause) and then drag on to the page by ExecuteWithParams operation from data controls but couldnt work.
    If anyone have idea to build dynamically please let me know.
    Amar

    User need to enter either of the field value and click search button to see his data.User need to enter either of the field value and click search button to see his data.
    Hi Amar,
    Is your requirement, creating a query panel with table??
    Drag and drop the view criteria(Application Navigator>DataControls> AppModule >NamedCriteria> ViewCriteriaName ) onto the page.
    In the context menu, select Query->ADFQueryPanel With Table.. That brings your necessary two columns and Search field with data represented as a table.
    Harsha
    Edited by: Harsha049 on Nov 28, 2012 3:51 PM

  • Dynamic where clause in my query

    I am using a view
    select * from vw_pt_inv_customer
    My requirement is have a web page where users can search for customers by filling in a form which has the following feilds: - User can fill in the form with all the feilds or not. I want a dynamic where clause.. how can i get this work for me?
    Title
    Firstname
    Surname
    Address1
    Address2
    Postcode
    Telephone No

    879796 wrote:
    I am using a view
    select * from vw_pt_inv_customer
    My requirement is have a web page What web frame work is used? Apex? Something else?
    where users can search for customers by filling in a form which has the following feilds: - User can fill in the form with all the feilds or not. I want a dynamic where clause.. how can i get this work for me?Dynamic where clauses are a Very Bad Idea (tm).
    And having an open ended search function on a web page is also not a great idea.
    If you are using Apex, the for performance (and even query flexibility) it will be better creating a separate reporting region for each unique query. A boolean rendering condition checks the existing bind variables in order to determine if that specific reporting region should be executed.
    This results in a reporting region having a proper and dedicated SQL query (no hacking of the where clause) and that region only being rendered for the proper combination of supplied filter criteria.
    A slightly more complex, but more flexible approach, is using a generic reporting region that calls a PL/SQL function that creates returns the SQL query for execution and rendering. The approach to this is very similar to constructing a SQL ref cursor (dynamically) for a client. The only difference is that instead of creating the actual ref cursor, the code simply needs to return the SQL source code statement - with bind variables. The Apex run-time does the rest (does the binds and execution and rendering).
    If you are not using Apex - you should still consider these approaches. And not hacking a single SQL to cater for all different types of filter conditions.

  • Dynamic where clause in select query

    Hi
    I'm trying for a dynamic query and in the dynamic where clause i'm checking a field for constant.....for instance if i wanna to use WERKS EQ '0478' how to declare it in dync where clause. i tried for the following:
    SELECT  (TAB_FIELD) INTO TABLE DITAB UP TO 10 ROWS FROM (TAB_NAME) WHERE (CONDI).
    heree CONDI = 'werks eq 0287'   . in this case the query fails as the werks shud be equal to '0287' and not just 0287. How to handle this? i tried for the following
    CONDI = 'werks eq " '0287' " ' but no luck as it is not a valid stmt as i knew.

    hi prabhu,
    this is how u select dynamically...
    DATA: COND(72) TYPE C,
    ITAB LIKE TABLE OF COND.
    PARAMETERS: CITY1(10) TYPE C, CITY2(10) TYPE C.
    DATA WA TYPE SPFLI-CITYFROM.
    CONCATENATE 'CITYFROM = ''' CITY1 '''' INTO COND.
    APPEND COND TO ITAB.
    CONCATENATE 'OR CITYFROM = ''' CITY2 '''' INTO COND.
    APPEND COND TO ITAB.
    CONCATENATE 'OR CITYFROM = ''' 'BERLIN' '''' INTO COND.
    APPEND COND TO ITAB.
    LOOP AT ITAB INTO COND.
    WRITE COND.
    ENDLOOP.
    SKIP.
    SELECT CITYFROM
    INTO WA
    FROM SPFLI
    WHERE (ITAB).
    WRITE / WA.
    ENDSELECT.
    regards,
    sohi

  • Dynamic WHERE Clause in a Calendar

    I would like to have a Calendar display values based on a dynamic WHERE clause created using PL/SQL anonymous block evaluating the values of items that the user uses as filters. I have done this dynamic SQL for reports and would lke to do the same for a Calendar.

    I figured out how to do this.
    I created a Hidden Item with the source value of &APP_USER.
    named P50_APP_USER.
    This is how my query looks now:
    SELECT * FROM APX_EVENT WHERE APX_EVENT.STORE_NR IN (SELECT APX_Z.STORE_NR FROM APX_Z WHERE APX_Z.USERNAME = :P50_APP_USER)
    And it works.
    I got the answer from this thread:
    CALENDAR - SQL ORDER BY CLAUSE NOT WORKING

  • Dynamic where clause in Loop

    Is iot possible to use a dynamic where clause in a loop?  If so how to you code this?
    i.e. Loop at itab in wa where (dynamic_where_clause)...
        endloop...
    Moderator message: please read ABAP documentation for your SAP release.
    Edited by: Thomas Zloch on Mar 29, 2011 3:20 PM

    You should be aware that a LOOP AT ... WHERE is not an optimized access .
    + because on a standard table there is not sort order,
       so the loop goes over the whole table and does  
       something when the condition is fulfilled
    + it is optimzed for sorted tables, but only for one key!
    => so your idea must have bad performance!
    If this is not a problem, then you can solve the problem
    in the following way:
    loop at table
       if ( dynamic condition )
       endif.
    endloop.
    But maybe is dynamic condition is not necessary, but
    a some fixed if-conditions are also o.k.
    Siegfried

  • Dynamic Where Clause in SQR

    How to construct dynamic WHERE clause in our sqr programming ?
    In my run control table I am having parameters fromdate, thrudate [mandatory parameters] and location as [Optional Parameter] how can I declare dynamic where clause to achieve this could any one help me with coding ? Here is my sample coding
    Begin-Procedure Main
    if $prcs_process_instance=' '
    do askvalues
    else
    do getvalues
    end-if
    End_Procedure Main
    Begin-Procedure askvalues
    input $frmdate 'Enter From Id' type=text format=number !Mandatory Parameter
    input $todate 'Enter To Id' type=text format=number !Mandatory Parameter
    input $loc 'Enter Location' value=text !Optional Parameter
    End-Procedure
    Begin-Procedure getvalues
    Begin-Select
    FROMDATE
    THRUDATE
    SQR_LOCATION
    let $frmdate=&FROMDATE
    let $todate=&THRUDATE
    let $loc=&SQR_LOCATION
    let where=-------------------------- ?
    FROM
    PS_PROCESS_TBL WHERE OPRID=$PRCS_OPRID AND RUN_CNTL_ID=$PRCS_RUN_CNTL_ID
    End-Select
    End-Procedure getvalues
    Begin-Procedure selectall
    BEGIN-SELECT
    SQR_EMPLID
    SQR_FNAME
    SQR_LNAME
    SALARY
    FROM
    PS_SQR_FIRST_TBL WHERE SQREMPID BETWEEN $frmdate AND $todate
    END-SELECT
    End-Procedure selectall

    SQR will understand Where Clause as dynamic, when you include it in Square Brackets []
    In your case, since fromdate & thrudate are mandatory values, I would code like this
    let $frmdate=&FROMDATE
    let $todate=&THRUDATE
    let $loc=&SQR_LOCATION
    let $Where_Clause = 'SQREMPID BETWEEN' || ' ' || $frmdate || ' ' || 'AND' || ' ' ||$todate
    if $loc != ''
    let $Where_Clause = $Where_Clause || ' '|| 'AND' || ' ' || 'LOCATION = ' || $loc
    end-if
    Now you can use this Dynamic Where Clause in which procedure you want. Only thing is you need to encode the where clause with brackets([$Where_Clause])
    Edited by: 935179 on Sep 6, 2012 2:11 AM

  • Dynamic where clause with loop statement

    Hi all,
    is it possible to use a dynamic where clause with a loop statement?
    Can you please advise me, how the syntax needs to be?
    Thanks for your suggestions,
    kind regards, Kathrin!

    Hi Kathrin,
               If u are in ECC 6.0, please go through the code...
              REPORT  zdynamic_select.
    TYPES:
      BEGIN OF ty_sales,
        vbeln  TYPE vbak-vbeln,            " Sales document
        posnr  TYPE vbap-posnr,            " Sales document item
        matnr  TYPE vbap-matnr,            " Material number
        arktx  TYPE vbap-arktx,            " Short text for sales order item
        kwmeng TYPE vbap-kwmeng,           " Order quantity
        vkorg TYPE vbak-vkorg,             " Sales organization
        kunnr TYPE vbak-kunnr,             " Sold-to party
        netwr TYPE vbak-netwr,             " Net Value of the Sales Order
      END OF ty_sales.
    DATA :
      gt_sales TYPE STANDARD TABLE OF ty_sales,
      wa_sales TYPE ty_sales.
    DATA: ob_select TYPE REF TO cl_rs_where.
    DATA: ob_from   TYPE REF TO cl_rs_where.
    DATA: ob_where  TYPE REF TO cl_rs_where,
          gv_source TYPE abapsource.
    START-OF-SELECTION.
    *Step 1 : Prepare the select fields.
      PERFORM zf_build_select.
    *Step 2 : Build the from clause for the select
      PERFORM zf_build_from.
    *Step 3 : Build the where clause for the select
      PERFORM zf_build_where.
    *Step 4 : Execute the dynamic select
      SELECT (ob_select->n_t_where)
          FROM (ob_from->n_t_where)
            INTO CORRESPONDING FIELDS OF TABLE gt_sales
            WHERE (ob_where->n_t_where).
      LOOP AT gt_sales INTO wa_sales.
        WRITE :   /5 wa_sales-vbeln,
                  15 wa_sales-vkorg,
                  20 wa_sales-kunnr,
                  40 wa_sales-netwr,
                  50 wa_sales-posnr,
                  60 wa_sales-matnr,
                  70 wa_sales-arktx,
                  90 wa_sales-kwmeng.
      ENDLOOP.
    *&      Form  zf_build_select
    FORM zf_build_select .
      CREATE OBJECT ob_select.
    *Build the table name/field name combination
    *Add Sales order header fields
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAK'
          i_fieldname = 'VBELN'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAK'
          i_fieldname = 'VKORG'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAK'
          i_fieldname = 'KUNNR'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAK'
          i_fieldname = 'NETWR'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
    *Add Sales order item fields
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAP'
          i_fieldname = 'POSNR'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAP'
          i_fieldname = 'MATNR'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAP'
          i_fieldname = 'ARKTX'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAP'
          i_fieldname = 'KWMENG'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
    ENDFORM.                    " zf_build_select
    *&      Form  zf_build_from
    FORM zf_build_from .
      CREATE OBJECT ob_from.
    *Add opening bracket
      CALL METHOD ob_from->add_opening_bracket
      CLEAR gv_source.
    *Add the join condition.This can be made
    *fully dynamic as per your requirement
      gv_source = 'VBAK AS VBAK INNER JOIN VBAP AS VBAP'.
    *Add the where line
      CALL METHOD ob_from->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
    *Add the join condition.This can be made
    *fully dynamic as per your requirement
      gv_source = 'ON VBAKVBELN = VBAPVBELN'.
    *Add the where line
      CALL METHOD ob_from->add_line
        EXPORTING
          i_line = gv_source.
    *Add the closing bracket
      CALL METHOD ob_from->add_closing_bracket
    ENDFORM.                    " zf_build_from
    *&      Form  zf_build_where
    FORM zf_build_where .
      DATA :
      lv_field TYPE REF TO data,
      lv_field_low TYPE REF TO data,
      lv_field_high TYPE REF TO data.
      CREATE OBJECT ob_where.
    *Add the field VBELN : Sales Document
    *Use this method if you want to assign a single value to a field
    *Set the value for VBELN : Sales Document Number
    CALL METHOD ob_where->add_field
       EXPORTING
         i_fieldnm  = 'VBAK~VBELN'
         i_operator = '='
         i_intlen   = 10
         i_datatp   = 'CHAR'
       IMPORTING
         e_r_field  = lv_field.
    CALL METHOD ob_where->set_value_for_field
       EXPORTING
         i_fieldnm = 'VBAK~VBELN'
         i_value   = '0000120020'.
    *Use this method if you want to assign a range of values
    *Set a range for the Sales Document number
      CALL METHOD ob_where->add_field_between_2values
        EXPORTING
          i_fieldnm      = 'VBAK~VBELN'
          i_intlen       = 10
          i_datatp       = 'CHAR'
        IMPORTING
          e_r_field_low  = lv_field_low
          e_r_field_high = lv_field_high.
      CALL METHOD ob_where->set_2values_for_field
        EXPORTING
          i_fieldnm    = 'VBAK~VBELN'
          i_value_low  = '0000120020'
          i_value_high = '0000120067'.
    *Set the 'AND' Clause
      CALL METHOD ob_where->add_and.
    *Add the field MATNR : Material
      CALL METHOD ob_where->add_field
        EXPORTING
          i_fieldnm  = 'MATNR'
          i_operator = '='
          i_intlen   = 18
          i_datatp   = 'CHAR'
        IMPORTING
          e_r_field  = lv_field.
    *Set the value for the Material field
      CALL METHOD ob_where->set_value_for_field
        EXPORTING
          i_fieldnm = 'MATNR'
          i_value   = '000000000050111000'.
    *Set the 'AND' Clause
      CALL METHOD ob_where->add_and
    *Add the field VKORG
      CALL METHOD ob_where->add_field
        EXPORTING
          i_fieldnm  = 'VKORG'
          i_operator = '='
          i_intlen   = 4
          i_datatp   = 'CHAR'
        IMPORTING
          e_r_field  = lv_field.
    *Set the value for VKORG : Sales Organization
      CALL METHOD ob_where->set_value_for_field
        EXPORTING
          i_fieldnm = 'VKORG'
          i_value   = 'GMUS'.
    ENDFORM.                    " zf_build_where

  • Passing values to Dynamic where clause as IN parameter - ADF

    Hi,
    I am trying to get the Dynamic where clause query output something like below,
    select * from EMP where emp_id IN(200,203,204)
    How to pass values from setWhereCluase(emp_id,????)
    Thanks,

    I'd go about this a little differently (probably not the best way):
    1. Create view object lk_department (lookup). In the query add a union with something like "select null as ID, 'All' as name' from dual;". This adds a null value that they can select by leaving the combo box on "All". Add a 'order by id" so the null value is the first one. When creating the combo box you want it set to navigation mode, so select the whole viewobject from the data palette rather a specific field.
    2. Create a jTextField for the "Jobs" field.
    3. Create an application module method that does something like:
    public void filterEmployees(String job){
    ViewObject vo_departments = findViewObject("lk_departments");
    ViewObject vo_employees = findViewObject("employees");
    String wc = "1 = 1 ";
    String wc = " and job like '%"+job+"%'"
    if (vo_departments.getCurrentRow().getAttribute("Id") != null) {wc += "and department_id = "+vo_departments.getCurrentRow().getAttribute("Id");}
    vo_employees.setWhereClause(wc);
    vo_employees.executeQuery();
    this.sync;
    4. In your Jclient app, you just need to call the method of your appmodule and insert the string from the textbox, using code similar to this:
    AppModule b = (AppModule)panelBinding.getApplicationModule();
    b.filterEmployees(jTextField.getText());
    I didn't test this code, but that's how I go about the same thing.

  • Dynamic where clause problem?

    Hi all,
    I am using 4 parameters for the attrition rate report of an employee on the selection screen.
    Level
    Grade
    Position
    Salary Range (pa0008-ansal)
    i have filled the values of level, grade, position, from database tables at the initialization event.
    And for the salary range i hardcoded them to 0-5000, 5001-10000 etc.. and so on.
    and then showed all 4 parameters are listbox on the selection screen.
    now the first 3 parameters are from infotype pa0001 and the last is from pa0008.
    Now I want to select pernr, persg ,persk ,plans, begda ,endda fields from infotype pa0001, and 'ansal' field from pa0008 , with the help of a dynamic where clause, is it possible, because here it might be needed for a join as well.
    Please help me out with some sample coding help.
    Regards
    Tarun

    DATA: lv_query TYPE string.
      lv_query = ' '.
      IF  position IS NOT INITIAL.
        IF lv_query IS NOT INITIAL.
          CONCATENATE lv_query '  and p1~plans eq   position '  '' INTO lv_query.
        ELSE.
          CONCATENATE  ' p1~plans eq  position '  '' INTO lv_query.
        ENDIF.
      ENDIF.
      IF  grade IS NOT INITIAL.
        IF lv_query IS NOT INITIAL .
          CONCATENATE lv_query '  and p1~PERSK eq  grade ' '' INTO lv_query.
        ELSE.
          CONCATENATE '  p1~PERSK eq  grade  ' '' INTO lv_query.
        ENDIF.
      ENDIF.
      IF  level IS NOT INITIAL.
        IF lv_query IS NOT INITIAL .
          CONCATENATE lv_query '  and p1~PERsg eq  level ' '' INTO lv_query.
        ELSE.
          CONCATENATE ' p1~PERsg eq  level  ' '' INTO lv_query.
        ENDIF.
      ENDIF.
      IF  sal_slab IS NOT INITIAL.
        SELECT pernr ansal begda endda FROM pa0008 INTO CORRESPONDING FIELDS OF TABLE lt_st_p8 WHERE ansal = sal_slab.
        *IF lv_query IS NOT INITIAL .*
          *CONCATENATE lv_query '  and p8~ansal le  sal_slab ' '' INTO lv_query.*
        *ELSE.*
          *CONCATENATE '  p8~ansal le  sal_slab  ' '' INTO lv_query.*
        *ENDIF.*
      ENDIF.
    SELECT p1~pernr
        p1~persg p1~persk p1~plans p1~begda p1~endda
         p8~ansal
      INTO CORRESPONDING FIELDS of TABLE lt_st_p1_p8
        FROM pa0001 AS p1 JOIN pa0008 AS p8  ON p1~pernr = p8~pernr
        WHERE (lv_query) .
    <Added code tags>
    Now in case of salary slab, i have ranges like 0-5000 , 5001-10000 and so on and I showed it as a listbox on sel. screen.
    So how can I read the figure after the '-'?????
    And also review, if for the previous 3 parameters it is correct, or it can be shortened and accurated.
    Edited by: Suhas Saha on Dec 28, 2011 1:44 PM

  • Dynamic Where clause - from third party system

    I have internal table A with fields I am getting from legacy system
    field1
    field2
    field3
    field4
    fieldn
    and i am getting a condition table (Where clause conditions) from a legacy system thru an RFC call.
    and in the RFC i need to delete records from internal table A using this where clause
    and where clause condition table(is 72 char length single field table) from legacy system looks like the following
             ( FIELD1                          BETWEEN '01' AND '05' ) AND
         FIELD1                         NE '06'
         AND ( FIELD4                     EQ 'BU' )
         AND ( FIELD5                      BETWEEN '001' AND '009' )
    How could i delete entries from internal table A using this where clause conditon table mentioned above

    Hi a®s,
    yes, thats what I thought of: Generate subroutine Pool.
    I did not elaborate on the fact that dynamic where clauses are allowed only for database selections. That means that FUNCTION 'FREE_SELECTIONS_WHERE_2_RANGE' can't be used either.
    But if you generate a subroutine, you can generate TYPE and DATA declarations as well. This gives you the ability to have static where condition for the DELETE itab WHERE statement.
    If the type vaies during runtime, the generation may vary too.
    I think you are able to do the coding for this.
    On the other hand, Thomas' 'slick' proposal using a temporary database table and a subsequent SELECT ... WHERE (<dynamic where clause) may be easier to implement.
    BTW: Are ther release notes on ABAP720?
    Regards,
    Clemens

  • Dynamic where clause for generated reports (designer 6.0)

    Hi,
    I'd like to include dynamic where clause into my reports. It's easy with report builder by using bind parameter in a query where clause (&param where param is a parameter in which you fill a VARACHAR2 to complete default where clause).
    Problem with designer 6.0 report generator is that he failed while trying to parse the query statement he contructs if there is a bind parameter within.
    How can I manage this problem ?
    Thanks for answers
    Romain

    Hi Divya,
         SET_REPORT_OBJECT_PROPERTY(repid,REPORT_OTHER,'paramform=no P_WHERE_CLAUSE= '||Where_Clause);Instead of using SET_REPORT_OBJECT_PROPERTY built in try using ADD_PARAMETER built in which
    adds parameters to a parameter list. Each parameter consists of a key, its type, and an associated value.
    v_rep := RUN_REPORT_OBJECT(repid); and instead of using RUN_REPORT_OBJECT try using RUN_PRODUCT.
    DECLARE
         repid REPORT_OBJECT;
         v_rep  VARCHAR2(100);
         Where_Clause Varchar2(4000) := null ;
            *Pl_Id        ParamList;*
            *Pl_Name      VARCHAR2(10) := 'param_list';*
    BEGIN
         Where_Clause := 'Where '||Create_Where_Clause();
         message(Where_Clause);
         message(' ');
            pl_id := Get_Parameter_List(pl_name);
            IF not Id_Null(pl_id) THEN
               Destroy_Parameter_List(pl_id);
            END IF;
            pl_id := Create_Parameter_List(pl_name);
            Add_Parameter(pl_id,'P_WHERE_CLAUSE', TEXT_PARAMETER, WHERE_CLAUSE);
            Add_Parameter(pl_id,'PARAMFORM',TEXT_PARAMETER,'NO');
    --      Add_Parameter(pl_id,'ANY_OTHER_PARAMETER', TEXT_PARAMETER, 'VALUE FOR OTHER PARAMETER');
            RUN_PRODUCT(REPORTS,'REPORT_NAME', ASYNCHRONOUS, RUNTIME, FILESYSTEM, pl_id, NULL);
    END;Also you can add as many User created or System parameters as you want using add_parameter. Updated the code to add PARAMFORM parameter.
    Best Regards
    Arif Khadas
    Edited by: Arif Khadas on Mar 15, 2011 9:31 AM

Maybe you are looking for

  • Adobe Reader 9.0 takes over most Exe. programs

    Help!  I am using Vista (can't change this). When I upgrade to Adobe 9.0, the links for most all Exe. programs are replaced by link to Adobe.  I note that others have referenced this problem for months. I can't believe I or anyone else is supposed to

  • Drop Box Function

    I'm a little confused about how the drop box feature works. My understanding of the drop box feature is that students are able to place their own work in the drop box for the instructor to review. A key component of this feature is the idea that the

  • Preformance in mapping

    can you give me the order for graphical,java,abap and xslt mappings in preformance point of view?

  • Unable to lookp system in ESS

    Hi, I am trying to configure ESS in EP 6.0 . I am getting  the following error. What am i supposed to do. I had created a system to connect to R/3 .How am i supposed to proceed after this. Any suggestions ! <b>Portal Runtime Error An exception occurr

  • Lenovo TAB S8 50F touch screen - additional touches when charged w/ insufficient charge

    As the title says  There are additional registered touches when the tablet is charging with an insufficient charge that follow the same horizontal line (going across the tablet or the same y coordinates) that appear at mostly random locations (althou