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

Similar Messages

  • 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

  • Inner join and select for all entries with respect to performance

    Hi Friends,
    I just want to know which is more efficient with respect to performance the Inner join or select for all entries?which is more efficient? and how? can you explain me in detail ?
    Regards,
    Dinesh

    INNER JOIN->
    The data that can be selected with a view depends primarily on whether the view implements an inner join or an outer join. With an inner join, you only get the records of the cross-product for which there is an entry in all tables used in the view. With an outer join, records are also selected for which there is no entry in some of the tables used in the view.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ec77446011d189700000e8322d00/content.htm
    FOR ALL ENTRIES->
    Outer join can be created using this addition to the where clause in a select statement. It speeds up the performance tremendously, but the cons of using this variation are listed below
    Duplicates are automatically removed from the resulting data set. Hence care should be taken that the unique key of the detail line items should be given in the select statement.
    If the table on which the For All Entries IN clause is based is empty, all rows are selected into the destination table. Hence it is advisable to check before-hand that the first table is not empty.
    If the table on which the For All Entries IN clause is based is very large, the performance will go down instead of improving. Hence attempt should be made to keep the table size to a moderate level.
    Not Recommended
    Loop at int_cntry.
    Select single * from zfligh into int_fligh
    where cntry = int_cntry-cntry.
    Append int_fligh.
    Endloop.
    Recommended
    Select * from zfligh appending table int_fligh
    For all entries in int_cntry
    Where cntry = int_cntry-cntry.

  • Inner join and select for all entries with respect to performance in SAP

    Hi Friends,
    I just want to know which is more efficient with respect to performance the Inner join or select for all entries?which is more efficient?
    Regards,
    Dinesh

    I did some testing a while ago and found that a JOIN is usually a bit more efficient than FOR ALL ENTRIES. This wasn't always the case though, so the best thing to do is to write it both ways and see which is faster.
    Rob

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

  • 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

  • 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

  • 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

  • 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

  • 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

  • How can we recognize the time taking for executing any process chain

    Hi,
    I have one metachain which consists of several local process chain. It was executed successfully. So how can I find out total time for executing this meta chain.Is there any way to find out that this process execution time is lile some hours and some mins.

    ST13 trans description is Analysis & Service Tools Launch pad and is part of the ST-A/PI plugin.  See Note 69455 - Servicetools for Applications ST-A/PI (ST14, RTCCTOOL, ST12) aand talk to your Basis folks to find out if they can install it since it sounds like it is not installed at your site.
    Here's a list of functions the tool provides - only some are BW specific, so if you can not get ST13 authorization, see if you can at least run the pgm
    Analysis/Service Tools
    Name                     Title                                          
    RTCCTOOL              SAP Servicetools Update
    ST12                        Single transaction analysis
    SDCCVIEWER          SDCC: View data from ST-A/PI subroutines
    SOS_CUSTOMER_DATA                Customer Checks for Security Optimitation
    BATCH_JOB_ANALYSIS               Batch job analysis
    CMO_SYSTEM_MONITORING            CMO - System Monitoring
    ITSTRACEVIEW                     ITS trace viewer (SAPjulep) for EBP/CRM
    STAD_DATA_GET                    Select STAD data and put to download
    BPSTOOLS                         BW-BPS Performance Toolset
    BIIPTOOLS                        BI-IP Performance Toolset
    BW_QUERY_ACCESSES                BW: aggregate/InfoCube accesses of queries
    BW_QUERY_USAGE                   BW: query usage statistics
    BW-TOOLS                         BW Tools
    SEM_BCS_STATISTIC_ANALYSIS       SEM-BCS: Statistic Analysis
    BWQUAC_CUST                      BW Query Alert Collector Customizing
    TABLE_ANALYSIS                   Table Analysis Tools
    UPGRADE_TOOLS                    Tools for Upgrade
    MASS_MAN_MONITORING              Monitoring for Mass Data
    CUST_DMA_TAANA                   DVM: Settings for ST14 CA
    PROJBROWSER                      Service Software: Local project browser
    ANALYSISBROWSER                  Service Software: Analysis browser
    SDCC_DOWNLOAD_SIMULATION         SDCC download simulation for ST-A/PI collectors
    TEXTBROWSER                      Service Software: Short&Longtext browser
    SET_SDCC_PRODUCTIVE_CLIENT       Manually set analysis client for SDCC datacollection
    There were a few OSS Notes relating to ST03N dumping you might want to review to see if they need to be applied
    Nothing is ever as easy as it ought to be.

  • 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

  • Inner join in select statement

    hi,
    i am using select statement like
    SELECT ekkoebeln ekkobukrs ekkobstyp ekkobsart ekko~ernam
               ekkolifnr ekkozterm ekkozbd1t ekkozbd2t ekko~zbd3t
               ekkozbd1p ekkozbd2p ekkoekorg ekkoekgrp ekko~waers
               ekkowkurs ekkokufix ekkobedat ekkokdate
    Begin of Changes, RICEF : 293.
               ekkozzhedg ekkozzheda ekkozzpba ekkozzpbubu lfa1~vbund
    End of Changes, RICEF . 293.
             lfa1land1 lfa1name1
             ekpa~lifn2
             INTO CORRESPONDING FIELDS OF TABLE iekko
             FROM ekko
                  JOIN lfa1 ON lfa1lifnr = ekkolifnr
                  LEFT JOIN ekpa ON ekpaebeln = ekkoebeln AND
                                    ekpa~ebelp = '00000'    AND
                                    ekpa~parvw = 'RS'
             FOR ALL entries IN icooi
             WHERE ekko~ebeln = icooi-refbn
             AND   ekko~zzhedg IN s_zzhedg
             AND   ekko~zzheda IN s_zzheda.
    where in ekko table ,the fields zzhedg and zzheda are appended..but in the debugging mode i am unable to see this 2 field....in the output also....so how should i write my select query?

    Hi,
    Is your select statement returning sy-subrc 0. In debugging mode may be your fields may not be visible in the screen since your internal table has many fields, you have to press >> forward button to check the fields.
    Thanks & Regards,
    Navneeth K.

  • 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

  • Replacing a inner join with for all entries

    Hi Team,
       In a already developed program I am replacing a inner join with select query follow up with for-all-entris and passing the data to final internal table but in both the case the result should be same then only my replacement will be correct. But my no records in both cases differs. This happening because when i am selecting data from first data base table is 32 lines. then I am doing fo-all-entries moving all the duplicate entries then the no records are four. but in final internal table i am looping the first internal table. So in final internal table the no of records are 32. But in inner join query the records are 16.So please let me know how resolve this issue?
    Thanks and REgards
    Deepa

    Hi Thomas,
      Thanks for ur suggestion.
    The solved that in below.
    In select query I did not change anything The way I had written the code was correct.
    I think many of us know how to write that how to make the performance better in that way.
    I made the change when I transfered the to final internal table.
    The original Inner join code:
    select a~field1 a~field2 a~field3 b~field2 b~field3 b~field4
               from dbtab1 as a  inner join dbtab2 as b
              on a~field1 = b~field1 into it_final where
              a~field1 in s_field1. [Field1  in both the table are key field]
    Before code:
    Sort itab1 by key-fields.
    sort itab2 by keyfields.
    loop at itab1 into wa1.
    move: wa1-field1 to wa_final-field1,
               wa1-field2 to wa_final-field2,
               wa1-field3 to wa_final-field3.
    read table itab2 into wa2 witk key field1 = wa1-field1 binary search.
      if sy-subrc = 0.
      move : wa2-field2 to wa_final-field4,
                 wa2-field3 to wa_final-field5,
                 wa2-field4 to wa_final-field6.
    append wa_final to it_final.
    endif.
    Clear : wa1, wa2, wa_final.
    endloop.
    In this case if the one key fieild value is not present there in second internal table but its there in first internal table still it will read that row with 2nd internal values having zeroes. Normally what does not happen in inner join case if the key field value will same in both the case ,then that will fetch only those rows.
    Changed Code
    loop at itab1 into wa1.
    read table itab2 into wa2 witk key field1 = wa1-field1 binary search.
      if sy-subrc = 0.
    move: wa1-field1 to wa_final-field1,
               wa1-field2 to wa_final-field2,
               wa1-field3 to wa_final-field3.
      move : wa2-field2 to wa_final-field4,
                 wa2-field3 to wa_final-field5,
                 wa2-field4 to wa_final-field6.
    append wa_final to it_final.
    endif.
    Clear : wa1, wa2, wa_final.
    endloop.
    In this case the values will read to final internal table if both key field matches.
    With Regards
    Deepa

Maybe you are looking for