Alternative for inner joins

Hi,
please check this code and suggest me of an alternative for this performance wise.
SELECT b~partner
                  APPENDING CORRESPONDING FIELDS OF
                  TABLE t_db_pos_match
                    FROM adrc AS a
                    JOIN but020 AS b
                      ON   aaddrnumber = baddrnumber
                    JOIN but000 AS c
                      ON   bpartner    = cpartner
                    WHERE  c~partner   NE t_bp_obj-act-ekun-partner
                      AND  c~mc_name1   = t_bp_obj-act-ekun-name_last
                      AND  a~city1      = wa-city1
                      AND  a~post_code1 = wa-post_code1
                      AND  a~po_box     = wa-po_box
                      AND  a~street     = wa-street
                      AND  a~house_num1 = wa-house_num1
                      AND  a~house_num2 = wa-house_num2
                      AND  a~region     = wa-region
                      AND  a~addr_group = 'BP'.
awaiting your reply.
Binay.

HI
*PARAMETERS P_CITY TYPE SPFLI-CITYFROM.
**TYPES: BEGIN OF ENTRY_TAB_TYPE,
        CARRID TYPE SPFLI-CARRID,
        CONNID TYPE SPFLI-CONNID,
      END OF ENTRY_TAB_TYPE.
**DATA: ENTRY_TAB   TYPE TABLE OF ENTRY_TAB_TYPE,
     SFLIGHT_TAB TYPE SORTED TABLE OF SFLIGHT
                      WITH UNIQUE KEY CARRID CONNID FLDATE.
**SELECT CARRID CONNID
      FROM SPFLI
      INTO CORRESPONDING FIELDS OF TABLE ENTRY_TAB
      WHERE CITYFROM = P_CITY.
**SELECT CARRID CONNID FLDATE
      FROM SFLIGHT
      INTO CORRESPONDING FIELDS OF TABLE SFLIGHT_TAB
      FOR ALL ENTRIES IN ENTRY_TAB
      WHERE CARRID = ENTRY_TAB-CARRID AND
            CONNID = ENTRY_TAB-CONNID.
TRY LIKE THIS
REWARD IF USEFULL

