How to build a query to join on two tables without mapping

I did Automatic mapping by the workbench Directofield mapping with the table and java object.
Wanted to build a simple join query by joining on the same field on both the tables.Not the sql query through the toplink using expression builder.
Please help.............
Spent one full day for this................

Thanks Don for the reply,sorry to bug you,but i need help.....
SELECT A.AGNCY_C,
     A.TYPE_C,
     A.RESN_C,
     A.S_TYPE_C,
     A.SUB_ID_C,
     A.RY_C
FROM RATING A, REF B
WHERE A.ID_C = B._ID_C
AND A.ALPHA_C = B.ALPHA_C
AND A.EFF_D >= B.MATURITY_D
This is the real query i was talking about.I did mapping automatically through the workbench,generated java classes also throught the workbench.
Now they don't want to execute the raw sql.They wanted to get all the RATING objects with the where condition.
So how to build a query by using toplink.
tried your example
ExpressionBuilder builder = new ExpressionBuilder();
Expression creditRating = builder.getTable("RATING").getField("ID_C");
Expression issue_ref = builder.getTable("REF").getField("ID_C");
Expression join = creditRating.equal(issue_ref);
I am getting java.lang.OutOfMemoryError
error.
I selected the option generate classes and descriptors
from the tables (RATING,REF).,so it created the classes and dscriptors automatically.
In Database script for the table RATING like this
ALTER TABLE RATING ADD (
CONSTRAINT RATING_F1 FOREIGN KEY (ID_C, ALPHA_C)
REFERENCES REF (ID_C,ALPHA_C));
I think when i generate descriptor automatically it is keeping this association.
Please help me.........

