Querying multiple intersection tables against another table for row exists

Hi all,
Running on:
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
With the Partitioning and OLAP options
JServer Release 9.2.0.8.0 - Production
I am setting up email subscription service for news service website. News articles are tagged with multiple audiences, topics, regions and departments. Legacy data model we're dealing with implements one intersection table (M:N) for each of audience, topic, region and department lookup table and main news article table.
Email subscribers can pick any combination of the above options (audience, dept etc..) to customize the content of their email. Emails will be either daily or weekly digests of articles of interest, based on their chosen options.
The subscriber options are captured in one table, each option type being its own column. I'm trying to write one query to basically extract all articles that match a given subscriber's chosen options.
create table audiences(articleid number, audienceid number);
create table topics(articleid number, topicid number);
create table regions(articleid number, regionid number);
create table depts(articleid number, deptid number);
create table subscriber_options(emailid number,audienceid number,topicid number, regionid number, deptid number);
insert into audiences(articleid,audienceid)
SELECT
ceil(dbms_random.value(1,10)),
ceil(dbms_random.value(1,50))
from all_objects where rownum < 100;
insert into topics(articleid,topicid)
select
ceil(dbms_random.value(1,10)),
ceil(dbms_random.value(1,50))
from all_objects where rownum < 100;
insert into regions(articleid,regionid)
select
ceil(dbms_random.value(1,10)),
ceil(dbms_random.value(1,50))
from all_objects where rownum < 100;
insert into depts(articleid,deptid)
select
ceil(dbms_random.value(1,10)),
ceil(dbms_random.value(1,50))
from all_objects where rownum < 100;
INSERT INTO subscriber_options (
   EMAILID, audienceid, topicid,
   regionid, deptid)
select
ceil(dbms_random.value(1,10)),
ceil(dbms_random.value(1,50)),
ceil(dbms_random.value(1,50)),
ceil(dbms_random.value(1,50)),
ceil(dbms_random.value(1,50))
from all_objects where rownum < 100;
commit;If a subscriber hasn't chosen any options, then no rows will exist in the subscriber_options table, which implies that they will receive all articles.
I am struggling with this query.. can this be achieved using only 1 query or is this a case where some PL/SQL is required?
All I really want to know is if a given subscriber option matches an option for a given article, using the following boolean logic (topic OR audience) AND dept AND region.
Because I'm more concerned with row existence, I thought of using the "EXISTS" with subquery approach.
Thanks for tips and advice.

Well.. a little persistence, and I think I cracked this nut. ;-)
WITH instant_subscribers AS
     (SELECT   email_subscriber_id, email_subscriber.subscriber_email,
               email_subscriber.subscriber_first_name,
               email_subscriber.subscriber_last_name,
               email_subscriber.subscriber_identifier_code,
               email_subscriber.languageid, COUNT (newscreatorid)
                                                                 dept_options,
               COUNT (newscategoryid) topic_options,
               COUNT (newscoveragespatialid) region_options,
               COUNT (newsaudiencetypeid) audience_options
          FROM email_subscriber LEFT OUTER JOIN subscriber_option
               USING (email_subscriber_id)
         WHERE email_subscriber.subscription_frquncy_type_id = 1
           AND email_subscriber.subscription_status_id = 2
           and email_subscriber_id=53169
      GROUP BY email_subscriber_id,
               email_subscriber.subscriber_email,
               email_subscriber.subscriber_first_name,
               email_subscriber.subscriber_last_name,
               email_subscriber.subscriber_identifier_code,
               email_subscriber.languageid)
SELECT subscr.*, d.*
  FROM instant_subscribers subscr,
       (SELECT ccnews.newsid, ccnews.title, ccnews.embargodate, ccnews.description,
               ccnews.languageid
          FROM ccnews
         WHERE ccnews.embargodate >= TRUNC (SYSDATE - 7)
           AND ccnews.embargodate < TRUNC (SYSDATE)
           AND ccnews.newsstatusid = 2
           AND ccnews.isreadingroom = 'FALSE'
           )  d