Similar Messages

  • Alternative for Inner Join

    Hi all,
    Im extracting different fields from material master data into different internal tables. I need to have all the data in these internal table in one final internal table, I don't want to use inner join to get the data into the final internal table. Can you suggest any alternative for this?
    Thanks.

    hi check this..this is the alternative for the joins..
    REPORT  ZZZZ000000.
    tables:mara,marc,mard,makt.
    data:begin of it_mara occurs 0,
         matnr like mara-matnr,
         mtart like mara-mtart,
         meins like mara-meins,
         end of it_mara.
    data:begin of it_marc occurs 0,
         matnr like marc-matnr,
         pstat like marc-pstat,
         werks like marc-werks,
         end of it_marc.
    data:begin of it_mard occurs 0,
         werks like mard-werks,
         lgort like mard-lgort,
         labst like mard-labst,
         end of it_mard.
    data:begin of it_final occurs 0,
         matnr like mara-matnr,
         mtart like mara-mtart,
         meins like mara-meins,
         pstat like marc-pstat,
         werks like marc-werks,
         lgort like mard-lgort,
         labst like mard-labst,
         maktx like makt-maktx,
         end of it_final.
    select-options:s_matnr for mara-matnr.
    select  matnr
            mtart
            meins
            from mara
            into table it_mara
            where matnr in s_matnr.
            if not it_mara[] is initial.
            select matnr
                   pstat
                   werks
                   from marc
                   into table it_marc
                   for all entries in it_mara
                   where matnr = it_mara-matnr.
                   if not it_marc[] is initial.
                   select werks
                          lgort
                          labst
                          from mard
                          into table it_mard
                          for all entries in it_marc
                          where werks = it_marc-werks.
                   endif.
          endif.
    loop at it_mara.
    it_final-matnr = it_mara-matnr.
    it_final-mtart = it_mara-mtart.
    it_final-meins = it_mara-meins.
    read table it_marc with key matnr = it_mara-matnr.
    it_final-werks = it_marc-werks.
    it_final-pstat = it_marc-pstat.
    read table it_mard with key werks = it_marc-werks.
    it_final-lgort = it_mard-lgort.
    it_final-labst = it_mard-labst.
    if sy-subrc = 0.
    select maktx from makt into it_final-maktx where matnr = it_final-matnr.
    endselect.
    endif.
    append it_final.
    endloop.
    loop at it_final.
    write:/ it_final-matnr under 'material',
            it_final-mtart under 'material type',
            it_final-meins under 'unit of measure',
            it_final-werks under 'plant' ,
            it_final-pstat under 'status',
            it_final-lgort under 'storage loc',
            it_final-labst under 'stock',
            it_final-maktx.
    endloop.
    regards,
    venkat

  • Need help with program for Inner join

    Hello Experts,
    I need to create a list from table sbook containing booking number (sbook-bookid), customer number (sbook-customid), customer name (scustom-name) , customer class (sbook-class) and ticket price (sflight-price). I am new to ABAP and am very confused I tried reading up some examples and came up with the attached program
    Attached is my program for inner join
    Kindly Help
    Thanks Su

    Hi Su K
              You May use key fields , Foreign keys for joining , Here
    SELECT SBOOK~BOOKID SBOOK~CUSTOMID SBOOK~CLASS
      SCUSTOM~ID SCUSTOM~NAME  FROM SFILGHT
       INNER JOIN SBOOK ON   SBOOK~CARRID EQ SFILGHT~CARRID
                                              SBOOK~CONNID EQ SFILGHT~CONNID
                                              SBOOK~FLDATE EQ SFILGHT~FLDATE
      INNER JOIN SCUSTOM ON SCUSTOM~ID = SBOOK~ID

  • Alternate for inner join to improve performance

    Hi all,
    I have used an inner join query to fetch data from five different tables into an internal table with where clause conditions.
    The execution time is almost 5-6 min for this particular query(I have more data in all five DB tables- more than 10 million records in every table).
    Is there any alternate for inner join to improve performance.?
    TIA.
    Regards,
    Karthik

    Hi All,
    Thanks for all your interest.
    SELECT  a~object_id a~description a~descr_language
                a~guid AS object_guid a~process_type
                a~changed_at
                a~created_at AS created_timestamp
                a~zzorderadm_h0207 AS cpid
                a~zzorderadm_h0208 AS submitter
                a~zzorderadm_h0303 AS cust_ref
                a~zzorderadm_h1001 AS summary
                a~zzorderadm_h1005 AS summary_uc
                a~zzclose_date     AS clsd_date
                d~stat AS status
                f~priority
                FROM crmd_orderadm_h AS a INNER JOIN crmd_link AS b ON  a~guid = b~guid_hi
                INNER JOIN crmd_partner AS c ON b~guid_set = c~guid
                INNER JOIN crm_jest AS d ON objnr  = a~guid
                INNER JOIN crmd_activity_h AS f ON f~guid = a~guid
                INTO CORRESPONDING FIELDS OF TABLE et_service_request_list
                WHERE process_type IN lt_processtyperange
                AND   a~created_at IN lt_daterange
                AND   partner_no IN lr_partner_no
                AND   stat IN lt_statusrange
                AND   object_id IN lt_requestnumberrange
                AND   zzorderadm_h0207 IN r_cpid
                AND   zzorderadm_h0208 IN r_submitter
                AND   zzorderadm_h0303 IN r_cust_ref
                AND   zzorderadm_h1005 IN r_trans_desc
                AND   d~inact = ' '
                AND   b~objtype_hi = '05'
                AND   b~objtype_set = '07'.
                f~priority
                FROM crmd_orderadm_h AS a INNER JOIN crmd_link AS b ON  a~guid = b~guid_hi
                INNER JOIN crmd_partner AS c ON b~guid_set = c~guid
                INNER JOIN crm_jest AS d ON objnr  = a~guid
                INNER JOIN crmd_activity_h AS f ON f~guid = a~guid
                INTO CORRESPONDING FIELDS OF TABLE et_service_request_list
                WHERE process_type IN lt_processtyperange
                AND   a~created_at IN lt_daterange
                AND   partner_no IN lr_partner_no
                AND   stat IN lt_statusrange
                AND   object_id IN lt_requestnumberrange
                AND   zzorderadm_h0207 IN r_cpid
                AND   zzorderadm_h0208 IN r_submitter
                AND   zzorderadm_h0303 IN r_cust_ref
                AND   zzorderadm_h1005 IN r_trans_desc
                AND   d~inact = ' '
                AND   b~objtype_hi = '05'
                AND   b~objtype_set = '07'.

  • What is syntax for inner join of Select statement with  Secondary Index

    Hi Genies,
                    Here i have created the Secondary index for table COEP and also used for select query but there is no improvement in runtime . taking same time for select query without index as well as with index. my code is
    SELECT *  INTO CORRESPONDING FIELDS OF TABLE ITAB_COEP FROM COEP AS A
                 INNER JOIN COBK  AS B ON ( A~BELNR = B~BELNR AND A~KOKRS = B~KOKRS AND A~GJAHR = B~GJAHR )
                 WHERE A~OBJNR = OBJNR
                 AND A~GJAHR = CURRY
                 AND B~GJAHR = CURRY
                 AND A~RBEST = ''
                 AND A~BEKNZ = 'S'
                 AND B~BELNR NE WA_COBK-BELNR
                 AND B~AWREF_REV = ''
                 AND B~AWORG_REV = ''
                 AND B~KOKRS = WA_COIOB-KOKRS
                 AND B~BLDAT BETWEEN START_DATE AND END_DATE
                 AND B~BLART IN ('SA','KA','KR','AB')  %_HINTS ORACLE 'INDEX("COEP" "COEP~ZBU")'.
    index name is ZBU.
    please any one let me know is there any syntax mistakes? but while checking and during the runtime it does'nt shows any error.
    Regards,
            Thangam.P

    Hi Genies,
                    Here i have created the Secondary index for table COEP and also used for select query but there is no improvement in runtime . taking same time for select query without index as well as with index. my code is
    SELECT *  INTO CORRESPONDING FIELDS OF TABLE ITAB_COEP FROM COEP AS A
                 INNER JOIN COBK  AS B ON ( A~BELNR = B~BELNR AND A~KOKRS = B~KOKRS AND A~GJAHR = B~GJAHR )
                 WHERE A~OBJNR = OBJNR
                 AND A~GJAHR = CURRY
                 AND B~GJAHR = CURRY
                 AND A~RBEST = ''
                 AND A~BEKNZ = 'S'
                 AND B~BELNR NE WA_COBK-BELNR
                 AND B~AWREF_REV = ''
                 AND B~AWORG_REV = ''
                 AND B~KOKRS = WA_COIOB-KOKRS
                 AND B~BLDAT BETWEEN START_DATE AND END_DATE
                 AND B~BLART IN ('SA','KA','KR','AB')  %_HINTS ORACLE 'INDEX("COEP" "COEP~ZBU")'.
    index name is ZBU.
    please any one let me know is there any syntax mistakes? but while checking and during the runtime it does'nt shows any error.
    Regards,
            Thangam.P

  • Time taking for inner joins in select

    Hi all,
    I am using inner join on 3 tables  ( PLKO,PLPO,PLAS) for the materials,
    it is taking database time 20% and abap time 78 %  and when i am using FM CARO_ROUTING_READ
    database time 48% and abap 52%.
    i am in confusion which is th ebest method to use inner join or FM.
    when i am checking in the server for plant in the selection screen , it is running lot of time
    This is first time i am working on the performance issue.
    Can you please anbody help me how to solve this issue.
    Regards,
    Madhavi

    Percentages don't mean much, how does the overall runtime compare? Is there a problem at all?
    Since you already used SE30, go a step further and study the hit list sorted by net time descending, only look at the top few items.
    Also read this:
    Please Read before Posting in the Performance and Tuning Forum
    Thomas

  • Alternative to INNER JOIN

    I've a table like this:
    CREATE TABLE ADRESY
    IDPOWIATU NUMBER(10) NOT NULL,
    IDOBIEKTU NUMBER(10) NOT NULL,
    IDADRESU NUMBER(10) NOT NULL,
    TYPADRESU NUMBER(10) NOT NULL,
    NAZWAWLASNA VARCHAR2(255 BYTE),
    IDKRAJU NUMBER(10),
    IDWOJEWS NUMBER(10),
    IDPOWIATUS NUMBER(10),
    IDGMINYS NUMBER(10),
    IDMIEJSC NUMBER(10),
    IDULICY NUMBER(10),
    NRDOMU VARCHAR2(50 BYTE),
    NRLOKALU VARCHAR2(50 BYTE),
    KODPOCZTOWY VARCHAR2(50 BYTE),
    POCZTA VARCHAR2(50 BYTE),
    STATUS NUMBER(3) NOT NULL,
    DATAUTW DATE NOT NULL,
    DATAWER DATE NOT NULL,
    DATAARCH DATE
    and need to query all the duplicate rows that have a common subset of columns:
    SELECT
    ADRA.IdObiektu,
    ADRA.Status,
    ADRB.IdObiektu AS ZnalezioneId
    FROM
    ADRESY ADRA
    INNER JOIN
    ADRESY ADRB
    ON
    (ADRA.IDPOWIATU = ADRB.IDPOWIATU) AND
    (ADRA.TYPADRESU = ADRB.TYPADRESU) AND
    (ADRA.NAZWAWLASNA = ADRB.NAZWAWLASNA OR (ADRA.NAZWAWLASNA IS NULL AND ADRB.NAZWAWLASNA IS NULL)) AND
    (ADRA.IDKRAJU = ADRB.IDKRAJU OR (ADRA.IDKRAJU IS NULL AND ADRB.IDKRAJU IS NULL)) AND
    (ADRA.IDWOJEWS = ADRB.IDWOJEWS OR (ADRA.IDWOJEWS IS NULL AND ADRB.IDWOJEWS IS NULL)) AND
    (ADRA.IDPOWIATUS = ADRB.IDPOWIATUS OR (ADRA.IDPOWIATUS IS NULL AND ADRB.IDPOWIATUS IS NULL)) AND
    (ADRA.IDGMINYS = ADRB.IDGMINYS OR (ADRA.IDGMINYS IS NULL AND ADRB.IDGMINYS IS NULL)) AND
    (ADRA.IDMIEJSC = ADRB.IDMIEJSC OR (ADRA.IDMIEJSC IS NULL AND ADRB.IDMIEJSC IS NULL)) AND
    (ADRA.IDULICY = ADRB.IDULICY OR (ADRA.IDULICY IS NULL AND ADRB.IDULICY IS NULL)) AND
    (ADRA.NRDOMU = ADRB.NRDOMU OR (ADRA.NRDOMU IS NULL AND ADRB.NRDOMU IS NULL)) AND
    (ADRA.NRLOKALU = ADRB.NRLOKALU OR (ADRA.NRLOKALU IS NULL AND ADRB.NRLOKALU IS NULL)) AND
    (ADRA.KODPOCZTOWY = ADRB.KODPOCZTOWY OR (ADRA.KODPOCZTOWY IS NULL AND ADRB.KODPOCZTOWY IS NULL)) AND
    (ADRA.POCZTA = ADRB.POCZTA OR (ADRA.POCZTA IS NULL AND ADRB.POCZTA IS NULL)) AND
    ADRA.IdAdresu <> ADRB.IdAdresu
    WHERE
    ADRA.IdObiektu IN (SELECT IdObiektu FROM ObiektyTrans) AND
    ADRB.STATUS = 0 AND
    ADRA.STATUS IN (2,5);
    For 64000 matching rows (SELECT IdObiektu FROM ObiektyTrans) and 64428 rows in ADRESY it takes about few minutes to
    complete. I try to use GROUP BY or analytical functions
    to write faster query but so far didn't succeeded.
    Any ideas ?
    Thank You

    I think I've found the solution for my problem, quite a big one :)
    SELECT
      adra.idobiektu,
      adra.status,
      adrb.idobiektu AS znalezioneid
    FROM
      SELECT
        idobiektu,
        status,
        klasa
      FROM
    SELECT idobiektu, status, klasa
        FROM (SELECT idobiektu, status,
                     MIN (idadresu) OVER (PARTITION BY idpowiatu, typadresu, nazwawlasna, idkraju, idwojews, idpowiatus, idgminys, idmiejsc, idulicy, nrdomu, nrlokalu, kodpocztowy, poczta)
                                                                            klasa,
                     SUM (DECODE (status, 2, 1, 5, 1, 0)) OVER (PARTITION BY idpowiatu, typadresu, nazwawlasna, idkraju, idwojews, idpowiatus, idgminys, idmiejsc, idulicy, nrdomu, nrlokalu, kodpocztowy, poczta)
                                                                         status25,
                     SUM (DECODE (status, 0, 1, 0)) OVER (PARTITION BY idpowiatu, typadresu, nazwawlasna, idkraju, idwojews, idpowiatus, idgminys, idmiejsc, idulicy, nrdomu, nrlokalu, kodpocztowy, poczta)
                                                                          status0
                FROM adresy)
       WHERE status0 <> 0 AND status25 <> 0   
      WHERE
        status IN (2, 5) AND
        idobiektu IN (SELECT idobiektu FROM obiektytrans@lnkmatraakt)
    ) adra
    INNER JOIN
      SELECT
        idobiektu,
        klasa
      FROM
    SELECT idobiektu, status, klasa
        FROM (SELECT idobiektu, status,
                     MIN (idadresu) OVER (PARTITION BY idpowiatu, typadresu, nazwawlasna, idkraju, idwojews, idpowiatus, idgminys, idmiejsc, idulicy, nrdomu, nrlokalu, kodpocztowy, poczta)
                                                                            klasa,
                     SUM (DECODE (status, 2, 1, 5, 1, 0)) OVER (PARTITION BY idpowiatu, typadresu, nazwawlasna, idkraju, idwojews, idpowiatus, idgminys, idmiejsc, idulicy, nrdomu, nrlokalu, kodpocztowy, poczta)
                                                                         status25,
                     SUM (DECODE (status, 0, 1, 0)) OVER (PARTITION BY idpowiatu, typadresu, nazwawlasna, idkraju, idwojews, idpowiatus, idgminys, idmiejsc, idulicy, nrdomu, nrlokalu, kodpocztowy, poczta)
                                                                          status0
                FROM adresy)
       WHERE status0 <> 0 AND status25 <> 0   
      WHERE
        status = 0
    ) adrb
    USING (klasa);
    I've also tried sthg like this, but it takes to long time to execute this statement:
    SELECT
      adra.idobiektu,
      adra.status,
      adrb.idobiektu AS znalezioneid
    FROM
      SELECT
      FROM
        adresy
      WHERE
        status IN (2, 5) AND
        idobiektu IN (SELECT idobiektu from obiektytrans@lnkmatraakt)
    ) adra
    INNER JOIN
      SELECT
      FROM
        adresy
      WHERE
        status = 0
    ) adrb
    on
        (ADRA.IDPOWIATU = ADRB.IDPOWIATU) AND
        (ADRA.TYPADRESU = ADRB.TYPADRESU) AND
        (ADRA.NAZWAWLASNA = ADRB.NAZWAWLASNA OR (ADRA.NAZWAWLASNA IS NULL AND ADRB.NAZWAWLASNA IS NULL)) AND
        (ADRA.IDKRAJU = ADRB.IDKRAJU OR (ADRA.IDKRAJU IS NULL AND ADRB.IDKRAJU IS NULL)) AND
        (ADRA.IDWOJEWS = ADRB.IDWOJEWS OR (ADRA.IDWOJEWS IS NULL AND ADRB.IDWOJEWS IS NULL)) AND
        (ADRA.IDPOWIATUS = ADRB.IDPOWIATUS OR (ADRA.IDPOWIATUS IS NULL AND ADRB.IDPOWIATUS IS NULL)) AND
        (ADRA.IDGMINYS = ADRB.IDGMINYS OR (ADRA.IDGMINYS IS NULL AND ADRB.IDGMINYS IS NULL)) AND
        (ADRA.IDMIEJSC = ADRB.IDMIEJSC OR (ADRA.IDMIEJSC IS NULL AND ADRB.IDMIEJSC IS NULL)) AND
        (ADRA.IDULICY = ADRB.IDULICY OR (ADRA.IDULICY IS NULL AND ADRB.IDULICY IS NULL)) AND
        (ADRA.NRDOMU = ADRB.NRDOMU OR (ADRA.NRDOMU IS NULL AND ADRB.NRDOMU IS NULL)) AND
        (ADRA.NRLOKALU = ADRB.NRLOKALU OR (ADRA.NRLOKALU IS NULL AND ADRB.NRLOKALU IS NULL)) AND
        (ADRA.KODPOCZTOWY = ADRB.KODPOCZTOWY OR (ADRA.KODPOCZTOWY IS NULL AND ADRB.KODPOCZTOWY IS NULL)) AND
        (ADRA.POCZTA = ADRB.POCZTA OR (ADRA.POCZTA IS NULL AND ADRB.POCZTA IS NULL));

  • Replacement for inner join.

    I have the following SELECT stmt with inner join which is taking more time to execute......Kindly help me how to improve performance
    SELECT AWERKS AMATNR AMBLNR AMJAHR AMENGE ABWART A~SHKZG
                    AAUFNR  BBUDAT
                   INTO CORRESPONDING FIELDS OF TABLE TRANSTAB
        FROM MSEG AS A INNER JOIN MKPF AS B ON AMBLNR = BMBLNR AND
                                              AMJAHR = BMJAHR
                    WHERE A~BUKRS =  BUKRS   AND
                          A~WERKS IN R_WERKS AND
                          A~MATNR IN S_MATNR AND
                          B~BUDAT >= YFDATE  AND
                          B~BUDAT <= P_DATUM AND
                          A~BWART IN (101,102,601,602,641,642).
    YOUR HELP IS HIGHLY APPRECIATED....

    Goldie - IN may or may not take more time. It depends on selectivity. If the IN is wide open, then the database will not be able to use and index effectively and may have to use a full index scan. I encourage you to run this:
    REPORT ztest_indexed_selects.
    PARAMETERS: p_bukrs   LIKE bkpf-bukrs,
                p_blart   LIKE bkpf-blart,
                p_budat   LIKE bkpf-budat,
                p_gjahr   LIKE bkpf-gjahr.
    DATA: bkpf  TYPE bkpf.
    DATA: bkpf_int TYPE TABLE OF bkpf .
    DATA: cc      LIKE bkpf-bukrs,
          doc     LIKE bkpf-belnr,
          start   TYPE i,
          end     TYPE i,
          dif     TYPE i.
    START-OF-SELECTION.
    * Hardcoded values
    * Preliminary select.
      REFRESH bkpf_int.
      SELECT  *
        FROM bkpf
        INTO TABLE bkpf_int
        WHERE bukrs EQ p_bukrs
        AND gjahr EQ p_gjahr
        AND bstat IN (' ', 'A', 'B', 'D', 'M', 'S', 'V', 'W', 'Z')
        AND blart = p_blart
        AND budat = p_budat.
      DO 5 TIMES.
        REFRESH bkpf_int.
        GET RUN TIME FIELD start.
        SELECT  *
          FROM bkpf
          INTO TABLE bkpf_int
          WHERE bukrs EQ p_bukrs
          AND gjahr EQ p_gjahr
          AND blart = p_blart
          AND budat = p_budat.
        GET RUN TIME FIELD end.
        dif = end - start.
        WRITE: /001 'Time for SELECT without BSTAT', ':', dif,
                     'microseconds'.
        REFRESH bkpf_int.
        GET RUN TIME FIELD start.
        SELECT  *
          FROM bkpf
          INTO TABLE bkpf_int
          WHERE bukrs EQ p_bukrs
          AND gjahr EQ p_gjahr
          AND bstat IN (' ', 'A', 'B', 'D', 'M', 'S', 'V', 'W', 'Z')
          AND blart = p_blart
          AND budat = p_budat.
        GET RUN TIME FIELD end.
        dif = end - start.
        WRITE: /001 'Time for SELECT with    BSTAT', ':', dif,
                     'microseconds'.
    ENDDO.
    Rob

  • Select query for inner join

    Hi all,
    give me the query with innerjoin
    Based on the input values of Material number (MARC-MATNR) from selection screen check and get the Special Procurement type details from MARC-SOBSL and Material description details from MAKT-MAKTX.
    basha....
    Moderator message - instead of asking, you should try to write the code yourself and get back to the forum if you have a specific question.
    Edited by: Rob Burbank on Apr 19, 2009 4:46 PM

    Hi,
    Please Test the following Sample Code it is according to your requirement hope will solve out your problem,
    TABLES: marc.
    SELECt-OPTIONS somatnr for marc-matnr.
    TYPES: BEGIN OF ty_matnr,
      matnr LIKE marc-matnr,
      sobsl LIKE marc-sobsl,
      maktx LIKE makt-maktx,
      END OF ty_matnr.
    DATA: it_matnr TYPE STANDARD TABLE OF ty_matnr WITH HEADER LINE.
    SELECT marc~matnr marc~sobsl makt~maktx
      into CORRESPONDING FIELDS OF TABLE it_matnr
      from marc INNER JOIN makt on ( marc~matnr eq makt~matnr )
      WHERE marc~matnr in somatnr.
    Best Regards,
    Faisal

  • Iam not getting output for inner join where condition

    the condition i have give
    TYPES:BEGIN OF TY_TAB,
          WERKS TYPE WERKS_D,
          LGORT TYPE LGORT_D,
          LGOBE TYPE LGOBE,
          NAME1 TYPE NAME1,
          END OF TY_TAB.
    DATA WA_TAB TYPE TY_TAB.
    DATA IT_TAB TYPE TABLE OF TY_TAB.
    SELECT  T001L~WERKS
            T001L~LGORT
            T001L~LGOBE
            T001W~NAME1
            INTO TABLE IT_TAB FROM T001L INNER JOIN T001W ON T001LWERKS = T001WWERKS
           WHERE  T001L~WERKS = 'amjt' and
               T001L~WERKS = 'bimi' and
               T001L~WERKS = 'biml'.
    LOOP AT IT_TAB INTO WA_TAB.
      WRITE: / WA_TAB-WERKS,WA_TAB-LGORT,WA_TAB-LGOBE,WA_TAB-NAME1.
      ENDLOOP.
    iam not getting output for this

    Well, re-read carefully your code
    WHERE T001L~WERKS = 'amjt' and
    T001L~WERKS = 'bimi' and
    T001L~WERKS = 'biml'
    - WERKS cannot be simultaneously equal to three different values, replace AND with OR ([Boolean algebra|http://en.wikipedia.org/wiki/Boolean_algebra])
    - WERKS domain does not allow lowercase, so use uppercase ([Creating Domains|http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21edf2446011d189700000e8322d00/frameset.htm])
    Regards,
    Raymond

  • Alternative for OUTER Join for use in fast refresh materialized view

    Hi ,
    I have two tables as :
    CREATE TABLE TEST_SANDY1
    COL1 NUMBER
    CREATE TABLE TEST_SANDY2
    COL1 NUMBER,
    COL2 VARCHAR2(10 BYTE)
    Data for the tables are :
    INSERT INTO TEST_SANDY1 ( COL1 ) VALUES (
    1);
    INSERT INTO TEST_SANDY1 ( COL1 ) VALUES (
    2);
    INSERT INTO TEST_SANDY1 ( COL1 ) VALUES (
    3);
    COMMIT;
    INSERT INTO TEST_SANDY2 ( COL1, COL2 ) VALUES (
    1, 'a');
    INSERT INTO TEST_SANDY2 ( COL1, COL2 ) VALUES (
    2, 'b');
    INSERT INTO TEST_SANDY2 ( COL1, COL2 ) VALUES (
    4, 'd');
    COMMIT;
    Now when I run the following select statement :
    select
    b.col1
    from
    test_sandy1 a,
    test_sandy2 b
    where
    b.COL1 = a.COL1(+)
    I get :
    COL1
    1
    2
    4
    I want to build a materialized view to generate the same values but it has to be fast refresh. But since I am using outer join I am unable to create a fast refresh one.
    Can someone suggest an alternate select to create fast refresh materialized view.
    Thanks,
    Sandipan

    The select statement was not fitting my problem , so I'll change it as :
    select
    a.col1, nvl(b.col2, 'DEFAULT')
    from
    test_sandy1 a,
    test_sandy2 b
    where
    b.COL1(+) = a.COL1
    I get :
    COL1     VAL
    1     a
    2     b
    3     DEFAULT
    How do I this ?

  • Urgent: inner joins

    i wanna add inner joins in my report,plz give me d link of websites which provide suitable example.. if u r having example of it den do tell me...
    its really urgent...

    HI
    SELECT - join
    ... [(] {dbtab_left [AS tabalias_left]} | join
              {[INNER] JOIN}|{LEFT [OUTER] JOIN}
                {dbtab_right [AS tabalias_right] ON join_cond} [)] ...  .
    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.
    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.
    REWARD if usefull

  • Syntax of  inner join

    hello sir,
                 plz tell me the syntax of inner join for three tables.

    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.
    we r using 2 type of joins in abap they are
    1) inner join.
    this will join 2 tables using an common fiend and return the result with field values wich are common in both the tables
    itab1 itab2
    a b c a d
    1 2 3 1 5
    2 3 4 3 6
    after innerjoining itab1 n itab2 on field a we wil get the o/p as
    a b c d
    1 2 3 5
    only common field is taken..
    2)left outer join
    here it wil work in opossite way it will give values whic are not common
    itab1 itab2
    a b c a d
    1 2 3 1 5
    2 3 4 3 6
    after left outer joining itab1 n itab2 on field a we wil get the o/p as
    a b c d
    2 3 4
    only fields which are not common is taken from the left table..other field(d here) wil be empty
    I think it will help u.
    Reward Points if helpful.
    Check for ALVROBOT.COM also it is also helpful.

  • ANSI inner join syntax

    Hi,
    Is there a way to configure BI Server 11g to generate ANSI join sytax ("INNER JOIN" clause) for Oracle, as it does when using OUTER JOINs?
    Thank you.

    OBIEE will not generate ANSI syntax for Inner Joins and as you said it only generates for Outer joins. Hope this clears your doubt.

  • 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

Maybe you are looking for