Dynamic where clause, user/row security

I haev two tables:
create table table1(
First_name varchar2(12),
Last_Name varchar2(17),
Middle_name varchar2(1),
Cabinet varchar2(2),
Department varchar2(3),
Division varchar2(2),
branch varchar2(2),
section varchar2(2),
unit varchar2(2),
serial varchar2(3),
job_title varchar2(13),
other fields......
create table security(
USERname VARCHAR2(14),
FIRST_NAME VARCHAR2(20),
PER_CABINET VARCHAR2(2),
PER_DEPT VARCHAR2(3),
PER_DIVISION VARCHAR2(2),
PER_BRANCH VARCHAR2(2),
PER_SECTION VARCHAR2(2),
PER_UNIT VARCHAR2(2),
PER_SERIAL VARCHAR2(2),
other fields....
****security table sample data****
username first_name cabinet dept division branch section unit serial
username1 firstname1 10 785 05 01 02
username2 firstname2 32 527 02 03
username3 firstname3 32 527 02 01
username4 firstname4 46 546 22 06 05
username5 firstname5 46 546 27 15 01
username6 firstname6 10 005 01 01 01 01
username7 firstname7 10 005 01 01 01 01
username8 firstname8 10
username9 firstname9 10 005
username10 firstname10 10 005 01
What I would like to do is, based on the values assigned to user in security table, the records from table1 should be fetched.
For example: (lets say there are 1000 records in table 1 for cabinet 10)
username8 should be able to see all records pertaining to cabinet 10. (record count=1000)
Username9 should be able to see all records pertaining to cabinet 10 and dept 005 (record count=800)
username10 should be able to see all records pertaining to cabinet 10 and dept 005 and division 01 (record count=600)
username1 should be able to see all records pertaining to cabinet 10 and dept 785 and division 05 and branch 01 and unit 02 (record count=10)
....and so on
To summarize I have to narrow down the number of records a user can see.
I tried to implement this using set_context each for cabinet, department etc... the problem is some users may not have all the values. so my where clause fails and returns 0 rows.
example:
select count(1) from table1 where cabinet=(select per_cabinet from security where username='username1') and department=(select per_dept from security where username='username1') and division=(select per_division from security where username='username1') and branch=(select per_branch from security where username='username1') and section=(select per_section from security where username='username1') and unit=(select per_unit from security where username='username1');
I would get 0 rwos because username1 does not have any value for section.
I point to keep in mind is that not all users have same values.
Any thoughts or ideas on how to resolve my problem? Thanks.

By set_context, I hope you mean you are using sys_context and VPD/RLS for this filtering. For the filter condition, how about modifying each part in the form:
unit = nvl((select per_unit from security where username = :username), unit)or
unit = (select nvl(per_unit, unit) from security where username = :username)

Similar Messages

  • About dynamic  where clause

    hi
    on Jdev 11.1.2.3.0
    Imade dynamic search (where clause)
    It woks fine with me
    but I want to be sure from the best way to do that
    the ideia is to run search according to what is the user chose
    on (Hr) schema employees table
    the end user could search according to departmentID only
    or job id only or both of them or display all employees taable data if there are no seletion
    I used
    this.setWhereClause( );
    this.defineNamedWhereClauseParam();
    this.setNamedWhereClauseParam();
    methods in employeesImpl and I revale it to the client interface to display two text boxes and a button
    my full code is
    ================
    public void setwhereClause(String jobid ,String departmentId ) {
    if (jobid==null & departmentId ==null) {
    this.skipNamedWhereClauseParam ("P_DEPARTMENT_ID");
    this.skipNamedWhereClauseParam("P_jobid");
    this.setWhereClause("1=1");
    this.executeQuery();
    if (jobid==null & departmentId !=null) {
    this.setWhereClause("EmployeesEo.DEPARTMENT_ID =:P_DEPARTMENT_ID");
    this.defineNamedWhereClauseParam("P_DEPARTMENT_ID", null, null);
    this.setNamedWhereClauseParam("P_DEPARTMENT_ID",departmentId );
    this.skipNamedWhereClauseParam("P_jobid");
    this.executeQuery();
    if (jobid!=null & departmentId ==null) {
    this.setWhereClause("EmployeesEo.JOB_ID=:P_jobid ");
    this.defineNamedWhereClauseParam("P_jobid", null, null);
    this.setNamedWhereClauseParam("P_jobid",jobid );
    this.skipNamedWhereClauseParam ("P_DEPARTMENT_ID");
    this.executeQuery();
    if (jobid!=null & departmentId !=null)
    this.setWhereClause( "EmployeesEo.JOB_ID=:P_jobid and EmployeesEo.DEPARTMENT_ID =:P_DEPARTMENT_ID " );
    this.defineNamedWhereClauseParam("P_DEPARTMENT_ID", null, null);
    this.setNamedWhereClauseParam("P_DEPARTMENT_ID",departmentId );
    this.defineNamedWhereClauseParam("P_jobid", null, null);
    this.setNamedWhereClauseParam("P_jobid",jobid );
    this.executeQuery();
    ==========================================
    but Iwas geting error when I run the search For the First Time only without selecting any thing
    the error wase about ( attempt to define parameter which is not in the where clause)
    one time for both variable if there are no selection
    anothe for the P_DEPARTMENT_ID when I search for job
    and the oposet for P_jobid when I search for department
    so why this eror came despite of IF Statment existance
    and why when I run search for both parameter job and departemnt
    next time i search for all data or department only or job only
    the error dosnot come again
    Isuccesd to avoide this error by adding P_DEPARTMENT_ID and P_jobid
    as bind varable in the same names for the employeesVo
    note
    (Idont want to use view Criteria for a segnificant reason)
    and becasue Ineed to pass varaible to open a report_
    in the same way user search_
    and Ican't catch bindings for the view criteria_
    my qusetions
    1-Is what i Did is the correct way I mean adding the binde varable visicaly to SQL tab In the EmployeesVO
    2- why is the error of ( attempt to define paramter not iexist in the where clause mainwhile the If Statment condition dosnot succesd)
    3- how to add bindig variable programaticly without adding it phisicaly in the EmployeesVo SQL

    Duplicate to about dynamic  where clause
    User, please don't post the same question multiple times in this forum.
    Timo

  • 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

  • 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

  • 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

  • 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

  • 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

  • Dynamic where clause: Urgent

    Hi,
    I am facing a problem with data retrieval in a BADI with dynamic where clause.
    I have a variable defined as:
    data: lv_where_condn    TYPE string.
    I concatenate the data in the string based on the user's input and perform the following select:
       SELECT *
       FROM zd_apo_prodvar1
       INTO TABLE lt_data
       WHERE (lv_where_condn).
    The sy-subrc returns a value 4 although there is data in the system for the users data input.
    Earlier it used to give a short dump which I have now take care of with the catch statement.
    SAP has suggested the following:
    This problem happens if an attempt was made to bind or define a variable character string with a buffer length less than the two-byte minimum requirement. Please check the variable definition in your custom code and increase the buffer size or use a different type.
    Any inputs will b appreciated in declaring the dats type for lv_where_condn.
    cheers
    Aveek

    hi,
    check this sample ..
    REPORT  ZDYNAMIC_SELECT                         .
    TABLES: VBAK.
    DATA: CONDITION TYPE STRING.
    DATA: BEGIN OF ITAB OCCURS 0,
    VBELN LIKE VBAK-VBELN,
    POSNR LIKE VBAP-POSNR,
    END OF ITAB.
    SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
    CONCATENATE 'VBELN' 'IN' 'S_VBELN.'
    INTO CONDITION SEPARATED BY SPACE.
    SELECT VBELN POSNR FROM VBAP INTO TABLE ITAB
    WHERE (CONDITION).
    LOOP AT ITAB.
    WRITE 'hello'.
    ENDLOOP.
    Regards
    vijay

  • 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

  • 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

  • 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

  • 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 SELECT statement

    Hi,
    I need to extract (SELECT) all the products in different salesorganizations. Since a product can be available in more than 1 salesorg I have created several properties in the PRODUCT dimension - 1 for each salesorganization (naming: Sxxxx where xxxx is the salesorganization number).
    Since I need to prefix the salesorganization property with an "S" I have created a property on the SALESORG dimension called SALESORG.
    Therefore I need to create a dynamic WHERE clause in the SELECT statement. Currently my script is:
    *SELECT(%SORG%, "[SALESORG]",SALESORG, [ID]=%SALESORG_SET%)
    *SELECT(%PROD%, "[ID]",PRODUCT, [%SORG%]="X")
    My first SELECT find the Sxxx (equal to the property I need in the PRODUCT dimension). My second SELECT uses the variable in the first SELCT statement to use the correct property for the WHERE clause.
    Unfortunately the code is not validated - any suggestions?
    /Lars

    Hi Lars,
    If you run it from a DM package without validating it, does it still work? I would bet it does.
    If this is the case I would open a message with SAP (it would be an enhancement request). Until they fix the validation code, you would just have to live with the script not validating.
    Cheers,
    Ethan

  • Dynamic Where clause in 4.6C [Literals allowed but not variables]

    Good afternoon-
    We have a dynamic select statement that works perfectly in 4.7 ext 2, but is causing a short dump in 4.6C. The error in the short dump says:
    The current ABAP/4 program attempted to execute an ABAP/4 Open SQL       
    statement containing a WHERE condition of the form WHERE (itab) or       
    WHERE ... AND (itab). The part of the WHERE condition specified at       
    runtime in the internal table itab contains an invalid                   
    value "HDR_COMP_CODE". Literals are allowed as values, but not variables.
    HDR_COMP_CODE is in incoming parameter to the function module that is calling this code. It is of type BKPF-BUKRS.
    Here is the code:
    DATA: BEGIN OF L_WHERE_CLAUSE OCCURS 0,
            TEXT_LINE(60) TYPE C,
      END OF L_WHERE_CLAUSE.
      CLEAR L_WHERE_CLAUSE.
      IF NOT HDR_COMP_CODE IS INITIAL.
        SELECT SINGLE KTOPL
        INTO LV_KTOPL
        FROM T001
        WHERE BUKRS = HDR_COMP_CODE.
        L_WHERE_CLAUSE = 'B~BUKRS = HDR_COMP_CODE'.
        APPEND L_WHERE_CLAUSE.
        CLEAR  L_WHERE_CLAUSE.
        L_WHERE_CLAUSE = 'AND'.
        APPEND L_WHERE_CLAUSE.
        CLEAR  L_WHERE_CLAUSE.
        L_WHERE_CLAUSE = 'T~KTOPL = LV_KTOPL'.
        APPEND L_WHERE_CLAUSE.
        CLEAR  L_WHERE_CLAUSE.
        L_WHERE_CLAUSE = 'AND'.
        APPEND L_WHERE_CLAUSE.
        CLEAR  L_WHERE_CLAUSE.
      ENDIF.
      L_WHERE_CLAUSE = 'T~SPRAS = SY-LANGU'.
      APPEND L_WHERE_CLAUSE.
      CLEAR  L_WHERE_CLAUSE.
      SELECT BSAKNR TTXT50
      INTO (LT_GL_ACCOUNT_DATA-GL_ACCOUNT, LT_GL_ACCOUNT_DATA-DESCRIPTION)
      FROM  SKB1 AS B INNER JOIN SKAT AS T
         ON TSAKNR = BSAKNR
      WHERE (L_WHERE_CLAUSE).
        APPEND LT_GL_ACCOUNT_DATA.
        CLEAR  LT_GL_ACCOUNT_DATA.
      ENDSELECT.
    This EXACT query works in 4.7, has anyone run into this, or can they tell me why I might be getting the error?
    Thanks,
    Andy

    Well, in this case, unless I'm missing something,  you do not requre a dynamic WHERE clause.  You can use RANGES instead.
    report zrich_0001.
    *DATA: BEGIN OF L_WHERE_CLAUSE OCCURS 0,
    *TEXT_LINE(60) TYPE C,
    *END OF L_WHERE_CLAUSE.
    ranges: r_bukrs for t001-bukrs.
    ranges: r_ktopl for t001-ktopl.
    *CLEAR L_WHERE_CLAUSE.
    IF NOT HDR_COMP_CODE IS INITIAL.
    clear r_bukrs. refresh r_bukrs.
    r_bukrs-sign = 'I'.
    r_bukrs-option = 'EQ'.
    r_bukrs-low = hdr_comp_code.
    append r_bukrs.
    SELECT SINGLE KTOPL
    INTO LV_KTOPL
    FROM T001
    WHERE BUKRS = HDR_COMP_CODE.
    clear r_ktopl. refresh r_ktopl.
    r_ktopl-sign = 'I'.
    r_ktopl-option = 'EQ'.
    r_ktopl-low = lv_ktopl.
    append r_ktopl.
    *L_WHERE_CLAUSE = 'B~BUKRS = HDR_COMP_CODE'.
    *APPEND L_WHERE_CLAUSE.
    *CLEAR L_WHERE_CLAUSE.
    *L_WHERE_CLAUSE = 'AND'.
    *APPEND L_WHERE_CLAUSE.
    *CLEAR L_WHERE_CLAUSE.
    *L_WHERE_CLAUSE = 'T~KTOPL = LV_KTOPL'.
    *APPEND L_WHERE_CLAUSE.
    *CLEAR L_WHERE_CLAUSE.
    *L_WHERE_CLAUSE = 'AND'.
    *APPEND L_WHERE_CLAUSE.
    *CLEAR L_WHERE_CLAUSE.
    ENDIF.
    *L_WHERE_CLAUSE = 'T~SPRAS = SY-LANGU'.
    *APPEND L_WHERE_CLAUSE.
    *CLEAR L_WHERE_CLAUSE.
    SELECT B~SAKNR T~TXT50
    INTO (LT_GL_ACCOUNT_DATA-GL_ACCOUNT, LT_GL_ACCOUNT_DATA-DESCRIPTION)
    FROM SKB1 AS B INNER JOIN SKAT AS T
    ON T~SAKNR = B~SAKNR
    WHERE  b~bukrs in r_bukrs
      and  t~ktopl in r_ktopl.
    APPEND LT_GL_ACCOUNT_DATA.
    CLEAR LT_GL_ACCOUNT_DATA.
    ENDSELECT.
    Regards,
    Rich Heilman

Maybe you are looking for

  • Determinação de contas do razão nas compras de entrega futura

    Boa dia amigos, Estou com uma dúvida conceitual sobre a entrega futura e seus IVAs. Gostaria da ajuda de vocês para entender qual tipo de conta do razão devemos entrar na chave ICC. No cenário de entrega futura simples, o IVA K1 é usado no pedido, te

  • Whats a good mac to use for a home flight simulator with flight controls and foot pedals?

    whats a good mac to use for a home flight simulator with flight controls and foot pedals? My old 6100 AV worked great on A10 ATTACK, back in 1993. whats a good set up now a days? I havent seen any MAC set ups as a lot of the after market accessories

  • SQL query to fetch approximately 9000 rows

    Hi, I am using the following SQL query in a java class. Using JDBC to connect to an Oracle database using JRUN app server connection pooling. SELECT PT.ACCOUNT_NUMBER,PAYMENT_REF_ID, TO_CHAR (PT.DATE_CREATED, 'MM/DD/YYYY'), PT.AMOUNT_PAID, DECODE(STA

  • Setup of PXE boot for SCCM 2012

    I have setup SCCM Server on a test network with IP 192.168.9.10. I have also setup a DC which is running AD, DNS and DHCP and its IP is 192.168.9.2 On what server do I install WDS and how do I configure WDS/DHCP to point SCCM 2012 to enable PXE boot

  • Changing frames on a button

    Hello, I was going to make a level select frame in my game, and to unlock the different level, you need to complete the previous level. I've done this, but I also want an effect on my button. So if level1 completed=true, it goes red, but if it's fals