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

Similar Messages

  • Use HR_READ_INFOTYPE or select (for all entries)

    Hi
    As I have understood the difference between FM HR_READ_INFOTYPE and a select directly from PA0001 (as example) is that the FM take the authorization into account. (please correct me if I am wrong).
    My problem is that I need to select from the infotype for a lot of pernr, so I would use this statement:
        SELECT * FROM pa0001 INTO CORRESPONDING FIELDS OF TABLE wt_pa0001
          FOR ALL ENTRIES IN wt_pernr
             WHERE pernr = wt_pernr-pernr
              AND begda LE pn-endda
              AND endda GE pn-begda.
    but then I don't get the authorization check.
    For the FM HR_READ_INFOTYPE I can't use the "FOR ALL ENTRIES".
    Can I do it in an easy way, or do need to do the select, and then use an authority check after the select from each infotype?

    Calling HR_READ_INFOTYPE or selecting directly from the tables may depend on how much data you are processing.  If you only need to retrieve a few records, you could process the PERNR records you need in a loop and call HR_READ_INFOTYPE for each.  If you're processing a larger number of records, check the authorization for the each table first and then do a SELECT for all entries.  Before you read, make sure that your "FOR ALL ENTRIES" table is not empty.  In order to make your code more generic, you may want to use function module HR_CHECK_AUTHORITY_INFTY to check the authorization for each infotype.  This is the FM that the HR_READ_INFOTYPE function module uses.
    .. Craig

  • Select for all entries+offset

    Folks,
    please find my code below:
    SELECT partner bpkind FROM but000 INTO TABLE i_but000
        FOR ALL ENTRIES IN lt_cmst_rtcm_bw
        WHERE partner = lt_cmst_rtcm_bw-tk_partner_i+0(10).
        SORT i_but000 BY partner.
    partner is of length 10, tk_partner_i is of length 32.
    when i use this offset value for comparison, its giving me the correct output. no errors.
    but am getting this warning:
    Bei der Verwendung von FOR ALL ENTRIES wird die Längenangabe für "TK_PARTNER_I" in dieser Bedingung ignoriert.          
    Do i have to mind this warning??..
    if this is to be considered, please suggest me an alternate solution to use "For all entries" in this case.
    Thanks in advance..
    Yog

    >
    yogaprakash srirangan wrote:
    > Hi,
    >
    > Actually i am writing this code in CRM system's CMOD-User exit program.
    >
    > when i remove the offset i am getting this error:
    >
    > When using the addition "FOR ALL ENTRIES IN itab", the fields "PARTNER"     and "LT_CMST_RTCM_BW-TK_PARTNER_I" must have the same type and length.and length.     
    >
    > but with offset its generating warning and internal table is getting filled..
    >
    > so can you please explain me on this?..
    >
    > Thanks,
    > Yog
    Wow!  It seems you have indeed found a bug!  With the length specification you get a warning, without you get an error!
    I've also written a little test program
    TYPES: BEGIN OF mandt_ty,
             mandt TYPE char6,
           END OF mandt_ty.
    DATA: t_mandt TYPE STANDARD TABLE OF mandt_ty WITH NON-UNIQUE KEY mandt,
          l_mandt TYPE mandt_ty.
    DATA: lt_t000 TYPE STANDARD TABLE OF t000 WITH NON-UNIQUE KEY mandt,
          ls_t000 TYPE t000.
    l_mandt-mandt = '1201'.
    INSERT l_mandt INTO TABLE t_mandt.
    SELECT * FROM t000 INTO TABLE lt_t000 FOR ALL ENTRIES IN t_mandt WHERE mandt = t_mandt-mandt+1(3).
    *SELECT * FROM t000 INTO TABLE lt_t000 FOR ALL ENTRIES IN t_mandt WHERE mandt = t_mandt-mandt.
    LOOP AT lt_t000 INTO ls_t000.
      WRITE: ls_t000-mandt.
    ENDLOOP.
    And it seems that the offset isn't being ignored.  I've also done and SQL trace, and this confirms that the offset isn't being ignored - the SQL issued actually says SELECT WHERE "MANDT" = '020' even though I've set it in the table to be 1201.
    So it seems that, at the moment, you can safely ignore the message.  But if SAP ever enforce it, or they make it an error instead of a warning, there will be problems.
    matt

  • Select -- for all entries.. fetching Duplicates

    Hi,
    Im using a Select- for all entries structure. Actually Select will supress the Duplicates .But i have a table which has 20000 entries , but my select --for all entries fetching around 56000 records..!
    Any idea/ anybody have Experience this kind of Problem..?
    If i sort the internal table would it resolve the proble..? Because its not happening in all cases.. but for few cases only its extracting duplicates.. other times..its supressing the duplicates.
    Appreciate any advise.

    Hi,
    Just check the table is not initial and then write select statement.
    if not internaltable1[] is initial.
    select field into table internaltable2 for all entries in internaltable1 where field1 = internaltable1-field1.
    endif.
    *Then sort the internaltable2
    sort internaltable2 by field.
    delete adjacent dulpcates from internaltable2 comparing field.
    Hope this helps.
    Regards,
    J.Jayanthi

  • Dynamic select for all entries?

    Hi!
    Is it possible to do a dynamic SELECT FOR ALL ENTRIES IN... command?
    sg. like:
      DATA:
        select_text TYPE string,
        from_text TYPE string,
        where_text TYPE string.
      SELECT FOR ALL ENTRIES IN <gt_table1> (select_text)
      into corresponding fields of table <gt_table2>
      FROM (from_text)
      WHERE (where_text).
    Thanks and Best Regards,
    Tamas

    Hi,
    you can use the Dynamic Selects for FOR ALL ENTRIES, but i think you may need to use the correct Internal table to match the tabel structure
    Regards
    Sudheer

  • Usage of 'Select for all entries' for dynamic internal tables..

    Hi all,
    I have a situation where I need to use select for all entries for a dynamic internal table.
    select * from /BIC/AZHSD_O1500 into i_table for all entries in <b>Dynamic_table</b> where doc_number = <dynamic_table????????>
    here iam not knowing how to match the <dynamic_table????????> doc_number ?
    the dynamic_table contains the doc_number as one field.
    here dynaimc_table is the internal table which is dynamic.
    I have tried various options but couldnot find the solution.
    Please resolve.
    Sidhartha.

    data : i_dyn_where type char72 occurs 0.
    field-symbols : <fs> type table.
    assign itab[] to <fs>.
    i_dyn_where = 'docno = <fs>-docno'.
    append i_dyn_where.
    select *
    from   vbak
    into   table t_vbak
    for    all entries in <fs>
    where  (I_dyn_where).   "Populate this where condition dynamically too
    Hope this will solve ur prob.

  • Select for all entries

    Hi,
          I am new in abap reports. Now i want to know why we should use select for all entries in query. We can do retrieve directly by accessing the table in database dictionary.
          Experts please give me the reasons I want to know the concepts behind it.It will be better if you kindly explain this with help of code.
         With regards,
           Abir.

    HI
    GOOD
    SELECT
    Basic form
    SELECT result [target] FROM source [where] [GROUP BY fields] [ORDER BY order].
    Effect
    Retrieves an extract and/or a set of data from a database table or view (see Relational database ). SELECT belongs to the OPEN SQL command set.
    Each SELECT command consists of a series of clauses specifying different tasks:
    The SELECT result clause specifies
    whether the result of the selection is a table or a single record,
    which columns the result is meant to have and
    whether the result is allowed to include identical lines.
    The INTO target clause specifies the target area into which the selected data is to be read. If the target area is an internal table, the INTO clause specifies
    whether the selected data is to overwrite the contents of the internal table or
    whether the selected data is to be appended to the contents and
    whether the selected data is to be placed in the internal table all at once or in several packets.
    The INTO clause can also follow the FROM clause.
    You can omit the INTO clause. The system then makes the data available in the table work area (see TABLES ) dbtab . If the SELECT clause includes a "*", the command is processed like the identical SELECT * INTO dbtab FROM dbtab statement. If the SELECT clause contains a list a1 ... an , the command is executed like SELECT a1 ... an INTO CORRESPONDING FIELDS OF dbtab FROM dbtab .
    If the result of the selection is meant to be a table, the data is usually (for further information, see INTO -Klausel ) read line by line within a processing loop introduced by SELECT and concluded by ENDSELECT . For each line read, the processing passes through the loop once. If the result of the selection is meant to be a single record, the closing ENDSELECT is omitted.
    The FROM source clause the source (database table or view ) from which the data is to be selected. It also determines
    the type of client handling,
    the behavior for buffered tables and
    the maximum number of lines to be read.
    The WHERE where clause specifies the conditions which the result of the selection must satisfy. It thus determines the lines of the result table. Normally - i.e. unless a client field is specified in the WHERE clause - only data of the current client is selected. If you want to select across other clients, the FROM clause must include the addition ... CLIENT SPECIFIED .
    The GROUP-BY fields clause combines groups of lines together into single lines. A group is a set of lines which contain the same value for every database field in the GROUP BY clause.
    The ORDER-BY order clause stipulates how the lines of the result table are to be ordered.
    Each time the SELECT statement is executed, the system field SY-DBCNT contains the number of lines read so far. After ENDSELECT , SY-DBCNT contains the total number of lines read.
    The return code value is set as follows:
    SY-SUBRC = 0 At least one line was read.
    SY_SUBRC = 4 No lines were read.
    SY-SUBRC = 8 The search key was not fully qualified.
    (nur bei SELECT SINGLE ). The returned single record is any line of the solution set.
    Example
    Output the passenger list for the Lufthansa flight 0400 on 28.02.1995:
    TABLES SBOOK.
    SELECT * FROM SBOOK
      WHERE
        CARRID   = 'LH '      AND
        CONNID   = '0400'     AND
        FLDATE   = '19950228'
      ORDER BY PRIMARY KEY.
      WRITE: / SBOOK-BOOKID, SBOOK-CUSTOMID,   SBOOK-CUSTTYPE,
               SBOOK-SMOKER, SBOOK-LUGGWEIGHT, SBOOK-WUNIT,
               SBOOK-INVOICE.
    ENDSELECT.
    Note
    Performance
    In client/server environments, storing database tables in local buffers (see SAP buffering ) can save considerable amounts of time because the time required to make an access via the network is much more than that needed to access a locally buffered table.
    Notes
    A SELECT command on a table for which SAP buffering is defined in the ABAP/4 Dictionary is normally satisfied from the SAP buffer by bypassing the database. This does not apply with
    - SELECT SINGLE FOR UPDATE
    - SELECT DISTINCT in the SELECT clause ,
    - BYPASSING BUFFER in the FROM clause ,
    - ORDER BY f1 ... fn in the ORDER-BY clause ,
    - aggregate functions in the SELECT clause ,
    - when using IS [NOT] NULL WHERE condition ,
    or if the generic key part is not qualified in the WHERE-Bedingung for a generically buffered table.
    Authorization checks are not supported by the SELECT statement, so you must program these yourself.
    In dialog systems, the database system locking mechanism cannot always guarantee to synchronize the simultaneous access of several users to the same dataset. In many cases, it is therefore advisable to use the SAP locking mechanism .
    Changes to data in a database are only finalized after a database commit (see LUW ). Prior to this, any database update can be reversed by a database rollback (see Programming transactions ). At the lowest isolation level (see the section on the "uncommitted read" under Locking mechanism ), this can result in the dataset selected by the SELECT command not really being written to the database. While a program is selecting data, a second program can add, change or delete lines at the same time. Then, the changes made by the second program are reversed by rolling back the database system. The selection of the first program thus reflects only a very temporary state of the database. If such "phantom data" is not acceptable for a program, you must either use the SAP locking mechanism or at least set the isolation level of the database system to "committed read" (see Locking mechanism ).
    In a SELECT-ENDSELECT loop, the CONTINUE statement terminates the current loop pass prematurely and starts the next.
    If one of the statements in a SELECT ... ENDSELECT loop results in a database commit, the cursor belonging to the SELECT ... ENDSELECT loop is lost and the processing terminates with a runtime error. Since each screen change automatically generates a database commit, statements such as CALL SCREEN , CALL DIALOG , CALL TRANSACTION or MESSAGE are not allowed within a SELECT ... ENDSELECT loop.
    Related OPEN CURSOR , FETCH und CLOSE CURSOR
    GO THROUGH THIS LINK
    http://www.geocities.com/SiliconValley/Campus/6345/select.htm
    THANKS
    MRUTYUN

  • Select FOR ALL ENTRIES statement cannot get duplicates entries

    Hi all,
    t_yxapy_fields consist of
    inty  field
    0001 kostl
    0002 perid
    0008 ansal
    0008 preas
    0008 trfst
    The following is the code for me to transfer the contents of t_yxapy_fields into t_pa_fields.
    SELECT dbtab
          FROM t777d
          INTO TABLE t_pa_fields
          FOR ALL ENTRIES IN t_yxapy_fields
          WHERE infty = t_yxapy_fields-infty.
    And t_pa_fields just ended up with
    field   infty
    pa0001
    pa0002
    pa0008
    Question:The first table have 3 similar infotype 0008 but the result table only have one pa0008. I need to filled up acordingly as what table 1 have. I need another 2 pa0008 in my 2nd table. What is wrng with my Select for all entries statement here?
    Edited by: Siong Chao on Mar 27, 2010 10:35 AM

    This has nothing to do with duplicates in t777d.
    Correct, I failed to recognize that table t777d has only infty as key as pointed out by Aby. Thus in your particular case my comment was misleading. In general though FOR ALL ENTRIES removes all duplicate rows from your result set.
    If you want the other 2 values just loop t_yxapy_fields this table and read t_pa_fields and if record found add the other values to t_pa_fields table. --> will trigger performance tuning issue
    I'm pretty sure if you'd code this, you won't run into any performance issues, so follow Aby's recipe. To be more concrete, here's what I'd do: Define a mapping table t777d_tab, which holds the translation from infty to dbtab:
    types:
      begin of T_T777D_VIEW,
        INFTY type T777D-INFTY,
        DBTAB type T777D-DBTAB,
      end of T_T777D_VIEW.
    data:
      T777D_TAB type hashed table of T_T777D_VIEW with unique key INFTY.
    Fill table t_pa_fields, typed using t_t777d_tab from above, from table t777d. Then loop over your table t_yxapy_fields (I'd use [LOOP AT ... ASSIGNING|http://help.sap.com/abapdocu_70/en/ABAPLOOP_AT_ITAB_RESULT.htm] instead of LOOP AT ... INTO) and for each entry get the corresponding DBTAB value from t777d_tab (again use the [READ TABLE ... ASSIGNING|http://help.sap.com/abapdocu_70/en/ABAPREAD_TABLE_OUTDESC.htm] variant) and build your result table t_pa_fields.
    Anyhow, I suspect that even with less optimal coding (e.g. using just standard table for lookup of DBTAB values) you'd not see much of an performance impact, because it seems that your internal tables are most likely rather small...
    Cheers, harald

  • Inner join and select for all entries with respect to performance

    Hi Friends,
    I just want to know which is more efficient with respect to performance the Inner join or select for all entries?which is more efficient? and how? can you explain me in detail ?
    Regards,
    Dinesh

    INNER JOIN->
    The data that can be selected with a view depends primarily on whether the view implements an inner join or an outer join. With an inner join, you only get the records of the cross-product for which there is an entry in all tables used in the view. With an outer join, records are also selected for which there is no entry in some of the tables used in the view.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ec77446011d189700000e8322d00/content.htm
    FOR ALL ENTRIES->
    Outer join can be created using this addition to the where clause in a select statement. It speeds up the performance tremendously, but the cons of using this variation are listed below
    Duplicates are automatically removed from the resulting data set. Hence care should be taken that the unique key of the detail line items should be given in the select statement.
    If the table on which the For All Entries IN clause is based is empty, all rows are selected into the destination table. Hence it is advisable to check before-hand that the first table is not empty.
    If the table on which the For All Entries IN clause is based is very large, the performance will go down instead of improving. Hence attempt should be made to keep the table size to a moderate level.
    Not Recommended
    Loop at int_cntry.
    Select single * from zfligh into int_fligh
    where cntry = int_cntry-cntry.
    Append int_fligh.
    Endloop.
    Recommended
    Select * from zfligh appending table int_fligh
    For all entries in int_cntry
    Where cntry = int_cntry-cntry.

  • Driver table in select for all entries

    anyone please let me what is driver table in select for all entries and when do we go for select for all entries

    Here is something from help
    FOR ALL ENTRIES WHERE
    Syntax
    ... FOR ALL ENTRIES IN itab WHERE ... col operator itab-comp ...
    Effect
    If the addition FOR ALL ENTRIES is specified before the language element WHERE, then the components comp of the internal table itab can be used as operands when comparing with relational operators.
    The internal table itab must have a structured line type and the component comp must be compatible with the column col.
    The logical expression sql_cond of the WHERE condition can comprise various logical expressions by using AND and OR. However, if FOR ALL ENTRIES is specified, there must be at least one Comparison with a column of the internal table itab, which can be specified either statistically or dynamically (Release 6.40 and higher). In a statement with a SELECTstatement with FOR ALL ENTRIES, the addition ORDER BY can only be used with the addition PRIMARY KEY.
    The whole logical expression sql_cond is evaluated for each individual line of the internal table itab. The resulting set of the SELECT statement is the union of the resulting sets from the individual evaluations. Duplicate lines are automatically removed from the resulting set. If the internal table itab is empty, the whole WHERE statement is ignored and all lines in the database are put in the resulting set.
    Notes
    In Release 6.10 and higher, the same internal table can be specified after FOR ALL ENTRIES and after INTO.
    The addition FOR ALL ENTRIES is only possible before WHERE conditions of the SELECT statement.
    Example
    Exporting all flight data for a specified departure city. The relevant airlines and flight numbers are first put in an internal table entry_tab, which is evaluated in the WHERE condition of the subsquent SELECT statement.
    PARAMETERS p_city TYPE spfli-cityfrom.
    TYPES: BEGIN OF entry_tab_type,
             carrid TYPE spfli-carrid,
             connid TYPE spfli-connid,
           END OF entry_tab_type.
    DATA: entry_tab   TYPE TABLE OF entry_tab_type,
          sflight_tab TYPE SORTED TABLE OF sflight
                           WITH UNIQUE KEY carrid connid fldate.
    SELECT carrid connid
           FROM spfli
           INTO CORRESPONDING FIELDS OF TABLE entry_tab
           WHERE cityfrom = p_city.
    SELECT carrid connid fldate
           FROM sflight
           INTO CORRESPONDING FIELDS OF TABLE sflight_tab
           FOR ALL ENTRIES IN entry_tab
           WHERE carrid = entry_tab-carrid AND
                 connid = entry_tab-connid.
    Regards,
    Santosh

  • Regarding SELECT FOR ALL ENTRIES AND DELETE ADJACENT DUPLICATES

    Hi,
    i got few doubts.....
        1) Is it necessary to DELETE ADJACENT DUPLICATES when we perform a SELECT FOR ALL ENTRIES ? because for all entries itself eliminates the duplicate entries?
       2) Wat Sy-subrc returns after a SELECT FOR ALL ENTRIES statement?
       I found some code where these are used
               SORT ITAB[] BY NEWKO[].
              DELETE ADJACENT DUPLICATES FORM ITAB[].
      SELECT buknr
                   kunnr
    FORM KNB1
        into table ITAB_KNB1
      FOR ALL ENTRIES IN ITAB
        where kunnr eq itab-newko.
    Regards.
    Maehsh.

    Hi Mahesh,
    To be more specific, first you should delete "adjacent duplicates" using the sorting key ( here : NEWKO ), if Itab contains other fields.
    SORT ITAB[] BY NEWKO[].
    DELETE ADJACENT DUPLICATES FORM ITAB COMPARING NEWKO.
    You can delete or not the duplicates, but, you must know that if you don't delete them in the Itab, you will retrieve them in the ITAB_KNB1.
    Concerning the return code, it works like for the "SELECT"  ( 0 = entries found / 4 = no entrie found )
    => One more thing, it's better check :
    Check not ITab[] is initial
    because, if the Itab is empty, you'll retrieve all the record of KNB1 !
    Hope this helps,
    Erwan.
    Message was edited by:
            Erwan LE BRUN

  • Regarding select for all entries

    Hi all,
    I want to use select for all entries....
    because i have to club 3 tablese and get the data.
    I can go for inner joins but i cant use because of performmance issues.
    so can anybody help me regarding this.
    thanks and regards,
    giri.

    do this way............
    types: begin of gt_vbrk,
            vbeln type vbrk-vbeln,
            fkart type vbrk-fkart,
            knumv type vbrk-knumv,
            bukrs type vbrk-bukrs,
            waerk type vbrk-waerk,
            netwr type vbrk-netwr,
            end of gt_vbrk,
            begin of gt_vbrp,
            vbeln type vbrp-vbeln,
            posnr type vbrp-posnr,
            fkimg type vbrp-fkimg,
            meins type vbrp-meins,
            gsber type vbrp-gsber,
            netwr type vbrp-netwr,
            aubel type vbrp-aubel,
            aupos type vbrp-aupos,
            end of gt_vbrp,
            begin of gt_vbak,
            vbeln type vbak-vbeln,
            augru type vbak-augru,
            vkgrp type vbak-vkgrp,
            gsber type vbak-gsber,
            end of gt_vbak,
            begin of gt_vbap,
            vbeln type vbap-vbeln,
            posnr type vbap-posnr,
            matnr type vbap-matnr,
            netwr type vbap-netwr,
            end of gt_vbap,
    data : git_vbrk type standard table of gt_vbrk,
          git_vbrp type standard table of gt_vbrp,
          git_vbak type standard table of gt_vbak,
          git_fcode type table of gt_fcode,
          git_vbap type table of gt_vbap.
    data : wa_vbrk type gt_vbrk,
          wa_vbrp type gt_vbrp,
          wa_vbak type gt_vbak,
          wa_fcode type gt_fcode,
          wa_vbap type gt_vbap.
    select  vbeln
              fkart
              knumv
              bukrs
              waerk
              netwr
        from vbrk into table git_vbrk
        where vbeln in s_vbeln.
      if sy-subrc eq 0.
        sort git_vbrk by vbeln.
      endif.
    if not git_vbrk[] is initial.
    clear git_vbrp[].
      select  vbeln
              posnr
              fkimg
              meins
              gsber
              netwr
              aubel
              aupos
         from vbrp into table git_vbrp
         for all entries in git_vbrk
         where vbeln = git_vbrk-vbeln.
      if sy-subrc eq 0.
        sort git_vbrp by vbeln.
      endif.
    select  vbeln
              augru
              vkgrp
              gsber
        from vbak into table git_vbak
        for all entries in git_vbrp
        where vbeln = git_vbrp-aubel.
      if sy-subrc eq 0.
        sort git_vbak by vbeln.
      endif.
    reward points if helpful............

  • Inner join and select for all entries with respect to performance in SAP

    Hi Friends,
    I just want to know which is more efficient with respect to performance the Inner join or select for all entries?which is more efficient?
    Regards,
    Dinesh

    I did some testing a while ago and found that a JOIN is usually a bit more efficient than FOR ALL ENTRIES. This wasn't always the case though, so the best thing to do is to write it both ways and see which is faster.
    Rob

  • Dynamic OpenSQL - SELECT FOR ALL ENTRIES ?

    Hi!
    Is it possible to do a dynamic SELECT FOR ALL ENTRIES IN... command?
    sg. like:
    DATA:
    select_text TYPE string,
    from_text TYPE string,
    where_text TYPE string.
    SELECT FOR ALL ENTRIES IN <gt_table1> (select_text)
    into corresponding fields of table <gt_table2>
    FROM (from_text)
    WHERE (where_text).
    Thanks and Best Regards,
    Tamas

    Hi
    INSERT INTO (SELECT department_id, department_name, location_id
       FROM departments WHERE location_id < 2000)
       VALUES (9999, 'Entertainment', 2500);
    Is this you are looking for ?
    Regards
    Vinod

  • Performance on Select Single&Write  AND Select*(For All Entries)&Read&Write

    Hi Experts,
    I got a code review problem & we are in a argument.
    I need the best performance code out of this two codes. I have tested this both on 5 & 1000 & 3000 & 100,000 & 180,000 records.
    But still, I just need a second opinion of experts.
    TYPES : BEGIN OF ty_account,
            saknr   TYPE   skat-saknr,
            END OF ty_account.
    DATA : g_txt50      TYPE skat-txt50.
    DATA : g_it_skat    TYPE TABLE OF skat,       g_wa_skat    LIKE LINE OF g_it_skat.
    DATA : g_it_account TYPE TABLE OF ty_account, g_wa_account LIKE LINE OF g_it_account.
    Code 1.
    SELECT saknr INTO TABLE g_it_account FROM skat.
    LOOP AT g_it_account INTO g_wa_account.
      SELECT SINGLE txt50 INTO g_txt50 FROM skat
        WHERE spras = 'E'
          AND ktopl = 'XXXX'
          AND saknr = g_wa_account-saknr.
      WRITE :/ g_wa_account-saknr, g_txt50.
      CLEAR : g_wa_account, g_txt50.
    ENDLOOP.
    Code 2.
    SELECT saknr INTO TABLE g_it_account FROM skat.
    SELECT * INTO TABLE g_it_skat FROM skat
      FOR ALL ENTRIES IN g_it_account
          WHERE spras = 'E'
            AND ktopl = 'XXXX'
            AND saknr = g_it_account-saknr.
    LOOP AT g_it_account INTO g_wa_account.
      READ TABLE g_it_skat INTO g_wa_skat WITH KEY saknr = g_wa_account-saknr.
      WRITE :/ g_wa_account-saknr, g_wa_skat-txt50.
      CLEAR : g_wa_account, g_wa_skat.
    ENDLOOP.
    Thanks & Regards,
    Dileep .C

    Hi Dilip.
    from you both the code I have found that you are selecting 2 diffrent fields.
    In Code 1.
    you are selecting SAKNR and then for these SAKNR you are selecting TXT50 from the same table.
    and in Code 2 you are selecting all the fields from SAKT table for all the values of SAKNR.
    I don't know whats your requirement.
    Better you declare a select option on screen and then fetch required fields from SAKT table for the values entered on screen for SAKNR.
    you only need TXT50 and SAKNR fields.
    so declare two types one for SAKNR and another for TXT50.
    Points to be remember.
    1. while using for all entries always check the for all entries table should not be blank.
    2. you will have to fetch all the key fields in table while applying for all entries,
        you can compare key fields with a constant which is greater than initial value.
    3. while reading the table sort the table by the field on which you are going to read it.
    try this:
    TYPES : BEGIN OF ty_account,
    saknr TYPE skat-saknr,
    END OF ty_account.
    TYPES : begin of T_txt50,
          saknr type saknr,
          txt50 type txt50,
    end of t_txt50.
    DATA: i_account type table of t_account,
          w_account type t_account,
          i_txt50 type table t_txt50,
          w_txt50 type t_txt50.
    select SAKNR from SKAT into table i_account.
    if sy-subrc = 0.
    sort i_account by saknr.
    select saknr txt50 from SKAT into table i_txt50
    for all entries in i_account
    where SAKNR = i_account-SAKNR
    here mention al the primary keys and compare them with their constants.
    endif.     
    Note; here you need to take care that, you will have to fetch all the key fields in table i_txt50.
    and compare those fields with there constants which should be greater than initial values.
    they should be in proper sequence.
    now for writing.
    loop at i_account into w_account.
    clear w_txt50.
    sort i_txt50 by saknr.
    read table i_txt50 into w_txt50 with key SAKNR = w_account-saknr
    if sy-subrc = 0.
    write: w_txt50-saknr, w-txt50-txt50.
    clear w_txt50, w_account.
    endif.
    endloop.
    Hope it wil clear your doubts.
    Thanks
    Lalit

Maybe you are looking for

  • Images too heavy

    The images on my iweb site are too heavy and are making the site slow. Does anyone know of a trick to resolve this without resizing, reframing and remasking all of the images?

  • ORA-07445 ACCESS_VIOLATION kglophup+66 instance crash

    My db was crash as GATHER_STATS_JOB was trying to gather some status from db instance, rise the error ora-07445 [kglophup+66] at 6:00 am. I start it when I found it was down and works well till now. Sat Dec 22 06:00:31 中国标准时间 2012 Errors in file e:\o

  • Update 4.3.3 to ios 5 or newer version

    My wife has an old iphone 4 with 4.3.3 and we'd like tp update it to ios 5 or newer version. Please help me and explain how I could do this?!

  • Missing plugin for Sequence

    Im happy with the program yet i try to pick my sequence and GET THIS Please Respond as soo as possible THANK YOU!!

  • PC Media Keyboards

    In iTunes in Windows how do you get media keyboard buttons to operate on iTunes when iTunes is not in focus? I have this issue on multiple keyboards and multiple Windows OS, however to give an example: on my home gaming PC which is Windows 7 x64 I ha