How to join four tables in Update query??

Please how to join four tables in a single query to update one table row??

You can use this syntax to update. Here updation of 1 column to a constant value (50) in multiple rows in Table A based on an associated 'SOURCE' value in table B
Table A joins to Table B based on the TableA.definition_id = TableB.Att_Def_id
like..
update TableA
set value =50
where
TableA.definition_id = TableB.Att_Def_id
and TABLEB.Source = 'NEWPRODUCT'

Similar Messages

  • How does the MDKP table gets updates

    Dear PP Guru's,
    I am new to SAP PP,
    We have a query that how does the MDKP table gets updates,
    Some time If we create new material by coping the material which is showing in table MDKP,
    But new material is not showing in table MDKP,
    Based on table MDKP we are fetching some data, due to above problem we are not able to fetch the data for some materials,
    Please suggest what could be the reason,
    Any help will be highly appreciated,
    Thanks in advance,
    Sachin.

    Thanks Thaila,
    I have checked the same by doing MRP through MD02 & the entry is getting update in MDKP,
    But for some of our materials MRP (MD02) is done earlier, but these materials are not showing in MDKP,
    Please suggest, when the entries in MDKP are removed, are there any conditions for removing the entries from MDKP.
    please pour some light on the issue,
    Thanks once again,
    Sachin.

  • How to set the table input in Query template?

    Hi all.
    I need to call a Bapi_objcl_change, with import parameter and a table as an input. I have done this, in BLS. I have set the table input in the
    form of xml. In BLS, I get the output(the value gets change in SAP R3, what i have given in BLS).  But if i set the same xml structure  in
    query template, I didn't get the output. Table input parameter does not take that xml source.  How to set the table input in Query template?
    can anyone help me?
    Regards,
    Hemalatha

    Hema,
    You probably need to XML encode the data so that it will pass properly and then xmldecode() it to set the BAPI input value.
    Sam

  • How to join two tables

    hi
    how to join two tables using inner join  if the first table has two primary keys and second table has 3 primary keys

    Would describe type of joins in ABAP, which might differ with other joins.
    The join syntax represents a recursively nestable join expression. A join expression consists of a left-hand and a right- hand side, which are joined either by means of INNER JOIN or LEFT OUTER JOIN. Depending on the type of join, a join expression can be either an inner (INNER) or an outer (LEFT OUTER) join. Every join expression can be enclosed in round brackets. If a join expression is used, the SELECT command circumvents SAP buffering.
    On the left-hand side, either a single database table, a view dbtab_left, or a join expression join can be specified. On the right-hand side, a single database table or a view dbtab_right as well as join conditions join_cond can be specified after ON. In this way, a maximum of 24 join expressions that join 25 database tables or views with each other can be specified after FROM.
    AS can be used to specify an alternative table name tabalias for each of the specified database table names or for every view. A database table or a view can occur multiple times within a join expression and, in this case, have various alternative names.
    The syntax of the join conditions join_cond is the same as that of the sql_cond conditions after the addition WHERE, with the following differences:
    At least one comparison must be specified after ON.
    Individual comparisons may be joined using AND only.
    All comparisons must contain a column in the database table or the view dbtab_right on the right-hand side as an operand.
    The following additions not be used: NOT, LIKE, IN.
    No sub-queries may be used.
    For outer joins, only equality comparisons (=, EQ) are possible.
    If an outer join occurs after FROM, the join condition of every join expression must contain at least one comparison between columns on the left-hand and the right-hand side.
    In outer joins, all comparisons that contain columns as operands in the database table or the view dbtab_right on the right-hand side must be specified in the corresponding join condition. In the WHERE condition of the same SELECT command, these columns are not allowed as operands.
    Resulting set for inner join
    The inner join joins the columns of every selected line on the left- hand side with the columns of all lines on the right-hand side that jointly fulfil the join_cond condition. A line in the resulting set is created for every such line on the right-hand side. The content of the column on the left-hand side may be duplicated in this case. If none of the lines on the right-hand side fulfils the join_cond condition, no line is created in the resulting set.
    Resulting set for outer join
    The outer join basically creates the same resulting set as the inner join, with the difference that at least one line is created in the resulting set for every selected line on the left-hand side, even if no line on the right-hand side fulfils the join_cond condition. The columns on the right-hand side that do not fulfil the join_cond condition are filled with null values.
    Note
    If the same column name occurs in several database tables in a join expression, they have to be identified in all remaining additions of the SELECT statement by using the column selector ~.
    Example
    Join the columns carrname, connid, fldate of the database tables scarr, spfli and sflight by means of two inner joins. A list is created of the flights from p_cityfr to p_cityto. Alternative names are used for every table.
    PARAMETERS: p_cityfr TYPE spfli-cityfrom,
    p_cityto TYPE spfli-cityto.
    DATA: BEGIN OF wa,
    fldate TYPE sflight-fldate,
    carrname TYPE scarr-carrname,
    connid TYPE spfli-connid,
    END OF wa.
    DATA itab LIKE SORTED TABLE OF wa
    WITH UNIQUE KEY fldate carrname connid.
    SELECT ccarrname pconnid f~fldate
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM ( ( scarr AS c
    INNER JOIN spfli AS p ON pcarrid = ccarrid
    AND p~cityfrom = p_cityfr
    AND p~cityto = p_cityto )
    INNER JOIN sflight AS f ON fcarrid = pcarrid
    AND fconnid = pconnid ).
    LOOP AT itab INTO wa.
    WRITE: / wa-fldate, wa-carrname, wa-connid.
    ENDLOOP.
    Example
    Join the columns carrid, carrname and connid of the database tables scarr and spfli using an outer join. The column connid is set to the null value for all flights that do not fly from p_cityfr. This null value is then converted to the appropriate initial value when it is transferred to the assigned data object. The LOOP returns all airlines that do not fly from p_cityfr.
    PARAMETERS p_cityfr TYPE spfli-cityfrom.
    DATA: BEGIN OF wa,
    carrid TYPE scarr-carrid,
    carrname TYPE scarr-carrname,
    connid TYPE spfli-connid,
    END OF wa,
    itab LIKE SORTED TABLE OF wa
    WITH NON-UNIQUE KEY carrid.
    SELECT scarrid scarrname p~connid
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM scarr AS s
    LEFT OUTER JOIN spfli AS p ON scarrid = pcarrid
    AND p~cityfrom = p_cityfr.
    LOOP AT itab INTO wa.
    IF wa-connid = '0000'.
    WRITE: / wa-carrid, wa-carrname.
    ENDIF.
    ENDLOOP.

  • How to Join 2 tables if datetime diff is within range?

    Hi, problem figuring out how to join tables if the datediff ? is within range.  
    There are 3 tables  a main table then 2 sub tables, these are measurements with a date/time value.  Im trying to take the datetime entries from the 2 sub tables and match them, then add  them to the main table
    subtable1 has SampleID, datetime, 
    subtable2 has TesterID, datetime
    maintable has SampleID, datetime, TesterID, datetime
    so the maintable would always have the sampleID value and datetime regardless.  but it would only JOIN the testerID and its datetime, only IF these 2 datetime values were close, and the datediff interval was set to 1 second.
     its a function call that fills the main tables matching columns but only if the testerIDs datetime is close to the sampleIDs time????
    thanks

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
    use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. Thanks for making us do your typing and DDL for you :( 
    >> There are 3 tables; a main table then 2 sub tables, <<
    Really? Main table? Sub-tables? There are no such terms in SQL. Trust me on that; I helped with the Standards :) We have referenced referencing tables in the DRI model of SQL. 
    >> these are measurements with a date/time value. << 
    ++Both of them, the measurementID and otherID  have a millisecond timestamp, the goal is to associate these 2 measurements, they are coming from different systems.  
    Do you really need the full timestamp down to nanoseconds and not just a DATE? Oh, we also have no sample data :( So we have to guess at precision, constraints, keys, etc. 
    See why we need DDL? Is this relationship 1:1, 1:M OR N:1? My guess is that a tester can do many samples, but a sample has only one tester. And what were those two timestamps? Not redundant copies from the referenced tables!! That would non-normalized. 
    >> so the Sample_Tester_Relationship would always have the sample_nbr value and <something>_timestamp regardless. But it would only JOIN the tester_id and its DATETIME, only IF these 2 DATETIME values were close, and the DATEDIFF interval was set
    to 1 second. <<
    No, you do not do a JOIN inside a base table. That is VIEW.
    >> It is a function [sic: procedure, Functions return scalar values] call that fills the main tables matching columns but only if the tester_id DATETIME is close to the sample_id time? <<
    No sample data, no sample code and no business rules about ties. Here is my final guess at normalizing this problem: 
    CREATE TABLE Samples
    (sample_nbr CHAR(12) NOT NULL PRIMARY KEY,
    CREATE TABLE Testers
    (tester_id CHAR(10) NOT NULL PRIMARY KEY,
    CREATE TABLE Sample_Tester_Relationship --- needs a real name!
    (sample_nbr CHAR(12) NOT NULL PRIMARY KEY
     REFERENCES Samples
      ON UPDATE CASCADE
      ON DELETE CASCADE,
     tester_id CHAR(10) NOT NULL
     REFERENCES Testers
      ON UPDATE CASCADE
      ON DELETE CASCADE,
     PRIMARY KEY (sample_nbr, tester_id),
     tester_timestamp DATETIME2(1) DEFAULT CURRENT_TIMESTAMP NOT NULL,
     sample_timestamp DATETIME2(1) DEFAULT CURRENT_TIMESTAMP NOT NULL,
     CHECK (ABS (DATEDIFF (SECOND, tester_timestamp, sample_timestamp) <= 1) );
    Most of the work in SQL is in DDL, not DML. 
    I will try this out and advise.
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in
    Sets / Trees and Hierarchies in SQL
    Dear Celko
    thank you for this constructive feedback, clearly you're an expert and I am going to be better for following this advice.  In the 1970s I was told to avoid going into software because Japan had invented a way for computers to write their own code, so
    programmers would be out of a job and the field would be a dead-end.  I didnt formally begin training in sw until the 90s.  SQL is one of those last frontiers i never trained in.  but now Im trying to learn and find anything i can read to absorb
    it.
    I posted in laymans words because i thought thats how you experts would prefer it described, clearly not.  I will now take the time to read each reference to the standards...

  • How to join cluster table?

    How to join the cluster table with the transparent table?In specific ,can you pls tell me how can i join bkpf and bseg?

    Hi Aravind,
    Check this code,
    tables : bkpf,
             bseg.
       INTERNAL TABLE AND WORK AREA FOR THE FIELDS IN BKPF TABLE         *
    data : begin of itab_bkpf occurs 0,
           bukrs like bkpf-bukrs,            "Company Code.
           gjahr like bkpf-gjahr,            "Fiscal Year.
           budat like bkpf-budat,            "Posting Date in the Document.
           belnr like bkpf-belnr,            "Accounting document number.
           blart like bkpf-blart,            "Document Type.
           end of itab_bkpf.
    data : wa_bkpf like line of itab_bkpf.
       INTERNAL TABLE AND WORK AREA FOR THE FIEDLS IN BSEG TABLE         *
    data : begin of itab_bseg_debit occurs 0,
           bukrs like bseg-bukrs,            "Company Code.
           gjahr like bseg-gjahr,            "Fiscal Year.
           belnr like bseg-belnr,            "Accounting Document Number.
           buzei like bseg-buzei,            "Line Item.
           hkont like bseg-hkont,            "General Leadger Account.
           shkzg like bseg-shkzg,            "Credit/Debit Indicator.
           wrbtr like bseg-wrbtr,            "Amount in Document Currency.
           pswsl like bseg-pswsl,            "Update Currency for Gen.Ledger
           dmbtr like bseg-dmbtr,            "Amount in local currency.
           sgtxt like bseg-sgtxt,            "Item Text.
           zuonr like bseg-zuonr,            "Assignment Number.
           end of itab_bseg_debit.
    data : itab_bseg_credit like standard table of itab_bseg_debit with
           header line.
                      FINAL OUTPUT INTERNAL TABLE                        *
    data : begin of itab_output occurs 0,
           belnr(08)            ,
           bukrs(04)            ,
           budat like bkpf-budat,
           buzei(03)            ,
           hkont(07)            ,
           blart(02)            ,
           shkzg(01)            ,
           wrbtr(08)            ,
           pswsl(05)            ,
           dmbtr(10)            ,
           sgtxt(19)            ,
           zuonr(10)            ,
    end of itab_output.
    constants : c_debit  type c value 'S',
                c_credit type c value 'H'.
                               SELECT-OPTIONS                            *
    selection-screen begin of block input with frame title text-t01.
    select-options : s_bukrs for bkpf-bukrs.
    parameters     : p_year like bkpf-gjahr visible length 2.
    select-options : s_budat  for bkpf-budat,
                     s_dbacct for bseg-hkont,
                     s_cracct for bseg-hkont,
                     s_amt    for bseg-dmbtr.
    selection-screen end of block input.
         SELECTING RECORDS FROM BKPF TABLE BASED ON THE CONDITION        *
    select bukrs gjahr budat belnr blart
           from  bkpf into table itab_bkpf
           where bukrs in s_bukrs and
                 gjahr eq p_year  and
                 budat in s_budat.
        SELECTING DEBIT LINE ITEMITEMS FROM BSEG FOR THE DOCUMENT        *
                      NUMBER SELECTED FROM BKPF                          *
    if not itab_bkpf[] is initial.
      select bukrs gjahr belnr buzei
             hkont shkzg wrbtr pswsl
             dmbtr sgtxt zuonr
             from bseg into table itab_bseg_debit
             for all entries in itab_bkpf
             where bukrs eq itab_bkpf-bukrs and
                   belnr eq itab_bkpf-belnr and
                   gjahr eq itab_bkpf-gjahr and
                   hkont in s_dbacct        and
                   shkzg eq c_debit         and
                   dmbtr in s_amt.
        SELECTING CREDIT LINE ITEMITEMS FROM BSEG FOR THE DOCUMENT       *
                      NUMBER SELECTED FROM BKPF                          *
      select bukrs gjahr belnr buzei
             hkont shkzg wrbtr pswsl
             dmbtr sgtxt zuonr
             from bseg into table itab_bseg_credit
             for all entries in itab_bkpf
             where bukrs eq itab_bkpf-bukrs and
                   belnr eq itab_bkpf-belnr and
                   gjahr eq itab_bkpf-gjahr and
                   hkont in s_cracct        and
                   shkzg eq c_credit        and
                   dmbtr in s_amt.
    endif.
    sort itab_bkpf        by bukrs gjahr belnr.
    sort itab_bseg_credit by bukrs gjahr belnr.
                         LOOPING THE DEBIT ENTRIES                       *
    loop at itab_bseg_debit.
    READING THE CREDIT ENTRIES WHICH MATCHES WITH HE CURRENT DOC. NUMBER *
      read table itab_bseg_credit with key
                 bukrs = itab_bseg_debit-bukrs
                 gjahr = itab_bseg_debit-gjahr
                 belnr = itab_bseg_debit-belnr binary search.
      if sy-subrc eq 0.
    *READING THE POSTING DATE AND DOCUMENT TYPE FOR THE CURRENT DOUCMENT   *
           AND APPENDING THE DEBIT AND CREDIT ENTRIES                    *
        read table itab_bkpf into wa_bkpf with key
                   bukrs = itab_bseg_debit-bukrs
                   gjahr = itab_bseg_debit-gjahr
                   belnr = itab_bseg_debit-belnr binary search.
        itab_output-belnr = itab_bseg_debit-belnr.
        itab_output-bukrs = itab_bseg_debit-bukrs.
        itab_output-budat = wa_bkpf-budat.
        itab_output-buzei = itab_bseg_debit-buzei.
        itab_output-hkont = itab_bseg_debit-hkont.
        itab_output-blart = wa_bkpf-blart.
        itab_output-shkzg = itab_bseg_debit-shkzg.
        itab_output-wrbtr = itab_bseg_debit-wrbtr.
        itab_output-pswsl = itab_bseg_debit-pswsl.
        itab_output-dmbtr = itab_bseg_debit-dmbtr.
        itab_output-sgtxt = itab_bseg_debit-sgtxt.
        itab_output-zuonr = itab_bseg_debit-zuonr.
        append itab_output.
        itab_output-belnr = itab_bseg_credit-belnr.
        itab_output-bukrs = itab_bseg_credit-bukrs.
        itab_output-budat = wa_bkpf-budat.
        itab_output-buzei = itab_bseg_credit-buzei.
        itab_output-hkont = itab_bseg_credit-hkont.
        itab_output-blart = wa_bkpf-blart.
        itab_output-shkzg = itab_bseg_credit-shkzg.
        itab_output-wrbtr = itab_bseg_credit-wrbtr.
        itab_output-pswsl = itab_bseg_credit-pswsl.
        itab_output-dmbtr = itab_bseg_credit-dmbtr.
        itab_output-sgtxt = itab_bseg_credit-sgtxt.
        itab_output-zuonr = itab_bseg_credit-zuonr.
        append itab_output.
      endif.
    endloop.
    sort itab_output by belnr budat shkzg.
                     LOOPING OUTPUT INTERNAL TABLE                       *
    *FORMAT INTENSIFIED INPUT.
    *FORMAT INVERSE ON.
    loop at itab_output.
      format hotspot on.
      format color 5 inverse.
      write :/  sy-vline,
               000 itab_output-belnr, 12  sy-vline,
               013 itab_output-bukrs, 17  sy-vline,
               019 itab_output-budat,     sy-vline,
               034 itab_output-buzei, 40  sy-vline,
               042 itab_output-hkont,     sy-vline,
               054 itab_output-blart, 60  sy-vline,
               065 itab_output-shkzg, 70  sy-vline,
               072 itab_output-wrbtr,     sy-vline,
               085 itab_output-pswsl,     sy-vline,
               093 itab_output-dmbtr,     sy-vline,
               106 itab_output-sgtxt,     sy-vline,
                   itab_output-zuonr,     sy-vline.
      format hotspot off.
    endloop.
    uline 0(139).
    <b>Regards,
    Jackie.</b>

  • Joining four tables

    hi
    i have four tables, given the sample data for the relevant field of the tables here under
    table company:
    company_id     comp_parent_org_id
    241     238
    457     279
    225     200
    478     200
    10     279
    table representative:
    rep_id     rep_parent_org_id
    238     234
    279     170
    200     234
    table mobile_unit     :     
    rep_id     company_id     msisdn     creation_date
    238     241     91944400000     1-Sep-08
    279     457     91944400005     1-Sep-07
    200     225     91944400010     10-Sep-08
    200     478     91944400100     5-Jul-08
    279     10     91944410100     5-Jul-08
    table organization     :
    organization_id     name
    234     chennai
    170     kerala
    238     al
    279     da
    200     sd
    now i want to join all these table to get the output as below
    table output required: between creation_date in table mobile_unit
    name     no of companies     no of msisdns
    chennai     3     3
    kerala     2     2
    the organization table contains the name for all the ids in the table company, representative, etc
    name field should reflect the name of the distinct rep_parent_org_id
    companies column should count the number of company_id in company table w.r.t comp_parent_org_id (same as rep_id in representative table) which in turn should lie under the rep_parent_org_id
    for example here rep_parent_org_id 170 , its name is kerala, then under this id we have got 279 as the rep_id (same as comp_parent_org_id). with 279 as comp_parent_org_id we have got two company_id so no of companies =2
    no of msisdns column
    rep_parent_org_id 170 , its name is kerala, then under this id we have got 279 as the rep_id. for this 279 rep_id , we have got two msisdn (i.e 91944400005 & 91944410100) so count is 2
    i tried in this way as per the answer for my previous question, but am not able to count companies
    select DISTINCT o.name, count(mu.msisdn)
    FROM RTMS.ORGANIZATION O
    INNER JOIN RTMS.REPRESENTATIVE R
         ON O.ORGANIZATION_ID=R.PARENT_ORG_ID
    INNER JOIN RTMS.MOBILE_UNIT MU
         ON R.REP_ID=MU.REP_ID
    GROUP BY O.NAME
    can anybody help me out
    thanks
    Aemunathan
    Edited by: Aemunathan on Sep 10, 2008 11:15 PM

    Hi,
    Good question! Clear question, carefully written, complete sample data (but not too much), nothing irrelevant, clear sample output.
    Would you like to make your questions even better? Enclose the code and data in code tags, as described in the FAQ, to preserve spacing.
    You have a one-to-many relationship between representative and mobile_unit, so when you join those two tables, you can multiply rows in representative. For example, there are two rows in mobile_unit with rep_id = 279, so when you join mobile_unit to representative, it looks like there were two rows from representative with rep_id = 279. In the three-table query you posted, that was okay.
    You also have a one-to-many relationship between representative and company. If you simply join company the way you joined mobile_unit, those "extra" rows in representative become a problem. For example, there are two rows in company with comp_parent_rep_id = 279. If, because of the join with mobile unit, there seem to be two rows from represnetative with rep_id = 279, then both of the rows from comany will join to both of the rows from representative.
    To solve that problem, you should do the join between representative and mobile_unit separately from the join between representative and company. Here's one way to do that:
    WITH     m     AS
    (     -- Begin sub-query m, counts from mobil_unit
         SELECT     rep_parent_org_id
         ,     COUNT (msisdn)     AS msisdn_cnt
         FROM     representative     r
         JOIN     mobile_unit     mu     ON r.rep_id     = mu.rep_id
         GROUP BY     rep_parent_org_id
    )     -- End sub-query m, counts from mobil_unit
    ,     c     AS
    (     -- Begin sub-query c, counts from company
         SELECT     rep_parent_org_id
         ,     COUNT (company_id)     AS company_cnt
         FROM     representative     r
         JOIN     company          c     ON r.rep_id     = c.comp_parent_org_id
         GROUP BY     rep_parent_org_id
    )     -- End sub-query c, counts from company
    SELECT     o.name
    ,     m.msisdn_cnt
    ,     c.company_cnt
    FROM     organization     o
    JOIN               m     ON o.organization_id     = m.rep_parent_org_id
    JOIN               c     ON o.organization_id     = c.rep_parent_org_id
    ;If there is a chance that some organiztion will have matching rows in mobile_unit but not in company (or vice-versa), then you should make the joins in the main query outer joins.

  • The order of joining the tables in a query ANSI92

    Hi all!
    I have three table in Univerce.
    I need that those tables joined in next order:
    tab1 inner join tab2 right join tab3
    When creating a report in WebI they are connected as (regardless of the order of dimentions):
    tab1 right join tab3 inner join tab2
    How to set the correct order of joining the tables?
    OR
    how to change RIGHT OUTER JOIN on LEFT OUTER JOIN ?
    P.S. I use BO XI3.1, which not have parameter OUTERJOINS_GENERATION
    Thanks!

    it depends on your source system
    for example if you are using oracle, you can edit the link between the table and add this
    (+)
    for example
    TAB1.ID = TAB2.ID (+)
    AND TAB1.DEPT  = TAB2.DEPT(+)
    See the following link for discussing outer and inner joins for oracle
    http://www.dba-oracle.com/t_outer_joins.htm
    good luck
    Amr

  • Effects of Updating GRPO table from Update Query..

    Hi all,
    Wanted to know what are the repercussions of updating GRPO table with Update statement, Basically the client is not selected Project field in the GRPO rows in some of the documents during the Posting. Now the same is to be updated, as Invoices are created for most of them and payments also made document is un-editable.
    If i can update using UPDATE statement how will the system react? I know as per SAP guidelines, we cannot update the SAP Tables directly using INSERT or UPDATE statements but wanted to know what is the further effect on postings and SAP as a whole.
    Regards
    Rohan

    Hi,
    The using of update, insert or delete are not allowed in SAP B1. If you use it in B1 db, the maintenance contract with you will be stopped and your money will not be returned. The consequence of using the statements is the database inconsistency.
    Just an info, SAP AG support will use insert, update and delete statement only if the statements are needed and fix the db inconsistency. E.g., if your user is trying to add sales order and after add, the sales order row is empty and header is not empty. SAP will use  the statement to fix the database only if the cause of the error is explained to them. E.g. the server is suddenly shutdown because  the power supply is stopped and it made the sales order like that
    JimM

  • How to join these tables?

    hi,
    i was asked to create a view with select fields in these four tables. but i'm having a hard-time with the joins.
    oe_order_headers
    wsh_delivery_details
    ra_customers
    ra_addresses
    can someone help.
    thanks
    allen

    Allen Try this
    --Execute this first
    begin
    fnd_client_info.set_org_context(204); --R11
    mo_global.set_policy_context('S',204); --R12
    end;
    Run this sql..
    select * from oe_order_headers_all a, oe_ship_to_orgs_v b,wsh_delivery_details d
    where a.ship_to_org_id=b.organization_id
    and a.header_id=d.source_header_id;
    Thanks
    Nagamohan

  • How to join three tables?

    I have used this query to join three tables but it displays an error : field vbak-vbeln is unknown.
    please help me out..
    SELECT vbak-vbeln vbak-bstnk vbap-matnr vbap-zmeng makt-maktx
    INTO CORRESPONDING FIELDs OF TABLE itab FROM vbak
    inner JOIN vbap ON vbak-vbeln eq vbap-vbeln
    inner JOIN makt ON vbap-matnr eq makt-matnr
    WHERE vbak-bstnk = s_bstnk.

    Hi mohan kumar ,
    just follow the Syntax
    SELECT FLD1 FLD2 FLD3 FLD4 FLD5 INTO CORRESPONDING FIELDS OF TABLE ITAB FROM TABLE1 INNER JOIN TABLE2 ON
    TABLE1FLD1 = TABLE2FLD1 INNER JOIN TABLE3 ON TABLE2FLD2 = TABLE3FLD2 INNER JOIN TABL4 ON  TABLE3FLD3 = TABLE4FLD3
    WHERE FLD1 = 'AA'
    Hope this may be helpful.
    Please reward points if found ok.
    Thanks and regards,
    Rajeshwar.

  • How to join multiple tables !

    Give me the Example to join multiple tables 1

    Inner join
    IF p_bsart IS INITIAL.
    SELECT ekko~bukrs
    ekko~lifnr
    ekko~ebeln
    ekko~waers
    ekko~bsart
    ekko~ekorg
    ekko~ekgrp
    ekpo~ebelp
    ekpo~txz01
    ekpo~matnr
    ekpo~werks
    ekpo~menge
    ekpo~meins
    ekpo~netpr
    ekpo~netwr
    INTO TABLE t_itab1 FROM
    ekko INNER JOIN ekpo ON ekkoebeln = ekpoebeln
    WHERE ekko~ebeln IN s_ebeln AND
    ekko~bukrs IN s_bukrs AND
    ekko~lifnr IN s_lifnr AND
    ekko~ekorg IN s_ekorg AND
    ekko~ekgrp IN s_ekgrp AND
    ekpo~matnr IN s_matnr.
    The difference between an INNER JOIN and an OUTER JOIN is the following. If a query on an INNER JOIN of VBAK (outer table) and VBAP (inner table) finds a record in VBAK but no matching records in VBAP, then no data is retrieved from the database because the inner table is empty. If you still want to keep VBAK rows for which there are no matching VBAP rows, you need to use the OUTER JOIN construct available in ABAP/4 Open SQL in 4.x..
    Hi
    Syntax
    ... [(] {dbtab_left [AS tabalias_left]} | join
    {[INNER] JOIN}|{LEFT [OUTER] JOIN}
    {dbtab_right [AS tabalias_right] ON join_cond} [)] ... .
    Effect
    The join syntax represents a recursively nestable join expression. A join expression consists of a left-hand and a right- hand side, which are joined either by means of [INNER] JOIN or LEFT [OUTER] JOIN . Depending on the type of join, a join expression can be either an inner ( INNER) or an outer (LEFT OUTER) join. Every join expression can be enclosed in round brackets. If a join expression is used, the SELECT command circumvents SAP buffering.
    On the left-hand side, either a single database table, a view dbtab_left, or a join expression join can be specified. On the right-hand side, a single database table or a view dbtab_right as well as join conditions join_cond can be specified after ON. In this way, a maximum of 24 join expressions that join 25 database tables or views with each other can be specified after FROM.
    AS can be used to specify an alternative table name tabalias for each of the specified database table names or for every view. A database table or a view can occur multiple times within a join expression and, in this case, have various alternative names.
    The syntax of the join conditions join_cond is the same as that of the sql_cond conditions after the addition WHERE, with the following differences:
    At least one comparison must be specified after ON.
    Individual comparisons may be joined using AND only.
    All comparisons must contain a column in the database table or the view dbtab_right on the right-hand side as an operand.
    The following language elements may not be used: BETWEEN, LIKE, IN.
    No sub-queries may be used.
    For outer joins, only equality comparisons (=, EQ) are possible.
    If an outer join occurs after FROM, the join condition of every join expression must contain at least one comparison between columns on the left-hand and the right-hand side.
    In outer joins, all comparisons that contain columns as operands in the database table or the view dbtab_right on the right-hand side must be specified in the corresponding join condition. In the WHERE condition of the same SELECT command, these columns are not allowed as operands.
    Resulting set for inner join
    The inner join joins the columns of every selected line on the left- hand side with the columns of all lines on the right-hand side that jointly fulfil the join_cond condition. A line in the resulting set is created for every such line on the right-hand side. The content of the column on the left-hand side may be duplicated in this case. If none of the lines on the right-hand side fulfils the join_cond condition, no line is created in the resulting set.
    Resulting set for outer join
    The outer join basically creates the same resulting set as the inner join, with the difference that at least one line is created in the resulting set for every selected line on the left-hand side, even if no line on the right-hand side fulfils the join_cond condition. The columns on the right-hand side that do not fulfil the join_cond condition are filled with null values.
    Example
    Join the columns carrname, connid, fldate of the database tables scarr, spfli and sflight by means of two inner joins. A list is created of the flights from p_cityfr to p_cityto. Alternative names are used for every table.
    PARAMETERS: p_cityfr TYPE spfli-cityfrom,
    p_cityto TYPE spfli-cityto.
    DATA: BEGIN OF wa,
    fldate TYPE sflight-fldate,
    carrname TYPE scarr-carrname,
    connid TYPE spfli-connid,
    END OF wa.
    DATA itab LIKE SORTED TABLE OF wa
    WITH UNIQUE KEY fldate carrname connid.
    SELECT ccarrname pconnid f~fldate
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM ( ( scarr AS c
    INNER JOIN spfli AS p ON pcarrid = ccarrid
    AND p~cityfrom = p_cityfr
    AND p~cityto = p_cityto )
    INNER JOIN sflight AS f ON fcarrid = pcarrid
    AND fconnid = pconnid ).
    LOOP AT itab INTO wa.
    WRITE: / wa-fldate, wa-carrname, wa-connid.
    ENDLOOP.
    Example
    Join the columns carrid, carrname and connid of the database tables scarr and spfli using an outer join. The column connid is set to the null value for all flights that do not fly from p_cityfr. This null value is then converted to the appropriate initial value when it is transferred to the assigned data object. The LOOP returns all airlines that do not fly from p_cityfr.
    PARAMETERS p_cityfr TYPE spfli-cityfrom.
    DATA: BEGIN OF wa,
    carrid TYPE scarr-carrid,
    carrname TYPE scarr-carrname,
    connid TYPE spfli-connid,
    END OF wa,
    itab LIKE SORTED TABLE OF wa
    WITH NON-UNIQUE KEY carrid.
    SELECT scarrid scarrname p~connid
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM scarr AS s
    LEFT OUTER JOIN spfli AS p ON scarrid = pcarrid
    AND p~cityfrom = p_cityfr.
    LOOP AT itab INTO wa.
    IF wa-connid = '0000'.
    WRITE: / wa-carrid, wa-carrname.
    ENDIF.
    ENDLOOP.

  • How to join two tables using EJB-QL

    Hi There,
    How to join tables using EJB-QL ?
    Thanks.
    Edited by: vamseebobby on Nov 6, 2007 8:12 AM

    You might try
    SELECT b.entity2property FROM Entity1 a JOIN a.entity2 b
    for example, to retrieve players names, from a Players table, that belong to the team 'My Team' in the Teams table
    SELECT b.playerName FROM Teams a JOIN a.players b WHERE a.teamName = 'My Team'

  • How to join KNA1 table with SOOD, SOST or SOES table?

    Hi,
    I am creating an infoset and I cant join KNA1 with any of the following tables: SOST, SOES or SOOD.
    I am looking to get the following fields from the following table:
    KNA1 - KUNNR: Customer Number
    SOES - STATUS: Status
    SOOD- OBJNAM : Send Method
    SOOD - OBJDES : Document Title
    SOOD - CRONAM : Created by
    SOES- MSGV1 : Recipient
    SOST - STAT - DATE : Send date
    SOST - STAT - TIME : Send time
    I tried adding knvp table to find a common field but cant seem to join them. SOST, SOES and SOOD are easily joined with each other but KNA1 or KNVP cannot be joined, is there any intermediate table that I should use to join these tables to get the customer number against them or is there any other solution. kindly help.
    Regards,
    Moaz

    Hi,
    please try to connect KNA1 with SOOD using
    CALL METHOD cl_binary_relation=>read_links
       EXPORTING
         is_object           = ls_lpor
         it_relation_options = lt_relat
       IMPORTING
         et_links            = lt_links.
    where ls_por-instid = kna1-kunnr, ls_por-typeid = 'KNA1' and ls_por-catid = 'BO'
    and  lt_relat contains a line option 'I' 'EQ' 'NOTE'.
    Regards,
    Klaus

  • How to  Join two tables using the Inner Join

    Hi All,
    I have two tables i.e table1 and table2 as i have created two otds and my present requirement is to join this two tables and get the results and using this i need to do some logic and update another table3.
    can some one help me out how to go for the above req.
    Thanks in Advance
    Srikanth

    The best efficient way to use inner join is create two input otds,use there otd's in create a collaboration usinf etl.
    after selecting two input otd's create a inner join statement and map it to out put otd.
    while using the etl the performance of the over all integration is increased 20 time of the normal integration.
    Hopes this will helps,,
    Thanks,
    Papa Rao.

Maybe you are looking for