Can a JOIN statement be rewritten using FOR ALL ENTRIES in any case ?

I had a SELECT statement, like:
    select p~key1 t~col3 t~col4 p~col2 p~col3
      into table itab1
      from ( table1 as p left outer join table2 as t
              on p~key1 = t~key1 and t~col2 = someValue ).
Among which, table1 and table2 are fully buffered.
Code Inspector suggests that this statement should be, e.g., rewritten using FOR ALL ENTRIES.
Since FOR ALL ENTRIES is only possible for WHERE conditions of the SELECT statement, which means the internal table right after it is not available for the RESULT clause of the SELECT statement, can the above statement be rewritten? If yes, how?
Thanks!

hi ,
select pkey1 tcol3 tcol4 pcol2 p~col3
      into table itab1
      from ( table1 as p left outer join table2 as t
              on pkey1 = tkey1 and t~col2 = someValue ).
<i>look below code</i>
select * from  table2  into table int_tab2 where col2 = someValue.
select key1 col2 col3  into table  int_tab1
FOR ALL ENTRIES IN int_tab2
WHERE key = int_tab2-key1.
then use read statements for manipulations
rgds
Anver

Similar Messages

  • How can i write the below code using "For all entries"

    Hi
    How can we write the below code using "for all entries" and need to avoid joins...
    Please help
    SELECT aaufnr aobjnr aauart atxjcd a~pspel
    agstrp awerks carbpl cwerks
    INTO TABLE t_caufv
    FROM caufv AS a
    INNER JOIN afih AS b
    ON aaufnr = baufnr
    INNER JOIN crhd AS c
    ON bgewrk = cobjid
    AND c~objty = 'D'
    WHERE ( a~pspel = space
    OR a~txjcd = space
    OR NOT a~objnr IN
    ( select OBJNR from COBRB AS e
    WHERE objnr = a~objnr ) )
    AND a~werks IN s_plant
    AND a~auart IN s_wtype
    AND NOT a~objnr IN
    ( select OBJNR from JEST AS d
    WHERE objnr = a~objnr
    AND ( dstat = 'A0081'OR dstat = 'A0018' )
    AND d~inact 'X' ).
    Reward points for all helpfull answers
    Thanks
    Ammi.

    Hi,
    SELECT objnr objid aufnr
            from afih
            into table t_afih.
    SELECT objnr
            from JEST
            into table t_JEST
            where stat = 'A0045'
               OR stat = 'A0046'
               AND inact 'X'.
    SELECT objnr
            from COBRB
            into table t_cobrb.
    SELECT arbpl werks objid objty
          from crhd
          INTO table it_crhd
          FOR ALL ENTRIES IN it_afih
          WHERE objty eq 'D'
          AND gewrk = it_afih-objid.
    SELECT aufnr objnr auart txjcd pspel gstrp werks aufnr
            FROM caufv
            INTO table t_caufv
            FOR ALL ENTRIES IN it_afih
            WHERE aufnr = it_afih-aufnr
              And pspel = ' '
              AND txjcd = ' '
             ANd objnr ne it_crhd-objnr
              AND auart in s_wtype
              AND werks in s_plant.
             AND objnr ne it_jest-objnr.
    dont use NE in the select statements, it may effect performance also. Instead use if statements inside
    loops.
    loop at t_caufv.
    read table it_chrd............
      if t_caufv-objnr ne it_chrd-objnr.
      read table it_jest..........
       if   if t_caufv-objnr ne it_jest-objnr.
        (proceed further).
       endif.
      endif.
    endloop.
    hope this helps.
    Reward if useful.
    Regards,
    Anu

  • Select using for all entries

    hi gurus,
    plz check my report using for all entries where i am give data in selection screen from date to date as 3.01.2007 to 4.02.2007
    my code does not provide me data between  above date to date.
    it fetch data from other date like 26.06.2006 to some other
    plz check code and give me solution for it.
    TABLES: bseg, bkpf.
    *ALV grid_data
    TYPE-POOLS: slis.
                           INTERNAL TABLES
    TYPES: BEGIN OF it_output,
           bukrs  TYPE bseg-bukrs, "Company Code
           belnr  TYPE bseg-belnr, "Accounting Document Number
           gjahr  TYPE bseg-gjahr, "Fiscal Year
           buzei  TYPE bseg-buzei, "Number of Line Item
           augdt  TYPE bseg-augdt, "Clearing Date
           shkzg  TYPE bseg-shkzg, "Debit/Credit Indicator
           dmbtr  TYPE bseg-dmbtr, "Amount in local currency
           kostl  TYPE bseg-kostl, "Cost Center
           hkont  TYPE bseg-hkont, "G/L Account
           matnr  TYPE bseg-matnr, "Material Number
           werks  TYPE bseg-werks, "Plant
           erfmg  TYPE bseg-erfmg, "Quantity in unit of entry
           blart  TYPE bkpf-blart, "Document type
           bldat  TYPE bkpf-bldat, "Document Date
           budat  TYPE bkpf-budat, "Posting Date
           monat  TYPE bkpf-monat, "Fiscal period
           cpudt  TYPE bkpf-cpudt, "Document Entry Date
           usnam  TYPE bkpf-usnam, "User name
           tcode  TYPE bkpf-tcode, "Transaction Code20
           bktxt  TYPE bkpf-bktxt, "Document Header Text
           waers  TYPE bkpf-waers, "Currency Key
           awtyp  TYPE bkpf-awtyp, "Reference procedure
           awkey  TYPE bkpf-awkey, "Object key
          END OF it_output.
    TYPES: BEGIN OF it_bkpf,
           bukrs  TYPE bkpf-bukrs,
           belnr  TYPE bkpf-belnr,
           gjahr  TYPE bkpf-gjahr,
           blart  TYPE bkpf-blart,
           bldat  TYPE bkpf-bldat,
           budat  TYPE bkpf-budat,
           monat  TYPE bkpf-monat,
           cpudt  TYPE bkpf-cpudt,
           usnam  TYPE bkpf-usnam,
           tcode  TYPE bkpf-tcode,
           bktxt  TYPE bkpf-bktxt,
           waers  TYPE bkpf-waers,
           awtyp  TYPE bkpf-awtyp,
           awkey  TYPE bkpf-awkey,
          END OF it_bkpf.
    DATA: lt_output TYPE it_output OCCURS 0 WITH HEADER LINE.
    DATA: lt_bkpf   TYPE it_bkpf OCCURS 0 WITH HEADER LINE.
                       ALV DECLARATION DATA                              *
    DATA: it_fieldcat   TYPE    slis_t_fieldcat_alv,
          it_heading    TYPE    slis_t_listheader,
          it_sort       TYPE    slis_t_sortinfo_alv,
          it_events     TYPE    slis_t_event,
          it_alv_event  TYPE    slis_alv_event,
          gv_repname    TYPE    syrepid,
          gv_save       TYPE    char1,
          is_layout     TYPE    slis_layout_alv.
                     SELECTION SCREEN                                    *
    SELECTION-SCREEN BEGIN OF BLOCK bl WITH FRAME TITLE text-011.
    SELECT-OPTIONS: s_bukrs FOR bseg-bukrs NO INTERVALS,
                    s_blart FOR bkpf-blart,
                    s_budat FOR bkpf-budat.
    SELECTION-SCREEN END OF BLOCK bl.
                     START OF SELECTION                                  *
    START-OF-SELECTION.
      PERFORM get_data.
                       End of Selection                                  *
    END-OF-SELECTION.
      PERFORM build_field_catalog.
      PERFORM eventstab.
      PERFORM display_data.
                             FORMS                                       *
    *&      Form  get_data
          Get Data
    FORM get_data .
      SELECT bukrs
             belnr
             gjahr
             buzei
             augdt
             shkzg
             dmbtr
             kostl
             hkont
             matnr
             werks
             erfmg
             INTO TABLE lt_output
             FROM bseg
           WHERE bukrs IN s_bukrs.
      IF sy-subrc = 0.
        SORT lt_output BY belnr.
        DELETE ADJACENT DUPLICATES FROM lt_output COMPARING ALL FIELDS.
      ENDIF.
      IF NOT lt_output[] IS INITIAL.
        SELECT bukrs
               belnr
               gjahr
               blart
               bldat
               budat
               monat
               cpudt
               usnam
               tcode
               bktxt
               waers
               awtyp
               awkey
           INTO TABLE lt_bkpf FROM bkpf
           FOR ALL ENTRIES IN lt_output
           WHERE bukrs = lt_output-bukrs AND
                 belnr = lt_output-belnr AND
                gjahr = lt_output-gjahr."AND
                 blart IN s_blart        AND
                 budat IN s_budat ."     AND
                blart = 'SA'     OR
                blart = 'SB'     OR
                blart = 'AB'     OR
                blart = 'ZC'.
    *sort lt_bkpf  by blart budat.
       DELETE lt_bkpf WHERE blart NOT IN s_blart AND
                            budat NOT IN s_budat.
      ENDIF.
      SORT lt_bkpf BY bukrs belnr.
    SORT lt_output[].
    DELETE ADJACENT DUPLICATES FROM lt_output COMPARING ALL FIELDS.
      LOOP AT lt_output.
        READ TABLE lt_bkpf WITH KEY bukrs = lt_output-bukrs
                                    belnr = lt_output-belnr
                                    budat = lt_output-budat
                                    BINARY SEARCH.
        IF sy-subrc = 0.
          MOVE: lt_bkpf-gjahr TO  lt_output-gjahr,
                lt_bkpf-belnr TO  lt_output-belnr,
                lt_bkpf-blart TO  lt_output-blart,
                lt_bkpf-bldat TO  lt_output-bldat,
                lt_bkpf-budat TO  lt_output-budat,
                lt_bkpf-monat TO  lt_output-monat,
                lt_bkpf-cpudt TO  lt_output-cpudt,
                lt_bkpf-usnam TO  lt_output-usnam,
                lt_bkpf-tcode TO  lt_output-tcode,
                lt_bkpf-bktxt TO  lt_output-bktxt,
                lt_bkpf-waers TO  lt_output-waers,
                lt_bkpf-awtyp TO  lt_output-awtyp,
                lt_bkpf-awkey TO  lt_output-awkey.
          MODIFY lt_output.
       ELSE.
         DELETE lt_output.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "get_data
    thanks jayant

    Hi Jayant,
    You cannot retrieve data first from BSEG and then from BKPF.
    It is not correct and you cannot get the correct data.
    You should use BKPF which is header table first and then
    using for all entries retrieve data from BSEG.
    Use date field in the select statement condition for BKPF table retrieval and
    you don't have posting date field in BSEG.
    If you do like this, it will definitely work.
    Retrieve data from BKPF using date condition in SELECT statement.
    Then, using for all entries retrieve from BSEG.
    Reward if helpful.

  • Can anyone give me an example of for all entries in case of inner join

    Hi abapers,
    I am trying to replace an inner join with for all entries.
    So kindly give me a demo code so that i can understand the use and apply it.
    And plz tell me in which case it is better to use for all entries and in which case to use inner join so that better performance will occur.
    With Regards
    Ansuman

    Hello Ansuman,
    For example:
    DATA:
      BEGIN OF fs_eket,
        ebeln LIKE ekko-ebeln,             " Purchasing Document Number
        ebelp LIKE ekpo-ebelp,             " Item Number of Purchasing Doc
      END OF fs_eket.                      " fs_eket
    DATA:
      t_eket LIKE                          " Purchase table
    STANDARD TABLE
          OF fs_eket.
    Using joins:
    select ebeln ebelp
    into corresponding fields of table t_eket
    from ekko join ekpo
    on ekkoebeln eq ekpoebeln
    where ebeln in s_sbeln.
    The select statement can be replaced by
    SELECT ebeln
      FROM ekko
      INTO CORRESPONDING FIELDS OF TABLE t_eket
    WHERE ebeln IN s_ebeln.
    IF sy-subrc EQ 0.
      sort t_eket by ebeln.
      SELECT ebeln
             ebelp
        FROM ekpo
        INTO CORRESPONDING FIELDS OF TABLE t_eket
         FOR ALL ENTRIES IN t_eket
       WHERE ebeln EQ t_eket-ebeln.
    The duplicate entries are removed by using FOR ALL ENTRIES. Or else by using the join, you have teh sort the table by key fields and then delete adjacent duplicates.
    Hope it helps you
    Regards
    Indu

  • Join 3 tables using FOR ALL ENTRIES

    Hi,
    I want to join 3 tables and show their result in a text file delimited by comma.
    ITs a download program.Can someone tell me how to how to join the three table using for all entires instead of inner join.please give step  by step illustration

    Hi,
    Please check below code which downloads records from 3 tables into excel file.
    if you want other file means you can specify other file type in the fm parameter
    REPORT zstemp_qty2_  LINE-SIZE 255 .
    DATA:it_vbak LIKE vbak OCCURS 0 WITH HEADER LINE.
    DATA:v_file1 LIKE rlgrap-filename.
    DATA:v_file2(80) TYPE c.
    DATA:it_vbap LIKE vbap OCCURS 0 WITH HEADER LINE.
    DATA:it_mara LIKE mara OCCURS 0 WITH HEADER LINE.
    START-OF-SELECTION.
      SELECT * FROM vbak INTO TABLE it_vbak UP TO 100 ROWS.
      IF NOT it_vbak[] IS INITIAL.
        SELECT * FROM vbap INTO TABLE it_vbap
        FOR ALL ENTRIES IN it_vbak
        WHERE vbeln = it_vbak-vbeln.
      ENDIF.
      LOOP AT it_vbap.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
             EXPORTING
                  input  = it_vbap-matnr
             IMPORTING
                  output = it_vbap-matnr.
        MODIFY it_vbap TRANSPORTING matnr.CLEAR it_vbap.
      ENDLOOP.
      IF NOT it_vbap[] IS INITIAL.
        SELECT * FROM mara INTO TABLE it_mara
        FOR ALL ENTRIES IN it_vbap
        WHERE matnr = it_vbap-matnr.
      ENDIF.
      CALL FUNCTION 'F4_FILENAME'
       EXPORTING
         program_name        = sy-cprog
         dynpro_number       = sy-dynnr
      FIELD_NAME          = ' '
       IMPORTING
         file_name           = v_file1          .
      v_file2 = v_file1.
      CALL FUNCTION 'WS_DOWNLOAD'
       EXPORTING
      BIN_FILESIZE                  = ' '
      CODEPAGE                      = ' '
         filename                      = v_file2
         filetype                      = 'WK1'
      MODE                          = ' '
      WK1_N_FORMAT                  = ' '
      WK1_N_SIZE                    = ' '
      WK1_T_FORMAT                  = ' '
      WK1_T_SIZE                    = ' '
         col_select                    = '1'
      COL_SELECTMASK                = ' '
      NO_AUTH_CHECK                 = ' '
    IMPORTING
      FILELENGTH                    =
        TABLES
          data_tab                      = it_mara
      FIELDNAMES                    =
    EXCEPTIONS
      FILE_OPEN_ERROR               = 1
      FILE_WRITE_ERROR              = 2
      INVALID_FILESIZE              = 3
      INVALID_TYPE                  = 4
      NO_BATCH                      = 5
      UNKNOWN_ERROR                 = 6
      INVALID_TABLE_WIDTH           = 7
      GUI_REFUSE_FILETRANSFER       = 8
      CUSTOMER_ERROR                = 9
      OTHERS                        = 10
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      LOOP AT it_mara.
        WRITE:/ it_mara-matnr.
      ENDLOOP.
    Regds
    Sivaparvathi
    Please reward points if helpful.....

  • Left outer join using For All Entries

    how to implement left outer join using for all entries In REPORTS.

    hi Mansi,
    this is how i populate
    SELECT VGBEL LFIMG POSNR VBELN FROM LIPS INTO  TABLE IT_delv  FOR ALL ENTRIES IN IT_VBAP WHERE VGBEL = IT_VBAP-VBELN.
    LOOP AT IT_delv INTO WA_delv.
    WA_FINAL-VBELN_1 = WA_DELV-VBELN_1.
    WA_FINAL-LFDAT =   WA_DELV-LFDAT.
    WA_FINAL-LFIMG   = WA_DELV-LFIMG.
    WA_FINAL-POSNR2 =   WA_DELV-POSNR2..
    APPEND WA_FINAL TO IT_FINAL.
    CLEAR: WA_FINAL , WA_delv.
    ENDLOOP.
    LOOP AT IT_FINAL INTO WA_FINAL.
    READ TABLE IT_vbap INTO WA_vbap WITH KEY VGBEL = WA_FINAL-VBELN.
      WA_FINAL-VBELN = WA_VBAP-VBELN.
    WA_FINAL-MATNR = WA_VBAP-MATNR.
    WA_FINAL-KWMENG = WA_VBAP-KWMENG.
    WA_FINAL-NETWR = WA_VBAP-NETWR.
    MODIFY IT_FINAL FROM WA_FINAL.
    ENDLOOP.
    My question is , it_vbap has 5 five records A,B,C,D,E.
    in it_delv ,there are 20 record corrresponding to A,B,D of IT_VBAP.
    in final table i wont get info of recors B,E. I want those info also in final table ..how can i do that...

  • I have a problem in using  for all entries

    Hi i have a problem in using <b>for all entries</b>
    i have declared the two internal tables as below
      DATA: BEGIN OF ITAB OCCURS 10,
              EBELN LIKE EKKO-EBELN,
              LIFNR LIKE EKKO-LIFNR,
              EBELP LIKE EKBE-EBELP,
              BELNR LIKE EKBE-BELNR,
    *          MATNR LIKE EKPO-MATNR,
    *          TXZ01 LIKE EKPO-TXZ01,
              VGABE LIKE EKBE-VGABE,
              GJAHR LIKE EKBE-GJAHR,
              KNUMV LIKE EKKO-KNUMV,
         END OF ITAB.
    DATA: BEGIN OF ITAB1 OCCURS 10,
              EBELN LIKE EKPO-EBELN,
              MATNR LIKE EKPO-MATNR,
              TXZ01 LIKE EKPO-TXZ01,
              WERKS LIKE EKPO-WERKS,
              NETWR LIKE EKPO-NETWR,
              MENGE LIKE EKPO-MENGE,
              MWSKZ LIKE EKPO-MWSKZ,
              LIFNR LIKE EKKO-LIFNR,
              EBELP LIKE EKBE-EBELP,
              BELNR LIKE EKBE-BELNR,
          END OF ITAB1.
    <b>and now i have tried to move the values in those internal tables using these statements</b>
       SELECT  A~EBELN A~LIFNR A~KNUMV B~VGABE B~EBELP B~GJAHR B~BELNR
            FROM  EKKO AS A
            INNER JOIN EKBE  AS B ON  B~EBELN = A~EBELN
            INTO  CORRESPONDING
            FIELDS OF TABLE ITAB WHERE B~VGABE = '2'.
       SELECT EKPO~EBELN EKPO~MATNR EKPO~TXZ01 EKPO~WERKS EKPO~NETWR
              EKPO~MENGE EKPO~MWSKZ
          FROM EKPO
          INTO CORRESPONDING FIELDS OF TABLE ITAB1
          FOR ALL ENTRIES IN ITAB
          WHERE EBELN = ITAB-EBELN.
          LOOP AT ITAB1.
           READ TABLE ITAB WITH KEY EBELN = ITAB-EBELN.
           ITAB-EBELN = ITAB1-EBELN.
           ITAB1-LIFNR = ITAB-LIFNR.
           ITAB1-EBELP = ITAB-EBELP.
           ITAB1-BELNR = ITAB-BELNR.
           ITAB1-EBELP = ITAB-EBELP.
           APPEND ITAB1.
          ENDLOOP.
    But when i was using loop then it was displaying values in debugging mode but while i was trying to execute it was taking a lot of time i thought that it was due to more information in the already declared internal table so i have tried to remove the previous entries but it was showing an error while i was removing the old entries
    and when i  remove the loop at itab1 then i'll get output directly but it was displaying the itab fields which is my 1st internal table but not the values of itab1 can u explain me what is the possible error for that
    Regards ,
    Pavan

    before using for all entries in, u need to check whether the driver internal table is empty, if it is empty, u should not enter into select statement.
    if u wont use this check means, when the driver internal table is empty, the second select will take all the entires from the tables.
    SELECT  AEBELN ALIFNR AKNUMV BVGABE BEBELP BGJAHR B~BELNR
            FROM  EKKO AS A
            INNER JOIN EKBE  AS B ON  BEBELN = AEBELN
            INTO  CORRESPONDING
            FIELDS OF TABLE ITAB WHERE B~VGABE = '2'.
    if itab[] is not initial.
       SELECT EKPOEBELN EKPOMATNR EKPOTXZ01 EKPOWERKS EKPO~NETWR
              EKPOMENGE EKPOMWSKZ
          FROM EKPO
          INTO CORRESPONDING FIELDS OF TABLE ITAB1
          FOR ALL ENTRIES IN ITAB
          WHERE EBELN = ITAB-EBELN.
    endif.
    I hope this will help u.
    else,
    Sujatha.

  • What is the condition for using 'for all entries' and  why?

    what is the condition for using 'for all entries' and  why? can any body tell the reason for this ? its a big favour of me .
    regards,
    ravi.

    hi,
    for all entries is used to join two or more tables.
    It is same as join but performance wise for all entries is more effective.
    You can only use FOR ALL ENTRIES IN ...WHERE ...in a SELECT statement.
    SELECT ... FOR ALL ENTRIES IN itab WHERE cond returns the union of the solution sets of all SELECT
    statements that would result if you wrote a separate statement for each line of the internal table replacing the symbol
    itab-f with the corresponding value of component f in the WHERE condition.Duplicates are discarded from the result
    set. If the internal table itab does not contain any entries, the system treats the statement as though there were
    no WHERE cond condition, and selects all records (in the current client).
    for example:
    SELECT * FROM sflight INTO wa_sflight
    FOR ALL ENTRIES IN ftab
    WHERE CARRID = ftab-carrid AND
    CONNID = ftab-connid AND
    fldate = '20010228'.
    this condition, return all entries of the sflight
    hen using FOR ALL ENTRIES the number of matching records is restricted to the number of records in the internal table. If the number of records in the database tables is too large then join would cause overheads in performance. Additionally a JOIN bypasses the table buffering.
    So for all entries is used for filtering out the data from the two tables based on the entries in them.
    Advantages:
    1) For all entries avoids inner join & so the performance increases.
    2) For specified values in 1 itab, if you to fetch values from other table you can use it.
    3) Use of select stmt in loop is gets avoided, as u can use read statement on the the new itab.

  • Is it not recommended to use FOR ALL ENTRIES in version 4.5B

    Hi,
    Is it not recommended to used For all entries in version 4.5B as  Size limit for SQL is 32KB hence we should not be using FOR ALL ENTRIES, instead of this we should be using select inside the loop?
    Can anyone please let me know if this is correct and if you can provide me the SAP documentation on the specific statement.
    Regards
    Ria

    Hi Ria,
    From what I understand, you cannot use JOINS with FOR ALL ENTRIES in 4.5b & lower versions. In general the SELECT..FOR ALL ENTRIES statement has been in use from 3.1i versions. For more information, PL take a look at OSS Note #652634.
    Regards,
    Suresh Datti

  • Hi Prerequestion of using for all entries

    Hi ,
       What is the prerequestion of using For All Entries. Could you answer to me.
    Thanks & Regards
    Raghava

    Hi,
    1.First check whether the internal table which to be used in FOR ALL ENTRIES is initial or not.IF it is not initial ,then use the table.Otherwise it will go for an infinite loop.
    2.Sort the internal table.
    Go through this
    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.
    Regards,
    Padmam.

  • How to restrict field of BSEG using for all entries in

    Hi All,
    i want restrict field BSEG-UMSKZ by using for all entries in but facing some problem.can someone tell me how to use with example.If you want to see my Query is this.
    SELECT: bkpf~belnr
             with_item~buzei
             bkpf~blart
             with_item~wt_acco AS lifnr
             lfa1~name1
             lfa1~stras
             lfa1~ort01
             lfa1~stcd2 AS lifntn
             lfa1~stcd1 AS lifnic
             bkpf~budat
             wt_qsshb AS dmbtr
             qsatz
             witht
             wt_withcd
             wt_qbshb
             hkont
             with_item~wt_wtexmn
       INTO CORRESPONDING FIELDS
       OF TABLE gi_accdocs
       FROM bkpf
       JOIN with_item
       ON ( with_itembukrs = bkpfbukrs AND
       with_itembelnr = bkpfbelnr AND
       with_itemgjahr = bkpfgjahr )
       JOIN lfa1
       ON ( lfa1lifnr = with_itemwt_acco )
       WHERE bkpf~bukrs EQ p_bukrs AND
       bkpf~gjahr EQ p_gjahr AND
       bkpf~budat IN s_budat AND
       bkpf~stblg EQ space AND
       wt_withcd IN s_withcd AND
       with_item~wt_acco IN s_lifnr AND
       with_item~hkont IN s_hkont AND
       bkpf~belnr IN s_belnr.
    Thanks & Regards,

    hi,
    this is the whole coding with FOR ALL ENTRIES:
      SELECT: bkpf~belnr
             with_item~buzei
             bkpf~blart
             with_item~wt_acco AS lifnr
             lfa1~name1
             lfa1~stras
             lfa1~ort01
             lfa1~stcd2 AS lifntn
             lfa1~stcd1 AS lifnic
             bkpf~budat
             wt_qsshb AS dmbtr
             qsatz
             witht
             wt_withcd
             wt_qbshb
             hkont
             with_item~wt_wtexmn
       INTO CORRESPONDING FIELDS
       OF TABLE gi_accdocs
       FROM bkpf
       JOIN with_item
       ON ( with_itembukrs = bkpfbukrs AND
       with_itembelnr = bkpfbelnr AND
       with_itemgjahr = bkpfgjahr )
       JOIN lfa1
       ON ( lfa1lifnr = with_itemwt_acco )
       WHERE bkpf~bukrs EQ p_bukrs AND
       bkpf~gjahr EQ p_gjahr AND
       bkpf~budat IN s_budat AND
       bkpf~stblg EQ space AND
       wt_withcd IN s_withcd AND
       with_item~wt_acco IN s_lifnr AND
       with_item~hkont IN s_hkont AND
       bkpf~belnr IN s_belnr.
        SELECT UMSKZ
          from BSEG
          INTO  CORRESPONDING FIELDS OF TABLE  gi_amount
          FOR ALL ENTRIES IN GI_MAIN
          WHERE UMSKZ NE 'F'.
    Thanks & Regards.

  • Develop alv using for all entries

    Develop an Sales Document ALV Report .   
         Select the mentioned field from two tables using FOR ALL ENTRIES , display the output in ALV Format.
    Table Name 1     KNA1     General Data in Customer Master
    Fields     KUNNR     
         LAND1     
         ERDAT     
         NAME1     
         ORT01     
         PSTLZ
    Table Name 2     VBAK     Sales Document: Header Data
    Fields     VBELN     
         AUDAT     
         VBTYP     
         TRVOG     
         AUART     
    ALV O / P Format Fields     KUNNR     from KNA1 Table
         LAND1     from KNA1 Table
         ERDAT     from KNA1 Table
         NAME1     from KNA1 Table
         ORT01     from KNA1 Table
         PSTLZ     from KNA1 Table
         VBELN     from VBAK Table
         AUDAT     from VBAK Table
         VBTYP     from VBAK Table
         TRVOG     from VBAK Table
         AUART     from VBAK Table
    Moderator Message: This is not a training forum. Please refrain from using it as one.
    Edited by: kishan P on Jun 6, 2011 2:23 PM

    FOA is for passing one internal table to select statement..
    Press F1 on it, it will give you the details.
    if you really want to pass more than one tables, you can use range tables.. just similar to what we do in case of select-options..
    as in
    select x y z from dbtab
                         where x in s_x
                                  y in s_y.
    hope you understand..

  • Populating Empty Fields for Existing Internal Table Using For All Entries

    I have an internal table called itab_extract that populates without any issues in SELECT A and SELECT B below. Trying to avoid looping, I am using select DB table 'for all entries' in itab_extract. I want the empty fields in itab_extract to populate from the values in the database. However, about 200,000 entries are being appended to the table, and, the values that existed for the already populated fields in itab_extract are gone, and the new fields are populated.
    I've played with the syntax and cannot seem to get it to work. My next option is a time consuming loop.
    How should the for all entries syntax look to accomplish filling the empty fields in the itab?   Thank-You
    *read ekko
        select ebeln lifnr aedat bsart from ekko                                                     *SELECT A*
               into  CORRESPONDING FIELDS OF TABLE me->itab_extract
               where aedat in r_aedat.
        select ebeln lifnr aedat BSART from ekko                                                  *SELECT B*
               appending CORRESPONDING FIELDS OF TABLE me->itab_extract
               where aedat in S_DATE2 AND
                     BSART IN S_BSART.
          select ebelp werks matnr                                                                           *SELECT C*
            into CORRESPONDING FIELDS OF TABLE itab_extract
            from ekpo
            FOR ALL ENTRIES IN itab_extract
            where ebeln = itab_extract-ebeln.

    Hi Tom,
               This SQL statement will be time consuming, Do not use a loop.
    There are two options.
    1. Select EKKO and EKPO details based on standard SAP view. (You can type EKKO in se11 view to find the correct view).
        also use one range table populate r_aedat and s_date2 in the same. So you where condition will have r_newrange and   
        s_bsart. Also do not use into corresponding fields, it is not a good idea. It will increase your performance. Maintain the proper 
        sequence (Based on database structure of EKKO and EKPO)
    2. If you are keen to use for all entries, then first select ekko then after your sy-subrc check get the data from EKPO.
    Should be like this.
    select ebeln bsart aedat lifnr from ekko into table gt_ekko where aedat in r_newrange and bsart in s_bsart.
    if sy-subrc eq 0.
    sort gt_ekko by ebeln ascending.
    select ebeln ebelp werks matnr  into table gt_ekpo for all entries in gt_ekko where ebeln eq gt_ekko-ebeln.
    endif.
    Hope it helps,
    Best Regards,
    Tapodipta Khan.

  • Duplicate entries missing using for all entries in select query.

    Hi Gurus,
    Is there any way to avoid missing duplicate entries in an internal table if you use for all entries in select statement?
    Note : i am selecting two tables using non key fields and i have to aggregate the data. I want only 2 data fields and one amount field in my final internal table. I can add all the primary key fields into my internal table and collect my required fields in another table, but  I just want to know is there any other way to avoid missing duplicate entries without adding all the key fields?
    Regards,
    Raghavendra

    Hi,
    Just check what are the other possible fields in the table which may be having
    duplicate entries and make use of them in the selection accordingly.
    You may not miss any entries unless there is any restriction on them.
    You can better judge that in debugging mode while selecting data from that table.

  • Regarding Select using FOR ALL ENTRIES (FAEI)

    Hi all,
    Please help me with Select using FOR ALL ENTRIES (FAEI)
    Thanks in advns,
    Das.

    Hi,
    This version of the SELECT statement was the only way to join tables until SAP release 3.0E.  It is recommended that the SQL JOIN be used.  However, this is an alternate method of joining tables that may be used in some circumstances.  Remember, SQL JOIN doesn’t utilize the SAP internal database buffer.
    Example:
        SELECT EKGRP FROM T024
               INTO TABLE T_024.
        SELECT MATNR WERKS EKGRP FROM MARC
               INTO TABLE T_MARC
               FOR ALL ENTRIES IN T_024
               WHERE EKGRP = T_024-EKGRP.
    Prerequisites:
    The driver table cannot be empty. This would cause one full table scan.
    In general, keep the driver table as small and unique (in regards to the fields that would be needed for referencing in the FAEI) as possible. If duplicate entries are not deleted, identical data is read unnecessarily from the database.
    If FAEI is used, the selected field list must be a superset of all the key fields of the database tables used in SQL. This is absolutely required to avoid data loss since the DB interface in R/3 returns unique sets of the result set to the application program. Failing to ensure this may cause problems when you want to get all records from a database table that match a certain condition.
    Avoid using FAEI on a small DB table (like configuration tables). This could potentially cause full table scans for each FAEI packet. Even if it does index range scan, it is better to get data from the small DB tables by individual SELECT without the use of FAE.
    Always use FAEI in conjunction with a DB index otherwise it would cause multiple full table scans (one table scan for each FAEI packet).
    The first field(s) of the DB index should refer to the fields of the FAEI driver table in the SQL WHERE clause. Do not leave gaps between index fields in the WHERE clause. Inefficient index access will impact every FAEI packets.
    FAEI works best when retrieving a small percentage of data from a Database table. When a large percentage of data is needed, consider getting data out of the DB table without FAEI implementation, and then do additional filtration in your application
    Reward points if found helpfull...
    Cheers,
    Chandra Sekhar.

Maybe you are looking for

  • Transfer With Clearing VS. Transfer without Clearing

    Hi, In SAP There are the folloiwng two transactions 1. Transfer with clearing (F-30) 2. Transfer without Clearing (F-21) Functionality standpoint, what is the difference between those two? When we should use which one? Also, if we have an AR open ite

  • Lost all scheduled recordings

    I've been away a few days and last night whilst back at home I noticed nothing was recording when I knew it should have been. So I checked the recording menu and discovered that there was nothing in my scheduled recording menu, all the linked series,

  • Mail of vendor's code

    hi, in what table I can see the email of the number of vendor? I didn't find in tables lfa1 and lfb1 but I can see the email in transaction FK03.

  • Tutorial typos affect success of application

    Hello, I'm working through the Oracle® Application Development Framework Tutorial for Forms/4GL Developers 10g Release 3 (10.1.3) (http://www.oracle.com/technology/obe/ADFBC_tutorial_1013/ADFBC_tutorial.pdf), and I keep running into typos that are af

  • What T.code to see the development server logos?

    Hi, What T.code to see the development server logos? thanks in advance raja