FOR ALL ENTRIES IN  comando doesent work !!!

Dear all,
I have here a problem with my select. I dont know why it doesent work. In the table gt_struc1 I have 2 entries.
This entries are also in BSAD availible.
belnr
bukrs
gjahr
are the same in  gt_struc1 and in BSAD
TYPES: BEGIN OF ts_struc1,
               bukrs        TYPE bukrs,
               gjahr        TYPE gjahr,
               belnr        TYPE belnr_d,
               prctr        TYPE prctr,
       END OF ts_struc1.
DATA: gt_struc1    TYPE TABLE OF ts_struc1,
            lt_tabelle      TYPE REF TO data.
*       BSAD
        CREATE DATA lt_tabelle TYPE STANDARD TABLE OF BSAD.
        ASSIGN lt_tabelle->* TO <ft_itab>.
*       Get data from DB
        SELECT * FROM bsad INTO TABLE <ft_itab>
        FOR ALL ENTRIES IN gt_struc1
          WHERE belnr EQ gt_struc1-belnr AND
                bukrs EQ gt_struc1-bukrs AND
                gjahr EQ gt_struc1-gjahr.

The gt_struc1is correct see blow:
* Über alle Datensätze
  LOOP AT lt_content
  ASSIGNING <fs_current_set>.
*   Ab welche Zeile
    CHECK sy-tabix >= pa_zeile.
*   Spliten der Daten
    SPLIT <fs_current_set> AT ';' INTO ls_struc1-bukrs
                                       ls_struc1-gjahr
                                       ls_struc1-belnr.
*   Siehe Selektionskriterien
    CHECK ls_struc1-bukrs IN pa_bukrs[].
    CHECK ls_struc1-gjahr IN pa_gjahr[].
    CHECK ls_struc1-belnr IN pa_belnr[].
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = ls_struc1-belnr
      IMPORTING
        output = ls_struc1-belnr.
    APPEND ls_struc1 TO gt_struc1.
  ENDLOOP.
Edited by: handeglo on Feb 26, 2010 10:29 AM

