Setting dynamic WHERE clause in VO

Hi all,
I am using JDev 11.1.2.2.0. Example Scenario : In my application, In the first page, I am choosing a location value. In the second page I have a model based VO. The where clause of the query has to be set dynamically, based on the location what I am choosing in the first page. How to achieve this?
Regards,
Infy

First make sure you have defined your method in the AM Impl class.
Here is a post from a few topics back :
umesh.agarwal wrote:
My question is how can I create a method that will return this information and use it from the ViewController ?For this:
1) Created a method in AMImpl
2) Exposed the method through Client Interface.
See this for more details:
http://docs.oracle.com/cd/E12839_01/web.1111/b31974/bcservices.htm#sm0212
Then
3) Define a method action binding in your jspx page(pagedef) where you want to access this method.
http://docs.oracle.com/cd/E15523_01/web.1111/b31974/web_adv.htm#ADFFD20984
4) Use the below code to call the AM method from View controller
DCBindingContainer bindings =
(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
OperationBinding operationBinding =
bindings.getOperationBinding("<method_name_in_AM>");
if (operationBinding != null) {
operationBinding.execute();
Object obj = operationBinding.getResult(); //obj will contain the value returned from your AM method
Step 4) is when you want to call that method from a bean.
You can also drag that method (from your data control) on your page. JDev will then ask if you want to make a form of it.
When you choose for that option, you will get an input field and a button. When you fill in the parameter in that input field and then hit the button, the method will be
executed and will use the inputed value as your parameter.

Similar Messages

  • How to set dynamic where clause in ADF?

    Hi,
    I have a View object called BillInfoVO. This has
    all the information about who created the request, the time , status etc.,
    I need to display this VO in a jsp. But before I display, i need to fileter this
    VO results with different where clauses according to the role of the user.
    For example, if the role is admin, then
    where clause should be 'status = 'Completed, and created by = 'Current user'
    If the role is requestor, then
    the where clause should be
    sales manager id = 'Current user' and
    Status != Complete etc.,
    Could any one please let me know how I can
    dynamically set the where clause to filter the appropirate
    result row set in the jsp?
    Your help will be greatly appreciated.
    Thanks,
    venki

    You'll create a service method in your AM that will use the setWhereClause method of a viewobject.
    Then you'll expose it as a client method.
    Then you'll drag it from your data-control onto a button in your JSF page that will call your page for the query.
    More about service methods here:
    http://download.oracle.com/docs/html/B25947_01/bcservices003.htm#sm0206
    http://download.oracle.com/docs/html/B25947_01/bcquerying008.htm#sthref286

  • 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

  • JSP, DataWebBean: How to dynamically set the where clause of query and display record

    Hi,
    I am reposting this question as per suggestions made by Mr. Dwight.
    I have used ViewCurrentRecord web bean to display records from EMP table. I have to use the Dept_Id_FK from the current
    record of the EMP table to display corresponding records of Dept table. I have a view object called DeptView in my Business
    Components which selects all the records from the Dept table.
    How do I get the value of Dept_Id_FK and use it to display the required records of the Dept table?
    I tried to declare a variable and get the value of Dept_Id_FK but it did not work. My code is as follows:
    <%! String m_DeptId = null; %>
    <jsp:useBean id="RowViewer" class="oracle.jbo.html.databeans.ViewCurrentRecord" scope="request">
    <%
    RowViewer.initialize(pageContext, "EMPApp_EMP_EMPAppModule.EMPView1");
    RowViewer.setReleaseApplicationResources(false);
    RowViewer.getRowSet().next();
    m_DeptId = (String)RowViewer.getRowSet().getCurrentRow().getAttribute("DeptIdFk");
    %>
    </jsp:useBean>
    Thanks.
    null

    First of all, Thank you very much for making use of the new topic format. It is very much appreciated.
    As for your question, I think there are several different ways to accomplish what I think you want to do.
    1. Create a view object that includes both Emp and Dept entities and join them there. In this case, your query would look something like this:
    Select e.empno,e.name,...,d.dname,d.loc from emp e, dept d
    where e.deptno = d.deptno
    You should be able to create a JSP off of this view object that contains both the employee and department information. In this case, BC4J takes care of the foreign key to primary key coordination.
    2. In order to set a dynamic where clause for a view, you need to do the following in your usebean tag:
    rsn.initialize(application,session, request,response,out,"DeptView");
    rsn.getRowSet().getViewObject().setWhereClause("deptno=" &#0124; &#0124; m_DeptId);
    rsn.getRowSet().getViewObject().executeQuery();
    rsn.getRowSet().first();
    You will need to do this in a separate usebean tag from the EmpView, since the usebean can only initialize one view object.
    In other words, you would have your ViewCurrentRecord bean tag for the EmpView, then a separate one for the DeptView where you use the above code to set the where clause to display just the information for the department you want.
    Another option, but one I'm not sure would work as well, is to create a master-detail JSP to do this for you. Usually a master-detail is a one-to-many (one department to many employees). Your request appears to be the reverse, but might still be doable using the same mechanism.
    You set up relationships between views in your BC4J project using View Links. If you used the BC4J project wizard and created default views, some of these links may have been created for you. They are created when BC4J detects a foreign key to primary key relationship in the database.
    You can create your own View Links using the View Link wizard. Select your BC4J project node and choose Create View Link... from the context menu. You will be asked to select a source view (Emp), and a target view (Dept), then select the attribute in each view that related the two of them (deptno).
    Next, you need to reflect this new relationship setting in your application module. Select your app module and choose Edit from the context menu. On the data model page, select the EmpView node in the Selected list. Now select the DeptView node in the available list and shuttle it over. You should see DeptView1 via yourlink appear indented under the EmpView node. Save and rebuild your BC4J project to reflect the changes.
    In your JSP project, you can now have the wizard create a master-detail form for you based on DeptView1.
    Let me know if the above answers your question, or if I have misunderstood what it is you wanted to do.
    null

  • Dynamically set ViewObject where clause dynamically from Java bean

    I have a requirement to display all of the records from a table when the JSP is first brought up, so my View Object looks like this:
    "select emp_name from emp"
    Then the users wants to ability to pass paramters to that View Object to refine the list so from by Java class I tried to do this:
    ViewObject vo = cpd.findViewObject("EmpViewObject");
    vo.setWhereClause("empName = :1");
    vo.setWhereClauseParam(1,varEmpName);
    vo.executeQuery();
    But I am getting JBO errors and I'm not sure what I'm doing wrong. Can anyone offer a hint as to how I can do this?

    this is exactly how the code is done -
    1. emp_name in the View Object
    2. emp_name in the where clause
    The two are identical. I have tried many variations of this - any time I set the where clause from my bean I get an error.
    When I take the SQL stmnt and run it in TOAD it returns expected rows when I run it in the SQL worksheet in JDev it gives an invalid Identifier - but if I hard code the where clause in the View Object it returns the same results as TOAD.

  • How to set the where clause of a value set on the basis of a form field

    I am using a DFF(Descriptive FlexField), which needs to display the value of a certain column(say columnA) on the basis of the value of another column(say columnB).
    So i have created a value set which points to the table which has both these columns, and the DFF uses this value set. However, the problem is that I have not put any where clause in the value set, because of which i cannot handle the exact fetch returns more than one rows error.
    The query has to be as follows:
    select ColumnA from tbl where ColumnB = [ a form value ];
    What I want to know is how can i get the value of a certain field of a certain block of the form in the above query.
    Edited by: 981615 on Jan 14, 2013 12:48 AM
    Edited by: 981615 on Jan 14, 2013 12:48 AM

    Just have a look over these two statements if it solves your problem
    one time where clause
    Set_Block_Property('BLOCK_NAME',ONETIME_WHERE,your form item);
    dynamic where clause
    set_block_property('BLOCK_NAME'default_where, your form itme)
    you can where clause at run time from any procedure or some triggers

  • 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

  • Pagination after executequery with a dynamic where clause

    Hi all,
    I have a problem with pagination after setting a where clause dynamically and performing an executequery in ViewObjectImpl.java.
    As a result of this, the amount of records are decreased returned by the viewobject, however the pagination is not changed. It still reflects the previous amount. It changes only if you have selected the last range of the changed recordset
    Does anybody know how to get the pagination to refect the correct amount of the updated recordset of the viewobject?
    Jdeveloper version 10.1.3.4 / Jheadstart 10.1.3.3.81
    Thanks in advance, Erwin

    Hi,
    I would not add this to the VO query. Instead I would create a View Criteria that uses a bind variable. Then in the Application Module Data Model, you select the VO instance and choose edit (button on top) to permanently associate the view criteria)
    Advantages of this approach
    - The VO definition can be used elsewhere without the restriction
    - the bind variable is not mandatory and yu can set it such that if no value is provided a full query is executed
    Frank

  • Dynamic where clause in "delete itab where..." variant

    Hi,  I need to be able to delete the contents of an internal table based on a dynamic where clause. I don't want to loop through the entire table to test each record.  Since the delete statement doesn't seem to allow a dynamic "where" clause I am trying to use a macro.  I can't get the macro to work either. 
    I get the following error in my syntax check:
    Statement concluding with "...FINAL_STATEMENT" ended unexpectedly.          
    Is there any way to get this macro to pass the syntax text or accomplish the dynamic delete?
    MACRO TO FILTER OUT UNWANTED RECORDS (RETAIL OUTLETS)
      DEFINE DELOUT.
        DELETE MY_ITAB WHERE &1.
      END-OF-DEFINITION.
    Example FINAL_STATEMENT = (  ZRRDIVIS = '4' )
    USING MACRO DOES NOT PASS SYNTAX CHECK
      DELOUT FINAL_STATEMENT.

    Well, if you really need this kind of functionality,  here is a code sample that I just threw together that would work.  A lot of code for one little delete statement though.
    report zrich_0001 .
    data: begin of itab occurs 0,
          fielda type c,
          fieldb type c,
          fieldc type c,
          end of itab.
    data: where_clause type string.
    class lcl_source definition.
      public section.
        types: t_source(72).
        class-data: routine(32) value 'TEMP_ROUTINE',
                    program(8),
                    message(128),
                    line type i.
        class-data: isource type table of t_source,
                    xsource type t_source.
        class-methods: execute_source importing im_clause type string.
    endclass.
    start-of-selection.
    * Build the itab.
      itab-fielda = '1'.
      itab-fieldb = '2'.
      itab-fieldc = '3'.
      append itab.
      itab-fielda = '3'.
      itab-fieldb = '2'.
      itab-fieldc = '1'.
      append itab.
    * Set the where clause
      where_clause = 'FIELDA = ''1''.'.
    * call the delete statement.
      call method lcl_source=>execute_source
                exporting
                    im_clause = where_clause.
    *       CLASS lcl_source IMPLEMENTATION
    class lcl_source implementation.
      method execute_source.
        xsource = 'REPORT ZTEMP_REPORT.'.
        insert xsource  into isource index 1.
        xsource = 'FORM & tables itab.'.
        replace '&' with routine into xsource.
        insert xsource  into isource index 2.
        xsource = 'Data: begin of xitab occurs 0,'.
        append xsource to isource.
        xsource = 'fielda type c,'.
        append xsource to isource.
        xsource = 'fieldb type c,'.
        append xsource to isource.
        xsource = 'fieldc type c,'.
        append xsource to isource.
        xsource = 'end of xitab.'.
        append xsource to isource.
        xsource = 'xitab[] = itab[].'.
        append xsource to isource.
        concatenate 'DELETE xITAB WHERE' im_clause into xsource
                      separated by space.
        append xsource to isource.
        xsource = 'ENDFORM.'.
        append xsource to isource.
        generate subroutine pool isource name program
                                 message message
                                 line line.
        if sy-subrc = 0.
          perform (routine) in program (program) tables itab.
        else.
          write:/ message.
        endif.
      endmethod.
    endclass.
    Regards,
    Rich Heilman

  • ADF dynamic where clause for VO query using BC

    I'm hoping someone can help me out. I have a read only view object that I want to filter results based on some user choices. For example the user may want to see all results or they may only want to see a much smaller subset. This is for an error dashboard, the smaller subset maybe by application or maybe by application and by error severity. I think I can use a dynamic where clause but I'm not sure, Can someone get me started down the right path, or post an example that I can see.

    Hi user,
    You can use a dynamic where clause for this, but maybe there is a more practical option. Maybe you can have a fixed where clause, but using a bind parameter, like:
    vo.application like :applicationParam. This makes an executeWithParams method available that you can call from your page, and use in the bindings. This parameter you can populate with the results of for example a poplist, with a default value of '%'.
    When you do want to use a dynamic where clause, you will need to add a method to the java code of your application module, and make this method available for the client. In this method, you can use findViewObject to retrieve your VO, use VO.setWhereClause to set the whereclause to what you want, and then call VO.executeQuery. This method can then again be called from the page.
    Success,
    Jeroen van Veldhuizen

  • Creating dynamic where clause with string delimiter " ; "

    hi...
    i need a solution for complex problem like, 1. start_date IN date,
    end_date IN date,
    shift_type IN varchar2
    i will get shift_type as "first_shift" or "first_shift;second_shift" or "first_shift;second_shift;third_shift" ....etc any combination. where fist & second & third shits are nothing but 1 , 2 , 3. i need to find out data between start_date and end_date in combination of shifts ( may be 1;2 or 1;3 or 1;2;3 or 2;3 ...etc) . now i need to write this code in dynamic where clause ...i tried in different ways...but not succeeded. can anybody guide me step by step...or with script.
    NOTE: there is a table called "shift" with data like
    shift_type shift_mode
    1 first_shift
    2 second_shift
    3 third_shift

    Hi,
    Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.
    If the question involves parameters, give a few different sets of parameters and the results you want for each set, given the same sample data.
    It's unclear that you need dynamic SQL at all.
    If shift_type is a variable, that can be either a single value or a ;-delimited list (such as '1;3'), you can compare that to a column called shift_column like this:
    WHERE        ';' || shift_type   || ';'     LIKE
           '%;' || shift_column || ';%'No dynamic SQL or PL/SQL required.
    If you really do want to use dynamic SQL, these two pages should gives you some ideas:
    http://www.oracle-base.com/articles/misc/DynamicInLists.php
    http://tkyte.blogspot.com/2006/06/varying-in-lists.html

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

  • Less than or eual to Date issue in dynamic where clause

    Dear All,
    I have a requirement to search the leave balance information, here date as a parameter. When ever we pass the date as a parameter it should be display all the leave balance information till the parameter date.
    Steps I have followed to achieve this requirement
    • Created the VO and query as follows
    SELECT trunc(paa.creation_date) creation_date, paa.date_start, paa.date_end,
    SYSDATE duty_resumption_date, paa.absence_days leave_deducted,
    paa.absence_days leave_added, 'Leave Deucted' detail,
    paa.absence_days balance_remaining,
    fu.user_id
    FROM per_absence_attendances paa, per_all_people_f papf, fnd_user fu
    WHERE 1 = 1
    AND papf.person_id = paa.person_id
    AND papf.person_id = fu.employee_id
    AND fu.user_id=fnd_profile.value('USER_ID')
    And trunc(paa.creation_date) <= TO_DATE((to_char(trunc(to_date(:1)),'DD-MON-YYYY') ),'DD-MON-YYYY')
    •     Created the Advance Search Region
    •     In the controller of the region, I have captured the go button logic and setting the dynamic where clause as below
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean);
    OAApplicationModuleImpl am= (OAApplicationModuleImpl)pageContext.getApplicationModule(webBean);
    OAQueryBean oaquerybean = (OAQueryBean)webBean.findIndexedChildRecursive("QueryRN");
    if (pageContext.getParameter(oaquerybean.getGoButtonName()) != null)
    OAViewObject oaviewobject = (OAViewObject)am.findViewObject("XXLeaveBalanceVO");
    String creationDate = pageContext.getParameter("CreationDate");
    oaviewobject.setWhereClauseParam(0,creationDate);
    oaviewobject.executeQuery();
    •     But this where condition is working equal condition to the parameter but it is not working less than condition.
    •     When I am running the VO query in Toad it is working the less than condition.
    Please help me out to resolve this issue.
    Thanks in Advance,
    Sai

    Dear Kumar,
    I have changed my vo query as you suggested, now the equal condition also not working and I am getting the following error message
    JBO-27122: SQL error during statement preparation. Statement: SELECT * FROM (SELECT trunc(paa.creation_date) creation_date, paa.date_start, paa.date_end,
    SYSDATE duty_resumption_date, paa.absence_days leave_deducted,
    paa.absence_days leave_added, 'Leave Deucted' detail,
    paa.absence_days balance_remaining,
    fu.user_id
    FROM per_absence_attendances paa, per_all_people_f papf, fnd_user fu
    WHERE papf.person_id = paa.person_id
    AND papf.person_id = fu.employee_id
    AND fu.user_id=fnd_profile.value('USER_ID')
    And trunc(to_char(paa.creation_date) ,'dd-MMM-yyyy')<= trunc(to_char(:1, 'dd-MMM-yyyy'))) QRSLT WHERE (( CREATION_DATE = :2 )) ORDER BY CREATION_DATE ASC
         at oracle.apps.fnd.framework.OAException.wrapperException(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageErrorHandler.prepareException(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageErrorHandler.processErrors(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at OA.jspService(_OA.java:72)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:597)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:521)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
         at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    ## Detail 0 ##
    java.sql.SQLException: ORA-01722: invalid number
    Thanks,
    Sai

  • Creating a dynamic where clause

    hello,
    I am trying to create a procedure whech needs to parse a dynamic where clause into a cursor. The problem is I do not know the number of items that the user has selected (from previous input), thus what I want to pass in is a string of variables, but I donl;t think I can do this.
    Does anyone have any ideas on how I can do this?
    Thanks
    Bryan
    [email protected]
    an example of theh code I am trying to run is:
    v_update:='UPADTE :tabnam
    SET ctrecid = :ctrec';
    WHERE :v_and
    AND pxlrecno = :strt';
    v_cursor2 := DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE(v_cursor2,v_update,DBMS_SQL.V7);
    DBMS_SQL.BIND_VARIABLE(v_cursor2,':tabnam',tabnam);
    DBMS_SQL.BIND_VARIABLE(v_cursor2,':ctrec',ctrec);
    DBMS_SQL.BIND_VARIABLE(v_cursor2,':v_and',v_and);
    DBMS_SQL.BIND_VARIABLE(v_cursor2,':strt',strt);
    v_numrows:=DBMS_SQL.EXECUTE(v_cursor);
    Where v_and is something like:
    item1='TEST1' AND item2='TEST2' AND item3='TEST3'
    null

    SQL> EDIT update_tabnam
    CREATE OR REPLACE PROCEDURE update_tabnam
    (tabnam IN VARCHAR2,
    ctrec IN VARCHAR2,
    v_and IN VARCHAR2,
    strt IN VARCHAR2)
    IS
    v_update VARCHAR2 (3000);
    v_cursor2 INTEGER;
    v_numrows INTEGER;
    BEGIN
    v_update := 'UPDATE ' &#0124; &#0124; tabnam
    &#0124; &#0124; ' SET ctrecid = ' &#0124; &#0124; '''' &#0124; &#0124; ctrec &#0124; &#0124; ''''
    &#0124; &#0124; ' WHERE ' &#0124; &#0124; v_and
    &#0124; &#0124; ' AND pxlrecno = ' &#0124; &#0124; strt;
    v_cursor2 := DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE (v_cursor2, v_update, DBMS_SQL.V7);
    v_numrows := DBMS_SQL.EXECUTE (v_cursor2);
    DBMS_SQL.CLOSE_CURSOR (v_cursor2);
    END update_tabnam;
    SQL> START update_tabnam
    Procedure created.
    SQL> EXEC update_tabnam('TEST',7,'ITEM1=''TEST1'' AND ITEM2=''TEST2'' AND ITEM3=''TEST3''',1)
    PL/SQL procedure successfully completed.
    SQL> SELECT * FROM test;
    CTRECID PXLRECNO ITEM1 ITEM2 ITEM3
    7 1 TEST1 TEST2 TEST3
    Note: Posting on this forum causes spaces to be inserted between the concatenation symbols where they don't belong, so anywhere you see a space between | and | remove it, before saving the file and starting it to create the procedure.
    null

Maybe you are looking for

  • IMac clock in top right shows time Imac went to sleep briefly when waking

    I have Lion which came with my iMac, this is my second iMac as my last one had a hardrive issue. Whenever I wake my iMac from sleep the display clock shows the time the iMac went to sleep until it connects to the Internet via wifi, has anyone experie

  • Formula column

    Hi,everyone: I am trying to create a formular column, which will be a sum of two columns from two different queries. In the data model, I could not put this CF_1 in neither of the two queries, so I put it outside the two queries, which is supposed to

  • BAPI for billing plan and billing order

    Hi Sap Guru, i need your help on bellow questions : Are there any BAPIs or MF standard used to read billing plan from the business partner (header and lines) ? Are there any that permit to create, simulate, modifify or cancel a billing plan ? Are the

  • Quotation Configuration

    I have searched the forums, etc and cannot find the answer to a question.  I am creating a SD Quotation with the BAPI CreateFromData2.  The quotation is being created except for the execution of the Configuration process to populate selection data as

  • I´m getting these error ORA-00936:missing expression runnig a Task on Info

    I´m getting these error ORA-00936: missing expression, when running the SDE_ORA_Reverse_GLJournals task. I´m setting the variables $$FILTER_BY_LEDGER_ID, $$FILTER_BY_LEDGER_TYPE, $$LEDGER_ID_LIST and $$LEDGER_TYPE_LIST in the DAC correctly. I see the