Joins in abap

Hi experts,
Can anyone give me the usage of all type of joins(inner, self,outer) used in abap  with one practical ex.
thanks in advance
R.Vijai

Hi
In a relational database, you normally need to read data simultaneously from more than one database table into an application program. You can read from more than one table in a single SELECT statement, such that the data in the tables all has to meet the same conditions, using the following join expression:
SELECT...
FROM <tab> [INNER] JOIN <dbtab> [AS <alias>] ON <cond> <options>
where <dbtab> is a single database table and <tab> is either a table or another join expression. The database tables can be specified statically or dynamically as described above. You may also use aliases. You can enclose each join expression in parentheses. The INNER addition is optional.
A join expression links each line of <tab> with the lines in <dbtab> that meet the condition <cond>. This means that there is always one or more lines from the right-hand table that is linked to each line from the left-hand table by the join. If <dbtab> does not contain any lines that meet the condition <cond>, the line from <tab> is not included in the selection.
The syntax of the <cond> condition is like that of the WHERE clause, although individual comparisons can only be linked using AND. Furthermore, each comparison must contain a column from the right-hand table <dbtab>. It does not matter on which side of the comparison it occurs. For the column names in the comparison, you can use the same names that occur in the SELECT clause, to differentiate columns from different database tables that have the same names.
The comparisons in the condition <cond> can appear in the WHERE clause instead of the ON clause, since both clauses are applied equally to the temporary table containing all of the lines resulting from the join. However, each join must contain at least one comparison in the condition <cond>.
SELECT pcarrid pconnid ffldate bbookid
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( spfli AS p
INNER JOIN sflight AS f ON pcarrid = fcarrid AND
pconnid = fconnid )
INNER JOIN sbook AS b ON bcarrid = fcarrid AND
bconnid = fconnid AND
bfldate = ffldate )
WHERE p~cityfrom = 'FRANKFURT' AND
p~cityto = 'NEW YORK' AND
fseatsmax > fseatsocc.
Specifying Two or More Database Tables as a Left Outer Join
In an inner join, a line from the left-hand database table or join is only included in the selection if there is one or more lines in the right-hand database table that meet the ON condition <cond>. The left outer join, on the other hand, reads lines from the left-hand database table or join even if there is no corresponding line in the right-hand table.
SELECT...
FROM <tab> LEFT [OUTER] JOIN <dbtab> [AS <alias>] ON <cond>
<options>
<tab> and <dbtab> are subject to the same rules and conditions as in an inner join. The OUTER addition is optional. The tables are linked in the same way as the inner join with the one exception that all lines selected from <tab> are included in the final selection. If <dbtab> does not contain any lines that meet the condition <cond>, the system includes a single line in the selection whose columns from <dbtab> are filled with null values.
In the left outer join, more restrictions apply to the condition <cond> than in the inner join. In addition to the above restrictions:
EQ or = is the only permitted relational operator.
There must be at least one comparison between columns from <tab> and <dbtab>.
The WHERE clause may not contain any comparisons with columns from <dbtab>. All comparisons using columns from <dbtab> must appear in the condition <cond>.
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 = 'FRANKFURT'.
check this
Re:JOINS
Module Pool
--charitha