Similar Messages

  • Subject: How to do join between two tables using something like SE16

    SE16, SE11 provide form based interface query information from a single table. Is there a way to do join between two tables without creating an infoset erc? I am looking for something similar to sql join but in SAP BI 7.0
    Thanks.

    Hi
    Pls look into below links. Hope this helps you.
    1. http://help.sap.com/saphelp_46c/helpdata/EN/d2/cb45bf455611d189710000e8322d00/content.htm
    2. http://help.sap.com/saphelp_46c/helpdata/EN/d2/cb45a5455611d189710000e8322d00/content.htm
    Regards
    Sirigiri

  • How to build a query based on(UNION) 3 vendor InfoObject

    Dear Experts:
    I have a requirement to build one query based on 3 vendor InfoObjct: 0VENDOR + 0VEN_COMPC + 0VEN_PURORG.
    I tried to build a multiprovider upon these 3 infoobjects, but when I Identify(Assign) the key for each InfoObject, supposely there should be 3 InfoObject for me to check (0VENDOR, 0VEN_COMPC and 0VEN_PURORG) so that I can UNION these 3 infoobjects together on vendor number. But since the reference infoobject of these 3 vendor master data is different, I can not check the 3 together.
    Can anybody let me know how to build that query? I only need vendor number show once, and the attributes of 0VEN_COMPC and 0VEN_PURORG can be union to 0vENDOR.
    Any post would be appreciated and thank you all in advance!
    Best Regards!
    Tim

    Hi,
    you can create a link between the vendor objects itself, means link 0vendor with 0ven_compc and 0ven_purorg. This should give you a list of all vendors multiplied with the comp codes multiplied with the purch. org. May be here it is possible to create another link between a attribute (eg. comp_code of 0ven_purorg with comp_code of 0ven_compc). In case it is not possible you need to add this link information somehow. Another option might be to create 2 queries. One on a infoset of 0vendor and 0ven_purorg and another one on 0vendor and 0ven_compc.
    regards
    Siggi

  • How to build a query dynamically....

    hi...i want to build a query dynamically. i don't want to build query by using string buffer. i want to create it directly by using sql query itself.
    my situation is like this....i have four drop down list in a page. The user can search the things based on one or two or three or four selected values.
    how to build a query for this kind of situation....pls let me know.
    Edited by: success_shiva6mca on Mar 3, 2008 12:39 PM

    there are two problems with building sql directly.
    1. it allows sql injection
    2.it allows XSS
    google them and you will understand if you dont already.
    I will recoment catching the values and using preparedStatements

  • Can we implement the custom sql query in CR for joining the two tables

    Hi All,
    Is there anyway to implement the custom sql query in CR for joining the two tables?
    My requirement here is I need to write sql logics for joining the two tables...
    Thanks,
    Gana

    In the Database Expert, expand the Create New Connection folder and browse the subfolders to locate your data source.
    Log on to your data source if necessary.
    Under your data source, double-click the Add Command node.
    In the Add Command to Report dialog box, enter an appropriate query/command for the data source you have opened.
    For example:
    SELECT
        Customer.`Customer ID`,
        Customer.`Customer Name`,
        Customer.`Last Year's Sales`,
        Customer.`Region`,
        Customer.`Country`,
        Orders.`Order Amount`,
        Orders.`Customer ID`,
        Orders.`Order Date`
    FROM
        Customer Customer INNER JOIN Orders Orders ON
            Customer.`Customer ID` = Orders.`Customer ID`
    WHERE
        (Customer.`Country` = 'USA' OR
        Customer.`Country` = 'Canada') AND
        Customer.`Last Year's Sales` < 10000.
    ORDER BY
        Customer.`Country` ASC,
        Customer.`Region` ASC
    Note: The use of double or single quotes (and other SQL syntax) is determined by the database driver used by your report. You must, however, manually add the quotes and other elements of the syntax as you create the command.
    Optionally, you can create a parameter for your command by clicking Create and entering information in the Command Parameter dialog box.
    For more information about creating parameters, see To create a parameter for a command object.
    Click OK.
    You are returned to the Report Designer. In the Field Explorer, under Database Fields, a Command table appears listing the database fields you specified.
    Note:
    To construct the virtual table from your Command, the command must be executed once. If the command has parameters, you will be prompted to enter values for each one.
    By default, your command is called Command. You can change its alias by selecting it and pressing F2.

  • How can i have Query trace results in a table format?

    How can i have Query trace results in a table format?

    Are you referring to reading the trace files generated under udump folder?
    Well, you can make use of external tables, but you really need to be a master in understanding that cryptic data.
    Check out following link for an alternative.
    http://www.oracle.com/technology/pub/articles/gallagher_tfm.html

  • Query for Linking Two Tables without Reference

    Hi Folks,
    Good Day!
    I have this dilemma on how to link two tables without a reference. In the Business Partner Master Data, there is a field for the Territory which is from the table OTER. This OTER focuses on its description. Once you have added the particular Territory for that Business Partner, it is being stored in the Territory field of the BP right? Our client wants to have an automated way of searching for the Business Partner's Profit Center in creating a Sales Order wherein it is the same as the Business Partner's Territory. The Profit Center is from the table OPRC.
    When I create a Sales Order, after I have entered the Business Partner/Customer Code, the Profit Center should have the value of the Profit Center Code wherein it is the Business Partner's Territory. My query will go like this:
    Enter the BP/Customer Code automatically the Profit Center code where Profit Name = BP's Territory.
    OTER and OCRD don't have connections. How can it be?
    I'm thinking of retrieving the Territory first before the Profit Center but can you suggest of any other way?
    Thank you much!
    Regards,
    Fringe

    Hi Fringe,
    Okay, I already understood your case here. I presume your configuration as follows:
    OTER (Territory)
    territryID - descript
    1 - Philippine
    2 - Indonesia
    3 - Germany
    OPRC (Cost Centre)
    PrcCode - PrcName
    25 - Philippine
    33 - Indonesia
    47 - Germany
    Was above illustration correct? Then, you could use this formatted search in Cost Centre / Dimension field in Sales Order rows
    SELECT PrcCode FROM OPRC WHERE PrcName=(
    SELECT TOP 1 descript FROM OTER T0
    INNER JOIN OCRD T1 ON T0.territryID=T1.Territory
    WHERE T1.CardCode=$[OCRD.CardCode.0])
    However, I suggest you use a little bit different approach here. Since you can't define Territory Code / Territory ID (you could only type the Territory name, Philippine etc.), why don't you standardize Territory name with Cost Centre code? Let say, you define Philippine as PHI, Indonesia as INA, Germany as DEU and so on. Therefore, user can read the Cost Centre or more precisely Distribution Rules in Sales Order form in more familiar way.
    OTER (Territory)
    territryID - descript
    1 - PHI
    2 - INA
    3 - DEU
    OPRC (Cost Centre)
    PrcCode - PrcName
    PHI - Philippine
    INA - Indonesia
    DEU - Germany
    When FMS worked in Sales Order document, your user will read PHI instead of 25, should be more familiar to them. With that being said, you could use simpler FMS
    SELECT descript FROM OTER T0
    INNER JOIN OCRD T1 ON T0.territryID=T1.Territory
    WHERE T1.CardCode=$[OCRD.CardCode.0]
    You only need to maintain consistency between Territory Name and Cost Centre code. Just my two cents. Hope this help.
    Best Regards,
    Hendry Wijaya

  • Prcedure to joining of two tables and pls explore the primary & foriegn key

    Dear All,
    Am new to this forum looking forward to have some discussions and guidance reg ABAP.
    <b>My query is</b>
    what is the prcedure to joining of two tables and pls explore the primary & foriegn key relationships.
    Your kind help is required in this query .
    Thanks n regards
    Carol P

    Hi Carol,
    Joining two tables fetch data from tables that has relevent entry based on the keys. like LIKP and LIPS these are delivery tables. if the business requirement is fetching delivery data that are exists in both two tables. here LIKP will conatins a single entry against a condition and LIPS may contains several entry because one delivery may has multiple line items. so, fetch the data joining the two tables on vbeln that is delivrey number. this is used to increase the performance of the program except for all entries.
    Foreign key is poiting twowards primary key; it may be 1:1 , 1:many and many:many. if field1 of table a is pointing towards field1 of table b. then based on these condition at the time of entry SAP will check how many entry can be entred in field1 of table a.
    regards
    Krishnendu

  • Join this two table HELP

    Hi to all.. i have this two table , the problem is i dunno how to join this two table into one, becoz in the forms i have two button "BUTTON A IS FOR TABLE A WHICH IS THE EMPLOYEE.. AND BUTTON B IS FOR ADMIN... WHAT I WANT IS TO MAKE THIS TWO BUTTON INTO ONE BUTTON.. i;m using form6i and run in client server..
    Guys any one here know plz help how to do this..
    TABLE 1
    BEGIN
    iF :username IS NULL THEN
    MESSAGE ('Please enter Username ');
    MESSAGE ('Please enter Username ');
    GO_ITEM('username');
    RAISE FORM_TRIGGER_FAILURE;
    end if;
    IF :PASSNAME1 IS NULL THEN
    MESSAGE('Please enter password.');
    MESSAGE('Please enter password.');
    GO_ITEM('PASSNAME1');
    RAISE FORM_TRIGGER_FAILURE;
    end if;
    select username,passname
    into :pass.username,:pass.passname1
    from Employees
    where :pass.username=username
    and :pass.passname1=passname;
    Message('Access Granted');
    Message('Access Granted');
    go_block('maina');
    hide_view('pass1');
    exception
    when no_Data_found then
    set_alert_Property('wrong',Alert_Message_text,'Invalid Password');
    if show_alert('wrong')=alert_button1 then
              go_item('PASSNAME1');
              :passname1:=null;
              end if;
    end;
    TABLE 2
    BEGIN
    iF :username IS NULL THEN
    MESSAGE ('Please enter Username ');
    MESSAGE ('Please enter Username ');
    GO_ITEM('username');
    RAISE FORM_TRIGGER_FAILURE;
    end if;
    IF :PASSNAME1 IS NULL THEN
    MESSAGE('Please enter password.');
    MESSAGE('Please enter password.');
    GO_ITEM('PASSNAME1');
    RAISE FORM_TRIGGER_FAILURE;
    end if;
    select username,passname
    into :pass.username,:pass.passname1
    from Admin1
    where :pass.username=username
    and :pass.passname1=passname;
    Message('Access Granted');
    Message('Access Granted');
    go_block('maina');
    hide_view('pass1');
    exception
    when no_Data_found then
    set_alert_Property('wrong',Alert_Message_text,'Invalid Password');
    if show_alert('wrong')=alert_button1 then
              go_item('PASSNAME1');
              :passname1:=null;
              end if;
    end;

    like i told you before in this posting How to join this two tables
    use a union
    select username,passname
    into :pass.username,:pass.passname1
    from Employees
    where :pass.username=username
    and :pass.passname1=passname
    union
    select username,passname
    into :pass.username,:pass.passname1
    from Admin1
    where :pass.username=username
    and :pass.passname1=passname;

  • Query the data between two tables

    Need help for query the data between two tables
    Table 1: Time sheet
    P.ID      P.Name EmpID HoursSpend DateTime
    c12234  Test      25        4                06/12/2013
    c12234  Test      25        7                06/13/2013
    c12234  Test      25        8                06/15/2013
    c12234  Test      5          3                06/21/2013
    c12234  Test      2          5                07/15/2013
    c12234  Test      25        4                07/21/2013
    Table 2: cost table
    EmpID  FromDate       ToDate         Rate
    25         05/01/2013    06/30/2013    250
    2         04/01/2013    05/31/2013      150
    25         07/01/2013     09/30/2013    300 
    Output
    P.ID      P.Name EmpID HoursSpend DateTime       Rate   Total (HoursSond x Rate)
    c12234  Test      25        4                06/12/2013    250     1000 (4*250)
    c12234  Test      25        7                06/13/2013    250      1750
    c12234  Test      25        8                06/15/2013    250      
    2000
    c12234  Test      25        4              07/21/2013     300       
    1200
    c12234  Test      2          5              07/15/2013    150          
    750
    ===========================================     
    Total                           28                                                 
    6700
    ============================================
    Here EmpID =2 don't have rate in the cost table on july month should be pick from last entry from cost table.

    Hi Gopal,
    According to your description, it seems that the output needn’t include the row when EmpID=2. Because the DateTime for it in Table1 doesn’t included between FromDate column and ToDate column. After testing the issue in my environment, we can refer to the
    query like below to achieve your requirement:
    SELECT time.*,cost.EmpID,cost.Rate,(time.HoursSpend * cost.Rate)as [Total (HoursSond x Rate)]
    FROM [Time sheet] as time
    INNER JOIN
    [cost table]as cost
    ON time.EmpID = cost.EmpID
    AND time.DateTime BETWEEN cost.FromDate AND cost.ToDate
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Join on two tables using "LIKE"

    Hi all,
    I need make join on two tables (QMEL and STXL) using keys for connection:
    - field for join of first table is (QMEL-QMNUM - Notif. number - Char 12)
    - field for join of second table is  (STXL-TDNAME - Char 70)
    If it is connection based on EQ, I think, it's no problem but I need to connect it on base of 'LIKE'.
    Example:
    QMEL-QMNUM = '100100698075'
    I would like get all rows from STXL which contain or even better start with notif. number.
    Examples I would like connect with QMEL-QMNUM:
    STXL-TDNAME = '100100698075'
    STXL-TDNAME = '1001006980750001'
    STXL-TDNAME = '10010069807500010001'
    STXL-TDNAME = '10010069807500010002'
    etc..
    Am I able to manage that with select which join these two tables this way?
    Thanks for any solution
    Vaclav Hosek.

    Hi,
    Write 2 separate selects for this.
    select * from QMEL
    where......
    if sy-subrc = 0.
    loop at i_qmel into wa.
    r_tdname-option = 'CP'.
    r_tdname-sign = 'I'
    concatenate wa-qnum '*' into r_tdname-low.
    append r_tdname.
    endloop.
    select *
    from STL
    where tdname in r_tdname.
    endif.

  • Sql join on two tables where column like another column

    hi all,
    been trying to get the results from a join between two tables where one column is like another one.
    table1 (nameA) examples: black2, green1
    table2 (nameB) example: black2.location.uk.com, green1.location.uk.com
    so for example I want to match all those in table1 with black2 to the column in table2 that begins with black2 and so on if you see what im trying to get at!
    my sql so far:
    select * from  schema.table1 a
    join schema.table2 b
    on a.nameA like concat('%', b.nameB, '%'); but it errors:
    ORA-00909: invalid number of arguments
    00909. 00000 - "invalid number of arguments"
    Any help or advice would be greatly appreciated, thankyou!

    Either of these should do it...
    select * from  schema.table1 a
    join schema.table2 b on a.nameA like '%'||b.nameB||'%';or
    select * from  schema.table1 a
    join schema.table2 b on instr(b.nameB,a.nameA) > 0

  • How to build sql query for view object at run time

    Hi,
    I have a LOV on my form that is created from a view object.
    View object is read-only and is created from a SQL query.
    SQL query consists of few input parameters and table joins.
    My scenario is such that if input parameters are passed, i have to join extra tables, otherwise, only one table can fetch the results I need.
    Can anyone please suggest, how I can solve this? I want to build the query for view object at run time based on the values passed to input parameters.
    Thanks
    Srikanth Addanki

    As I understand you want to change the query at run time.
    If this is what you want, you can use setQuery Method then use executeQuery.
    http://download.oracle.com/docs/cd/B14099_19/web.1012/b14022/oracle/jbo/server/ViewObjectImpl.html#setQuery_java_lang_String_

  • How to build a query to get the item properties is tick or not?

    hello everybody. i'm 1 of the sap b1 user. i face a problem in build a query to check one of the item properties is tick or not? pls help...

    Hi Grace,
    your query could look like this:
    Select itemcode from oitm where qrygroup1= "Y"
    qrygroup1 is item property 1, qrygroup2 is item property 2 etc.
    Regards
    Ad

  • How to tune the query for duplicate records while joining the two tables

    hi,i am executing the query which has retrieving multiple tables,in which one of them has duplicate record,how to get single record

    Not enough info...subject says "tune" the query, message says "write" the query...and where is actual query that you had tried ?

Maybe you are looking for