FOR ALL ENTRIES stmnt. in SELECT query is not running properly

Hello experts,
          In my report program, I write one query on table BSIS.
         Internal table declaration -             
       DATA : BEGIN OF DLC_BSIS OCCURS 0,
                        BUKRS LIKE BSIS-BUKRS,
                        GJAHR LIKE BSIS-GJAHR,
                        BELNR LIKE BSIS-BELNR,  
                        SHKZG LIKE BSIS-SHKZG,
                        BSCHL LIKE BSIS-BSCHL,
                        AUFNR LIKE BSIS-AUFNR,
                        HKONT LIKE BSIS-HKONT,
                        QSSKZ LIKE BSIS-QSSKZ,
                        DMBTR LIKE BSIS-DMBTR,
                   END OF DLC_BSIS.                                                                               
Query as follows --
         SELECT BUKRS
                       GJAHR
                       BELNR
                       AHKZG
                       BSCHL
                       AUFNR
                       HKONT
                       QSSKZ
                        DMBTR FROM BSIS
                                  INTO TABLE DLC_BSIS
                                 FOR ALL ENTRIES IN IT_BKPF2
                                 WHERE BELNR = IT_BKPF2-BELNR
                                              AND BUKRS = IT_BKPF2-BUKRS
                                              AND GJAHR = IT_BKPF2-GJAHR.
IT_BKPF2 internal table having -- BUKRS - LT01
                                                     BELNR - 6400000061
                                                     GJAHR - 2009.
And in BSIS database  table  -- 3 entries are there for the above documnet.
But, in my internal only one entry has come for the same above document.
I think For all entries stmnt. is not running properly. But Why it's not running properly.??
What would be the reason..??
Thanks in advance....!!
Regards,
Poonam.

>
Poonam Patil wrote:
> Hello experts,
>           In my report program, I write one query on table BSIS.
>
>          Internal table declaration -             
>                                            
>        DATA : BEGIN OF DLC_BSIS OCCURS 0,
>                         BUKRS LIKE BSIS-BUKRS,
>                         GJAHR LIKE BSIS-GJAHR,
>                         BELNR LIKE BSIS-BELNR,  
>                         SHKZG LIKE BSIS-SHKZG,
>                         BSCHL LIKE BSIS-BSCHL,
>                         AUFNR LIKE BSIS-AUFNR,
>                         HKONT LIKE BSIS-HKONT,
>                         QSSKZ LIKE BSIS-QSSKZ,
>                         DMBTR LIKE BSIS-DMBTR,
>                    END OF DLC_BSIS.                                                                               
>                           
>          Query as follows --
>
>          SELECT BUKRS
>                        GJAHR
>                        BELNR
>                        AHKZG
>                        BSCHL
>                        AUFNR
>                        HKONT
>                        QSSKZ
>                         DMBTR FROM BSIS
>                                   INTO TABLE DLC_BSIS
>                                  FOR ALL ENTRIES IN IT_BKPF2
>                                  WHERE BELNR = IT_BKPF2-BELNR
>                                               AND BUKRS = IT_BKPF2-BUKRS
>                                               AND GJAHR = IT_BKPF2-GJAHR.
>
> IT_BKPF2 internal table having -- BUKRS - LT01
>                                                      BELNR - 6400000061
>                                                      GJAHR - 2009.
>
> And in BSIS database  table  -- 3 entries are there for the above documnet.
>
> But, in my internal only one entry has come for the same above document.
>
> I think For all entries stmnt. is not running properly. But Why it's not running properly.??
> What would be the reason..??
>
>
> Thanks in advance....!!
>
> Regards,
> Poonam.
include the buzei field in selection criteria i have faced the same situation earlier.
always select all the key fields.
varun