WHERE subscr.languageid = d.languageid and ( (subscr.audience_options=0 OR subscr.topic_options=0 OR EXISTS (
                    SELECT NULL
                          FROM subscriber_option INNER JOIN ccnews_audience_rel
                               USING (newsaudiencetypeid, languageid)
                         WHERE subscriber_option.email_subscriber_id =
                                       subscr.email_subscriber_id
                           AND ccnews_audience_rel.newsid = d.newsid))
        OR ( EXISTS (
                 SELECT NULL
                          FROM subscriber_option INNER JOIN ccnews_category_rel
                               USING (newscategoryid, languageid)
                         WHERE email_subscriber_id =
                                       subscr.email_subscriber_id
                           AND ccnews_category_rel.newsid = d.newsid))
   AND (subscr.dept_options = 0 OR EXISTS (
                SELECT NULL
                      FROM subscriber_option INNER JOIN ccnews_creator_rel
                           USING (newscreatorid, languageid)
                     WHERE email_subscriber_id =
                                       subscr.email_subscriber_id
                       AND ccnews_creator_rel.newsid = d.newsid))
   AND (subscr.region_options = 0 OR EXISTS (
                    SELECT NULL
                      FROM subscriber_option INNER JOIN ccnews_coverage_spatial_rel
                           USING (newscoveragespatialid, languageid)
                     WHERE email_subscriber_id =
                                       subscr.email_subscriber_id
                       AND ccnews_coverage_spatial_rel.newsid = d.newsid)) order by d.embargodate DESCI basically outer join my subscriber (supertype) with my subscriber_options (subtype)... and count each option type groupe by subscriber, to determine if they have any options for given type (if count is 0, then they chose "all")
From there, I use this count to "short-circuit" the predicates.. if count=0 OR exists subquery with inner join on chosen options matched to article.
Explain plan reveals the following:
Plan
SELECT STATEMENT  CHOOSECost: 70  Bytes: 727  Cardinality: 1                                                    
     36 SORT ORDER BY  Cost: 70  Bytes: 727  Cardinality: 1                                               
          35 FILTER                                          
               10 TABLE ACCESS BY INDEX ROWID NEWSROOM.CCNEWS Cost: 64  Bytes: 371  Cardinality: 1                                     
                    9 NESTED LOOPS  Cost: 68  Bytes: 727  Cardinality: 1                                
                         7 VIEW NEWSROOM_DEV02. Cost: 4  Bytes: 356  Cardinality: 1                           
                              6 SORT GROUP BY  Cost: 4  Bytes: 121  Cardinality: 1                      
                                   5 FILTER                 
                                        4 NESTED LOOPS OUTER  Cost: 2  Bytes: 605  Cardinality: 5            
                                             2 TABLE ACCESS BY INDEX ROWID NEWSROOM_DEV02.EMAIL_SUBSCRIBER Cost: 1  Bytes: 80  Cardinality: 1       
                                                  1 INDEX UNIQUE SCAN UNIQUE NEWSROOM_DEV02.EMLSUBSR_PK Cardinality: 1 
                                             3 INDEX RANGE SCAN UNIQUE NEWSROOM_DEV02.SUBSCRIBER_OPTION_UQ_IDX Cost: 1  Bytes: 205  Cardinality: 5       
                         8 INDEX RANGE SCAN NON-UNIQUE NEWSROOM.CCNEWS_IN Cost: 1  Cardinality: 317                           
               16 TABLE ACCESS BY INDEX ROWID NEWSROOM.CCNEWS_AUDIENCE_REL Cost: 5  Bytes: 12  Cardinality: 1                                     
                    15 NESTED LOOPS  Cost: 5  Bytes: 39  Cardinality: 1                                
                         12 TABLE ACCESS BY INDEX ROWID NEWSROOM_DEV02.SUBSCRIBER_OPTION Cost: 2  Bytes: 297  Cardinality: 11                           
                              11 INDEX RANGE SCAN UNIQUE NEWSROOM_DEV02.SUBSCRIBER_OPTION_UQ_IDX Cost: 2  Cardinality: 4                      
                         14 BITMAP CONVERSION TO ROWIDS                           
                              13 BITMAP INDEX SINGLE VALUE NEWSROOM.CCNEWS_AUDIENCE_REL_IN                     
               22 TABLE ACCESS BY INDEX ROWID NEWSROOM.CCNEWS_CATEGORY_REL Cost: 5  Bytes: 12  Cardinality: 1                                     
                    21 NESTED LOOPS  Cost: 5  Bytes: 78  Cardinality: 2                                
                         18 TABLE ACCESS BY INDEX ROWID NEWSROOM_DEV02.SUBSCRIBER_OPTION Cost: 2  Bytes: 297  Cardinality: 11                           
                              17 INDEX RANGE SCAN UNIQUE NEWSROOM_DEV02.SUBSCRIBER_OPTION_UQ_IDX Cost: 2  Cardinality: 4                      
                         20 BITMAP CONVERSION TO ROWIDS                           
                              19 BITMAP INDEX SINGLE VALUE NEWSROOM.CCNEWS_CATEGORY_REL_IN                     
               28 TABLE ACCESS BY INDEX ROWID NEWSROOM.CCNEWS_CREATOR_REL Cost: 5  Bytes: 14  Cardinality: 1                                     
                    27 NESTED LOOPS  Cost: 5  Bytes: 41  Cardinality: 1                                
                         24 TABLE ACCESS BY INDEX ROWID NEWSROOM_DEV02.SUBSCRIBER_OPTION Cost: 2  Bytes: 297  Cardinality: 11                           
                              23 INDEX RANGE SCAN UNIQUE NEWSROOM_DEV02.SUBSCRIBER_OPTION_UQ_IDX Cost: 2  Cardinality: 4                      
                         26 BITMAP CONVERSION TO ROWIDS                           
                              25 BITMAP INDEX SINGLE VALUE NEWSROOM.CCNEWS_CREATOR_REL_IN                     
               34 TABLE ACCESS BY INDEX ROWID NEWSROOM.CCNEWS_COVERAGE_SPATIAL_REL Cost: 5  Bytes: 12  Cardinality: 1                                     
                    33 NESTED LOOPS  Cost: 5  Bytes: 39  Cardinality: 1                                
                         30 TABLE ACCESS BY INDEX ROWID NEWSROOM_DEV02.SUBSCRIBER_OPTION Cost: 2  Bytes: 297  Cardinality: 11                           
                              29 INDEX RANGE SCAN UNIQUE NEWSROOM_DEV02.SUBSCRIBER_OPTION_UQ_IDX Cost: 2  Cardinality: 4                      
                         32 BITMAP CONVERSION TO ROWIDS                           
                              31 BITMAP INDEX SINGLE VALUE NEWSROOM.CCNEWS_SPATIAL_REL_IN                     To me it looks pretty good... I'd be curious to know how it looks to a trained eye.. ;-)
I do get my results back as expected...
Edited by: pl_sequel on Sep 24, 2010 4:24 PM

Similar Messages

  • Multiple source tables for Measures dimension.

    Hi,
    We have two different SQL source tables for the Measure dimension in our project. Both the tables have the same structure but the Measures they contain are different. Based on certain condition Essbase will have to pick up Measures from one of the two tables. So basically the source table changes based on the condition. Is it possible to design rule files to achieve this? Please help me with this.
    Thanks,
    Krishna

    as I am sure many will say essbase and load rules are not really an ETL tools.^^^ :)
    Glenn is going to counter with a "I know how to do this in three steps using create column as text, join, and a oft-overlooked but awesome command that everyone but Tom Tortolani (I think I have the spelling on that right -- he was the Arbor employee that wrote Load Rules) forgot.
    I 100% agree with John -- why not do it in SQL?
    Regards,
    Cameron Lackpour
    Edited by: CL on Jan 23, 2013 6:33 AM
    Misspelt Tom's name

  • Querying a Supersession Table for an HTML5/Javascript Windows Store App

    Hi Guys,
    I'm fairly new to SQL and am just setting up a Windows 8 app using an Azure SQL server. The issue I have is looking up a part number supersession and getting the latest number. One part number can have multiple supersessions (ie (oldest number) RTC5756
    > STC8572 > STC3765 > STC9150 > STC9191 > SFP500160 (latest number) )
    The data I am supplied monthly has both the superseded items and the supersession information in both columns and is not easy to decipher - for example:
    Supersessions Table
    RTC5756 | STC9191
    SFP500160 | STC9191
    STC9191 | STC2951
    STC3765 | STC9191
    STC8572 | STC9191
    STC9150 | STC9191
    Source Table
    SFP500160 | KIT BRAKE LINING | 58.02
    The newest part number is kept in a separate table - called "source" - which in this instance is SFP500160.
    I need access to the latest part number but also to the part's previous numbers, due to the fact that some people may still be stocking them as an old part number and for them to search by. Is there an easy and efficient way of doing both a lookup for the supersessions
    and a join on the two tables to minimize the queries on the database?
    What I'm really trying to achieve is, a user inputs a part number, ie STC8572 (the customer does not necessarily have access to or know any of the other part numbers associated with this number), the lookup table then checks for supersessions of that part
    number - in this case:
    (oldest number) RTC5756 > STC8572
    > STC3765 > STC9150 > STC9191 > SFP500160 (newest number)
    The query then returns the newest number as the number to be used, along with the part information, which it knows based on the 'source' table, with a message such as 'The part number you have entered has been superseded to SFP500160'.
    The query will also return all of the previous numbers associated with that number, to be consumed by the application for cross
    reference.
    Any help would be greatly appreciated.
    If I need to make anything clearer, please let me know.
    Thanks

    Hi Vishal,
    Thanks for your reply.
    My two tables are as follows:
    supersessions (table)
    supersession_a  |  supersession_b
    RTC5756
    SFP500160
    STC9191
    STC3765
    STC8572
    STC9191
    STC9191
    STC9191
    STC2951
    STC9191
    STC9191
    STC9150
    source (table)
    partnumber
    description
    price
    SFP500160
    KIT BRAKE LINING
    52.28
    (where SFP500160 is the latest part number)
    For example, customer enters part number STC8572 in to a search. 
    The database queries the "source" table, where of course it is not found because the "source" table only stores the latest part number.
    (oldest number) RTC5756 > STC8572 >
    STC3765 > STC9150 > STC9191 > SFP500160 (newest number)
    I would like the database to query the "supersessions" database at the same time, to see if the part number exists in the supersession stream. If it does, then query all of the supersession numbers linked to that part number, until it finds a match in the "source"
    table - or if the part number being used to search is the latest part number and therefore the number in the "source" table - in this case SFP500160, then return the "source" data related to that number. In both instances, I need the supersession data linked
    to the part and the source data returned with the query.
    If a customer enters an old part number, I would like them them to be informed that it has been superseded and that they will therefore be using the latest number to stock their part under. I need the supersession data for a) as a way of pushing the user to
    the latest part number and b) being able to consume all of the supersession numbers that the query has returned for a reference in the application as a list for the user. 
    In the automotive industry, sometimes parts get superseded while they are still stocked under an old part number. Hence needing to eliminate the confusion, say for example, if a part was automatically stocked as an SFP500160 because of a supersession update
    (which happens monthly) and was still on the shelf as an STC9191.
    This, obviously, is an example using only one part number to demonstrate the supersession chain, when in fact there are 120,000 part numbers to check using this method.
    I hope this adds some clarity to what I am trying to achieve.

  • How to define a JPA "Entity" used to query multiple database tables

    While using JPA to access database, I have a need to define a generic "Entity" class to use for query different tables. The reason is I have a lot of non-business tables (reference tables) I need to query. I intend to use Native SQL to do the query. Most query will only return 1 - 3 columns. It is tedious to define many JPA entities only to use them sparsely.
    For example, if I have two Native query, and define a JavaBean that has 3 properties, how do I implement this in JPA?
    Thanks for your help.
    query 1:
    select LASTNAME as f1, AGE as f2 from PERSON
    query 2:
    select zipcode as f1 from LOCATION
    package model.uti;
    public class SimpleBean {
    private String f1;
    private String f2;
    private String f3;
    public SimpleBean() {
    public void setF1(String f1) {
    this.f1 = f1;
    public String getF1() {
    return f1;
    public void setF2(String f2) {
    this.f2 = f2;
    public String getF2() {
    return f2;
    public void setF3(String f3) {
    this.f3 = f3;
    public String getF3() {
    return f3;
    }

    An @Entity is mapped to a specific table. You can't fill it with totally random data from a collection of tables.
    If you want to access data from multiple tables within the one entity, then the JPA spec defines an annotation @SecondaryTable, which allows you to specify a
    second table and the join condition.
    http://java.sun.com/javaee/5/docs/api/javax/persistence/SecondaryTable.html
    The JPA spec talks about this as do most good EJB/JPA books.
    -steve-

  • A question about the multiple source table for the logical table

    Hi All,
    I am to test, having two physical sources for an logical table, but it is failing as it is always getting data from only one table rather than two tables.
    !http://picasaweb.google.com/KSivaUS/OracleForumQuestions#5433761212378087346!
    Any suggestion or inputs would be appreciated.
    Thanks
    Siva

    your 2 measure columns are in the same unique - low level??
    your connections look good.
    which is the result if you bring only the sales column at your report??is it the sum of the 2 datasources??
    try to repass again all your bussiness model.or make an other one.
    fisrt pass your fact with 2 sources and then your dimensions....
    as i can see you have customer_dim,do both of your columns have the appropriate key to this dimension??try to make a physical connection from both fact sources to this dimension as well as for time...
    if you do it in this way ,there is no possibility not to work
    hope i helped...
    http://greekoraclebi.blogspot.com/

  • Conformed dimension and query multiple fact tables

    Hello,
    Please if someone can guide me on this requirement.
    Requirement - I have a conformed dimension D1 and two fact tables F1 and F2. Both fact tables have many columns so I cannot merge
    the two fact tables into one logical table. Currently both these fact tables have logical tables F1 and F2 respectively.
    As per design the conformed dimension is a simple logical table in the rpd and not a dimension.
    Can someone guide me how should i proceed so that i'll be able to fetch information from both the fact tables?
    Edited by: 930542 on Apr 26, 2012 12:28 PM

    Hi,
    Currently the dimension table is taken as a simple logical table in rpd as it does not have have any levels or hierarchy.
    Its a flat dimension. Can you guide me how can I implement a flat dimension in OBIEE? Because this dimension is taken as simple logical table
    I am not able to set appropriate level for fac tables. This dimension does not appear in the list of dimensions.

  • Run a query multiple times in the same report for different nodes in Hier

    Hi,
    I have created a query as per my requirements. But my issue is I need to run the report for all the profit centers in a hierarchy. Right now I enter a node value of the hierarchy in the variable and I get the result. But I want to run it for each node in the hierarchy and display the result in the same report.Is it possible to do so in web using information broadcaster or any BI 7.0 tools. Has anyone done similar to this in web. I would prefer the web route rather than the excel but if excel is the only answer I will follow the excel path.
    Looking forward to your suggestions on this.
    Thanks,
    Kal

    Hello Kal,
    if the number of Profit Centers is limited, you could probably work with query views (one for each PC) and include all these into your Web Template.
    If this is not appropriate, I don´t know if there is any way of programming possible.
    Regards
    Cornelia

  • Querying CMS tables for users' security, history & favorites

    Hello,
    We are running BOBJ over a BW environment, and we've been asked to help design a Webdynpro interface that reads a user's security credentials in both BW and BOBJ servers and pulls in all reports, Bex or BOBJ, that they have access to.
    To do this, we would need to query the CMS tables for:
    All reports a user is authorized to view
    Groups a user is associated with
    User's History
    User's Favorites
    Does anyone have suggestions?  I've researched Query Builder, but I'm not sure if it can help us, as it accesses three virtual tables instead of the physical tables in the CMS.  The option I am guessing we will need to use is SDK. 
    I'm fairly new to both BW and BOBJ, so any advice is appreciated.
    Thanks
    Scott

    Hello Scott,
    Did you check the possibility of using Audit universe and reports? Please check below link for some useful sample files.
    http://scn.sap.com/docs/DOC-53904
    Regards,
    Nikhil Joy

  • Sql Problems, Same Field Names In Multiple Mysql Tables?

    I have a keyword search that searches multiple DB tables for thumbnail images using UNION ALL. I have two pages, results.php, and view.php.  My goal is to able to click a thumbnail image on results.php and be directed to a larger version of that same image on view.php. The problem is each image in all my tables uses the field name "id" so when I click a thumbnail on results.php I get two different images with the same id from different tables.  I tried changing the id's to different names, but when it was time to pass url parameters I can only choose 1 value. (if you can choose more than 1 I don't know how).  So my question is why are my id's from different tables being grouped together, and how can I change this?
    Image Results Page (which works perfect):
    SELECT *
    FROM table1
    WHERE keyword LIKE %colname% OR id  LIKE %colname% 
    UNION ALL
    SELECT *
    FROM table2
    WHERE keyword LIKE %colname% OR id  LIKE %colname% 
    View Image Page (having problems here):
    SELECT *
    FROM table1
    WHERE id = colname
    UNION ALL
    FROM table2
    WHERE id = colname

    Yes, that is going to be a problem - and it's just the beginning of your problems when you do not normalize your data. Your data model is not correct. You should not be storing similar data in 15 tables - it's a really big mistake.
    To solve your current problem you would need to include a table identifier in the query results in the Image results page, and pass that to the view page and then use PHP to dynamically create the SQL with the correct table....ugh!

  • Query in Nested Table

    Hi Friends,
    My Present project requires to query a nested table for key words and display a result based on the occurence of key words
    The description of table
    Name Type Nullable Default Comments
    CID NUMBER(10)
    NT_KEYMAP NT_KEYS(NESTED TABLE)Y
    FLAG NUMBER(1) 0
    MGR_ID NUMBER(10)
    CATEGORY_ID NUMBER(10)
    NT_KEYS is a nested table of varchar2(50).
    Each key words of the card is stored in the nested table.
    Now when a user enters the key words for searching , I want to display the result depending upon the occurence of key words of a particular key word.
    Could some one help me most optimised search method of nested table.
    Thanks in advance,
    Suman

    If you're asking how to do this with the TopLink Java-based expression framework -- it's not possible. You would be best to use ad hoc SQL for this kind of query. As for what that SQL would look like, I'd check with one of the database forums.
    - Don

  • Query regarding the data type for fetcing records from multiple ODS tables

    hey guys;
    i have a query regarding the data type for fetcing records from multiple ODS tables.
    if i have 2 table with a same column name then in the datatype under parent row node i cant add 2 nodes with the same name.
    can any one help with some suggestion.

    Hi Mudit,
    One option would be to go as mentioned by Padamja , prefxing the table name to the column name or another would be to use the AS keyoword in your SQL statement.
    AS is used to rename the column name when data is being selected from your DB.
    So, the query  Select ename as empname from emptable will return the data with column name as empname.
    Regards,
    Bhavesh

  • Generic report query that will work against common table ..

    Context
    We have a custom audit log scheme that inserts all table changes into a backing table via triggers. For example, an insert into table ORDER would cause a insert into ORDER_AUD.
    Problem
    We want to build a generic report query that will work against any audit table.
    While constructing a report query for a class that uses inheritance, we see TopLink? add an extra where-clause.
    We are required to set the ReferenceClass? for the query, however, the tables we are querying are not mapped to TopLink?. We just want to map the query results to objects of the Reference Class.
    The extra where-clause specifies the table of the Reference Class, but since that table is not in the From clause, the query doesn't work.
    The ReportQuery? in Question
    public DatabaseQuery loadAuditHistory(Class cls, String audTableName ) {
    String emanAuditTableName = "eman_audit";
    ExpressionBuilder expressionBuilder = new ExpressionBuilder();
    Expression exp = expressionBuilder.getTable(audTableName)
    .getField("instance_id")
    .equal(expressionBuilder.getParameter("instanceId"))
    .and(expressionBuilder.getTable(audTableName).getField("audit_id")
    .equal(expressionBuilder.getTable(emanAuditTableName).getField("audit_id")));
    ReportQuery query = new ReportQuery(expressionBuilder);
    query.setReferenceClass(cls);
    query.setSelectionCriteria(exp);
    query.addArgument("instanceId");
    query.addAttribute("Changed By", expressionBuilder.getTable(emanAuditTableName).getField("audit_user"));
    query.addAttribute("Host", expressionBuilder.getTable(emanAuditTableName).getField("audit_host"));
    query.addAttribute("UTC Timestamp", expressionBuilder.getTable(emanAuditTableName).getField("audit_utc_timestamp"));
    query.addAttribute("Action", expressionBuilder.getTable(audTableName).getField("table_action_code"));
    Descriptor orderDescriptor = session.getDescriptor(cls);
    Vector mappings = orderDescriptor.getMappings();
    for (Iterator iter = mappings.iterator(); iter.hasNext();) {
    Object element = (Object) iter.next();
    if (element instanceof DirectToFieldMapping) {
    DirectToFieldMapping mapping = (DirectToFieldMapping)element;
    DatabaseField field = mapping.getField();
    String tableName = field.getTableName();
    String fieldName = field.getName();
    query.addAttribute(fieldName, expressionBuilder.getTable(audTableName).getField(fieldName));
    Expression version = expressionBuilder.getTable(audTableName).getField("version_id");
    query.addOrdering(version.descending());
    query.setName(GET_AUDIT_HISTORY);
    return query;
    Code Generated by the ReportQuery?
    SELECT t0.audit_user, t0.audit_host, t0.audit_utc_timestamp,
    t1.table_action_code, t1.INSTANCE_ID, t1.STATUS,
    t1.REQUESTER, t1.DESCRIPTION, t1.RECIPIENT
    FROM eman_audit t0, example_order_aud t1
    WHERE (((t1.instance_id = 60432)
    AND (t1.audit_id = t0.audit_id))
    AND (EXAMPLE_ORDER.CLASS_NAME = 'eman.infra.toplink.example.project.model.Order'))
    ORDER BY t1.version_id DESC
    Descriptor used to Map Oder.class
    public Descriptor buildOrderItemDescriptor() {
    Descriptor descriptor = new Descriptor();
    descriptor.setJavaClass(eman.infra.toplink.example.project.model.OrderItem.class);
    descriptor.addTableName("ORDERITEM");
    descriptor.addPrimaryKeyFieldName("ORDERITEM.INSTANCE_ID");
    // Inheritance properties.
    descriptor.getInheritancePolicy().setClassIndicatorFieldName("ORDERITEM.CLASS_NAME");
    descriptor.getInheritancePolicy().useClassNameAsIndicator();
    // Descriptor properties.
    descriptor.useSoftCacheWeakIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.useRemoteSoftCacheWeakIdentityMap();
    descriptor.setRemoteIdentityMapSize(100);
    descriptor.setSequenceNumberFieldName("ORDERITEM.INSTANCE_ID");
    descriptor.setSequenceNumberName("CIM_ID");
    VersionLockingPolicy lockingPolicy = new VersionLockingPolicy();
    lockingPolicy.setWriteLockFieldName("ORDERITEM.VERSION_ID");
    descriptor.setOptimisticLockingPolicy(lockingPolicy);
    descriptor.setAlias("OrderItem");
    // Query manager.
    descriptor.getQueryManager().checkCacheForDoesExist();
    //Named Queries
    // Event manager.
    // Mappings.
    DirectToFieldMapping instanceIdMapping = new DirectToFieldMapping();
    instanceIdMapping.setAttributeName("instanceId");
    instanceIdMapping.setFieldName("ORDERITEM.INSTANCE_ID");
    descriptor.addMapping(instanceIdMapping);
    DirectToFieldMapping ItemNumberMapping = new DirectToFieldMapping();
    ItemNumberMapping.setAttributeName("ItemNumber");
    ItemNumberMapping.setFieldName("ORDERITEM.ITEM_NUMBER");
    descriptor.addMapping(ItemNumberMapping);
    DirectToFieldMapping QuantityMapping = new DirectToFieldMapping();
    QuantityMapping.setAttributeName("Quantity");
    QuantityMapping.setFieldName("ORDERITEM.QUANTITY");
    descriptor.addMapping(QuantityMapping);
    OneToOneMapping orderMapping = new OneToOneMapping();
    orderMapping.setAttributeName("order");
    orderMapping.setReferenceClass(eman.infra.toplink.example.project.model.Order.class);
    orderMapping.setRelationshipPartnerAttributeName("orderItems");
    orderMapping.dontUseIndirection();
    orderMapping.addForeignKeyFieldName("ORDERITEM.ORDER_ID", "EXAMPLE_ORDER.INSTANCE_ID");
    descriptor.addMapping(orderMapping);
    return descriptor;

    I'm am very confused as to what you are trying to do, are you trying to query Order objects from the ORDER_AUD historical table instead of the table that the class is mapped to?
    TopLink 10.1.3 (DP3) has built in support for historization, you may wish to investigate this support to allow historical querying of your audit tables.
    In general you cannot use a ReportQuery to do this, a ReportQuery is for querying data from objects based on an object-level criteria. I think that you want to query objects, but just using different SQL than the descriptors are mapped to.
    You could do this through a custom SQL read query,
    i.e.
    ReadAllQuery query = new ReadAllQuery(Order.class);
    query.setSQLString("Select * from ORDER_AUD where INSTANCE_ID = #id");
    query.addArgument("id");
    Vector argumentValues = new Vector(1);
    argumentValues.add(id);
    List objects = (List) session.executeQuery(query, argumentValues);
    As long as the field names in the audit and the original table matched this would work. However if this is a historical table, then I would guess that there might be multiple objects with the same id, so querying these historical objects could confuse the TopLink cache. You could set dontMaintainCache() on the query to avoid this.
    In general you would probably be much better off having two sessions, one with the descriptors mapped to the normal tables, and one with the descriptors mapped to the audit tables. Then you would be able to query both using regular object-level queries.

  • Standard table for finding query where used list

    Are there any standard tables available to find the list of web templates, bex reports and views using a particular query?
    i.e if i have the query name i should be able to find out where all it is being used.
    Thanks,
    Archna

    Hello,
    You have to join multiple tables to achieve this, here we go
    FOR QUERY Related Information
    RSRREPDIR - Directory of all reports (Query GENUNIID)
    Choose Type of a reporting component -> REP
    Tips :
    Choose Type of a reporting component -> QVW for query view
    SE11 -> RSZ* -> F4 gives you all tables related to queries
    For WORKBOOK Related Information
    Use the FM RRMX_WORKBOOK_QUERIES_GET to get the queries in a workbook by selecting the workbook ID from table RSRWORKBOOK
    Tips :
    SE11 -> RSRWB* -> F4 gives you all tables related to workbooks
    SE37 ->RRMX_WORKBOOKS* -> F4 gives you all the FM related to workbooks
    For Webtemplate Related Information
    Choose the dataprovider for query / view ID.
    SE11 -> RSZWOBJXREF - Structure of the BW Objects in a Template
    Also see,
    SE11 - > RSZWTEMPLATE - Header Table for BW HTML Templates
    Thanks
    Chandran

  • What is the table for query name

    Hi All,
    I need an urgent requirement for removing duplicate technical query names from the production. Since there are few issues with the SAP given program I am customizing the SAP Program. Can any one tell me what is the table where the QUERY NAME and it's technical name can be found?
    Thanks,
    Alex.

    hi Alex,
    try RSRREPDIR, RSZCOMPDIR.
    there is one oss note all the tables.
    Table containing Work Book and query relation
    Query Detailes
    oss 792779
    Symptom
    Report ANALYZE_RSZ_TABLES is designed as a check-tool for detecting and solving different types of inconsistencies in the main query definition database tables.
    The program is recommended for BW system administrators.
    Other terms
    Query definition, query, reusable, component, variable, missing elements, missing records, missing UID, INCONSISTENCY, RSZELTDIR, RSZCOMPDIR, RSZCOMPIC, RSZGLOBV, RSZCALC, RSZSELECT, RSRREPDIR.
    Reason and Prerequisites
    ATTENTION: the described version of the program is delivered with the following Support Packages:
    SP27 for release BW 3.0B
    SP21 for release BW 3.1C
    SP13 for release BW 3.5
    All versions of this report available in systems before those Support Packages are test versions which can be used only for information purposes.
    Check prerequisites
    Checks are possible only for elements in object version 'A' (active) and 'D' (delivered).
    Checks for query elements in 'D' version are possible only in the systems which are set as content.
    Checks description
    Report performs checks in the tables containing the parts of the definitions of queries and query components: RSRREPDIR, RSZCOMPDIR, RSZCOMPIC, RSZGLOBV, RSZELTDIR and RSZELTXREF.
    1. Table RSRREPDIR
    The table RSRREPDIR is a header table of the generated reports. Consistency of query definition in this table allows to select a query in the Open Dialogs of fronted application and to call report generated for this particular query using transaction RSRT.
    The following errors can be found:
    - queries with missing definition;
    - queries with missing GENUNIID;
    - queries with technical names different than in RSZCOMPDIR;
    - non-queries in the table.
    1.1 Queries with missing definition
    The queries are available only in the table RSRREPDIR and not found in the table RSZELTDIR in the corresponding object version. Such queries (in active version) can be accessed only from RSRT transaction. An attempt to execute such query will return the short dump 'Exception condition INCONSISTENCY'. The error also happens during query generation in RSRT or during mass regeneration of the queries using RSR_GEN_DIRECT_ALL_QUERIES report or application menu of transaction RSRT. The inconsistent queries can not be repaired because of missing query definitions. The recommended solution is to delete those records in order to avoid the possible system dumps.
    1.2 Queries with missing GENUNIID
    Queries having empty GENUNIID field in the table RSRREPDIR. Such queries may be available in the frontend and in RSRT transaction. An attempt to execute such query will return the message'GENUNIID not found'. Situation requires additional investigation at SAP. Create an OSS message for BW-BEX-ET-QDEF.
    1.3 Queries with technical names different than in RSZCOMPDIR
    The check outputs the queries which have different technical names in the RSRREPDIR and RSZCOMPDIR tables. Execution of a query using the technical name given in Query Designer and stored in the table RSZCOMPDIR will return the error message 'GENUNIID not found'. The system tries to find the corresponding GENUNIID for the wrong COMPID which does not exist in the system or which belong to another query. The recommended solution is to correct the wrong COMPID in the table RSRREPDIR via corresponding procedure.
    1.4 Non-queries in the table
    The table RSRREPDIR normally contains only reports. Query elements of other types should not exist in this table and can be deleted. In case, when such records exist in the table an attempt to access them in RSRT returns the error message 'GENUNIID not found'. The recommended solution is to delete those records from the table using the corresponding procedure.
    2. Table RSZCOMPIC
    The table RSZCOMPIC contains an InfoProvider assignment for queries and other reusable query components (STR, RKF and CKF).
    The following errors can be found:
    - local elements in RSZCOMPIC;
    - components with inconsistent definition;
    - components based on non-existing InfoProviders;
    - components based on non-active InfoProviders.
    2.1 Local elements in RZSCOMPIC
    The table RSZCOMPIC contains an InfoProvider assignment for the reusable components. The local elements and also variables have no InfoProvider assignment and should not exist in this table. Those elements can be deleted via corresponding procedure.
    2.2 Components with inconsistent definition
    The reusable queries or query components existing in the table RSZCOMPIC, but not found in the table RSZELTDIR. Those reusable components may return 'Exception condition INCONSISTENCY' dump during accessing/execution. The situation may have different outcomes and has to be investigated at SAP. Create an OSS message for BW-BEX-ET-QDEF.
    2.3 Components based on non-existing InfoProviders
    Queries or query components are assigned to the InfoProviders which do not exist anymore in the system. Queries without InfoProvider are not available in Open Dialogs of frontend applications, but can be executed in RSRT. The execution will return the error message'InfoProvider not found'. The recommended solution is to delete the unnecessary components. Deletion of these queries or query components can be done directly from the list using corresponding procedure similar to RSZDELETE transaction.
    2.4 Components based on non-active InfoProviders
    Queries or query components which are assigned to the InfoProviders which do not exist in the system in the active version. Queries without active InfoProvider are not available in Open Dialogs of frontend applications. In case, an affected query is technically consistent, an attempt to execute it in transaction RSRT will return the message 'Activate the XXX InfoCube / InfoProvider again. Message #BRAIN 056'. Quite often this error is combined with other errors like missing GENUNIID in the RSRREPDIR or other inconsistencies. Each case has to be investigated in order to get the current status of this object. If the affected query is useless, it can be deleted from the system using transaction RSZDELETE.
    The check is available only for the query elements in object version 'A' (active).
    3. Table RSZCOMPDIR
    The table RSZCOMPDIR is the directory table containing the main properties of all reusable components.
    The following errors can be found:
    - duplicated technical names (COMPID);
    - components with inconsistent definition;
    - components without InfoProvider assignment;
    - components with missing OWNER.
    3.1 Duplicated technical names (COMPID)
    The check outputs queries or other reusable query components which have duplicated technical names (COMPID).
    The error does not cause any dumps in ABAP or terminations in Query Designer, but may cause several symptoms in different reporting areas:
    different queries are available in BEX Analyzer and RSRT under the same name;
    wrong query is used as Data Source for Web Template (Web Reporting, Reporting Agent, Broadcasting, MDX);
    replacement of variables does not work... etc.
    The recommended solution is to provide a new technical name for the duplicated component using corresponding procedure.
    ATTENTION: in case when there are only 2 components with the duplicated technical name, only one of those 2 components can be renamed using the corresponding procedure.
    The alternative solution for renaming the duplicated technical names is to use the ABAP report RENAME_DUPLICATE_ELEMENTS.
    3.2 Components with inconsistent definition
    Reusable query components which are not found in the element directory table RSZELTDIR are displayed. This situation may cause the short dump 'Exception condition INCONSISTENCY' during accessing the affected component in Query Designer or execution the affected query in RSRT. Further investigations are required at SAP. Create an OSS note for the SAP component BW-BEX-ET-QDEF.
    3.3 Components without InfoProvider assignment
    All reusable query component (except variables) should be assigned to a particular InfoProvider. This assignment is located in the table RSZCOMPIC. When the record is not found in this table, the affected component may become not available in Query Designer in the corresponding InfoProvider. In some cases the error message "Component XXX.. (version A) has no InfoCube assignment". Further investigations are required at SAP. Create an OSS note for the SAP component BW-BEX-ET-QDEF.
    3.4 Components with empty ONWER field
    Reusable components which have empty OWNER field in the table RSZCOMPDIR are accessible by users having $USER setting in the authorization object S_RS_COMP1 (users which are authorized to their own queries or query components). This leads to authorization concept violation.
    For error solution the field OWNER in the RSZCOMPDIR should be filled with any value. Execute the corresponding edit mode in order to fill the empty field with user 'SAP'. This will prevent the potential authorization violation for users with $USER setting and will take no effect on the users without this setting.
    4. Table RSZELTXREF
    The table RSZELTXREF contains all links and dependencies between the query elements within a query or query component.
    The following errors can be found:
    - missing elements (INCONSISTENCY dump);
    - not supported relations between query elements;
    - extended RSZELTXREF check.
    4.1 Missing elements
    Missing elements are those query elements which exist as the dependant objects (field TELTUID) in the table RSZELTXREF, but not available in the element directory table RSZELTDIR in corresponding object version. In case, when such elements are used in any query or other query components (STR, CKF or RKF), this may lead to ABAP short dump with 'Exception condition INCONSISTENCY' error message in query run-time or design-time. Other known symptoms of this error is, that structures, calculated key figures or restricted key figures are not available in an Info Provider in Query Designer during design-time.
    The missing elements which are in use in other queries or query components, can not be automatically repaired or deleted without components where those elements are used. In most cases the manual repair operations directly in the DB tables are required. Create an OSS message for SAP component BW-BEX-ET-QDEF for further investigations and creation of a repair plan.
    The missing elements which are not in use in any query or query components, can be deleted from the system via corresponding delete procedure. This deletion will not affect any existing query or query component.
    ATTENTION: if missing element is variable, it can be repaired in some cases automatically using the corresponding repair procedure. See table RSZGLOBV check 5.1. 'Variables with inconsistent definition' for details.
    4.2 Not supported relations between query elements
    Some relations between query elements which are not supported and can cause dumps in ABAP or terminations in Query Designer (for example link STR <--> VAR). Such cases have to be additionally investigated at SAP. Create an OSS message for SAP component BW-BEX-ET-QDEF.
    4.3 Extended RSZELTXREF check
    The extended RSZELTXREF check outputs 2 situations which, in combination with other conditions in the system, may be responsible for slow performance of all operations which involve select from the table RSZELTXREF and resolving the relations between query elements (query load, query generation, expanding of a variable list for corresponding InfoObject, expanding of a list of reusable components in Query Designer,... etc.):
    - records with empty INFOCUBE field
    - records which are not used in any query or query component
    Records with empty INFOCUBE field
    The current algorithm of resolving of relations between the query elements uses an optimization which allows to reduce the amount of data selected from the table RSZELTXREF during such operations are query load, query generate, expand a list of reusable components (STR, CKF, RKF) and so on. All relations between query elements within one reusable component based on one InfoProvider 'N' are also located within the same InfoProvider. The system has to select only records where the INFOCUBE field contain the same InfoProvider 'N' and in addition to this all other records where the INFOCUBE field is empty. This is necessary, because in all BW releases below 3.x the INFOCUBE field was not in the RSZELTXREF table and all components created before 3.x release have this field empty. Selection of records with empty INFOCUBE is required in order to ensure the consistency of processed query.
    When the number of records with empty INFOCUBE is quite large (50.000 - 1 mln records), any simple operation which require resolving of the relations may take a long time, because those records are always being selected, loaded to Query Designer and processed in the design-time.
    Records which are not used in any query or query component
    The program makes a virtual attempt to reconstruct the table RSZELTXREF via resolving the relations between all reusable components existing in the system. All records which are not used in any query or query components are considered as non-used records. Usually these are fragments of old queries or other components which are not deleted due to former errors in the query delete algorithm.
    The current version of the program contain only information about those 2 issues. See the OSS note 823804 for additional information.
    ATTENTION: the extended RSZELTXREF check is recommended when all critical problems with reusable components are resolved and the system clean-up is done (no useless records in the tables, no useless non-executable queries or other affected query component available).
    Starting from SP28 for BW 30B, SP22 for BW 31C and SP14 for BW 3.5 the Extended RSZELTXREF check detects and fixes the following situations:
    records used in existing queries or query components with empty INFOCUBE field;
    records used in existing queries or query components with wrong INFOCUBE assignment;
    records with or without INFOCUBE assignment which are not used in any query or query component.
    For further check details read the OSS note 859086.
    5. Table RSZGLOBV
    The table RSZGLOBV contains the definitions and technical properties of the variables.
    The following errors can be found:
    - variables with inconsistent definition;
    - variables with missing or incorrect properties;
    5.1 Variables with inconsistent definition. Variable not found in RSZELTDIR/RSZCOMPDIR tables.
    The variable existing in the table RSZGLOBV, but not existing in the tables RSZELTDIR or RSZCOMPDIR have inconsistent definition. These situation may return 2 different error messages. When a variable is missing in RSZELTDIR table (or in both together), an attempt to expand a list of variable under a corresponding InfoProvider or a list of text/formula variables will return a message 'Inconsistency in loading...'. All variables which are created for corresponding InfoProvider, text/formula variable are not available. When a variable is missing in the RSZCOMPDIR table only the error message is 'Missing UID XXXXXX... in RSZCOMPDIR! You may continue to work, but this component is not loaded' in Query Designer.
    In both cases the variables can be repaired via the corresponding procedure provided in the program under the technical name (COMPID) corresponding to the name in VNAM field in the table RSZGLOBV with the text 'REPAIRED BY SAP'.
    As an alternative solution, when the affected variables which are not used in any query or query component can be deleted directly from the RSZGLOBV table. Both solutions will fix the reported symptoms.
    ATTENTION: it is recommended to open a repaired variable in Variable Wizard of Query Designer and to adjust the definition of this variable, when it is necessary.
    ATTENTION: deletion of the affected variables missing in the table RSZCOMPDIR is not possible using transaction RSZDELETE. An attempt to delete such variable will return the error message 'Component not found'.
    5.2 Variables with missing or incorrect properties
    Several errors can be found within this check. The variables of different type have their own sets of properties. Missing or incorrect properties may cause different error message during execution of a query where such variables are in use. In the case of the affect variables with processing type 'replacement' , the replacement may not work because of the problem.
    Each case has to be investigated at SAP. Create an OSS message for SAP component BW-BEX-ET-QDEF.
    6. Table RSZELTDIR
    The table RSZELTDIR is the main directory table containing all query elements available in the system.
    ATTENTION: the RSZELTDIR check may take a long running time depending upon the table size.
    The following errors can be found:
    - local elements not in use;
    - reusable elements not in RSZCOMPDIR table;
    - reusable elements not in RSZCOMPIC table;
    - structure (STR) without structure members;
    - selections or RKF without definition in RSZSELECT table;
    - formulas or CKF without definition in RSZCALC table;
    - variables (VAR) without definition in RSZGLOBV table;
    - queries (REP) without entries in RSRREPDIR table.
    6.1 Local elements not in use
    Local elements (field REUSABLE = false) which are not used as dependant objects in the table RSZELTXREF. These elements are useless and not accessible from Query Designer. Usually these are fragments of the definitions of old queries accumulated in system because of different problems with save/delete procedures which are not accessible by the end users. The recommended solution is to delete those elements using the corresponding delete procedure.
    6.2 Reusable elements not in RSZCOMPDIR table
    Reusable elements (field REUSABLE = true) must have a corresponding entry in the table RSZCOMPDIR which contains the definition and properties of this reusable component. An attempt to load such component in Query Designer may cause the error message 'Missing UID XXXXXX... in RSZCOMPDIR! You may continue to work, but this component is not loaded'. Additional investigations are requires at SAP. Create an OSS message for BW-BEX-ET-QDEF.
    ATTENTION: Deletion of such affected components is also not possible using transaction RSZDELETE. An attempt to delete will return the message 'Component not found'.
    6.3 Reusable elements not in RSZCOMPIC table
    Reusable elements (field REUSABLE = true), except variables (DEFTP = 'VAR'), must have a corresponding entry in the table RSZCOMPIC which contains an InfoProvider assignment for reusable components. When a reusable component has no InfoProvider assignment it may be not available in Query Designer during design-time. Additional investigations are required at SAP. Create an OSS message for BW-BEX-ET-QDEF. In case the affected component is useless, it can be also deleted from the system using transaction RSZDELETE.
    6.4 Structures (STR) without structure members
    Reusable and non-reusable structures (DEFTP = 'STR') should have dependant elements (structure members). When these structure members are not found a query containing this structure returns the error message 'Element structure not correct' during generation or execution in RSRT or BEx analyzer. The program outputs a query technical name where such structures are used or the technical name of an InfoProvider if the affected structure is reusable and not used in any query. In this case it can be accessed from any query created in the same InfoProvider in Query Designer. The solution is to open the affected structure in using the latest available version of Query Designer and to create the required structure members in order to avoid the error message.
    In case, when the affecter structure is local (non-reusable) and is not used in any query, this structure is not accessible by frontend users and can be deleted from the system by corresponding procedure provided in the program.
    6.5 Local selection of RKFs without records in RSZSELECT table
    Local selections and reusable Restricted Key Figure (DEFTP = 'SEL') usually should have the corresponding records in the DB table RSZSELECT. The program outputs all selections found in the system which have no corresponding records in the RSZSELECT table.
    Usually this issue has no impact on the existing queries and produces no error messages. There are 3 possible types of selections within a query:
    Normal selection - this selection represents a characteristic in Row, Columns or Free Characteristics area, Conditions or Exceptions. This situation produces no error messages, but the selection is not taken into account by OLAP.
    Dummy structure member - structure member type selection can be defined using Query Designer. Such structure member produces no selection and can be used only as place holder within a query. This situation produces no error messages during generation/execution of a query containing a structure with those dummy structure members.
    Cell selection - this type of selection is usually used as Cell selection and can be defined using Cell Editor in Query Designer. This situation produces no error messages, but the selection is not taken into account by OLAP.
    If it is necessary, the selection definition can adjusted using the latest available version of Query Designer. The affected local selections can be accessed from the queries presented in the WHERE-USED (INFOCUBE/QUERY). The Restricted Key Figures are available in Query Designer from any query created on the corresponding InfoProvider.
    In case, when a local selection is not used in any query or query components the recommended solution is to delete this selection using the corresponding delete procedure.
    6.6 Local formulas of CKFs without records in RSZCALC table
    Local formulas (DEFTP = 'FML') or Calculated Key Figures (DEFTP = 'CKF') should contain definition of the calculations in the table RSZCALC. When such definition is not found in the table RSZCALC the queries or query components which include those affected objects can not be generated or executed by OLAP. An attempt to generate such query returns the error message 'The (sub) formula XXX... is not available'.
    The definitions of the affected formulas or Calculated Key Figures can be adjusted using the latest available version of Query Designer. The adjustment of a local formula is possible from the corresponding query listed presented in the program. The Calculated Key Figures are available in Query Designer from any query created on the corresponding InfoProvider.
    In case, when a local formula is not used in any query or query components the recommended solution is to delete this formula using the corresponding delete procedure.
    6.7 Variables without records in RSZGLOBV table
    Variables (DEFTP = 'VAR') should exist in the table RSZGLOBV. The table RSZGLOBV contains all processing properties and definition of the variables. Query where such variables are used can not be executed without problems.
    The repair procedure is not possible, because of missing definition. In case, when such variable is not used in any query, the recommended solution is to delete it from the system in order to avoid potential problems. If the affected variable is already used in other queries or query components, create an OSS message for SAP component BW-BEX-ET-QDEF. Further investigations and possible repair plan have to be created at SAP.
    6.8 Queries without records in RSRREPDIR table
    Queries (DEFTP = 'REP') should exist in the table RSRREPDIR. The table RSRREPDIR is a header table of generated reports and also a part of the database view V_REP_JOIN which provides data for the BEx Open/Save Dialogs.
    A query which does not exist in the table RSRREPDIR is not accessible via RSRT transaction (error message 'GENUNIID not found') and not displayed in the Open/Save Dialogs of fronted applications.
    The recommended solution is to delete such queries using the corresponding procedure provided in the program and similar to RSZDELETE.
    In some cases the repair procedure is also possible. The success of the repair procedure depends upon the consistency of the affected query, the existence of a valid InfoProvider for this query and some other factors. For repair attempt create an OSS message for the SAP component BW-BEX-ET-QDEF.
    hope this helps.

  • Table for 2way,3way matching .query to generate invoice with 2 ways matchin

    hi
    table for 2way,3way matching .query to generate invoice with 2 ways matching
    plz help me
    thanks

    Hello John, I put the (1,2,3) list in the query to show it works with multiple invoices.
    You should comment out the conditions:
    select a.invoice_no, b.child, sum(a.amount) from invoice_detail a,
    select
    child,
    decode (instr(scbp,'.'),0,scbp,
           substr(scbp, 1, instr(scbp,'.') -1)
           ) starting_child
    from (
    select ltrim(sys_connect_by_path(child,'.'),'.') scbp,
    child from
    element_relation
    start with child in (select element_id from invoice_detail /* where invoice_no in (1,2,3) */)
    connect by child = prior parent
    ) b
    where a.element_id = b.starting_child
    /* and a.invoice_no in (1,2,3) */
    group by a.invoice_no,b.child
    order by 1,2to show it works for all invoices
    regards, Tony

Maybe you are looking for