Similar Messages

  • Does 'For All Entries in itab' work exactly like 'Join' statement?

    Hi,
    I would like to know that if 'For All Entries in itab' work exactly like 'Join' statement?
    If yes, then when I use 'For All Entries in itab' and a 'Join' statement seperately with the same logical conditions for both, the number of records returned by the two methods are not same. Ideally, they should both return the same number of recs.
    Can somebody help?
    With regards.

    Hi,
    for all entries will not work in the same way unless untill it should satisfy some conditions,
    it has some pre-requisests...
    like in the select clause or in where clause or in both the cluases, there should be entire key..
    then only it will behave like the join statement..
    hope i am clear.
    please revert back if u have any quiries.
    Regards,
    Sunil Kumar Mutyala.

  • The select with for all entries is not working correctly

    IF NOT i_ekko_ekpo[] IS INITIAL.
        SELECT ebeln
               ebelp
               zekkn
               vgabe
               bewtp
               menge
               bpmng
               shkzg
               INTO TABLE i_ekbe
               FROM ekbe
               FOR ALL ENTRIES IN i_ekko_ekpo
               WHERE ebeln EQ i_ekko_ekpo-ebeln.
                AND ebelp EQ i_ekko_ekpo-ebelp.
        IF sy-subrc EQ 0.
          SORT i_ekbe.
        ENDIF.
      ENDIF.
    I have a PO with 2 line items in i_ekko_ekpo. In EKBE, I have 49 recs for this PO and this select is returning only 13 recs.
    I tried by commenting EBELP and still the same result.
    Thanks
    Kiran
    Edited by: kiran dasari on May 22, 2009 9:56 PM

    Hi Sudhi, I added these now but still no charm
        SELECT ebeln
               ebelp
               zekkn
               vgabe
               bewtp
               menge
               bpmng
               shkzg
               INTO TABLE i_ekbe
               FROM ekbe
               FOR ALL ENTRIES IN i_ekko_ekpo
               WHERE ebeln EQ i_ekko_ekpo-ebeln
                 AND ebelp EQ i_ekko_ekpo-ebelp
                 AND zekkn GE '00'
                 AND vgabe IN ('1','2').
    And as per your note: in the 13 entries, am having duplicate also. This is something weird for me now.
    Any more clues.
    Thanks
    Kiran

  • Performance issue with select query and for all entries.

    hi,
    i have a report to be performance tuned.
    the database table has around 20 million entries and 25 fields.
    so, the report fetches the distinct values of two fields using one select query.
    so, the first select query fetches around 150 entries from the table for 2 fields.
    then it applies some logic and eliminates some entries and makes entries around 80-90...
    and then it again applies the select query on the same table using for all entries applied on the internal table with 80-90 entries...
    in short,
    it accesses the same database table twice.
    so, i tried to get the database table in internal table and apply the logic on internal table and delete the unwanted entries.. but it gave me memory dump, and it wont take that huge amount of data into abap memory...
    is around 80-90 entries too much for using "for all entries"?
    the logic that is applied to eliminate the entries from internal table is too long, and hence cannot be converted into where clause to convert it into single select..
    i really cant find the way out...
    please help.

    chinmay kulkarni wrote:Chinmay,
    Even though you tried to ask the question with detailed explanation, unfortunately it is still not clear.
    It is perfectly fine to access the same database twice. If that is working for you, I don't think there is any need to change the logic. As Rob mentioned, 80 or 8000 records is not a problem in "for all entries" clause.
    >
    > so, i tried to get the database table in internal table and apply the logic on internal table and delete the unwanted entries.. but it gave me memory dump, and it wont take that huge amount of data into abap memory...
    >
    It is not clear what you tried to do here. Did you try to bring all 20 million records into an internal table? That will certainly cause the program to short dump with memory shortage.
    > the logic that is applied to eliminate the entries from internal table is too long, and hence cannot be converted into where clause to convert it into single select..
    >
    That is fine. Actually, it is better (performance wise) to do much of the work in ABAP than writing a complex WHERE clause that might bog down the database.

  • For All Entries is NOT better than INNER JOIN in most cases

    I quote from Siegfried Boes' excellent post here: Will writing an inner join be better or creating a view?
    For all the FOR ALL ENTRIES lovers ... there is no proof for these reappearing recommendation.
    There is nearly nobody who receives forum points, who recommends FOR ALL ENTRIES instead of Joins. What is the reason ???
    It is easier to prove the opposite. A Join is a nested loop inside the database, a FOR ALL ENTRIES is partly outside of the database. FOR ALL ENTRIES works in blocks, joins on totals.
    FOR ALL ENTRIES are not recommded on really large tables, because the chances are too high that
    too many records are transferred.
    People prefer FOR ALL ENTRIES, because JOINs are not so easy to understand. Joins can go wrong, but with a bit of understanding they can be fixed.
    Some Joins are slow and can not be fixed, but then the FOR ALL ENTRIES would be extremely slow.
    There are several kinds of views:
    - projection views, i.e. only one table involved just fields reduced
    - join views, several tables, joins conditions stored in dictionary
    - materialized views, here the joined data are actually stored in the database. Storing and synchronisation has to be done manually.
    Only the last one creates real overhead. It should be the exception.
    Join Views and Joins are nearly identical. The view is better for reuse. The join is better in complicated, becuase if the access goes wrong, it can often be fixed by adding a hint. Hints can not be added to views.
    Abraham Bukit  points out:
    If it is cluster table, (you can't use join). If it is buffered table, I would also say avoid join.
    If they all are transaction table which are not buffered and are not cluster tables.  
    He further supports Siegfried's statement that FAE is easier to undestand than INNER JOINs.
    Thomas Zloch says, regarding buffered tables:
    At least think twice, maybe compare runtimes if in doubt. 
    So, unless someone has some EVIDENCE that FOR ALL ENTRIES is better, I don't think we want to see this discussed further.
    Kind regards
    Matt

    To give food for thought here's an example I  gave in a thread:
    If you have a statement like
    SELECT ... FOR ALL ENTRIES IN FAE_itab WHERE f = FAE_itab-f.
    SAP sends it to the database depending how the parameter rsdb/prefer_union_all is set:
    rsdb/prefer_union_all = 0 =>
    SELECT ... WHERE f = FAE_itab[1]-f
              OR    f = FAE_itab[2]-f
              OR    f = FAE_itab[N]-f
    You have some influence  of the generated statement type: Instead of OR'ed fields an IN list can be used
    if you have only a single coulmn N to compare:
    rsdb/prefer_in_itab_opt parameter:
    SELECT ... WHERE f IN (itab[1]-f, itab[2]-f, ..., itab[N]-f)
    rsdb/prefer_union_all = 1 =>
    SELECT ... WHERE f = FAE_itab[1]-f
    UNION ALL SELECT ... WHERE f = FAE_itab[2]-f
    UNION ALL SELECT ... WHERE f = FAE_itab[N]-f
    see: Note 48230 - Parameters for the SELECT ... FOR ALL ENTRIES statement
    As you can see for the 2nd parameter several statements are generated and combined with a UNION ALL,
    the first setting generates statements with OR's (or uses IN  if possible) for the entries in FAE_itab.
    I give you a little example here (my parameters are set in a way that the OR's are translated to IN lists; i traced the execution in ST05)
    Select myid into table t_tabcount from mydbtable
      for all entries in t_table    " 484 entries
        where myid = t_table-myid .
    ST05 trace:
    |Transaction SEU_INT|Work process no 0|Proc.type  DIA|Client  200|User |
    |Duration |Obj. name |Op.    |Recs.|RC    |Statement|
    | 640|mydbtable |PREPARE|   |  0|SELECT WHERE "myid" IN ( :A0 , :A1 , :A2 , :A3 , :A4 ) AND "myid" = :A5|
    | 2|mydbtable |OPEN   |   |  0|SELECT WHERE "myid" IN ( 1 , 2 , 3 , 4 , 5 ) AND "myid" = 72 |
    | 2.536|mydbtable |FETCH  |    0|  1403|   |
    | 3|mydbtable |REOPEN |   |  0|SELECT WHERE "myid" IN ( 6 , 7 , 8 , 9 , 10 ) AND "myid" = 72 |
    | 118|mydbtable |FETCH  |  0|  |
    | 2|mydbtable |REOPEN |  |  0|SELECT WHERE "myid" IN ( 11 , 12 , 13 , 14 , 15 ) AND "myid" = 72     |
    | 3|mydbtable |REOPEN |  |  0|SELECT WHERE "myid" IN ( 475 , 476 , 477 , 478 , 479 ) AND "myid" = 72  |
    | 94|mydbtable |FETCH  | 0| 1403|   |
    | 2|mydbtable |REOPEN |   |  0|SELECT WHERE "myid" IN ( 480 , 481 , 482 , 483 , 484 ) AND "myid" = 72 |
    You see the IN list contained 5 entries each , wich made up about 97 statements for all 484 entries.
    For every statment you have a single fetch operation wich means a separate access to the database.
    If you would replace the FAE with a join you would only have one fetch to the database.
    With the example above we can derive these observations:
    1. From database point of view these settings kill performance when you access a big table and/or have a lot of entries or columns in your FAE_itab. Furthermore, you hide information what data you will access
    at all and thus you block the database from creating a more efficient execution plan because it DOESN'T KNOW wich data you will select in the next step. I.e. it may be more efficient to scan the table in one shot instead of having many index accesses - but the database can make this decision only if it can examine ONE statement that has ALL the information of what data to retrieve.
    2. A second impact is that with every statement execution you trigger the allocation of database resources
    wich will contribute to the overhead described above.
    Said that, FAE  can never be a replacement for joining big tables (think of having a table with thousands of records in a FAE table )
    Edited by: kishan P on Nov 2, 2010 2:16 PM - Format Fixed

  • For all entries

    I was under the impression that, while getting data from database table 'for all entries' always imporves performance. Since we are not getting whole database table data. I was doing a select statement and I have used for all entries. I have only 20,000 records in the internal table. While selecting data from database table, it took more than one hour and timed out.
    Latter, I hard coded some values and query worked and it just took few minutes.
    So, do we need to avoid for all entries? What the best practice?
    For more details Please check the code:
    Source package has only 20,000 records and while getting data it timed out. So I commented for all entries and hardcoded the values. This time it took only few minutes. Can any one suggest the best practice for handling such things?
        IF SOURCE_PACKAGE[] IS NOT INITIAL.
          SELECT
            CALMONTH
            CALYEAR
            COMPANY
            /BIC/XPROF_CTR
            PCOMPANY
            /BIC/ZPRODASGN
            /BIC/ZSLSRPTCD
            CURKEY_TC
            UNIT
            GL_ACCOUNT
            MATERIAL
            FUNC_AREA
            COSTCENTER
            WBS_ELEMT
            CURKEY_LC
            /BIC/ZTEMPKEY
            QUANTITY
            /BIC/ZAMT_REP
            /BIC/ZSALETYP
          FROM
          /BIC/AZGMROA1400
          INTO TABLE IT_SOURCE_TMP
         FOR ALL ENTRIES IN SOURCE_PACKAGE
          WHERE
                CALMONTH       BETWEEN CMONTH1 AND CMONTH2 AND
                CALYEAR        = CURR_YEAR AND
               COMPANY        = SOURCE_PACKAGE-COMPANY AND
               /BIC/XPROF_CTR = SOURCE_PACKAGE-/BIC/XPROF_CTR AND
               PCOMPANY       = SOURCE_PACKAGE-PCOMPANY AND
               /BIC/ZPRODASGN = SOURCE_PACKAGE-/BIC/ZPRODASGN AND
               /BIC/ZSLSRPTCD = SOURCE_PACKAGE-/BIC/ZSLSRPTCD AND
               CURKEY_TC      = SOURCE_PACKAGE-CURKEY_TC AND
               UNIT           = SOURCE_PACKAGE-UNIT AND
               GL_ACCOUNT     = SOURCE_PACKAGE-GL_ACCOUNT AND
                MATERIAL       = SOURCE_PACKAGE-MATERIAL AND
                /BIC/ZSALETYP  in ('TS', 'CG', 'IS', 'IC',
                                   'TO', 'FG', 'OD', 'SS',
                                   'RD', 'I3', 'D1', 'D2',
                                   'D3', 'MS', 'PF', 'RA') .
               FUNC_AREA      = SOURCE_PACKAGE-FUNC_AREA AND
               COSTCENTER     = SOURCE_PACKAGE-COSTCENTER AND
               WBS_ELEMT      = SOURCE_PACKAGE-WBS_ELEMT AND
               CURKEY_LC      = SOURCE_PACKAGE-CURKEY_LC and
               /BIC/ZACCOUNT       = SOURCE_PACKAGE-/BIC/ZACCOUNT .
        ENDIF.

    Hi,
    if you have a statement like
    SELECT ... FOR ALL ENTRIES IN FAE_itab WHERE f = FAE_itab-f.
    SAP sends it to the database depending how the parameter rsdb/prefer_union_all is set:
    rsdb/prefer_union_all = 0 =>
    SELECT ... WHERE f = FAE_itab[1]-f
              OR    f = FAE_itab[2]-f
              OR    f = FAE_itab[N]-f
    You have some small influence of the number of generated statements in the case of  OR'ed  taht an IN list should be used  by
    rsdb/prefer_in_itab_opt parameter:
    SELECT ... WHERE f IN (itab[1]-f, itab[2]-f, ..., itab[N]-f)
    rsdb/prefer_union_all = 1 =>
    SELECT ... WHERE f = FAE_itab[1]-f
    UNION ALL SELECT ... WHERE f = FAE_itab[2]-f
    UNION ALL SELECT ... WHERE f = FAE_itab[N]-f
    see: Note 48230 - Parameters for the SELECT ... FOR ALL ENTRIES statement
    As you can see that the last setting generates several statements and combine them with a UNION ALL,
    the first setting generates a statement with OR's (or uses IN list) for the entries in FAE_itab.
    I give you a little example here (my parameters are set in a way that the OR's are translated to IN lists; i traced the execution in  ST05)
    Select myid into table t_tabcount from mydbtable
      for all entries in t_table    " 484 entries
        where myid = t_table-myid
        and myid = 72.
    ST05 trace:
    |Transaction SEU_INT|Work process no 0|Proc.type  DIA|Client  200|User     |
    |Duration |Obj. name |Op.    |Recs.|RC    |Statement                                                                                |
    |      640|mydbtable |PREPARE|     |     0|SELECT WHERE "myid" IN ( :A0 , :A1 , :A2 , :A3 , :A4 ) AND "myid" = :A5                                                                                |
    |        2|mydbtable |OPEN   |     |     0|SELECT WHERE "myid" IN ( 1 , 2 , 3 , 4 , 5 ) AND "myid" = 72                                                                                |
    |    2.536|mydbtable |FETCH  |    0|  1403|                                                                                |
    |        3|mydbtable |REOPEN |     |     0|SELECT WHERE "myid" IN ( 6 , 7 , 8 , 9 , 10 ) AND "myid" = 72                                                                                |
    |      118|mydbtable |FETCH  |    0|  1403|                                                                                |
    |        2|mydbtable |REOPEN |     |     0|SELECT WHERE "myid" IN ( 11 , 12 , 13 , 14 , 15 ) AND "myid" = 72                                                                                |
    |        3|mydbtable |REOPEN |     |     0|SELECT WHERE "myid" IN ( 475 , 476 , 477 , 478 , 479 ) AND "myid" = 72                                                                                |
    |       94|mydbtable |FETCH  |    0|  1403|                                                                                |
    |        2|mydbtable |REOPEN |     |     0|SELECT WHERE "myid" IN ( 480 , 481 , 482 , 483 , 484 ) AND "myid" = 72                                                                                |
    You see the IN list contained 5 entries each  , wich made up about 97 statements for all 484 entries.
    From database point of view these settings kill performance when you have a lot of entries and/or
    a lot of columns in your FAE_itab.
    Said that, FAE i.e. can never be a replacement for joining big tables (think of having a table with thousands of records in a FAE table like you had)
    If you say now that you completly threw away the FAE table of 20.000 entries it is no wonder
    that it performs better. 20.000 records is not a small number if you create a lot of UNION's or OR's / IN lists  that way!
    Your original statement is a good example for the abuse of a FAE. In the SAP Notes this is the core problem with FAE besides empty FAE tables.
    It's safe to use a FAE_itab table if the expected entries count is small (i.e. << 100).
    What you have to decide is if it's more advantagous to
    retrieve the FAE_tabs data once and executing other statements with the SAME FAE table in the same program to reuse it
    or having additional roundtrips to the database if you don't use FAE tables at all
    Bye
    yk

  • Max no of records in for all entries table

    Hello all,
    Hi have used for all entries in a select statement in BW extractor. This extractor is working fine for the test data. When i moved this code to pre-production for testing, there this extractor has to deal with thousands of records. In pre-prod , this select statement is not picking up all the records available in DB. Can any one give any idea on behavior of for all entries for large number of records. and is the any max limit for for all entries table.
    Thank you..correct answer will be rewarded.
    Regards
    Sravan

    Moderator message - Please search before asking and do not offer rewards (particularly since as far as I can see, you've awarded a total of two points in the last two years - post locked
    Rob

  • Using for all entries of two internal tables in where clause of the select

    Hi experts,
    My requirement is, need to select Marc-minbe and wrpl-sobst, for all the entries of the two internal tables it_mara , and it_t001w.
    here is the select queries i have used,
    select matnr normt from  mara into it_mara for all entries in it_data where normt = it_data-normt.
    select konnr werks from t001w into it_t001w for all entries in it_data where konnr = it_data-konnr.
    now i need to select minbe of marc table and sobse of wrpl table for all the entries of above internal tables, it_mara and it_t001w, using both matnr of it_mara and werks of it_t001w in where condition.
    Pls advise how i can do it.
    Thanks.
    Moderator message: very basic, please work on this yourself first, these forums are not a substitute for ABAP training.
    Edited by: Thomas Zloch on Dec 6, 2010 9:38 AM

    Hi
    call SE16 with table TFTIT in order to get a full list (it will be long...)
    A list of FMs with parameters can be found in table FUNCT.
    Finally go to sm37rsdf4
    that will give you all the function modules with description
    Here is the list:
    http://www.erpgenie.com/abap/functions.htm
    hope this helps...
    Regards
    CSM Reddy

  • For all entries table handled by Tables parameter of Subroutine!

    Hi....
    See my code...
    Dont leave as it seems very big code... Actually its very small one...
    In sourse code of function module...
    data:itab1  type standard table of <local structure of top include> with header line,
                     itab2 type standrad table of knvp with header line.
    perform routine_data tables  itab1
                          using    p_var
    Subroutine code, saved in F include of that function group...
    form routine_data  tables itab1 type standard table
                               using    p_var
      select * from <db table>
                  into corresponding fields of table itab
                  where <keyfield> = p_var.
    endform.
    Back to source cod eof Function module..
    if sy-subrc is = 0.
        select parvw kunn2 kunnr from knvp
                            into corresponding fields of table itab2 for all entries in itab1
                             where kunnr = itab1-kunnr
                             and ( parvw = 'WE' or parvw = 'RE' or parvw = 'RG').
    endif.
    This code is working fine......
    ==================Now coming to my problem==========================
    In source code of function module...
    data:itab1  type standard table of <local structure of top include> with header line,
                     itab2 type standrad table of knvp with header line.
    perform routine_data tables  itab1
                                   using    p_var
    Subroutine code, saved in F include of that function group...
    form routine_data  tables itab1 type standard table
                               using    p_var
      select * from <db table>
                  into corresponding fields of table itab
                  where <keyfield> = p_var.
    endform.
    Function module source code...
    perform routine2_data tables itab1
                                     itab2.
    F include coding part for above subroutine....
    form routine2_data  tables itab1 type standard table
                                          itab2 type standard table
        select parvw kunn2 kunnr from knvp
                            into corresponding fields of table itab2 for all entries in itab1
                             where kunnr = itab1-kunnr                                         <-----causing error
                             and ( parvw = 'WE' or parvw = 'RE' or parvw = 'RG').
    endform.
    Giving error message....
    >>> The specified type has no structure and therefore no component called 'KUNNR".....
    So here the problem is there is a incorrect way to declare parameters....
    Plz remind that SUBROUTINES OF FUNCTION MODULES SAVING IN INCLUDE PROGRAMS, because they making some deffenrce with normal external subroutines...
    also...
    Here for all entries is mandatory!
    And Two sub routines are mandatory!
    Thanks for your attention...
    Naveen Inuganti.

    Hi ,
    Use the below  syntax to pass the tables as parameters
    *The below perform is in the source code of the F.M
    PERFORM goods_movement_post TABLES itab1
                                       itab2
                                       itab3
                                   USING ls_goodsmvt_header
                                         g_mov_code.
    suppose u are using the itab1 & itab2 tables data to get the itab3 Data 
    And The below code is in the Frms include
    FORM goods_movement_post
                      TABLES
                         pt_itab1 STRUCTURE vbak
                         pt_itab2 STRUCTURE vbap
                         pt_itab3 STRUCTURE bapiret2
                      USING
                         p_ls_goodsmvt_header STRUCTURE bapi2017_gm_head_01
                         p_g_mov_code.
    ENDFORM
    Thanks & Reagrds
    Mallikharjuna Reddy

  • Which is better group by or for all entries in

    We have more than 11 Lac Records in AUFM table.
    I am working on a Report to find SO to Production Order to AUFM (for raw material).
    It's ALV OOP.
    Which code will give better result - For AUFM fetch with key AUFNR.
    GROUP BY matnr
    OR
    FOR ALL ENTRIES IN it_previous
    Moderator message: too vague to give decent advice, please try yourself first and compare runtimes, re-post including all relevant information if required, please use international units only when posting again.
    Please Read before Posting in the Performance and Tuning Forum
    locked by: Thomas Zloch on Sep 8, 2010 10:13 AM

    that oracle wont work if we have group by on a column which is character data type instead of number data typeEither he has been taught wrongly OR he has come across one specific case where it seems that there was an issue but he doesn't know enough about that case and is making a generalisation.
    Hemant K Chitale

  • For all entries.... urgent Please respond !

    I have to select data from one view and 2 tables viz. VF_KRED, ADRC, ADR6.
    I have written following code for select statement. but it is not working.
    Please tell the correct code.
    Select
    stceg stcd2 name1 ort01 pstlz land1 telf1 telfx brsch sperr lifnr zterm
    from vf_kred into table int_create_vendor
    where bukrs IN s_bukrs OR ktokk IN s_ktokk OR lifnr IN s_lifnr.
    Select
    street house_num1
    from adrc
    into table int_create_vendor
    for all entries in int_adrc
    where adrnr EQ int_adrc-addrnumber.
    Select
    smtp_addr
    from adr6
    into table int_create_vendor
    for all entries in int_adrc
    where adrnr EQ int_adr6-addrnumber.

    Hi,
    whenever if we use for all entries we have to youe condition statement IF. check with previous table. have a look this code.
    Select
    stceg stcd2 name1 ort01 pstlz land1 telf1 telfx brsch sperr lifnr zterm
    from vf_kred into table int_create_vendor
    where bukrs IN s_bukrs OR ktokk IN s_ktokk OR lifnr IN s_lifnr.
    if not int_adrc[] is initial.
    Select
    street house_num1
    from adrc
    into table int_create_vendor
    for all entries in int_adrc
    where adrnr EQ int_adrc-addrnumber.
    Select
    smtp_addr
    from adr6
    into table int_create_vendor
    for all entries in int_adrc
    where adrnr EQ int_adr6-addrnumber.
    endif.
    regards.
    sriram.

  • Select... for all entries in...

    Hi,
    Can anybody help me to sort out this issue. This select should work. I m filling an itab with distinct pernr. in temp it should give <b>all the records for which pernr should not be in itab.</b>
    report ZTEST4.
    data : begin of ITAB occurs 0,
            PERNR like PA0001-PERNR,
            ename like pa0001-ename,
           end of ITAB.
    data : temp like itab occurs 0 with header line.
    clear : ITAB, TEMP.
    refresh : ITAB,TEMP.
    select distinct PERNR into table ITAB from PA0001 where PERNR le 10.
    select PERNR ENAME into table TEMP from PA0001
    for all entries in ITAB where pernr not in itab-pernr.
    sort TEMP by PERNR.
    break-point.

    Hi Sagar,
    If i understand it well, you exclude all PERNR LE 10.
    But first things first.
    You cannot use the FOR ALL ENTRIES in your case (it doesn't allow the operator "NOT IN").
    Your code should be:
    REPORT ztest4.
    TYPES: BEGIN OF ty_itab,
             pernr TYPE persno,
             ename TYPE emnam,
           END OF ty_itab.
    DATA : itab TYPE ty_itab occurs 0,
           wtab TYPE ty_itab.
    CLEAR: itab,
           wtab.
    SELECT pernr ename
         INTO TABLE itab
               FROM pa0001
              WHERE pernr LE 10
           ORDER BY pernr.
    IF sy-subrc EQ 0.
      DELETE ADJACENT DUPLICATES FROM itab COMPARING pernr.
    ENDIF.
    Regards,
    Rob.

  • Join table SUM using for all entries

    Dear All,
                Will anyone pls. tell me what is the problem in this query, it is not working.
        SELECT aufnr SUM( menge )
         INTO CORRESPONDING FIELDS OF TABLE itab_aufnr
         FROM mkpf
         INNER JOIN mseg ON msegmblnr EQ mkpfmblnr AND mkpfmjahr EQ msegmjahr
         FOR ALL ENTRIES IN itab_rework
          WHERE mseg~aufnr = itab_rework-aufnr
          GROUP BY aufnr.
    Regards,
    Moderator message: please search for available information before asking, "it's not working" is not a proper error description.
    Edited by: Thomas Zloch on Dec 6, 2010 9:41 AM

    When I have used it in loop it is taking so much time to execute.
    That depends upon the amount of data you are processing and the set of codes written inside the loop. For sum you have to use collect statement or a SUM statement inside a control break statement.

  • Selecting single value using for all entries.

    Hi Experts,
    I want to know that is it possible to fetch only the first record for a particular condition while using for all entries.
    For ex:
    Suppose i got 10 different vbeln from vbak table into my internal table it_vbak. For a particular vbeln there can be multiple records in vbap table.
    Now i need to fetch only the first record which is getting from vbap table for different vbeln while using 'for all entries in it_vbak where vbeln = it_vbak-vbeln'. Is it possible?
    Thanks in Advance
    Be$t!N
    Moderator message - Moved to the correct forum
    Edited by: Rob Burbank on Nov 17, 2009 9:38 AM

    Hi Rob Burbank,
    Thanks..
    You are correct.. If that is the scenario in their company... Again it depends on the configuration and business process.. But it's possible that they may need to delete first on any line item after creation of sale order..
    In that case below solution will work..
    IF IT_VBAK[] IS NOT INITIAL.
    SELECT * FROM VBAP
    INTO TABLE IT_VBAP
    for all entries in it_vbak
    where vbeln = it_vbak-vbeln.
    ENDIF.
    SORT IT_VBAP BY VBELN POSNR.
    LOOP AT IT_VBAK INTO WA_VBAK.
    READ TABLE IT_VBAP INTO WA_VBAP WITH KEY VBELN = WA_VBAK-VBELN.
    IF SY-SUBRC = 0.
    APPEND WA_VBAP TO IT_VBAP2. " Another Internal table which stores only first record
    ENDIF.
    CLEAR : WA_VBAP.
    ENDLOOP.
    OR
    IT_VBAP3[] = IT_VBAP[].
    SORT IT_VBAP3 BY VBELN POSNR.
    DELETE ADJACENT DUPLICATES FROM IT_VBAP3 COMPARING VBELN.
    Now Table IT_VBAP2 and IT_VBAP3 will be having only first line items for all sales orders..
    Do some little changes in the code as per your requirement.
    Hope it will solve your problem..
    Thanks & Regards
    ilesh 24x7
    ilesh Nandaniya

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

Maybe you are looking for