Similar Messages

  • Is "Joins & For all entries" in same SQL Query Possible?

    Hi all Professional,
    Can we use "Inner Joins" and "For All Entries In" in the same SQL Query. if possible then pls clarify this query.
    Here I am using three Transparent Table and fetching data from them.
    SELECT abukrs abelnr ahkont axref2 ashkzg awrbtr agsber azfbdt azterm amwskz asgtxt axref1 agjahr abuzei
               bkunnr bwerks bmenge bmeins bmatnr bkoart
               cbukrs cbelnr cblart cbldat cbudat cxblnr cgjahr cstgrd cstblg cstblg c~xreversal
               INTO CORRESPONDING FIELDS OF TABLE it_bsid FROM ( ( bsid AS a
               INNER JOIN acctit AS b ON abukrs = bbukrs )
               INNER JOIN bkpf AS c ON cbukrs = abukrs
                                   AND cbelnr = abelnr
                                   AND cgjahr = agjahr )
               FOR ALL ENTRIES IN it_bkpf
                  WHERE
                    a~belnr EQ it_bkpf-belnr
                AND a~gjahr EQ it_bkpf-gjahr
                AND a~bukrs EQ it_bkpf-bukrs
                AND a~gsber IN so_bus.
    After executing this query, I'm getting Dump Error.
    Error analysis
        When the program was running, it was established that more
        memory was needed than the operating system is able to provide savely.
        To avoid a system crash, you must prevent this
        situation.
                   Last error logged in SAP kernel
        Component............ "EM"
        Place................ "SAP-Server Development_DVL_01 on host Development (wp
         2)"
        Version.............. 37
        Error code........... 7
        Error text........... "Warning: EM-Memory exhausted: Workprocess gets PRIV "
        Description.......... " "
        System call.......... " "
        Module............... "emxx.c"
        Line................. 1886
    Pls resolve, if anybody knows.
    Thanks
    Devinder

    Hi,
    During testing i notice that splitting into multiple selects does improve performance. But the best performance I achieved using DB Hints instead of splitting the select statements.
    Generally performance of joins together with for all entries is bad.
    However if you will look into SAP note 1662726 you will notice that this issue (bad performance in using join and for all entries together) has been addressed.
    Even though the note is for HANA DB, FM RSDU_CREATE_HINT_FAE can be used independent of DB.
    On HANA DB performance improvement is huge (i achieved 62 seconds using DB Hints compared to 1656 seconds using for all entries). On Oracle DB the same code initially run in 99 seconds with for all entries and with DB Hints in 82 seconds for ~ 1.000.000 records and ~660 seconds compared to 1349 seconds for ~8.000.000 records..
    Sample code from SAP Note below:
    Original statement:
    SELECT COL1 COL2 COL3 COL4 COL5
      FROM TAB1
      INTO CORRESPONDING FIELDS OF TABLE LT_RESULT
      FOR ALL ENTRIES IN LT_SOURCE_TMP
      WHERE COL3 = LT_SOURCE_TMP-COL3
      AND   COL4 = LT_SOURCE_TMP-COL4
      AND   COL5 = LT_SOURCE_TMP-COL5
    Revision:
    DATA: L_T_TABLNM TYPE RSDU_T_TABLNM,
          L_LINES TYPE I,
          L_HINT TYPE RSDU_HINT.
    APPEND 'TAB1' TO L_T_TABLNM.
    L_LINES = LINES( LT_SOURCE_TMP ).
    CALL FUNCTION 'RSDU_CREATE_HINT_FAE'
      EXPORTING
        I_T_TABLNM   = L_T_TABLNM
        I_FAE_FIELDS = 3
        I_FAE_LINES  = L_LINES
        I_EQUI_JOIN  = RS_C_TRUE
      IMPORTING
        E_HINT       = L_HINT
      EXCEPTIONS
        OTHERS       = 0.
    SELECT COL1 COL2 COL3 COL4 COL5
      FROM TAB1
      INTO CORRESPONDING FIELDS OF TABLE LT_RESULT
      FOR ALL ENTRIES IN LT_SOURCE_TMP
      WHERE COL3 = LT_SOURCE_TMP-COL3
      AND   COL4 = LT_SOURCE_TMP-COL4
      AND   COL5 = LT_SOURCE_TMP-COL5
              %_HINTS ADABAS  L_HINT.
    Best regards,
    Octavian

  • Why select query is not running on 10.2.0.2.0  but running on 10.2.0.1.0

    Hi Friends,
    The below given select statement is executing successfully in version
    select * from v$version;
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    "CORE     10.2.0.1.0     Production"
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    but NOT in version
    select * from v$version;
    Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bi
    PL/SQL Release 10.2.0.2.0 - Production
    "CORE     10.2.0.2.0     Production"
    TNS for Solaris: Version 10.2.0.2.0 - Production
    NLSRTL Version 10.2.0.2.0 - Production
    the error message is :
    ORA-00904:"SSRP"."RESOURCE_ID" invalid identifier
    Error at Line 12 : Column 40
    SELECT SR.RESOURCE_NAME,
    SRG.RESOURCE_GROUP_NAME,
    MAX(NVL((SELECT NVL(CHECKED, UNCHECKED)
    FROM
    (SELECT 2 AS UNCHECKED,
    (SELECT 1
    FROM S_USAGE_RESOURCE_PERMISSIONS SURP
    WHERE SURP.USAGE_PROFILE_ID = 1
    AND SURP.RESOURCE_PERMISSION_ID = SRP.RESOURCE_PERMISSION_ID) AS CHECKED
    FROM S_RESOURCE_PERMISSIONS SRP
    WHERE SRP.RESOURCE_PERMISSION_ID = SSRP.RESOURCE_PERMISSION_ID
    AND SRP.RESOURCE_ID = SSRP.RESOURCE_ID
    AND SRP.RESOURCE_PERMISSION_VAL = 4 )),0)) AS ALL_PERMISSION
    FROM
    S_RESOURCE_PERMISSIONS SSRP
    INNER JOIN
    S_RESOURCE SR ON SR.RESOURCE_ID = SSRP.RESOURCE_ID
    INNER JOIN
    S_RESOURCE_GROUP SRG ON SRG.RESOURCE_GROUP_ID = SR.RESOURCE_GROUP_ID
    GROUP BY SR.RESOURCE_NAME, SRG.RESOURCE_GROUP_NAME;
    Given SCHEMA is similar in all respects at both the databases.
    can someone suggest me what could be the problem?

    Sorry, didn't look close enough, here a corrected query you can try to run.
    If you still have problems, try to post a ddl scripts and small sample of data - this may do it easier for other to help you. When you post sql scripts, try as well to enclose them between [ pre ] [ pre ] or [ code ] [ code ] tags to increase readability.
    WITH t AS (
    SELECT NVL(CHECKED, UNCHECKED) NVL_CHECKED,
           RESOURCE_ID,
           RESOURCE_PERMISSION_ID
      FROM (SELECT 2 AS UNCHECKED,
                   (SELECT 1
                      FROM S_USAGE_RESOURCE_PERMISSIONS SURP
                     WHERE SURP.USAGE_PROFILE_ID = 1
                       AND SURP.RESOURCE_PERMISSION_ID =
                           SRP.RESOURCE_PERMISSION_ID) AS CHECKED,
                   SRP.RESOURCE_ID,RESOURCE_PERMISSION_ID
              FROM S_RESOURCE_PERMISSIONS SRP
             WHERE SRP.RESOURCE_PERMISSION_VAL = 4))
    SELECT SR.RESOURCE_NAME,
           SRG.RESOURCE_GROUP_NAME,
           MAX(NVL_CHECKED) AS ALL_PERMISSION
      FROM S_RESOURCE_PERMISSIONS SSRP INNER_JOIN T ON (T.RESOURCE_ID =
                                                       SSRP.RESOURCE_ID AND
                                                       T.RESOURCE_PERMISSION_ID =
                                                       SSRP.RESOURCE_PERMISSION_ID)
    INNER JOIN S_RESOURCE SR ON SR.RESOURCE_ID = SSRP.RESOURCE_ID
    INNER JOIN S_RESOURCE_GROUP SRG ON SRG.RESOURCE_GROUP_ID =
                                        SR.RESOURCE_GROUP_ID
    GROUP BY SR.RESOURCE_NAME, SRG.RESOURCE_GROUP_NAME;Best regards
    Maxim

  • I have reset Firefox, followed all the various instructions for ALL the faults and it is STILL not working properly !

    Various problems :
    Firefox crashing, missing toolbar, bookmarks disappeared (reset and now they won't work at all) , cannot set homepage again (despite following all instructions), shockwave flash constantly unresponsive (again, all instructions followed and no change), Firefox especially slow in facebook, sound volume keeps switching itself off.
    I have gone through each problem with all the suggested "fixes" AND reset Firefox, but it is worse now than before !
    Just about had enough.

    If you have submitted crash reports then please post the IDs of one or more recent crash reports that have a "bp-" prefix:
    *bp-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    You can find the IDs of the submitted crash reports on the <i>about:crashes</i> page.
    *You can open the <b>about:crashes</b> page via the location bar, like you open a website, or open the crash reports page via "Help > Troubleshooting Information".
    See:
    *http://kb.mozillazine.org/Mozilla_Crash_Reporter
    *https://support.mozilla.org/kb/Mozilla+Crash+Reporter
    You can check for problems with current Flash plugin versions and try these:
    *disable a possible RealPlayer Browser Record Plugin extension for Firefox and update the RealPlayer if installed
    *disable protected mode in the Flash plugin (Flash 11.3+ on Windows Vista and later)
    *disable hardware acceleration in the Flash plugin
    *http://kb.mozillazine.org/Flash#Troubleshooting

  • Select SUM in FOR ALL ENTRIES Select Query

    Hi ,
            I am using for all entries select statment ,can any one guide me how can i use SUM in the select statment with for all entries .
    Regards,
    Veera

    Hi,
    THis is  not possible using for all entries.
    Thanks,
    Sriram Ponna.

  • How does select stmt with for all entries uses Indexes

    Hello all,
    I goes through a number of documents but still confused how does select for all entries uses indexes if fields are not in sequences. i got pretty much the same results if i take like two cases on Hr tables HRP1000 and HRP1001(with for all entries based upon hrp1000). Here is the sequence of index fields on hrp1001 (MANDT, OTYPE, OBJID, PLVAR, RSIGN, RELAT, ISTAT, PRIOX, BEGDA, ENDDA, VARYF, SEQNR). in second case objid field is in sequence as in defined Index but i dont see significant increase in field even though the number of records are around 30000. My question is does it make a differrence to use field sequence (same as in table indexes) in comparison to redundant field sequence (not same as defined in table indexes), secondly how we can ge tto know if table index is used in Select for entries query i tried Explain in ST05 but its not clear if it uses any index at all in hrp1001 read.
    here is the sample code i use to get test results.
    test case 1
    REPORT  zdemo_perf_select.
    DATA: it_hrp1000 TYPE STANDARD TABLE OF hrp1000 WITH HEADER LINE.
    DATA: it_hrp1001 TYPE STANDARD TABLE OF hrp1001 WITH HEADER LINE.
    DATA: it_hrp1007 TYPE STANDARD TABLE OF hrp1007 WITH HEADER LINE.
    DATA: it_pa0000 TYPE STANDARD TABLE OF pa0000 WITH HEADER LINE.
    DATA: it_pa0001 TYPE STANDARD TABLE OF pa0001 WITH HEADER LINE.
    DATA: it_pa0002 TYPE STANDARD TABLE OF pa0002 WITH HEADER LINE.
    DATA: it_pa0105_10 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.
    DATA: it_pa0105_20 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.
    DATA: t1 TYPE timestampl,
          t2 TYPE timestampl,
          t3 TYPE timestampl 
    SELECT * FROM hrp1000 CLIENT SPECIFIED  INTO TABLE it_hrp1000 bypassing buffer
                WHERE mandt EQ sy-mandt AND
                      plvar EQ '01' AND
                      otype EQ 'S'AND
                      istat EQ '1' AND
                      begda <= sy-datum AND
                      endda >= sy-datum AND
                      langu EQ 'EN'.
    GET TIME STAMP FIELD t1.
    SELECT * FROM hrp1001 CLIENT SPECIFIED INTO TABLE it_hrp1001 bypassing buffer
                FOR ALL ENTRIES IN it_hrp1000
                 WHERE mandt EQ sy-mandt AND
                        otype EQ 'S' AND
    *                    objid EQ it_hrp1000-objid and
                        plvar EQ '01' AND
                        rsign EQ 'B' AND
                        relat EQ '007' AND
                        istat EQ '1' AND
                        begda LT sy-datum AND
                        endda GT sy-datum and
                        sclas EQ 'C' and
                        objid EQ it_hrp1000-objid.
    *                    %_hints mssqlnt 'INDEX(HRP1001~0)'.
    *delete it_hrp1001 where sclas ne 'C'.
    GET TIME STAMP FIELD t2.
    t3 = t1 - t2.
    WRITE: 'Time taken - ', t3.
    test case 2
    REPORT  zdemo_perf_select.
    DATA: it_hrp1000 TYPE STANDARD TABLE OF hrp1000 WITH HEADER LINE.
    DATA: it_hrp1001 TYPE STANDARD TABLE OF hrp1001 WITH HEADER LINE.
    DATA: it_hrp1007 TYPE STANDARD TABLE OF hrp1007 WITH HEADER LINE.
    DATA: it_pa0000 TYPE STANDARD TABLE OF pa0000 WITH HEADER LINE.
    DATA: it_pa0001 TYPE STANDARD TABLE OF pa0001 WITH HEADER LINE.
    DATA: it_pa0002 TYPE STANDARD TABLE OF pa0002 WITH HEADER LINE.
    DATA: it_pa0105_10 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.
    DATA: it_pa0105_20 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.
    DATA: t1 TYPE timestampl,
          t2 TYPE timestampl,
          t3 TYPE timestampl 
    SELECT * FROM hrp1000 CLIENT SPECIFIED  INTO TABLE it_hrp1000 bypassing buffer
                WHERE mandt EQ sy-mandt AND
                      plvar EQ '01' AND
                      otype EQ 'S'AND
                      istat EQ '1' AND
                      begda <= sy-datum AND
                      endda >= sy-datum AND
                      langu EQ 'EN'.
    GET TIME STAMP FIELD t1.
    SELECT * FROM hrp1001 CLIENT SPECIFIED INTO TABLE it_hrp1001 bypassing buffer
                FOR ALL ENTRIES IN it_hrp1000
                 WHERE mandt EQ sy-mandt AND
                        otype EQ 'S' AND
                        objid EQ it_hrp1000-objid and
                        plvar EQ '01' AND
                        rsign EQ 'B' AND
                        relat EQ '007' AND
                        istat EQ '1' AND
                        begda LT sy-datum AND
                        endda GT sy-datum and
                        sclas EQ 'C'." and
    *                    objid EQ it_hrp1000-objid.
    *                    %_hints mssqlnt 'INDEX(HRP1001~0)'.
    *delete it_hrp1001 where sclas ne 'C'.
    GET TIME STAMP FIELD t2.
    t3 = t1 - t2.
    WRITE: 'Time taken - ', t3.

    Mani wrote:
    Thank you for your answer, its very helpful but i am still nor sure how does parameter rsdb/max_blocking_factor affect records size.
    Hi,
    The blocking affects the size of the statement and the memory structures for returning the result.
    So if your itab has 500 rows and your blocking is 5, the very same statement will be executed 100 times.
    Nothing good or bad about this so far.
    Assume, your average result for an inlist 5 statement is 25 records with an average size of 109 bytes.
    You average result size will be 2725 byte plus overhead which will nearly perfectly fit into two 1500 byte ethernet frames.
    Nothing to do in this case.
    Assume your average result for an inlist 5 statement is 7 records with an average size of 67 bytes.
    You average result size will be ~ 470 byte plus overhead which will only fill 1/3 of a 1500 byte ethernet frame.
    In this case, setting the blocking to 12 ... 15 will give you 66% network transfer performance gain,
    and reduces the number of calls to the DB by 50%, giving additional benefit.
    Now this is an extreme example. The longer the average row length is, the lower will be the average loss in the network.
    You have the same effects in memory structures, but on that layer you are fighting single micro seconds instead of
    hundreds of these, so in real life it is rarely measurable.
    Depending on table-statistics, oracle might decide for short inlists to use a concatanation instead of an inlist.
    This is supposed to be more costy, but I never had a case where I could proove a big difference.
    Values from 5 to 15 for blocking seem to be ok for me. If you have special statements in customer coding,
    it #might# be benefitial to do the mentioned calculations and do some network tracing to see if you can squeeze your
    network efficiency by tuning the blocking.
    If you have jumbo frames enabled, it might be worth to be analyzed as well.
    If you are only on a DB-CI system that is loopback connected to the DB, I doubt there might be a big outcome.
    Hope this helps
    Volker

  • For all entries with 2 internal table

    HI experts.
    How to use  2 for all entries in a select statement.
    Below refer to my below code.
    select vbeln matnr lfimg vgbel posnr from lips into corresponding fields of table
      it_lips for all entries in  it_likp   where
                  vbeln = it_likp-vbeln and
                  matnr = it_mara-matnr.
    I want to add another for all entries it_mara.
    Please help me .Thanks in advanced.

    hi,
    it is possible....
    use this query...
    declare another internal table of the same type as it_lips.
    data : it_lips_final like it_lips.
    select vbeln matnr lfimg vgbel posnr from lips into corresponding fields of table
    it_lips for all entries in it_likp where
    vbeln = it_likp-vbeln .
    loop at it_lips.
      read table it_mara into it_mara with key matnr = it_lips-matnr.
      if sy-subrc = 0.
        append it_lips to it_lips_final.
      endif.
    endloop.
    refresh it_lips[].
    it_lips[] = it_lips_final[]
    what the above code does is selects all the entries of vbeln from lips and filters it in the loop reading it from mara checking for matnr value and finally
    all the entries according to your requirement is there in it_lips_final which we move it to it_lips again...
    this is something similar to writing a for all entries for 2 table.... but in another fashion
    Regards
    Siddarth

  • 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

  • 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

  • FOR ALL ENTRIES IN with two tables

    Hi Guy's,
    I have two int. tables, gt_likp, gt_lips.
    I need to use "FOR ALL ENTRIES IN" with this two tables.
      SELECT matnr
             vkorg
             vtweg
             ypcogsl
        FROM mvke
        INTO TABLE gt_mvke
    <b>    "FOR ALL ENTRIES IN gt_likp gt_lips"</b>
        WHERE matnr = gwa_liefpos_tab-matnr
        AND vkorg = gt_likp-vkorg
        AND vtweg = gt_lips-vtweg.
    How to do this?
    Please Help.
    Thanks in Advance.

    Hi,
    Fill gt_likp-vkorg values in a range(r_vkorg). Use gt_lips in FOR ALL ENTRIES.
    Basically you can use only 1 internal table with FOR ALL ENTRIES statement.
    SELECT matnr
    vkorg
    vtweg
    ypcogsl
    FROM mvke
    INTO TABLE gt_mvke
    FOR ALL ENTRIES IN gt_lips
    WHERE matnr = gwa_liefpos_tab-matnr
    AND       vkorg in r_vkorg
    AND       vtweg = gt_lips-vtweg.
    - SRao

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

  • Hi All,Pre-requisite of using FOR ALL ENTRIES

    Hi All,
             What are the Pre-requisite of using FOR ALL ENTRIES in the select statement .pls its Urgent .
    thanks&regards.
    Bharat

    hi,
    For using for all entries in below statement for all entries in itab_mara it will retrieve record corresponding fields of table itab_marc.
    In this case if we have duplicate records in mara .For that also it will retrieve the value in itab_marc.
    select matnr erdat from table itab_mara where matnr in s_matnr.
    if not itab_mara is initial.
    select matnr werks from table itab_marc for all entries of table itab_mara
                                                          where werks in s_werks and
                                                                    matnr in s_matnr.
    Reward with points if helpful.

  • FOR ALL ENTRIES - CDHDR / CDPOS Tables

    Hi,
    I know there have been a lot of threads concerning the "for all entries" statement. Nevertheless I got a problem downloading the change document tables CDHDR/CDPOS with this statement and I haven't found anything in this forum regarding this special issue.
    While trying the for all entries statement in the below manner for downloading first CDHDR and then the CDPOS for all entries of the selected CDHDR it took 3 days and didn't finish, so we aborted the ABAP. The JOIN statement doesn't work in a 4.6c environment for the Cluster tables, hence this isn't an option.
    Can you give me some advise of how to improve downloading those tables in this way:
    1. Download CDHDR with limitation of fields OBJECTCLAS and UDATE
    2. Then Download CDPOS for all CHANGENR out of the first selection of CDHDR
    This was the way I tried it:
    SELECT
    ACT_CHNGNO  CHANGE_IND  CHANGENR  MANDANT  OBJECTCLAS  OBJECTID  PLANCHNGNR  TCODE  UDATE  USERNAME  UTIME  WAS_PLANND APPENDING CORRESPONDING FIELDS OF TABLE T_CDHDR FROM CDHDR WHERE UDATE IN  s_UDAT1 AND OBJECTCLAS IN  s_OBJE0.
    ENDSELECT.
    SELECT
    CHANGENR  CHNGIND  CUKY_NEW  CUKY_OLD  FNAME  MANDANT  OBJECTCLAS  OBJECTID  TABKEY  TABNAME  UNIT_NEW  UNIT_OLD  VALUE_NEW  VALUE_OLD INTO gs_CDPOS FROM CDPOS CLIENT SPECIFIED for all entries in  T_CDHDR WHERE OBJECTCLAS IN  s_OBJE2 AND MANDANT EQ  T_CDHDR-MANDANT AND OBJECTCLAS EQ  T_CDHDR-OBJECTCLAS AND CHANGENR EQ  T_CDHDR-CHANGENR.
    ENDSELECT.

    THis prg might b usefull to u
    *  Mass display or print Purchase Order History
    *  You can request report by :
    *  1.  Change date
    *  2.  User Name
    *  3.  Purchase Order Number
    *  4.  Vendor Code
    * Written by : SAP Basis, ABAP Programming and Other IMG Stuff
    *              http://www.sap-img.com
    REPORT ZPOCHANGE LINE-SIZE 132 NO STANDARD PAGE HEADING
                     LINE-COUNT 065(001)
                     MESSAGE-ID VR.
    TABLES: DD04T,
            CDHDR,
            CDPOS,
            DD03L,
            DD41V,
            T685T,
            VBPA,
            TPART,
            KONVC,
            EKKO.
    SELECT-OPTIONS: XUDATE FOR CDHDR-UDATE,
                    XNAME  FOR CDHDR-USERNAME,
                    XEBELN FOR EKKO-EBELN,
                    XLIFNR FOR EKKO-LIFNR.
    SELECTION-SCREEN SKIP.
    * TEXT-001 - Sorting Sequence
    SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
    PARAMETERS: SUDATE RADIOBUTTON GROUP R1,
                SNAME  RADIOBUTTON GROUP R1,
                SOBID  RADIOBUTTON GROUP R1.
    SELECTION-SCREEN END OF BLOCK BLK1.
    DATA: WFLAG,
          WCHANGENR LIKE CDHDR-CHANGENR.
    DATA: INDTEXT(60) TYPE C.
    DATA: BEGIN OF ICDHDR OCCURS 50.
            INCLUDE STRUCTURE CDHDR.
    DATA: END OF ICDHDR.
    DATA: BEGIN OF ICDSHW OCCURS 50.
            INCLUDE STRUCTURE CDSHW.
    DATA: END OF ICDSHW.
    DATA: BEGIN OF EKKEY,
            EBELN LIKE EKET-EBELN,
            EBELP LIKE EKET-EBELP,
            ETENR LIKE EKET-ETENR,
          END OF EKKEY.
    DATA: BEGIN OF ITAB OCCURS 50,
            BEGIN OF EKKEY,
              EBELN LIKE EKET-EBELN,
              EBELP LIKE EKET-EBELP,
              ETENR LIKE EKET-ETENR,
            END OF EKKEY,
            CHANGENR LIKE CDHDR-CHANGENR,
            UDATE    LIKE CDHDR-UDATE,
            UTIME    LIKE CDHDR-UTIME,
            USERNAME LIKE CDHDR-USERNAME,
            CHNGIND  LIKE CDSHW-CHNGIND,
            FTEXT    LIKE CDSHW-FTEXT,
            OUTLEN   LIKE CDSHW-OUTLEN,
            F_OLD    LIKE CDSHW-F_OLD,
            F_NEW    LIKE CDSHW-F_NEW,
          END OF ITAB.
    DATA: OLD_OBJECTID LIKE CDHDR-OBJECTID.
    FIELD-SYMBOLS: <F_OLD>, <F_NEW>.
    SELECT * FROM EKKO WHERE EBELN IN XEBELN AND
                             LIFNR IN XLIFNR.
      CLEAR CDHDR.
      CLEAR CDPOS.
      CDHDR-OBJECTCLAS = 'EINKBELEG'.
      CDHDR-OBJECTID   = EKKO-EBELN.
      PERFORM GETCHGDOCS.
    ENDSELECT.
    IF SUDATE = 'X'.
      SORT ITAB BY UDATE EKKEY-EBELN CHANGENR EKKEY-EBELP
                   EKKEY-ETENR.
    ELSEIF SNAME = 'X'.
      SORT ITAB BY USERNAME EKKEY-EBELN CHANGENR EKKEY-EBELP
                   EKKEY-ETENR.
    ELSE.
      SORT ITAB BY EKKEY-EBELN CHANGENR EKKEY-EBELP EKKEY-ETENR.
    ENDIF.
    LOOP AT ITAB.
      CLEAR: INDTEXT, EKKEY.
      CASE ITAB-CHNGIND.
        WHEN 'U'.
            INDTEXT(50) = ITAB-FTEXT.
            INDTEXT+51  = TEXT-020.
            CONDENSE INDTEXT.
        WHEN 'D'.
            INDTEXT = TEXT-021.
        WHEN 'E'.
            INDTEXT(5) = ITAB-FTEXT.
            INDTEXT+51 = TEXT-021.
            CONDENSE INDTEXT.
          WHEN 'I'.
            INDTEXT = TEXT-022.
        ENDCASE.
        RESERVE 4 LINES.
        IF WCHANGENR NE ITAB-CHANGENR.
          WCHANGENR = ITAB-CHANGENR.
          EKKEY = ITAB-EKKEY.
          WRITE:/ ITAB-UDATE UNDER 'Change Date',
                  ITAB-UTIME UNDER 'Time',
                  ITAB-USERNAME UNDER 'User Name',
                  ITAB-EKKEY-EBELN UNDER 'PO No',
                  ITAB-EKKEY-EBELP UNDER 'Item',
                  ITAB-EKKEY-ETENR UNDER 'Sch No',
                  INDTEXT     UNDER 'Changes'.
        ELSEIF ITAB-EKKEY NE EKKEY.
          WRITE:/ ITAB-EKKEY-EBELP UNDER 'Item',
                  ITAB-EKKEY-ETENR UNDER 'Sch No',
                  INDTEXT     UNDER 'Changes'.
        ENDIF.
        CASE ITAB-CHNGIND.
          WHEN 'U'.
            ASSIGN ITAB-F_OLD(ITAB-OUTLEN) TO <F_OLD>.
            ASSIGN ITAB-F_NEW(ITAB-OUTLEN) TO <F_NEW>.
            WRITE: / TEXT-023  UNDER 'Changes',
                     <F_OLD>.
            WRITE: / TEXT-024 UNDER 'Changes',
                     <F_NEW>.
          WHEN 'E'.
            ASSIGN ITAB-F_OLD(ITAB-OUTLEN) TO <F_OLD>.
            WRITE: TEXT-023 UNDER 'Changes',
                   <F_OLD>.
        ENDCASE.
        SKIP.
    ENDLOOP.
    TOP-OF-PAGE.
    WRITE:/ SY-DATUM,SY-UZEIT,
           50 'P U R C H A S E  O R D E R   H I S T O R Y',
          120 'Page', SY-PAGNO.
    WRITE: / SY-REPID,
             60 'Purchase Orders Changes'.
    SKIP.
    ULINE.
    IF SUDATE = 'X'.
      WRITE:/001 'Change Date',
             014 'Time',
             024 'User Name',
             038 'PO No',
             050 'Item',
             057 'Sch No',
             065 'Changes'.
    ELSEIF SOBID = 'X'.
      WRITE:/001 'PO No',
             013 'Item',
             020 'Sch No',
             028 'Change Date',
             041 'Time',
             051 'User Name',
             065 'Changes'.
    ELSE.
      WRITE:/001 'User Name',
             015 'Change Date',
             028 'Time',
             038 'PO No',
             050 'Item',
             057 'Sch No',
             065 'Changes'.
    ENDIF.
    ULINE.
    FORM GETCHGDOCS.
      CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
           EXPORTING
                DATE_OF_CHANGE    = CDHDR-UDATE
                OBJECTCLASS       = CDHDR-OBJECTCLAS
                OBJECTID          = CDHDR-OBJECTID
                TIME_OF_CHANGE    = CDHDR-UTIME
                USERNAME          = CDHDR-USERNAME
           TABLES
                I_CDHDR           = ICDHDR
           EXCEPTIONS
                NO_POSITION_FOUND = 1
                OTHERS            = 2.
      CHECK SY-SUBRC EQ 0.
      DELETE ICDHDR WHERE CHANGE_IND EQ 'I'.
      CHECK NOT ICDHDR[] IS INITIAL.
      LOOP AT ICDHDR.
        CHECK ICDHDR-UDATE IN XUDATE.
        CHECK ICDHDR-USERNAME IN XNAME.
        CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
                     EXPORTING  CHANGENUMBER       = ICDHDR-CHANGENR
                     IMPORTING  HEADER             = CDHDR
                     TABLES     EDITPOS            = ICDSHW
                     EXCEPTIONS NO_POSITION_FOUND  = 1
                                OTHERS             = 2.
        CHECK SY-SUBRC EQ 0.
        LOOP AT ICDSHW.
          CHECK ICDSHW-TEXT_CASE EQ SPACE.
          MOVE-CORRESPONDING ICDSHW TO ITAB.
          MOVE-CORRESPONDING ICDHDR TO ITAB.
          MOVE ICDSHW-TABKEY+3 TO ITAB-EKKEY.
          APPEND ITAB.
        ENDLOOP.
      ENDLOOP.
    ENDFORM.
    * END OF PROGRAM

  • Using aggregate function along with for all entries: sugest alternative

    My requirement:
    For each record in i_vbap for which 'charg' is initial, need to determine batch using the following logic:
    For the material (MATNR) in i_vbap, select the batch (CHARG) which has the largest (MAX) unrestricted inventory quantity (CLABS) from MCHB table.
    How do I implement this logic without using select statement inside a loop as I cannot use MAX ( CLABS ) function along with FOR ALL ENTRIES in a SELECT?
    Suggest an alternative.

    For each record in i_vbap for which 'charg' is initial ,fetch all the existing 'clabs' value.
    [ Remember to include all the key fields in selct ]
    Sort the new table .
    Put a loop,use at end of 'charg' and append to another table. U get ur solution
    I think this should be the most economic way to do so.

  • For All entries in

    Dear Abapers,
    I want to get all the records from COEP table on the basis of record selected from AFPO table. Its very very slow , some times SAP Clicked out from the report. Pl. help.
    In AFPO -> AUFNR field links to OBJNR field for that I have to Pass OR+Aufnr for check.
    regards
    Vikas

    The reason for the poor performance of your COEP select is that you are not supplying sufficient fields for it to use an existing index or the table key, and therefore the database will be performing a table scan for each record.
    To read COEP based on OBJNR you need to select with LEDNR and OBJNR supplied in your WHERE block.  You will most likely find that LEDNR has a fixed value (probably '00') - specifying this as well as the OBJNR will speed up the select.
    Looking at COEP inxedes, it looks like index 2 would allow select using OBJNR without needing LEDNR, but SAP delivers index 2 and 4 of the COEP table flagged as "No Database Index" so they do not really exist and cannot be used without creating them (a repair to the table).  So this leaves only index 1 as a real index, and it needs the additional field provided.
    So your process would be:
    1. Read AFPO and populate internal tabel.
    2. Loop at internal table and set up extra OBJNR field as 'OR'+Aufnr
    3. Check internal table is not empty
    4. Read COEP using FOR ALL ENTRIES and both LEDNR and OBJNR fields
    NB: make sure you read all three key COEP fields KOKRS, BELNR, BUZEI to avoid loss of duplicates due to FOR ALL ENTRIES behaving like "SELECT DISTINCT".
    Andrew

Maybe you are looking for

  • ITunes v7.6 still NOT working w/Vista 64-bit

    I believe it's not working because AppleMobileDeviceSupport.msi WON'T install. It gives me a "The installer encountered errors before Apple Mobile Device Support could be configured." error. Is there ANY WAY around this at all? Also I've installed &

  • Creating a WEB Service for SAP enterprise connector

    Hi, I am using the SAP enterprise connector plugin for Netweaver 04. It generated me all the classes that I need for the BAPI. It also generated me a Proxy class. I want to create a service. This is what I've done : 1) create a portal service. 2) cre

  • Group Policy Editor problem

    Hi I updated Windows 7 SP1 Enterprise 64 bit with the Windows Update. Now, when I open the Group Policy Editor, this window is displayed with the following error message: How come? Thanks Bye Balubeto

  • 1921 ISR certificate request not valid

    I'm trying to perform a certificate request on a 1921 router.  I've followed the wizard using Cisco Configuration Professional several times.  First I created a 2048 RSA key pair, then used the "Cut-and-Paste" wizard in CCP to generate the CSR using

  • Eyedropper tool for Defringe?

    While searching for instructions on how to use the new Defringe controls, I came across mention of a an eyedropper tool in this Lightoom Journal blog - New Color Fringe Correction Controls http://blogs.adobe.com/lightroomjournal/2012/04/new-color-fri