Similar Messages

  • Using nested Joins in abap prog

    Hi All,
    please help me  out in using nested joins in abap progrmaming. I dont know about joins in abap.specially in case of outer join.
      I have 5 internal tables.. mara ,marc, mvke,mbew,ampl. am using  a  select query with certain fields from all these tables.
      I need to disply  all the materials  of  a mara for  a particular date irrespective of  the values in fields of  other tables.
            Even if that materail is not present in other table for certain condtion ,that material  should get displyed with all other fields  showing null value..

    Hi RK,
    the  code am using is of the same way...but my problem was with the joins..in the  select query  am using nested join combining inner  and outer join.. but i could  not able to display all the materials  of mara of a particular date..
    The code looks like this..
    SELECT <some fields.......>
    INTO  TABLE i_materials
          FROM  ( marc AS b
          INNER JOIN mara AS a ON amatnr = bmatnr
          INNER JOIN mvke AS c ON cmatnr = amatnr
          INNER JOIN ampl AS g ON gbmatn = amatnr
          LEFT OUTER JOIN mbew AS d ON dmatnr = bmatnr
                                   AND dbwkey = bwerks )
      WHERE a~matnr  IN s_matnr AND .................
    Else
    SELECT <some fields.......>
    INTO  TABLE i_materials
          FROM  ( marc AS b
          INNER JOIN mara AS a ON amatnr = bmatnr
          INNER JOIN mvke AS c ON cmatnr = amatnr
          INNER JOIN ampl AS g ON gbmatn = amatnr
          LEFT OUTER JOIN mbew AS d ON dmatnr = bmatnr
                                   AND dbwkey = bwerks )
       FOR ALL ENTRIES IN i_mara
         WHERE a~matnr = i_mara-matnr AND ............

  • About inner join in abap

    hi
        i am new to sap , i dont no about inner join in abap coding
    plz send me some notes or coding.
                            thank u.
                                                              your regrads
                                                                    divya.

    hi
    use this links
    INNER JOIN  and OUTER JOINhttp://help.sap.com/erp2005_ehp_03/helpdata/EN/cf/21ec77446011d189700000e8322d00/frameset.htm
    JOINED TABLES
    http://help.sap.com/erp2005_ehp_03/helpdata/EN/0f/49bd6a5d5049edba7b3afe6c7956e3/frameset.htm
    u will find all thins related to joins with example and how to use it
    Cheers
    Snehi
    Edited by: snehi chouhan on Jul 25, 2008 9:45 AM

  • Self join using ABAP Query

    Hello all,
    How to create a self join using ABAP Query?
    Say, I have this table EKBE with belnr (materials doc num) and lfbnr (reference material doc num). I have to pick the PO's from EKBE whose belnr doesnt have any lfbnr.
    Regards
    Madhumathi A

    hi madhu,
    tables : ekbe.
    data itab like standard table of ekbe with header line.
    select * from ekbe into table itab where belnr >< 0 and lfbnr = ' '.
    loop at itab.
    write :/ itab-belnr,itab-lfbnr.
    endloop.
    check this code this works to select the orders whose belnr doesnt have any lfbnr
    reward points if useful.

  • SUBQUERY with INNER JOIN in ABAP

    Hi Expert
    How Can I write SUBQUERY with INNER JOIN in ABAP.
    thanks

    Thanks Sidhharth for your Respose
    Actually I need data from VBAP, VBAK, VBUP, VBUK and VBKD with all functional validation satisfied for a sales order item data. The requirement is to report all item data with other information from table VBAK, VBUP, VBUK and VBKD in a corresponding record with ALL data in VBAP.
    Your help is appriciated.
    see the below query for reference
    select   alias_vbap~vbeln from  vbap as
    alias_vbap inner join vbak as alias_vbak
    on  alias_vbapvbeln eq  alias_vbakvbeln
    "and  alias_vbak~bukrs_vf eq '2400'
    inner join vbuk as alias_vbuk
    on alias_vbukvbeln = alias_vbapvbeln
    inner join vbup as alias_vbup
    on alias_vbupvbeln = alias_vbapvbeln
    and alias_vbupposnr = alias_vbapposnr
    left OUTER join veda as alias_veda
    on alias_vedavbeln = alias_vbapvbeln
    and alias_vedavposn = alias_vbapposnr
    left outer join vbkd as alias_vbkd
    on alias_vbkdvbeln = alias_vbapvbeln
    and alias_vbkdposnr = alias_vbapposnr

  • Inner join in ABAP and exporting the data

    Hi,
    I want to use inner join in ABAP for retrieving data from 2 tables and export that data.How will i do it?

    Hi,
    Refer following code
    *--Select query to pick the data from table VBRK
    VBRP and VBPA using inner join
      SELECT a~vbeln                            "Billing document
             a~fkdat                            "Billing date
             a~fktyp                            "Billing category
             a~fkart                            "Billing type
             a~vtweg                            "Distribution channel
             a~knumv                            "Number of doc condition
             b~posnr                            "Billing item
             b~matnr                            "Material Number
             b~werks                            "Plant
             b~vgbel                            "Referance
             b~netwr                            "Net value of billing item
             b~wavwr                            "Cost in document currency
             c~kunnr                            "Partner function
             FROM vbrk AS a
             INNER JOIN vbrp AS b
             ON avbeln EQ bvbeln
             INNER JOIN vbpa AS c
             ON  bvbeln EQ cvbeln
            AND bposnr EQ cposnr
             INTO CORRESPONDING FIELDS OF TABLE it_vbrp
             WHERE fkdat IN s_erdat
             AND   parvw EQ 'ZS'.
      IF sy-subrc EQ 0.
    *--Sort table by
        SORT it_vbrp BY vgbel1.
      ENDIF.
    Regards,
    Prashant

  • Inner join Vs Outer join with ABAP code...?

    Inner join Vs Outer join with ABAP code...?

    Inner Join means, it will not select that recor at all, unless there is a matching entry in the second table.
    suppose table VBAK INNER join table VBAP on VBAKVBELN = VBAPVBELN.
    In this case, if there are no entries in VBAP, the header entry also will not show up.
    But in case of OUTER JOIN, even if there is no items, it will show the header entry(VBAK) with blank columns for fields  from item table.(VBAP)
    here is one sample for inner join.
    SELECT   A~EBELN
               A~EKORG
               A~EKGRP
               A~BSART
               A~LPONR
               A~LOEKZ
               A~LIFNR
               A~RESWK
               B~AEDAT
               B~WERKS
               B~MATNR
               B~MENGE
               B~EBELP
               B~ELIKZ
               B~PLIFZ
               B~PSTYP
               B~KNTTP
               B~MATKL
               B~ZZD_PLANT
               FROM EKKO AS A INNER JOIN EKPO AS B
               ON
               AEBELN = BEBELN
               INTO CORRESPONDING FIELDS OF TABLE T_DATA
               FOR ALL ENTRIES IN T_EKET
               WHERE
               A~EBELN EQ T_EKET-EBELN AND
               A~BSART EQ C_UBSTO      AND
               A~EKORG IN S_EKORG      AND
               A~EKGRP IN S_EKGRP      AND
               A~BSTYP EQ C_BSTYP      AND
               A~LOEKZ EQ SPACE        AND " Order not deleted
               A~RESWK IN S_RESWK      AND
               B~EBELN EQ T_EKET-EBELN AND
               B~EBELP EQ T_EKET-EBELP AND
               B~WERKS IN S_WERKS      AND
               B~MATNR IN S_MATNR      AND
               B~MATKL IN S_MATKL      AND
               B~LOEKZ EQ SPACE.           " Line item not deleted

  • How to construct Dynamic Join in ABAP?

    Hello ALL,
    I am typically faced with a situvation where in I need to write a dynamic JOIN SQL statement in ABAP.
    For example :
    REPORT ZTEST .
    PARAMETERS: TBLNAME(50) DEFAULT 'SPFLI'.
    DATA: TOTAL_ROWS TYPE P.
    SELECT COUNT(*) FROM (TBLNAME) INTO TOTAL_ROWS.
    WRITE: / TBLNAME, TOTAL_ROWS.
    In the above example, here the fetch from Table is dynamic.
    Where as if i have to conisder the following SQL statement which is a normal JOIN statement in ABAP,
    select
      mara~matnr
      marc~werks
      from mara
      join marc on maramatnr = marcmatnr
      into table it_join
      where mara~mtart = 'FERT' and
            marc~werks = '3000'.
    How do i convert this into DYNAMIC JOIN STATEMENT</b> .
    Looking forward to your responses.
    Thank you

    Hi,
    This is from the ABAP keyword help in 6.40, not sure if it works in previous releases or not.
    Example
    Dynamic specification of the inner joins. The column specification after SELECT is also dynamic.
    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.
    DATA: column_syntax TYPE string,
          dbtab_syntax TYPE string.
    column_syntax = `ccarrname pconnid f~fldate`.
    dbtab_syntax = `( ( 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 )`.
    SELECT (column_syntax)
           FROM (dbtab_syntax)
           INTO CORRESPONDING FIELDS OF TABLE itab.
    LOOP AT itab INTO wa.
      WRITE: / wa-fldate, wa-carrname, wa-connid.
    ENDLOOP.
    Regards
    Vilmos

  • EXEC SQL join in ABAP program

    Hi All,
    I am using EXEC SQL join in my ABAP report,but it is giving dump.could you please correct my following code?
    START-OF-SELECTION.
      CONCATENATE '%' pa_match '%' INTO tp_match.
      EXEC SQL.
        OPEN dbcur FOR
        SELECT  kunnr,name1, banks
               FROM  kna1 as a inner join
               knbk as b
               on akunnr = bkunnr
               WHERE a.kunnr = b.kunnr and
               upper(a~name1) LIKE :tp_match
      ENDEXEC.
      DO.
        EXEC SQL.
          FETCH NEXT dbcur INTO :wa_name1
        ENDEXEC.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
        APPEND wa_name1 TO ta_name1.
        COLLECT wa_name1 INTO ta_name1.
      ENDDO.
      EXEC SQL.
        CLOSE dbcur
      ENDEXEC.

    Remove the 'As' from the statement
    EXEC SQL.
      OPEN dbcur FOR
      SELECT kunnr,name1, banks
      FROM kna1 a inner join        "Delete 'AS' here
      knbk b
      on a~kunnr = b~kunnr
      WHERE a.kunnr = b.kunnr and
      upper(a~name1) LIKE :tp_match
    ENDEXEC.

  • Table Join in ABAP Query

    Hi,
    I'm new to ABAP Query. I want to include a table and join with an existing table in abap query. how to do this?

    Hi
    select lipsvbeln lipslfimg likp~wadat
            into corresponding fields of table ltab_orders
            from lips join likp on ( lipsvbeln = likpvbeln )
            join vbfa on ( lipsvbeln = vbfavbelv )       
            where lips~matnr = matnr
            and   lips~vbeln in vbeln
            and   likp~vbeln in vbeln         
            and   vbfa~vbelv in vbeln
            and   lips~werks in werks
            and   likp~wadat in datum
            and   vbfa~vbtyp_n = 'Q'            
            and   vbfa~vbtyp_v = 'J'. 
    Thanks,
    Neelima.

  • Joins in abap programming

    hi
       i am a fresher and i have a question. how many joins can program have.

    Hi Jaya,
    ABAP has two Joins.
    INNER  JOIN  and  OUTER JOIN.
    Check out the post :
    JOINS and Matchcodes
    IF you press F1 on JOIN statement ,it has explained really good.I am pasting the same for you.
    ... FROM tabref1 [INNER] JOIN tabref2 ON cond
    Effect
    The data is to be selected from transparent database tables and/or views determined by tabref1 and tabref2. tabref1 and tabref2 each have the same form as in variant 1 or are themselves Join expressions. The keyword INNER does not have to be specified. The database tables or views determined by tabref1 and tabref2 must be recognized by the ABAP Dictionary.
    In a relational data structure, it is quite normal for data that belongs together to be split up across several tables to help the process of standardization (see relational databases). To regroup this information into a database query, you can link tables using the join command. This formulates conditions for the columns in the tables involved. The inner join contains all combinations of lines from the database table determined by tabref1 with lines from the table determined by tabref2, whose values together meet the logical condition (join condition) specified using ON>cond.
    Inner join between table 1 and table 2, where column D in both tables in the join condition is set the same:
    Table 1 Table 2
    A
    B
    C
    D
    D
    E
    F
    G
    H
    a1
    b1
    c1
    1
    1
    e1
    f1
    g1
    h1
    a2
    b2
    c2
    1
    3
    e2
    f2
    g2
    h2
    a3
    b3
    c3
    2
    4
    e3
    f3
    g3
    h3
    a4
    b4
    c4
    3
    |--|||--|
    Inner Join
    A
    B
    C
    D
    D
    E
    F
    G
    H
    a1
    b1
    c1
    1
    1
    e1
    f1
    g1
    h1
    a2
    b2
    c2
    1
    1
    e1
    f1
    g1
    h1
    a4
    b4
    c4
    3
    3
    e2
    f2
    g2
    h2
    |--||||||||--|
    Example
    Output a list of all flights from Frankfurt to New York between September 10th and 20th, 2001 that are not sold out:
    DATA: DATE LIKE SFLIGHT-FLDATE,
    CARRID LIKE SFLIGHT-CARRID,
    CONNID LIKE SFLIGHT-CONNID.
    SELECT FCARRID FCONNID F~FLDATE
    INTO (CARRID, CONNID, DATE)
    FROM SFLIGHT AS F INNER JOIN SPFLI AS P
    ON FCARRID = PCARRID AND
    FCONNID = PCONNID
    WHERE P~CITYFROM = 'FRANKFURT'
    AND P~CITYTO = 'NEW YORK'
    AND F~FLDATE BETWEEN '20010910' AND '20010920'
    AND FSEATSOCC < FSEATSMAX.
    WRITE: / DATE, CARRID, CONNID.
    ENDSELECT.
    If there are columns with the same name in both tables, you must distinguish between them by prefixing the field descriptor with the table name or a table alias.
    Note
    In order to determine the result of a SELECT command where the FROM clause contains a join, the database system first creates a temporary table containing the lines that meet the ON condition. The WHERE condition is then applied to the temporary table. It does not matter in an inner join whether the condition is in the ON or WHEREclause. The following example returns the same solution as the previous one.
    Example
    Output of a list of all flights from Frankfurt to New York between September 10th and 20th, 2001 that are not sold out:
    DATA: DATE LIKE SFLIGHT-FLDATE,
    CARRID LIKE SFLIGHT-CARRID,
    CONNID LIKE SFLIGHT-CONNID.
    SELECT FCARRID FCONNID F~FLDATE
    INTO (CARRID, CONNID, DATE)
    FROM SFLIGHT AS F INNER JOIN SPFLI AS P
    ON FCARRID = PCARRID
    WHERE FCONNID = PCONNID
    AND P~CITYFROM = 'FRANKFURT'
    AND P~CITYTO = 'NEW YORK'
    AND F~FLDATE BETWEEN '20010910' AND '20010920'
    AND FSEATSOCC < FSEATSMAX.
    WRITE: / DATE, CARRID, CONNID.
    ENDSELECT.
    Note
    Since not all of the database systems supported by SAP use the standard syntax for ON conditions, the syntax has been restricted. It only allows those joins that produce the same results on all of the supported database systems:
    Only a table or view may appear to the right of the JOIN operator, not another join expression.
    Only AND is possible in the ON condition as a logical operator.
    Each comparison in the ON condition must contain a field from the right-hand table.
    If an outer join occurs in the FROM clause, all the ON conditions must contain at least one "real" JOIN condition (a condition that contains a field from tabref1 amd a field from tabref2.
    Note
    In some cases, '*' may be specified in the SELECT clause, and an internal table or work area is entered into the INTO clause (instead of a list of fields). If so, the fields are written to the target area from left to right in the order in which the tables appear in the FROM clause, according to the structure of each table work area. There can then be gaps between table work areas if you use an Alignment Request. For this reason, you should define the target work area with reference to the types of the database tables, not simply by counting the total number of fields. For an example, see below:
    Variant 3
    ... FROM tabref1 LEFT [OUTER] JOIN tabref2 ON cond
    Effect
    Selects the data from the transparent database tables and/or views specified in tabref1 and tabref2. tabref1 und tabref2 both have either the same form as in variant 1 or are themselves join expressions. The keyword OUTER can be omitted. The database tables or views specified in tabref1 and tabref2 must be recognized by the ABAP-Dictionary.
    In order to determine the result of a SELECT command where the FROM clause contains a left outer join, the database system creates a temporary table containing the lines that meet the ON condition. The remaining fields from the left-hand table (tabref1) are then added to this table, and their corresponding fields from the right-hand table are filled with ZERO values. The system then applies the WHERE condition to the table.
    Left outer join between table 1 and table 2 where column D in both tables set the join condition:
    Table 1 Table 2
    A
    B
    C
    D
    D
    E
    F
    G
    H
    a1
    b1
    c1
    1
    1
    e1
    f1
    g1
    h1
    a2
    b2
    c2
    1
    3
    e2
    f2
    g2
    h2
    a3
    b3
    c3
    2
    4
    e3
    f3
    g3
    h3
    a4
    b4
    c4
    3
    |--|||--|
    Left Outer Join
    A
    B
    C
    D
    D
    E
    F
    G
    H
    a1
    b1
    c1
    1
    1
    e1
    f1
    g1
    h1
    a2
    b2
    c2
    1
    1
    e1
    f1
    g1
    h1
    a3
    b3
    c3
    2
    NULL
    NULL
    NULL
    NULL
    NULL
    a4
    b4
    c4
    3
    3
    e2
    f2
    g2
    h2
    |--||||||||--|
    Example
    Output a list of all custimers with their bookings for October 15th, 2001:
    DATA: CUSTOMER TYPE SCUSTOM,
    BOOKING TYPE SBOOK.
    SELECT SCUSTOMNAME SCUSTOMPOSTCODE SCUSTOM~CITY
    SBOOKFLDATE SBOOKCARRID SBOOKCONNID SBOOKBOOKID
    INTO (CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,
    BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,
    BOOKING-BOOKID)
    FROM SCUSTOM LEFT OUTER JOIN SBOOK
    ON SCUSTOMID = SBOOKCUSTOMID AND
    SBOOK~FLDATE = '20011015'
    ORDER BY SCUSTOMNAME SBOOKFLDATE.
    WRITE: / CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,
    BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,
    BOOKING-BOOKID.
    ENDSELECT.
    If there are columns with the same name in both tables, you must distinguish between them by prefixing the field descriptor with the table name or using an alias.
    Note
    For the resulting set of a SELECT command with a left outer join in the FROM clause, it is generally of crucial importance whether a logical condition is in the ON or WHERE condition. Since not all of the database systems supported by SAP themselves support the standard syntax and semantics of the left outer join, the syntax has been restricted to those cases that return the same solution in all database systems:
    Only a table or view may come after the JOIN operator, not another join statement.
    The only logical operator allowed in the ON condition is AND.
    Each comparison in the ON condition must contain a field from the right-hand table.
    Comparisons in the WHERE condition must not contain a field from the right-hand table.
    The ON condition must contain at least one "real" JOIN condition (a condition in which a field from tabref1 as well as from tabref2 occurs).
    Note
    In some cases, '*' may be specivied as the field list in the SELECT clause, and an internal table or work area is entered in the INTO clause (instead of a list of fields). If so, the fields are written to the target area from left to right in the order in which the tables appear in the llen in der FROM clause, according to the structure of each table work area. There can be gaps between the table work areas if you use an Alignment Request. For this reason, you should define the target work area with reference to the types of the database tables, as in the following example (not simply by counting the total number of fields).
    Example
    Example of a JOIN with more than two tables: Select all flights from Frankfurt to New York between September 10th and 20th, 2001 where there are available places, and display the name of the airline.
    DATA: BEGIN OF WA,
    FLIGHT TYPE SFLIGHT,
    PFLI TYPE SPFLI,
    CARR TYPE SCARR,
    END OF WA.
    SELECT * INTO WA
    FROM ( SFLIGHT AS F INNER JOIN SPFLI AS P
    ON FCARRID = PCARRID AND
    FCONNID = PCONNID )
    INNER JOIN SCARR AS C
    ON FCARRID = CCARRID
    WHERE P~CITYFROM = 'FRANKFURT'
    AND P~CITYTO = 'NEW YORK'
    AND F~FLDATE BETWEEN '20010910' AND '20010920'
    AND FSEATSOCC < FSEATSMAX.
    WRITE: / WA-CARR-CARRNAME, WA-FLIGHT-FLDATE, WA-FLIGHT-CARRID,
    WA-FLIGHT-CONNID.
    ENDSELECT.
    Regards,
    Priyanka.

  • Need to delete a table join in ABAP query

    Hi
      I have created an ABAP query with a join over AUFK, AFIH, AFKO, AFVV, AFVC and AFRU.
      I need to delete the table AFRU from the join. I tried to delete the table in the edit option in the Join table option. I deleted the links between the table AFVC and AFRU and clicked on delete table option. I get the message Table AFRU not used. Please let me know if there is any method to delete the table.
    Thanks and Regards,
    Ajith

    u have to break the link between this table and other tables...U need to delete where conditions and then delete the join...

  • Cross Join in ABAP Open SQL

    Hi guys!
    I need to implement a CROSS JOIN (cartesian product) based on two tables. To my understanding there is no construct to implement a cross join in OPEN SQL. So the question is first is this correct? And secondly in which way would you then implement a cross join of two tables with the constructs at hand in ABAP?
    I have come up with the following solution of cross joining two tables, but would like to know if there is a better (not so ugly way).
    Example:
    SELECT * FROM tab1 AS t1 JOIN tab2 AS t2 ON t1mandt = t2mandt INTO CORRESPONDING FIELDS OF itab.
    Note that this only works if the tables tab1 and tab2 is client dependent.
    Regards,
    Christian

    Christian,
      There's no cross join construct in abap. Join statement results in a cartesin product rarely because of completely obsolete statistics missing selection or join conditions.
    Try the following join to get result similar to cartesian product
    select tab1location tab2matnr into itab
      from tab1 join tab2 on tab1location ne tab2matnr.
    if you really want to implement cross join, use native sql, try the following code,
    beware of cartesian products, Basis folks doesn't like em....
    data: begin of itab occurs 0,
      loc like tab1-sloc
      matnr like tab2-matnr,
    end of itab.
    exec sql performing append_itab.
      select a.loc, b.matnr
        into :itab
        from tab1 a
        cross join tab2 b
    endexec.
    form append_itab.
      append itab.
    endform.               
    Regards
    Sridhar.

  • Help with Joins in ABAP

    Hello Experts,
    I am struggling with a problem.
    In my development I have two db tables for eg. Table A and Table B.
    Now table A has about 200,000 entries and table B has about 800,000 entries.
    I want to delete all the extra entries (junk entries-not  present in A but present in B) from table B on the basis of one field that is common between them
    i.e. All the entries for whom 'A-field NE B-field'
    Now i tried using internal tables but the loop execution is taking forever.
    And I tried using a Select query for all entries:
    SELECT *
        FROM B
          INTO TABLE itab_B
          FOR ALL ENTRIES IN itab_A
    WHERE field EQ itab_A-field.
    This query gives me the records which are present in both tables.
    But if I try to change the 'where' condition to 'NE' it does not work.
    Is there any join statement to meet my requirement?
    Thanks in Advance
    Omkar

    Hi Omkar,
    reduce the internal table to the fields you really need to identify, the key fields and the fields of interest. Use field-symbols for loops. make one of the two tables a hashed table with unique key.
    You will observe a performance enhancement of factor 100 at least.
    If you had given more information or even a piece of code, I may have done the coding for you.
    Regards,
    Clemens

  • ABAP Query  - Duplicates in joins

    Hi All,
    In using joins in ABAP query, I am getting duplicate records in the output. Is there any way to restrict that?
    Please help me with this.
    Thanks in Advance,
    Sushmitha

    Depending on the tables you are using, you may have time-slicing of data where you need to specify the time slice you want to use. 
    In SAP Utilities, when selecting data from tables with time-slicing, we check for a BIS (end) date of 12/31/9999 to denote the most current entry.  Check the tables you are joining and see if any of them indicate they have time-sliced data.  If they do, include a check for the end date in your WHERE conditions.
    K---

Maybe you are looking for

  • POV and User POV in Web Analysis 9.3

    Hi, I am a bit confused with POV and User POV in Web Analysis 9.3.1. I have a few web analysis dashboard to be used by several different groups of users. I use the admin to go in and for each of the report, I set whether need to use User POV (in data

  • Faxing from pc hp7520 photosmart software

    I have an HP Photosmart 7520 all in one.  It will not fax from the pc software.  It will fax fine if i do it manually on the touch screen of the printer.  What am I doing wrong?  It seems simple enough when I am using the software to fill in the blan

  • Constraint & update

    Hi friends, We have to update a single column data in about 10 tables which has child/parent table relations, pk/fk constraints.. The column that we are updating is a part of primary key in half of the tables and part of foreign key in the other half

  • Thunderbolt Notification/ringtone issue after 2.11.605.9 Update

    I know that this latest update was supposed to fix the bug where the wrong ringtones were being played when a custom ringtone had been set; however, now I am seeing a different issue with ringtones/notification sounds.   After receiving the update on

  • HT201209 My new itunes gift card doesn't work.  I have tried 8-10 times.  It just won't accept the 16 digit code. Help!

    I have a new $30 itunes gift card.  The 16 digit code doesn't work.  There's no way to contact itunes for help.  Can anyone help?