Skip to Content
avatar image
Former Member

abap query

how can i join a table by using abap query?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

10 Answers

  • avatar image
    Former Member
    Jun 13, 2006 at 09:45 AM

    Hi,

    u can go through the following two examples :

    Inner Join:

    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.

    Outer join :

    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'.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 17, 2006 at 11:12 PM

    Priya-

    SELECT lfa1lifnr lfa1stcd1

    bsakxblnr bsakaugbl bsak~auggj

    FROM lfa1

    INNER JOIN bsak ON lfa1lifnr = bsaklifnr

    INTO TABLE i_lfa1

    WHERE lfa1~lifnr = actualvendorid

    AND bsak~xblnr = ap03_invoicenumber .

    I hope this will help you out...

    Thanks,

    Venky

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 18, 2006 at 02:00 AM

    Hi,

    The above example is right. I'll give you another example:

    SELECT apsphi brefbn b~lifnr

    FROM prps AS a INNER JOIN cooi AS b

    ON aobjnr = bobjnr

    INTO CORRESPONDING FIELDS OF it_hdr

    WHERE a~psphi IN so_psphi

    AND a~pbukr = pa_bukrs

    AND a~erdat LE v_budat

    AND b~refbn IN so_ebeln

    AND b~lifnr IN so_lifnr

    AND b~matnr IN so_matnr

    AND b~rfart = 'P'.

    Regards!

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 18, 2006 at 06:55 AM

    table should be having pri-foer key relation ship , the only u can join table in SQVI or any Joins , u cannt use Cluster table in ABAP Quey .

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 18, 2006 at 07:10 AM

    Hi Priya,

    You can join tables using JOIN statement in ABAP.

    But you can not join on cluster tabels.Be sure that your join tables are not of cluster tables.To Join two tables you need to have a foreign key relation ship between tables. There are two kinds of joins.

    <b>1)Inner Join:</b> 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.

    <b>2)Outer Join:</b> 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.

    A maximum of 24 join expressions that join 25 database tables or views with each other can be specified after FROM.

    The ABAP statement for joinin tables is as follows.

    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.

    <b>SELECT scarrid scarrname p~connid

    INTO CORRESPONDING FIELDS OF TABLE itab

    FROM scarr AS s

    INNER JOIN spfli AS p ON scarrid = pcarrid

    AND p~cityfrom = p_cityfr.</b>

    LOOP AT itab INTO wa.

    IF wa-connid = '0000'.

    WRITE: / wa-carrid, wa-carrname.

    ENDIF.

    ENDLOOP.

    Thanks,

    Vinay

    Note: plz reward points to helpful answers

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 18, 2006 at 07:16 AM

    Hi,

    select single a~smtp_addr from adr6 as a inner join

    kna1 as k

    on kadrnr = aaddrnumber

    into i_clientinfo-Email

    where k~KUNNR = i_clientinfo-clientid.

    Regards,

    abhishek

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 18, 2006 at 07:21 AM

    hi priya.

    try out this.

    parameters: p_matno like mkpf-mblnr.

    data: begin of wt_mseg occurs 10,

    zeile like mseg-zeile,

    matnr like mseg-matnr,

    maktx like makt-maktx,

    menge like mseg-menge,

    meins like mseg-meins,

    end of wt_mseg.

    select msegzeile msegmatnr

    maktmaktx msegmenge

    mseg~meins

    into (wt_mseg-zeile,

    wt_mseg-matnr,

    wt_mseg-maktx,

    wt_mseg-menge,

    wt_mseg-meins)

    from mseg inner join makt

    on msegmatnr = maktmatnr

    where mblnr = p_matno.

    append wt_mseg.

    endselect.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 04, 2006 at 01:40 PM

    howhat r the steps in table controls in user exits

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 04, 2006 at 02:25 PM

    Refer to this for abap query. In info sets you can do join between tables.

    ABAP" target="_blank">http://www.sappoint.com/abap/ab4query.pdf">ABAP Query

    Regds

    Manohar

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 14, 2006 at 12:51 PM

    Hi,

    You can join the TABLES in the Functional Area (Info Set in 5.0 ver.) Directly. You have the 'Insert Table' Option in the Tool Bar.

    Regards

    BaLaji

    Add comment
    10|10000 characters needed characters exceeded