FOR ALL ENTRIES IN Problem

Hello,
probably it is a silly problem, but can anybody tell me why this FOR ALL ENTRIES IN statement does not fill all the columns of my internal table?
At the end of the report only the columns LGOBE contains values.
data itab type zmm_t_alv.
select mardmatnr mardwerks mardlgort mardlabst
  maktspras maktmaktx
  into corresponding fields of table itab
  from mard inner join makt
    on mardmatnr = maktmatnr
where makt~spras = 'D'.
select lgobe
  into corresponding fields of table itab
  from t001l
  for all entries in itab
  where t001l~werks = itab-werks.
break-point.
Thanks,
Manuel

Please read the documentation aboutr for all entries
For all entries selects all records from a db table which correspond to the entries in an internal table, the result must be stored in a different table.
Otherwise use a loop at itab.
   select single ...
   modify itab
   endloop
Be careful with empty For all entries tables, it behave like a ranges table, no entry means no restriction and you get all records from the db table. That is a different behavior than the loop above.
Use   field1 field2 ... in corresponding fields of ....
If you specify only one field then you get only one result.
If you want one the field 'lgobe' then use into wa-lgobe and not the much slower into corresponding!
Siegfried

Similar Messages

  • Joins and use FOR ALL ENTRIES

    Two questions :
    <b>(1) I use join with for all entries: the performance will go down?:</b>
    SELECT t1~MBLNR t1~MJAHR ZEILE BUDAT
    INTO TABLE gt_mseg
    FROM MSEG as T1 INNER JOIN MKPF AS T2
    ON T1~MBLNR = T2~MBLNR and
       T2~MJAHR = T2~MJAHR
    FOR ALL ENTRIES IN gt_coss
    WHERE  T1~MJAHR = gt_coss-GJAHR AND
           T1~AUFNR = gt_coss-aufnr AND
           ( BWART = '261' OR
             BWART = '262' ) AND
           T2~BUDAT IN r_budat.
    <b>(2)  With "For all entries", if itab is too long, performance will go down?. In affirmative case. What  can I do?</b>

    Hi Jose,
    You'll have to make sure your global table gt_coss isn't empty.
    A nasty little habit of the IN statement (for all entries is a kind of IN statement)
    is that when it is empty, the system selekts all records.
    You might know this when u use Select-Options in your statement (like r_budat).
    Also there is an OSS note on he for all entries (531337) problems on i-series database.
    Greetings Fred.

  • Performance Problems with "For all Entries" and a big internal table

    We have big Performance Problems with following Statement:
    SELECT * FROM zeedmt_zmon INTO TABLE gt_zmon_help
      FOR ALL ENTRIES IN gt_zmon_help
        WHERE
        status = 'IAI200' AND
        logdat IN gs_dat AND
        ztrack = gt_zmon_help-ztrack.
    In the internal table gt_zmon_help are over 1000000 entries.
    Anyone an Idea how to improve the Performance?
    Thank you!

    >
    Matthias Weisensel wrote:
    > We have big Performance Problems with following Statement:
    >
    >  
    SELECT * FROM zeedmt_zmon INTO TABLE gt_zmon_help
    >   FOR ALL ENTRIES IN gt_zmon_help
    >     WHERE
    >     status = 'IAI200' AND
    >     logdat IN gs_dat AND
    >     ztrack = gt_zmon_help-ztrack.
    >
    > In the internal table gt_zmon_help are over 1000000 entries.
    > Anyone an Idea how to improve the Performance?
    >
    > Thank you!
    You can't expect miracles.  With over a million entries in your itab any select is going to take a bit of time. Do you really need all these records in the itab?  How many records is the select bringing back?  I'm assuming that you have got and are using indexes on your ZEEDMT_ZMON table. 
    In this situation, I'd first of all try to think of another way of running the query and restricting the amount of data, but if this were not possible I'd just run it in the background and accept that it is going to take a long time.

  • For all entries problem

    Hi experts,
    I have a below statement in my code
    "SELECT on EKPO for all entries on ITAB (which is having 4 hundread thousand recods )"
    giving dump saying "MEMORY_PGFREE_FAILED"  and "Error releasing memory block in paging"
    i need your suggestion to avoid the memory problem
    "MEMORY_PGFREE_FAILED" ?
    can we go ahead with EXTRACT logic, does this solve the memory problem?
    thoughts will be appriciated,
    Thanks,
    Shaik bhasha

    See the example code :
    REPORT  ZSPFLI  LINE-SIZE 132 LINE-COUNT 65(3)
                                                 NO STANDARD PAGE HEADING.
    TABLES:SPFLI,SCARR, SFLIGHT, SBOOK.
    SELECT-OPTIONS: MYCARRID FOR SPFLI-CARRID.
    FIELD-GROUPS: HEADER, SPFLI_FG, SFLIGHT_FG, SBOOK_FG.
    INSERT:
            SPFLI-CARRID
            SPFLI-CONNID
            SFLIGHT-FLDATE
            SBOOK-BOOKID
           INTO HEADER,
            SPFLI-CARRID
            SPFLI-CONNID
            SPFLI-CITYFROM
            SPFLI-AIRPFROM
            SPFLI-CITYTO
            SPFLI-AIRPTO
            SPFLI-DEPTIME
            SCARR-CARRNAME
          INTO SPFLI_FG,
            SFLIGHT-FLDATE
            SFLIGHT-SEATSMAX
            SFLIGHT-SEATSOCC
            SFLIGHT-PRICE
          INTO SFLIGHT_FG,
            SBOOK-BOOKID
            SBOOK-CUSTOMID
            SBOOK-CUSTTYPE
            SBOOK-SMOKER
           INTO SBOOK_FG.
    SELECT * FROM SPFLI WHERE CARRID IN MYCARRID.
      SELECT SINGLE * FROM SCARR WHERE CARRID = SPFLI-CARRID.
      EXTRACT SPFLI_FG.
      SELECT * FROM SFLIGHT
       WHERE CARRID = SPFLI-CARRID AND  CONNID = SPFLI-CONNID.
        EXTRACT SFLIGHT_FG.
        SELECT * FROM SBOOK
               WHERE CARRID = SFLIGHT-CARRID AND
               CONNID = SFLIGHT-CONNID AND FLDATE = SFLIGHT-FLDATE.
          EXTRACT SBOOK_FG.
          CLEAR SBOOK.
        ENDSELECT.
        CLEAR SFLIGHT.
      ENDSELECT.
      CLEAR SPFLI.
    ENDSELECT.
    SORT.
    LOOP.
      AT SPFLI_FG.
        FORMAT COLOR COL_HEADING.
        WRITE: / SCARR-CARRNAME,
                 SPFLI-CONNID, SPFLI-CITYFROM,
                 SPFLI-AIRPFROM, SPFLI-CITYTO, SPFLI-AIRPTO, SPFLI-DEPTIME.
        FORMAT COLOR OFF.
      ENDAT.
      AT SFLIGHT_FG.
        WRITE: /15 SFLIGHT-FLDATE, SFLIGHT-PRICE, SFLIGHT-SEATSMAX,
                   SFLIGHT-SEATSOCC.
      ENDAT.
      AT SBOOK_FG.
        WRITE: /30 SBOOK-BOOKID, SBOOK-CUSTOMID,
                     SBOOK-CUSTTYPE, SBOOK-SMOKER.
      ENDAT.
    ENDLOOP.

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

  • Facin problems in the 'Select... for all entries'

    I am facing problem with this piece of code, please share ur thoughts on it. I have specified the inputs.
    I am extracting the open items from the BSIS table for specified 3 account number.
    Inputs to the prg:
    field     No. of values
    r_bukrs       1
    r_hkont      2
    r_blart     6
    r_budat  date range of 1 yr
    r_bldat  nil
    v_tosdef contain 1 account number
    " In each FI document posted, one line will have the 'v_tosdef' account number and one account from the 'r_hkont' values."
    So will this query efficient.
      SELECT bukrs
             hkont
             gjahr
             belnr
             budat
             bldat
             xblnr
             blart
             shkzg
             dmbtr
        FROM bsis
        INTO TABLE i_bsis
       WHERE bukrs IN r_bukrs                    " Company code
         AND hkont =  v_tosdef                  " Account number
         AND budat IN r_budat                    " Posting date
         AND bldat IN r_bldat                    " Document date
         AND blart IN r_blart.                   " Document type
      IF sy-subrc <> 0.
        MESSAGE i003.
        STOP.
      ENDIF.
    *@ Collecting the BELNR & GJAHR From the extracted records
      li_bsis[] = i_bsis[].
      SORT li_bsis BY bukrs gjahr belnr.
      DELETE ADJACENT
      DUPLICATES FROM li_bsis
            COMPARING bukrs gjahr belnr.
      IF NOT li_bsis[] IS INITIAL.
        SELECT bukrs
               hkont
               gjahr
               belnr
               budat
               bldat
               xblnr
               blart
               shkzg
               dmbtr
          FROM bsis
    APPENDING TABLE i_bsis
           FOR ALL ENTRIES IN li_bsis
         WHERE bukrs = li_bsis-bukrs               " Company code
           AND hkont IN r_hkont                    " Account number
           AND gjahr =  li_bsis-gjahr              " Fiscal year
           AND belnr =  li_bsis-belnr.             " Document num
    BSIS table size around 86GB
    primary index size aroung 33GB
    and the index quality is 54%
    the CBO shows less cost, but the actual runs takes too much disk read's / bgets..
    Message was edited by:
            Sandy

    Hi Sandy,
    You indicated the size of the tables and index, what is the total number of records in your BSIS?
    In your range tables, make sure they are postive formed.
    Ex. r_bukrs :  I EQ '1001', and not I NE '1000'.
    You should consider coding your statements to check for input for bldat, code it with r_bldat and then another set without. It should be better performance to not have empty where conditions. So two routines, Selects with bldat and without.
    Don't know if you have a Basis person to help analyze the performance, but you should look at the indexes in BSIS. You may have several indexes that contain some of your input fields but they may be spread across several indexes or there may be none. But say you have 5 indexes and it happens that just one of your parameters are in each of those indexes. Well, it can only use one index so while you think you are providing alot of parameters to help performance only one field is being used to access the index. What you need to do then is to find an index that has the most fields in your where clause and see if you can add to that, so long it's not an SAP index. If it's a z index consider adding additional fields to it, or consider creating a new index.
    You can at least analyze the first Select in your DEV client. Run a trace, ST05 and then execute your code. It will show you which index it has used if any.
    Also, look at the query values it is passing to the database. You said you get 6 M records on the first Select. This just seem like a lot of records, which is for just one account number (v_tosdef) along with the other parameters. I'm wondering if there's a problem with your input data. With 6M in your first table, your FOR ALL ENTRIES statement will be executed 1.2 million times. Tyically the database interface breaks down your Select-For All entries statement into 5 records per query. Again, run ST05 and you will see this.
    In SE16, on your BSIS table, what is your count of records if you enter only the account number?
    As a test, you might want to try entering all your parameters in SE16, run ST05 to trace the SQL to see what it is doing. You may have to kill your SE16 session or it may time out on you. You can stop your ST05 trace before your SE16 finishes and it will still show how SAP is going after the data and what index it used.
    Let me know if this helped any.
    Regards,
    Filler

  • Problem with FOR ALL ENTRIES statement

    Hi all
    please find the problem in the select statement.
    SELECT vbbe~vbeln
             vbap~vstel
             marc~dispo
             vbbe~matnr
             vbbe~kunnr
             vbbe~werks
             vbbe~mbdat
             vbbe~omeng
      INTO TABLE l_t_dvbeln
      FROM vbbe
      INNER JOIN vbak
      ON
      vbbe~vbeln = vbak~vbeln
      inner join vbap
      on
      vbbe~vbeln = vbap~vbeln and
      vbbe~matnr = vbap~matnr
      inner join marc
      on
      vbbe~matnr = marc~matnr and
      vbbe~werks = marc~werks
      FOR ALL entries IN g_t_stock
      WHERE vbbe~matnr = g_t_stock-matnr
      AND   vbbe~werks = g_t_stock-werks
      AND   vbak~vkorg = g_t_stock-vkorg
      AND   vbak~vtweg = g_t_stock-vtweg
      AND   vbbe~kunnr = g_t_stock-kunnr
      AND   vbbe~mbdat IN r_mbdat.
    g_t_stock is having only one record i.e.,
    g_t_stock-vstel = 'DF01'.
    g_t_stock-dispo = 'DEI'.
    g_t_stock-matnr = '00100833'.
    g_t_stock-maktx = 'SAC (300X400)'.
    g_t_stock-kunnr = '0000600431'.
    g_t_stock-werks = 'PF71'.
    g_t_stock-labst = '7727'.
    g_t_stock-vkorg = 'SF71'.
    g_t_stock-vtweg = 'IC'.
    and r_mbdat has the date range as
    r_mbdat-sign = I
    r_mbdat-option = BT
    r_mbdat-low = 15.05.2008
    r_mbdat-high =  08.06.2008
    In vbak vbap & marc tables i have only one record as per the above selection criteria.
    in VBBE table i have 7 records which satisfies the above criteria. But the select staement retrieves only 5 records.
    if we remove for all entries and hardcode the values in the select statement then it retrieves all 7 records.
    can anybody help me.
    what is the reason it is showing only 5 records.

    Hi all
    actually it has to retrieve the following records
    VBELN      MATNR    KUNNR WERKS  MBDAT    LABST
    30001417     00100833     600431  PF71   15.05.2008   20.000
    30001417     00100833     600431  PF71   15.05.2008   20.000
    30001417     00100833     600431  PF71   22.05.2008   5.000
    30001417     00100833     600431  PF71   22.05.2008   7.000
    30001417     00100833     600431  PF71   27.05.2008  10.000
    30001417     00100833     600431  PF71   27.05.2008  10.000
    30001417     00100833     600431  PF71   29.05.2008  10.000
    But it is retrieving only 5 records as below
    VBELN      MATNR    KUNNR WERKS  MBDAT    LABST
    30001417     00100833     600431  PF71   15.05.2008   20.000
    30001417     00100833     600431  PF71   22.05.2008   5.000
    30001417     00100833     600431  PF71   22.05.2008   7.000
    30001417     00100833     600431  PF71   27.05.2008  10.000
    30001417     00100833     600431  PF71   29.05.2008  10.000
    Please give the reason

  • Problem in FOR ALL ENTRIES IN statement

    Hi Abaper,
    I have a problem in FOR ALL ENTRIES IN statement.
    I have a table /ccsht/na_estadi in this table for the particulat date there are 14 records, but my internal table read only 5 record.
    Below is my code:
    SELECT sociedad
             xhotel_id
        FROM /ccsht/mt_photel
        INTO TABLE it_comp_hotel
       WHERE sociedad IN  p_comp
         AND xhotel_id IN p_hotid.
    BREAK-POINT.
    SORT it_comp_hotel BY sociedad.
    SELECT xhotel_id
             xfecha_id
             xocupacion
             tot_habs_hotel
             xnum_pax1
       FROM /ccsht/na_estadi
       INTO TABLE it_estadi "CORRESPONDING FIELDS OF TABLE it_estadi
        FOR ALL ENTRIES IN it_comp_hotel
      WHERE xhotel_id EQ it_comp_hotel-xhotel_id
        AND xfecha_id IN p_date.
    Can any one help me this issue.
    Thanks in advance.
    Thanks & Regards,
    Amit

    Hi Amit,
    Try below
    SELECT sociedad
    xhotel_id
    FROM /ccsht/mt_photel
    INTO TABLE it_comp_hotel
    WHERE sociedad IN p_comp
    AND xhotel_id IN p_hotid.
    BREAK-POINT.
    * SORT it_comp_hotel BY sociedad.  "Remove this SORT statement.
    SELECT xhotel_id
    xfecha_id
    xocupacion
    tot_habs_hotel
    xnum_pax1
    FROM /ccsht/na_estadi
    INTO TABLE it_estadi
    FOR ALL ENTRIES IN it_comp_hotel
    WHERE xhotel_id EQ it_comp_hotel-xhotel_id
    AND xfecha_id IN p_date.
    Note: 1) i didn't find the these tables in my SAP system
             2) If your table is still not fetching the data, tell me is it the Cluster table,. if yes,.. you need to
                 maintain the all the primary keys other wise you wont get the data in internal able.
    hope this will help you out.
    Regards!

  • Alternative for / Problems with: "For all entries in data_package"

    Hi Guys
    I doing some ABAP in a Start Rotine in BW and would like to do the following:
      select * from /BI0/PMATERIAL into table 0mat
      for all entries in DATA_PACKAGE
      where material = DATA_PACKAGE-/bic/zmaterial.
    But I get the following error:
    E:When using the addition "FOR ALL ENTRIES IN itab", the fields "MATERIAL" and "DATA_PACKAGE-/BIC/ZMATERIAL" must have the same type and length. and length.
    ZMATERIAL:
    - Length: 28
    - Type: CHAR - Character String
    ZMATERIAL:
    - Length: 18
    - Type: CHAR - Character String
    According to the error message "For all entries" cannot be used in this case since the lengths are not identical, but is there an alternative way to do what I would like to do?
    Thanks in advance, kind regards,
    Torben

    Hi
    one thing you can try like this define one variable in other itab of same type
    then loop at the first table and assign it to new field and modify the itab
    then use this field with for all entries
    Regards
    Shiva

  • Problem in using for all entries

    Hi,
    I am populating one field of an internal table for all entries existing in that internal table.That field is getting populated but rest of the fields changed to its default values. 
    Please check the code
    SELECT amatnr awerk almenge01 almenge02 almenge03 almenge04 almenge05 almenge06 a~lmenge07
           almenge08 aprueflos aart acharg bvcode bvdatum
        INTO CORRESPONDING FIELDS OF TABLE i_out
        FROM qals AS a INNER JOIN qave AS b
               ON aprueflos = bprueflos
        WHERE a~matnr IN s_matnr
          AND a~werk IN s_werk
          AND a~art IN s_art
         AND a~stat33 = 'X'
          AND b~vcodegrp IN s_vcdgrp
          AND b~vcode IN s_vcode
          AND b~vdatum IN s_vdatum.
    I am getting error here i_out is getting populated in teh first select statement
      SELECT mncod
             INTO CORRESPONDING FIELDS OF TABLE i_out
             FROM qmsm
             FOR ALL ENTRIES IN i_out
             WHERE qmnum = i_out-qmnum.

    Try changing your query in the following way....
    SELECT a~matnr a~werk a~lmenge01 a~lmenge02 a~lmenge03 a~lmenge04
    a~lmenge05 a~lmenge06 a~lmenge07
    a~lmenge08 a~prueflos a~art a~charg b~vcode b~vdatum
    <b>c~mncod</b>
    FROM qals AS a INNER JOIN qave AS b
    ON a~prueflos = b~prueflos
    <b>join qmsm as c
    ON a~prueflos = c~qmnum</b>
    INTO CORRESPONDING FIELDS OF TABLE i_out
    WHERE a~matnr IN s_matnr
    AND a~werk IN s_werk
    AND a~art IN s_art
    * AND a~stat33 = 'X'
    AND b~vcodegrp IN s_vcdgrp
    AND b~vcode IN s_vcode
    AND b~vdatum IN s_vdatum.
    with the above you can do the two steps only once .
    you need not to go for for all entries .
    Regards
    vijay

  • Problem with FOR ALL ENTRIES IN

    This is my simple source code.
    TABLES: stpo.
    DATA:  t_stpo      LIKE  stpo  OCCURS 0 WITH HEADER LINE,
    t_stpo_itm      LIKE  stpo  OCCURS 0 WITH HEADER LINE,
    t_stpo-stlnr = '00000058'.
    t_stpo-stlkn = '00000003'.
    append t_stpo.
    t_stpo-stlnr = '00000058'.
    t_stpo-stlkn = '00000007'.
    append t_stpo.
    SELECT * FROM stpo INTO TABLE t_stpo_itm
    FOR ALL ENTRIES IN t_stpo
    WHERE stlnr =  t_stpo-stlnr        " BOM No.
      AND stlkn <> t_stpo-stlkn.       " BOM item node number
    The output from this source including BOM item node number 00000003, 00000007 but at SQL stlkn <> t_stpo-stlkn doesn't effected.
    Could Anyone please tell me why?
    Are there something wrong?
    Thank you in advance.

    Hi,
    You can also Use ranges for Stlnr and Stlkn fields, instead of int table.
    TABLES: stpo.
    DATA: begin of  t_stpo OCCURS 0.
                  stlnr like stpo-stlnr,
                  stlkn  like stpo-stlkn,
                  end of t_stpo.
    data t_stpo_itm LIKE stpo OCCURS 0 WITH HEADER LINE.
    t_stpo-stlnr = '00000058'.
    t_stpo-stlkn = '00000003'.
    append t_stpo.
    clear t_stpo.
    t_stpo-stlnr = '00000058'.
    t_stpo-stlkn = '00000007'.
    append t_stpo.
    clear t_stpo.
    if not t_stpo[] is initial.
    SELECT * FROM stpo INTO TABLE t_stpo_itm
    FOR ALL ENTRIES IN t_stpo
    WHERE stlnr = t_stpo-stlnr " BOM No.
    AND stlkn <> t_stpo-stlkn. " BOM item node number
    endif.
    or you can simply write a select for STPO like this:
    SELECT * FROM stpo INTO TABLE t_stpo_itm
    WHERE stlnr = '00000058' " BOM No.
    AND ( stlkn <> '00000007' or stlkn <>  '00000003' ). " BOM item node number
    regards,
    Anji

  • Problem with for all entries

    Hi all,
       When i was trying to use for all entries, i am not able to pull records inside my internal table. Though both of the tables have the common key fields between them(and ofcourse have entries in that). Now what i have analyzed was, the first table is having 7 primary keys and the one i am using for 'for all entries' comes 6th. Does this gives any impact in pulling records inside my internal table?.Else please give me a possible solution for this. The alternate statement(a normal select query with * ) that i had used for this reserved my dialog processor for a while. Which resulted in 'time exceeded' short dump.

    Hi,
    The WHERE clause of the SELECT statement has a special variant that allows you to derive conditions from the lines and columns of an internal table:
    SELECT ... FOR ALL ENTRIES IN <itab> WHERE <cond> ...
    <cond> may be formulated as described above. If you specify a field of the internal table <itab> as an operand in a condition, you address all lines of the internal table. The comparison is then performed for each line of the internal table. For each line, the system selects the lines from the database table that satisfy the condition. The result set of the SELECT statement is the union of the individual selections for each line of the internal table. Duplicate lines are automatically eliminated from the result set. If <itab> is empty, the addition FOR ALL ENTRIES is disregarded, and all entries are read.
    The internal table <itab> must have a structured line type, and each field that occurs in the condition <cond> must be compatible with the column of the database with which it is compared. Do not use the operators LIKE, BETWEEN, and IN in comparisons using internal table fields. You may not use the ORDER BY clause in the same SELECT statement.
    You can use the option FOR ALL ENTRIES to replace nested select loops by operations on internal tables. This can significantly improve the performance for large sets of selected data.
    Hope this is useful
    Reema

  • Select ... for all entries problem

    Hi,
    I'm making select statements to BKPF and BSEG, but I can't do an inner join between this two table because BSEG it's a cluster table so I have to do a SELECT... FOR ALL ENTRIES, but in SE16 I make the same query that I have writen in my program as shown below,
    SELECT BUKRS BELNR GJAHR BUDAT MONAT
    FROM BKPF INTO CORRESPONDING FIELDS OF TABLE it_bkpf
    WHERE  BUKRS  = 'XXX'
    AND        GJAHR  = '2005'
    AND        BELNR  = '0000000250'. "just for proof
    AND        MONAT = '10'
    The above query returns me 1 row in program and in SE16 and then I make the next query for BSEG to do the join
    SELECT BUKRS BELNR GJAHR BSCHL SHKZG WRBTR HKONT
    FROM BSEG INTO CORRESPONDING FIELDS OF TABLE IT_BSEG
    FOR ALL ENTRIES IN it_bkpf
    WHERE bukrs = it_bkpf-bukrs
    and gjahr = it_bkpf-gjahr
    and belnr = it_bkpf-belnr.
    this query returns 897 rows and in SE16 this same query returns 901 rows
    Why SELECT...FOR ALL ENTRIES brings me less rows affected by the query in SE16
    Thanks for your help!!

    Hi,
      Please use the following code for selcting the exact number of rows.
    IF it_bkpf[] IS NOT INITIAL.
      SELECT *
      FROM BSEG INTO CORRESPONDING FIELDS OF   TABLE    IT_BSEG
    FOR ALL ENTRIES IN it_bkpf
    WHERE bukrs = it_bkpf-bukrs
    and gjahr = it_bkpf-gjahr
    and belnr = it_bkpf-belnr.
    ENDIF.
    Instead of * ,you can specify the exact fields required along with all the key fields as selection fields.Also it is must to check the condition it_bkpf[] IS NOT INITIAL before using the statement FOR ALL ENTRIES IN it_bkpf.Suppose if this condition is not used and if it_bkpf is initial,it will fetch all entries from the table.
    Reward if helpful.
    Regards,
    Aravind

  • Problem with for all entries in select querry

    hi,
    Hi,
    I am using select queery like this
    SELECT  version  COUNT( * ) 
    from ztbi_default_va4
    INTO  CORRESPONDING FIELDS OF TABLE   lit_new 
    FOR ALL ENTRIES IN lit_new1
    WHERE network = lit_new1-network GROUP BY version.
    this is not working showing error as:
    The addition "FOR ALL ENTRIES" excludes all aggregate functions with          
    the exception of "COUNT( * )" as the single element of the SELECT     clause.     
    I am using only count(*) ,not using othes like max,min etc,,,,,,,,,
    please suggest any missing in syntax,,,,attach relavant code using count(*) with for all entreis
    any help appriciated,,,,,
    Thanks in advance,,,,

    Hi,
    Try this -
    TYPES: begin of t_data,
                 version TYPE version,
                 count    type i,
                 end of t_data.
    DATA: i_data TYPE STANDARD TABLE OF t_data,
               wa_data TYPE t_data.
    DATA: l_version TYPE version,
               l_count TYPE i.
    SELECT  version  COUNT( * ) 
    from ztbi_default_va4
    INTO  CORRESPONDING FIELDS OF TABLE   lit_new 
    FOR ALL ENTRIES IN lit_new1
    WHERE network = lit_new1-network.
    SORT lit_new.
    LOOP AT lit_new INTO lwa_new.
        IF lwa_new EQ l_version.
          l_count = l_count + 1.
        ELSE.
          wa_data-version = l_version.
          wa_data-count = l_count + 1.
          APPEND wa_data TO i_data.
          CLEAR: wa_data.
          CLEAR: l_count.
        ENDIF.
        l_version = lwa_new-version.
        CLEAR: lwa_new.
    I hope this will do.
    Make any necessary changes.
    Regards,
    Harsh Bansal

  • Problem in getting records using FOR ALL ENTRIES

    Hi All,
    I am bringing the employee details with required selection criteria into an internal master table IT_EMPDETAILS.
    Now, I would want to fill the other columns of this internal table, using FOR ALL ENTRIES as  below:
      SELECT ZRCODE FROM PA9001
      INTO CORRESPONDING FIELDS OF TABLE IT_EMPDETAILS
      FOR ALL ENTRIES IN IT_EMPDETAILS
      WHERE   PERNR = IT_EMPDETAILS-PERNR
          AND ENDDA = '99991231'.
    but while i use this, it is actually clearing the IT_EMPDETAILS instead of filling the column of IT_EMPDETAILS table.
    what could be going wrong??
    Thanks in advance,
    Mohan

    Dear All,
    Thanks for the amazing replies, yesterday's world cup match is really doing wonders i guess!
    To give more insight at what i am looking for and what is done so far:
    I tried creating another Internal table and then filled that with only PERNR.
    and then using that. tried to fill IT_EMPDETAILS internal table using for all entries,
    alas it did not work, and it did not work with APPENDING CORRESPONDING either.
    now, coming to using LOOP, if I use loop, I am going run the loop for 1lakh emp(approx..and going high everyday) and modify the internal table for 1lakh records. AND not only that, I am going to loop another 9 tables in similar manner. that is 9lakh loops AND thats not all,
    after that I have to again loop the master internal table to loop and fill other employee details like 'text' instead of 'code' from a master table.
    This is one of the most query intensive, realtime, online comprehensive employee report that i am making.
    Appreciate replies from ABAP performance tuning experts and gurus in advance.
    Cheers,
    Mohan

Maybe you are looking for