Why should we select all key fields when using for all entries

Hi,
Why should we select all key fields in our select query when using for all entries statement?
I read about for all entries but this point was not clear in any post.
Please explain me
Regards,
Subhashini

Dear Subhasini,
It is because FOR ALL ENTRIES deletes the duplicate entries before populating the target internal table.
Please do an F1 on FOR ALL ENTRIES & read the SAP documentation.
I mean how duplicate entries will not get deleted when we use this?
Quite simple, if you select  all key fields then each entry will be unique & there will not be any duplicate entries to delete !!
BR,
Suhas
Edited by: Suhas Saha on Oct 16, 2009 9:41 AM

Similar Messages

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

  • Why I cannot process a disabled field when using htmldb_item

    I have a report that has this in the select statement
    case when c.sec_lic_status in (1,2,7,505,1002,1004,1005) then
    htmldb_item.text(2,sum( distinct a.fee_variable),8,20)
    else
    htmldb_item.text(2,sum( distinct a.fee_variable),8,20,'disabled')
    end "Quantity 1"
    The above shows correctly. If there are 2 records one field is disable and the other is enabled.
    I have a process that fires on submit - after Computations and Validations. But the records don't changed when updating the enabled one.
    In debugging and writing to a file using the UTL_FILE package, I'm able to pinpoint that the disable fields are the problem.
    Is there a trick on manually processing disabled fields?
    I've found that when I uncheck the show box in the report, I cannot use the fields either. This is not a problem, just another comment.
    My main problem is what do I have to do to manually process a disabled field.
    Thanks for your help, comments, pointers, or anything that could help me or give me ideas.
    juan

    Juan - HTML items with the disabled attribute are not POSTed with the form so your after-submit processes never see them. Try 'readonly="readonly"' instead. Others may be able to suggest how to also give those cells a greyed-out appearance.
    Scott

  • Why should we turn off query cache when alternative UOM solution is used?

    Hi, all, Why should we turn off query cache when alternative UOM solution is used?I found it in "Checklist for Query Performance", but I dont know why.
    Please tell me if u know.
    PS: I also dont know how to turn off the cache, Need your help, thanks!

    hi ,
           I have also some confusion regarding Cache Parameters . What is the importance of cache ,  Should we delete the cache memory time to time for each query ? I have chked it in RSRT but never use the chache monitor function .

  • N Mail, when using "reply all" why does Mail automatically include my email address in the cc line? Whey would I want to include my email address in an email I am sending.  Anybody have any idea how to stop this?

    In Mail, when using "reply all" why does Mail automatically include my email address in the cc line? Whey would I want to include my email address in an email I am sending.? Anybody have any idea how to stop Mail from including my email address in the cc line when using "reply all"?

    Automatically cc myself is not checked.  I did find out that if you have multiple email address that all of them need to be associated with "My Contact" tab.  Thanks

  • Why are my text messages being sent through my Apple ID to only one person and through my phone number to all other contact when using iMessage?

    Why are my text messages being sent through my Apple ID to only one person and through my phone number to all other contact when using iMessage?

    Is this one person using an iphone or ipad for imessaging?

  • Regarding Select using FOR ALL ENTRIES (FAEI)

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

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

  • Why should I adopt LABVIEW FPGA as a tool for developing my FPGA projects?

    Dear Friends, 
    Since I have started using LABVIEW FPGA, I got too many questions in my mind looking for answers! 
    1-      Does anybody can tell me “why should I adopt LABVIEW FPGA as a tool for developing my FPGA projects?”
    I mean there are many great tools in this field (e.g. Xilinx ISE, ….); what makes LABVIEW FPGA the perfect tools that can save my time and my money? 
    I’m looking for a comparison can show the following points:
    ·         The Code size and speed optimization.
    ·         Developing time.
    ·         Compiling time.
    ·         Verifying time.
    ·         Ability to developing in future.
    ·         …etc.. 2-     
    I’ve Spartan-3E kit, I’m so glad that LABVIEW support this kit; I do enjoyed programming the kit using LABVIEW FPGA, but there are too many obstacles!
    The examples come with Spartan-3E driver don't cover all peripherals on board (e.g. LAN port is not covered)! There is a declaration at NI website which is "LabVIEW FPGA drivers and examples for all on-board resources" Located at: http://digital.ni.com/express.nsf/bycode/spartan3eI don’t think that is true!
    Anyway, I will try to develop examples for the unsupported peripherals, but if the Pins of these peripherals are not defined in the UCF file, the effort is worthless! The only solution in this case is to develop VHDL code in ISE and use it in Labview FPGA using HDL node!?
    3-      I wonder if NI has any plan to add support for Processor setup in Labview FPGA (Like we do in EDK)?
    4-      I wonder if NI has any plan to develop a driver for Virtex-5 OpenSPARC Evaluation Platform ?http://www.digilentinc.com/Products/Detail.cfm?Nav​Path=2,400,599&Prod=XUPV5 
    Thnaks & regards,Walid
    Solved!
    Go to Solution.

    Thanks for your questions and I hope I can answer them appropriately
    1. LabVIEW FPGA utilizes the intuitive graphical dataflow language of LabVIEW to target FPGA technology. LabVIEW is particularly nice for FPGA programming because of its ability to represent parallelism inherent to FPGAs. It also serves as a software-like programming experience with loops and structures which has become a focus of industry lately with C-to-gates and other abstraction efforts. Here are some general comparison along the vectors you mentioned
    Code Size and speed optimization - LabVIEW FPGA is a programming language. As such, one can program badly and create designs that are too big to fit on a chip and too slow to meet timing. However, there are two main programming paradigms which you can use. The normal LabVIEW dataflow programming (meaning outside a single-cycle loop) adds registers in order to enforce dataflow and synchronization in parity with the LabVIEW model of computation. As with any abstraction, this use of registers is logic necessary to enforce LabVIEW dataflow and might not be what an expert HDL programmer would create. You trade off the simplicity of LabVIEW dataflow in this case. On the other hand, when you program inside a Single-Cycle timed loop you can achieve size and speed efficiencies comparable to many VHDL implementations. We have had many users that understand that way LabVIEW is transformed to hardware and program in such a way to create very efficient and complex systems.
    Development Time - Compared to VHDL many of our users get near infinite improvements in development time due to the fact that they do not know (nor do they have to know) VHDL or Verilog. Someone who knows LabVIEW can now reach the speeds and parallelism afforded by FPGAs without learning a new language. For harware engineers (that might actually have an alternative to LabVIEW) there are still extreme time saving aspects of LabVIEW including ready-made I/O interfaces, Simple FIFO DMA transfers, stichable IP blocks, and visualizable parallism.  I talk to many hardware engineers that are able to drastically improve development time with LabVIEW, especially since they are more knowledgable about the target hardware.
    Compilation Time - Comparable to slightly longer to due to the extra step of generating intermediate files from the LabVIEW diagram, and the increased level of hierarchy in the design to handle abstraction.
    Verification Time - One of our key development initiatives moving forward is increased debugging capabilities. Today we have the abilities to functionally simulate anything included in LabVIEW FPGA, and we recently added simluation capabilities for Imported IP through the IP Integration node on NI Labs and the ability to excite your design with simulated I/O. This functional simualation is very fast and is great for verification and quick-turn design iteration. However, we still want to provide more debugging from the timing prespective with better cycle-accurate simulation. Although significantly slower than functional simulation. Cycle-accuracy give us the next level of verification before compilation. The single cycle loop running in emulation mode is cycle accurate simluation, but we want more system level simulation moving forwrad. Finally, we have worked to import things like Xilinx chipscope (soon to be on NI Labs) for on-chip debugging, which is the final step in the verification process. In terms of verification time there are aspects (like functional simulation) that are faster than traditional methods and others that are comparable, and still other that we are continuing to refine.
    Ability to develop in the future - I am not sure what you mean here but we are certainly continuing to activiely develop on the RIO platform which includes FPGA as the key diffentiating technolgoy.  If you take a look at the NI Week keynote videos (ni.com/niweek) there is no doubt from both Day 1 and Day 2 that FPGA will be an important well maintained platform for many years to come.
    2. Apologies for the statement in the document. The sentence should read that there are example for most board resources.
    3. We do have plans to support a processor on the FPGA through LabVIEW FPGA. In fact, you will see technology on NI Labs soon that addresses this with MicroBlaze.
    4. We do not currently have plans to support any other evaluation platforms. This support was created for our counterparts in the academic space to have a platform to learn the basics of digital design on a board that many schools already have in house. We are currently foccussing on rounding out more of our off-the-shelf platform with new PCI Express R Series boards, FlexRIO with new adapter modules, cRIO with new Virtex 5 backplanes, and more.
     I hope this has anwered some of the questions you have.
    Regards 
    Rick Kuhlman | LabVIEW FPGA Product Manager | National Instruments | ni.com/fpga
    Check out the FPGA IPNet for browsing, downloading, and learning about LabVIEW FPGA IP Cores

  • Select using for all entries

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

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

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

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

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

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

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

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

  • Get all the field's value of addressbook entry using c++ api

    How can i get all the field values of address book entry in groupwise using c++ api.

    You should be able to do that via the Token API. There is an AddressBookGetEntry method. You could createsome sort of AddressbookEntry class that fetches (via iteration over the defined ABFields) all the innformation.

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

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

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

  • 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

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

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

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

Maybe you are looking for