Parallel cursor

hi experts,
can i use more than one parallel cursor , when i looping thru different internal tables,
i used once it in my current prog as i need multiple Grn no(ekbe-belnr) , with respect to single po(ekpo-ebeln).
but in my current prog. i also need multiple (konv-kposn) vaue with respect to sigle po no,
to display multiple tax calculation!
plz help , i badly needed this answer in no time

Hi,
Have a look at the code below. The select the entries from KONV based on the requirement. Better not to use the select *, instead select the required fields from the tables.
TABLES : ekko, ekpo, ekbe, konv.
DATA: it_ekpo TYPE TABLE OF ekpo WITH HEADER LINE,
      it_ekbe TYPE TABLE OF ekbe WITH HEADER LINE,
      it_konv TYPE TABLE OF konv WITH HEADER LINE.
DATA: l_index1 TYPE sytabix,
      l_index2 TYPE sytabix.
SELECT-OPTIONS s_ebeln FOR ekko-ebeln.
SELECT-OPTIONS s_knumv FOR konv-knumv.
SELECT * FROM ekpo INTO TABLE it_ekpo WHERE ebeln IN s_ebeln.
IF NOT it_ekpo[] IS INITIAL.
  SELECT * FROM ekbe INTO TABLE it_ekbe
    FOR ALL ENTRIES IN it_ekpo
    WHERE ebeln = it_ekpo-ebeln
      AND ebelp = it_ekpo-ebelp.
ENDIF.
SELECT * FROM konv INTO TABLE it_konv
              WHERE knumv = s_knumv.
SORT it_ekpo BY ebeln ebelp.
SORT it_ekbe BY ebeln ebelp.
SORT it_konv BY knumv.
LOOP AT it_ekpo.
  LOOP AT it_ekbe FROM l_index1.
    if ( it_ekbe-ebeln ne it_ekpo-ebeln )
          and ( it_ekbe-ebelp ne it_ekpo-ebelp ).
      exit.
    else. 
    l_index1 = sy-tabix.
*do the necessary calculations
    endif.
    LOOP AT it_konv FROM l_index2.
write the necessary if condition so that it would exit from the loop
  if (.......)
else.
fill the required fields and do the necessary calculations
      l_index2 = sy-tabix.
    ENDLOOP.
  ENDLOOP.
ENDLOOP.
The loop of the konv table has to be placed as required based on whether it has to be in the loop of EKBE or out of EKBE.

Similar Messages

  • Parallel Cursor Technique

    Hello,
             Can some one give me a description in detail as to what exactly Parallel cursor method is and how it works.
              Also, what are the Performance Tuning Techniques that we can follow during ABAP Development?
    Thanks and Regards,
    Venkat

    actually, I would not recommend the parallel cursor technique! First name is actually incorrect internal tables have no cursor only indexes, only parallel
    index would make sense.
    Performance improvement:
    If costs for sort are taken into account, then parallel index is not faster than loop with loop on sorted table.
    or with standard table
    loop
        read ...  binary search
        index = sy-tabix   
        loop ... from index
           if  ( condition is not fulfilled )
              exit
           endif.
        endloop
    endloop
    The full parallel index technique should find all deviations between 2 tables, additional lines in Tab1, additional lines in tab2, changes.
    Feel free to find a complete solution. We can compare results, it is not worth the effort!
    Siegfried

  • What is parallel cursor technique.

    what is parallel cursor technique. Please give an example
    thanx in advance

    Suppose u got data in two internal table itab1 and itab2 from header and from item table
    u have to take cobine the values into one table
    so normally what we do is that we write loop .(item table -itab2 ) inside antother loop (header table-itab1) . but it will affect the performance
    So go for Parallel cursor method
    Regards,
    Nikhil

  • What is parallel cursor

    what is parallel cursor

    Hi,
    Here is the sample program which use the parallel cursor,
    *              Performance Tuning using parallel cursor
    * Extracts from program ZFAL2002
    * START-OF-SELECTION
      SELECT *
      INTO TABLE I_KEPH FROM KEPH
      WHERE KADKY <= SY-DATUM
        AND TVERS = '01'
        AND KALKA IN ('01','Z1','Z2')
        AND BWVAR IN ('Z01','Z02','Z03','Z04','Z07')
        AND KKZST = ' '
        AND KKZMA = ' '
        AND KKZMM = ' '
        AND KEART = 'H'
        AND PATNR = 0.
    * Table must be sorted to ensure all required records are together
      SORT I_KEPH BY KALNR KALKA BWVAR KADKY.
    * Perform actual processing
      Perform get_cost_values.
    FORM GET_COST_VALUES.
    * Determine start position and then process all records for given key
    * from that starting point
    * i_keph is sorted on kalnr kalka bwvar kadky.
      READ TABLE I_KEPH WITH KEY KALNR = W_KEKO-KALNR
                                 KALKA = W_KEKO-KALKA
                                 BWVAR = W_KEKO-BWVAR
                                 KADKY = W_KEKO-KADKY BINARY SEARCH.
      IF SY-SUBRC = 0.
    * Loop at itab from first record found (sy-tabix) until record
    * no-longer matches your criteria.
        LOOP AT I_KEPH FROM SY-TABIX.
          IF  I_KEPH-KALNR = W_KEKO-KALNR AND I_KEPH-KALKA = W_KEKO-KALKA
          AND I_KEPH-BWVAR = W_KEKO-BWVAR AND I_KEPH-KADKY = W_KEKO-KADKY.
    *       Key match
            D_MAT_COST = D_MAT_COST + I_KEPH-KST001.
            D_LAB_COST = D_LAB_COST + I_KEPH-KST004.
            D_OVER_HEAD = D_OVER_HEAD + I_KEPH-KST010.
            D_EXT_PURCH = D_EXT_PURCH + I_KEPH-KST014.
            D_MISC_COST = D_MISC_COST + I_KEPH-KST002 + I_KEPH-KST003
                        + I_KEPH-KST005 + I_KEPH-KST006 + I_KEPH-KST007
                        + I_KEPH-KST008 + I_KEPH-KST009 + I_KEPH-KST011
                        + I_KEPH-KST012 + I_KEPH-KST013 + I_KEPH-KST015
                        + I_KEPH-KST016 + I_KEPH-KST017 + I_KEPH-KST018
                        + I_KEPH-KST019 + I_KEPH-KST020 + I_KEPH-KST021
                        + I_KEPH-KST022 + I_KEPH-KST023 + I_KEPH-KST024
                        + I_KEPH-KST025 + I_KEPH-KST026 + I_KEPH-KST027
                        + I_KEPH-KST028 + I_KEPH-KST029 + I_KEPH-KST030
                        + I_KEPH-KST031 + I_KEPH-KST032 + I_KEPH-KST033
                        + I_KEPH-KST034 + I_KEPH-KST035 + I_KEPH-KST036
                        + I_KEPH-KST037 + I_KEPH-KST038 + I_KEPH-KST039
                        + I_KEPH-KST040.
          ELSE.
    *       Key greater - can't be less
            EXIT.                                               " Exit loop
          ENDIF.
        ENDLOOP.
      ENDIF.
      D_MAT_COST  = D_MAT_COST  / W_KEKO-LOSGR.
      D_LAB_COST  = D_LAB_COST  / W_KEKO-LOSGR.
      D_OVER_HEAD = D_OVER_HEAD / W_KEKO-LOSGR.
      D_EXT_PURCH = D_EXT_PURCH / W_KEKO-LOSGR.
      D_MISC_COST = D_MISC_COST / W_KEKO-LOSGR.
    ENDFORM.                               " GET_COST_VALUES

  • What is meant by parallel cursor

    hi
    what is meant by parallel cursor

    Hi,
      Parallel cursor is the technique to increase the perforamance of the program. For example if we use nested select in our program instead of For all entries addition, then definetly performance going down. In the same way the if we use nested loops in the program it will also leads to down the performance.
      I will give you one example like take billing document header details in one table and item details in other table let say the header table have 1000 records and the item table have 1 lakh records. If you want to make an output then you need to put nested loops first loop at header table then next loop at item table. For each entry of header record the item table loops 1 lakh times. calculate the total. so instead of we develop parallel cursor technique,, see the belwo code..
    Loop at header.
    read table item with key number = header-number.
    if sy-subrc = 0.
    loop at item from sy-tabix.
    if item-number <> header-number.
    exit.
    else.
    do some process here.
    endif.
    endloop.
    endif.
    endloop.
    First the item table is read using the read table statement for getting the exact index number where the document number reside. if found then loop through the item table from that index upto item- number <> header-number.
    Rgds,
    Bujji
    Edited by: Bujji on Jun 26, 2008 12:48 PM

  • Using parallel cursor

    Hi Experts,
    In my program using nested loop. I want avoid that using parallel cursor. But In two nested loops, using
    I done, but where has three nested loops how ? plz tell me or send code?
    Ex: my Requirment is like this
    Loop at i_tab1 into wa_tab1.
      loop at  s_tab into wa_tab2.
    end loop.
          loop at k_tab into wa_tab3
    end loop.
    end loop.
    plz send code using parallel cursor, if u get more points.
    thanx
    srinu

    HI,
    Check this Code .....
    REPORT  zparallel_cursor.
    TABLES:
      likp,
      lips.
    DATA:
      t_likp  TYPE TABLE OF likp,
      t_lips  TYPE TABLE OF lips.
    DATA:
      w_runtime1 TYPE i,
      w_runtime2 TYPE i,
      w_index LIKE sy-index.
    START-OF-SELECTION.
      SELECT *
        FROM likp
        INTO TABLE t_likp.
      SELECT *
        FROM lips
        INTO TABLE t_lips.
      GET RUN TIME FIELD w_runtime1.
      SORT t_likp BY vbeln.
      SORT t_lips BY vbeln.
      LOOP AT t_likp INTO likp.
        LOOP AT t_lips INTO lips FROM w_index.
          IF likp-vbeln NE lips-vbeln.
            w_index = sy-tabix.
            EXIT.
          ENDIF.
        ENDLOOP.
      ENDLOOP.
      GET RUN TIME FIELD w_runtime2.
      w_runtime2 = w_runtime2 - w_runtime1.
      WRITE w_runtime2.
    Either you can use the above code ..or ucan replace the inside loops with read statement of lopp with where clause depending on requirement
    Edited by: avinash kodarapu on Nov 30, 2008 4:04 PM

  • Parallel Cursor method

    Dear Experts,
    I am using parallel cursor method for a nested loop by using this method the report got very fast
    but the data from the loop where I used Parallel cursor method is not coimng after 7000 records.
    Say when I am running the report from 1st jan to 30 jan  total records are 48,000 but data from parallel cursor method 's loop is cumin till 7th of jan (7000 records) after that all values are coming zero.
    When I am running it from 7th of jan to 30 th Jan data from that loop is cumin till 15th of jan(7000 records) after that values are cumin zero.
    Below I am writing the code I used for parallel cursor method loop
    paralele cursor method
    data : v_index type sy-tabix.
    read TABLE i_konv  into wa_konv   with key  knumv  = wa_vbrk-knumv
                                                kposn = wa_vbrp-posnr  binary search.
         if sy-subrc = 0.
          v_index = sy-tabix.
       loop at  i_konv into wa_konv FROM v_index.  "FROM v_index.
         if wa_konv-knumv = wa_vbrk-knumv.
           if wa_konv-kposn <> wa_vbrp-posnr.
             exit.
             endif.
           else.
             exit.
         endif.
    Thanks and Regards,
    Vikas Patel

    Hi Vikas,
    First check there are records available completely in you Internal table...
    and Here is a very simple example for parallel cusor..
    REPORT  zparallel_cursor.
    TABLES:
      likp,
      lips.
    DATA:
      t_likp  TYPE TABLE OF likp,
      t_lips  TYPE TABLE OF lips.
    DATA:
      w_runtime1 TYPE i,
      w_runtime2 TYPE i,
      w_index LIKE sy-index.
    START-OF-SELECTION.
      SELECT *
        FROM likp
        INTO TABLE t_likp.
      SELECT *
        FROM lips
        INTO TABLE t_lips.
      GET RUN TIME FIELD w_runtime1.
      SORT t_likp BY vbeln.
      SORT t_lips BY vbeln.
      LOOP AT t_likp INTO likp.
        LOOP AT t_lips INTO lips FROM w_index.
          IF likp-vbeln NE lips-vbeln.
            w_index = sy-tabix.
            EXIT.
          ENDIF.
        ENDLOOP.
      ENDLOOP.
    compare the difference.
    Thanks & regards,
    Dileep .C

  • BPM - Parallel Looping - numberOfCompletedIterations.

    Hi,
    In the human activity when using parallel looping, two local attributes are generated automatically currentCollectionItem and numberOfCompletedIterations. I need the value in the numberOfCompletedIterations to my webdynpro java component. I mapped the attribute to the string attribute with function String(/numberOfCompletedIterations), irrespective of the number of iterations completed I am getting the value as 0.
    Any help will be really appreciated.
    Best Wishes
    Idhaya R

    hi,
    hope this link will help u to know about parallel cursor ie using loops inside loops
    [http://www.****************/Tutorials/ABAP/ParallelCursor.htm]
    regards,
    priya

  • How to use parrallel cursor in this code

    hi can anyone expalin me how to use parallel cursor for this code ... 
    loop at itabkpf.
          read table ibsegpar_fu with key
                     belnr = itabkpf-belnr
                     gjahr = itabkpf-gjahr
                     bschl = '25' .
    Start insert by Pradeep 20082008
          sort: itabkpf by belnr,
                itabsegpar by belnr.
    End insert by Pradeep 20082008
          if sy-subrc = 0. "Deleted by pradeep 20082008
            select bukrs belnr gjahr bschl koart lifnr wrbtr
                   wskto pswbt zfbdt augbl augdt sgtxt rebzg rebzj
                   into corresponding
                   fields of table ibsegpar_fu_1 from bseg
                   where bukrs = itabkpf-bukrs and
                   belnr = itabkpf-belnr and
                   gjahr = itabkpf-gjahr and
                   augbl <> itabkpf-belnr and
                   rebzg <> space and
                   bschl = '25'.
            loop at ibsegpar_fu_1.
    Start insert by Pradeep 20082008
              sort ibsegpar_fu_1 by belnr.
    End insert by Pradeep 20082008
              move-corresponding ibsegpar_fu_1 to itabseg.
              move ibsegpar_fu_1-belnr to itabseg-augbl.
              move ibsegpar_fu_1-rebzg to itabseg-belnr.
              move ibsegpar_fu_1-rebzj to itabseg-gjahr.
    *********to include code to pick the description for partical payment
              select single * from bseg where
                  bukrs = ibsegpar_fu_1-bukrs and
                  belnr = ibsegpar_fu_1-belnr and
                  gjahr = ibsegpar_fu_1-gjahr and
                  augbl <> ibsegpar_fu_1-belnr and
                  rebzg = space and
                  bschl <> '25'.
              move bseg-sgtxt to itabseg-sgtxt.
              clear bseg.
    *********end of code
              itabseg-wrbtr = itabseg-wrbtr * -1.
              itabseg-pswbt = itabseg-pswbt * -1.
              select single budat into lsdat from
                   bkpf where bukrs = ibsegpar_fu_1-bukrs and
                   belnr = ibsegpar_fu_1-rebzg and
                   gjahr = ibsegpar_fu_1-rebzj.
              if sy-subrc = 0.
                move lsdat to itabseg-zfbdt.
              endif.
              append itabseg.
            endloop.
          endif. "Deleted by Pradeep 20082008
        endloop.
        loop at ibsegpar_fu.
          sort ibsegpar_fu by belnr. " insert by pradeep
          move-corresponding ibsegpar_fu to itabseg.
          select bukrs belnr gjahr bschl koart lifnr wrbtr
                 rebzg rebzj sgtxt into corresponding
                 fields of table ibsegpar_fu_1 from bseg
                 where  bukrs = ibsegpar_fu-bukrs and
                 gjahr = ibsegpar_fu-gjahr and
                 augbl = ibsegpar_fu-belnr and  " Pradeep 20082008 Delete
                augbl <> ibsegpar_fu-belnr and " Pradeep 20082008 Insert
                 rebzg = space and
                 bschl = '25'.
          if sy-subrc = 0.
            loop at ibsegpar_fu_1.
              move ibsegpar_fu_1-rebzg to itabseg-rebzg.
              move ibsegpar_fu_1-rebzj to itabseg-rebzj.
            endloop.
            move ibsegpar_fu-belnr to itabseg-augbl.
            move itabseg-rebzg to itabseg-belnr.
            move itabseg-rebzj to itabseg-gjahr.
            itabseg-wrbtr = itabseg-wrbtr * -1.
            itabseg-pswbt = itabseg-pswbt * -1.
            select single budat into lsdat from
                 bkpf where bukrs = ibsegpar_fu-bukrs and
                 belnr = itabseg-rebzj and
                 gjahr = itabseg-rebzj.
            if sy-subrc = 0.
              move lsdat to itabseg-zfbdt.
            endif.
            append itabseg.
            read table itabseg with key
                 belnr = itabseg-rebzg
                 gjahr = itabseg-rebzj
                 bschl = '31' .
            if sy-subrc = 0.
             delete itabseg index sy-tabix. "Deleted by Pradeep 20082108
            endif.
          endif.
        endloop.
    Start insert by Pradeep 20082008
         loop at itabseg.
          if itabseg-belnr = itabseg-augbl.
            delete itabseg.
          elseif itabseg-belnr = ' '.
            delete itabseg.
          endif.
        endloop.
    End insert by Pradeep 20082008

    hi can anyone expalin me how to use parallel cursor for this code ... 
    loop at itabkpf.
          read table ibsegpar_fu with key
                     belnr = itabkpf-belnr
                     gjahr = itabkpf-gjahr
                     bschl = '25' .
    Start insert by Pradeep 20082008
          sort: itabkpf by belnr,
                itabsegpar by belnr.
    End insert by Pradeep 20082008
          if sy-subrc = 0. "Deleted by pradeep 20082008
            select bukrs belnr gjahr bschl koart lifnr wrbtr
                   wskto pswbt zfbdt augbl augdt sgtxt rebzg rebzj
                   into corresponding
                   fields of table ibsegpar_fu_1 from bseg
                   where bukrs = itabkpf-bukrs and
                   belnr = itabkpf-belnr and
                   gjahr = itabkpf-gjahr and
                   augbl <> itabkpf-belnr and
                   rebzg <> space and
                   bschl = '25'.
            loop at ibsegpar_fu_1.
    Start insert by Pradeep 20082008
              sort ibsegpar_fu_1 by belnr.
    End insert by Pradeep 20082008
              move-corresponding ibsegpar_fu_1 to itabseg.
              move ibsegpar_fu_1-belnr to itabseg-augbl.
              move ibsegpar_fu_1-rebzg to itabseg-belnr.
              move ibsegpar_fu_1-rebzj to itabseg-gjahr.
    *********to include code to pick the description for partical payment
              select single * from bseg where
                  bukrs = ibsegpar_fu_1-bukrs and
                  belnr = ibsegpar_fu_1-belnr and
                  gjahr = ibsegpar_fu_1-gjahr and
                  augbl <> ibsegpar_fu_1-belnr and
                  rebzg = space and
                  bschl <> '25'.
              move bseg-sgtxt to itabseg-sgtxt.
              clear bseg.
    *********end of code
              itabseg-wrbtr = itabseg-wrbtr * -1.
              itabseg-pswbt = itabseg-pswbt * -1.
              select single budat into lsdat from
                   bkpf where bukrs = ibsegpar_fu_1-bukrs and
                   belnr = ibsegpar_fu_1-rebzg and
                   gjahr = ibsegpar_fu_1-rebzj.
              if sy-subrc = 0.
                move lsdat to itabseg-zfbdt.
              endif.
              append itabseg.
            endloop.
          endif. "Deleted by Pradeep 20082008
        endloop.
        loop at ibsegpar_fu.
          sort ibsegpar_fu by belnr. " insert by pradeep
          move-corresponding ibsegpar_fu to itabseg.
          select bukrs belnr gjahr bschl koart lifnr wrbtr
                 rebzg rebzj sgtxt into corresponding
                 fields of table ibsegpar_fu_1 from bseg
                 where  bukrs = ibsegpar_fu-bukrs and
                 gjahr = ibsegpar_fu-gjahr and
                 augbl = ibsegpar_fu-belnr and  " Pradeep 20082008 Delete
                augbl <> ibsegpar_fu-belnr and " Pradeep 20082008 Insert
                 rebzg = space and
                 bschl = '25'.
          if sy-subrc = 0.
            loop at ibsegpar_fu_1.
              move ibsegpar_fu_1-rebzg to itabseg-rebzg.
              move ibsegpar_fu_1-rebzj to itabseg-rebzj.
            endloop.
            move ibsegpar_fu-belnr to itabseg-augbl.
            move itabseg-rebzg to itabseg-belnr.
            move itabseg-rebzj to itabseg-gjahr.
            itabseg-wrbtr = itabseg-wrbtr * -1.
            itabseg-pswbt = itabseg-pswbt * -1.
            select single budat into lsdat from
                 bkpf where bukrs = ibsegpar_fu-bukrs and
                 belnr = itabseg-rebzj and
                 gjahr = itabseg-rebzj.
            if sy-subrc = 0.
              move lsdat to itabseg-zfbdt.
            endif.
            append itabseg.
            read table itabseg with key
                 belnr = itabseg-rebzg
                 gjahr = itabseg-rebzj
                 bschl = '31' .
            if sy-subrc = 0.
             delete itabseg index sy-tabix. "Deleted by Pradeep 20082108
            endif.
          endif.
        endloop.
    Start insert by Pradeep 20082008
         loop at itabseg.
          if itabseg-belnr = itabseg-augbl.
            delete itabseg.
          elseif itabseg-belnr = ' '.
            delete itabseg.
          endif.
        endloop.
    End insert by Pradeep 20082008

  • Parallel Looping

    Hi,
    How does parallel looping works?
    I need to get every entry from afko-plnbez for every crhd-arbpl...
    Now for every crhd-arbpl and afko-plnbez,,, I have to get the mseg-menge where mseg-bwart = 101 and 102...Then,
    Add the values where mseg-bwart is 101 and subtract from that the summation of values where mseg-bwart is 102...
    I have the code below:
       REFRESH i_crhd.
       SELECT a~kostl
              b~objid
              b~vgwts
              b~arbpl
         FROM crco AS a INNER JOIN crhd AS b
           ON aobjid = bobjid
           INTO TABLE i_crhd
           WHERE b~arbpl IN s_arbpl.
       REFRESH i_mseg.
       SELECT a~mblnr
              a~bwart
              a~matnr
              a~werks
              a~dmbtr
              a~menge
              a~meins
              a~aufnr
              a~kostl
              b~budat
              FROM mseg AS a INNER JOIN mkpf AS b
              ON amblnr = bmblnr
              INTO TABLE i_mseg
                WHERE a~werks = p_werks
                  AND b~budat IN s_dates.
    IF i_mseg[] IS NOT INITIAL.
           REFRESH i_afko.
           SELECT aufnr
                  plnbez
                  aufpl
                  rsnum
             FROM afko INTO TABLE i_afko
             FOR ALL ENTRIES IN i_mseg
             WHERE aufnr = i_mseg-aufnr.
    endif.

    hi,
    hope this link will help u to know about parallel cursor ie using loops inside loops
    [http://www.****************/Tutorials/ABAP/ParallelCursor.htm]
    regards,
    priya

  • Double cursor read of database

    Hi,
    What is meant by double cursor read select statements.
    Can u please provide specific examples?

    Are you sure you don't mean "parallel cursor read of internal tables?"
    Rob

  • SY-TABIX value of a loop in other loop in other loop.

    Hello Gurus,
    I have a problem i want to modify some columns in final internal table and it is possible by using Transporting and Index but when i see SY-TABIX value it is not really giving particular loop iteration value. Because my present loop is in another loop and it is in another loop. Please gurus help me out
    or
    How to Insert particular filed columns  and how to use where clause in insert..
    Thanks.

    Hi !
    Here are things you could do:
    1. You can use nested loops with the WHERE statement on the inner loop. But this can be slow.
         This will look like this
                   loop at i_tab1 into wa1
                   loop at i_tab2 into wa2 where cond1 = wa1-cond1....
                     (   move wa2-field3 to wa1-field3.....)
                        modify i_tab1.
                   endloop.
                   endloop.
    2. You can use the parallel cursor technique as suggested above.
         This technique speeds up processing of data significantly. Here it is:
         data lv_tabix type i.
              sort i_tab1 by field1 ascending.
              sort i_tab2 by field1 ascending.
              loop at i_tab1 into wa1
              read table i_tab2 transporting no fields with key cond1 = wa1-cond1 binary search.
              lv_tabix = sy-tabix.
                   loop at i_tab2 into wa2 from lv_tabix.
                        if wa2-cond1 <> wa1-cond1.
                                   exit.       
                         endif.
                   ( move wa2-field3 to wa1-field3.....)
                        modify i_tab1.
                    endloop.
              endloop.
    Please let me know if you want more explanation

  • Program times out while looping at internal table with huge records - Needs fine tuning suggestions

    Hi,
    I am trying to execute a report. It times out while looping at vbap internal table. This internal table has 140000  records and does the validation within this loop and geenrates data for the output. Due to this huge volume, the program times out when executed foreground.
    There are no nested loops, so I cannot apply 'Parallel Cursor' here.
    Is there any way I can fine tune the program so that it doesn't timeout? Is it possible to apply 'Parallel Processing' . If yes, how?
    Thanks,
    Pavan

    Hi Pavan ,
                  ->sort your internal table by all primary key for vbap.
                  ->Read a Record from the table (use your condition here)
                  ->if record satisfys your where condition ,get that record index .
                  ->loop the table from the index (without condition) .
                  its like parallel cursor only but for single loop .;-)
                  ->use field symbols ,wherever possible .
               if still dump is coming ,contact your basis team .
    regards,
    Krishna.

  • Hello experts read table statement is not working properly

    Hello Experts.
    my code is like this.
    sort it_matnr by matnr.
    loop at itab_result.
    read table it_matnr with key matnr = itab_result-matnr  binary search.
    endloop.
    there are nearly 2000 records in it_matnr . The records which satisfy the above condition is there here in this internal table. But it is unable to read the record which matches the condition. One thing is that , there are more than one record with the same material. ie mblnr is different but material is the same. In it_matnr table i have only 1 field ie matnr ,so i need to compare only with the matnr.I also tried by sorting it_result by matnr but of no use. Then finally I used loop at where matnr = it_result-matnr , it is working fine. But due to performance reasons we should not use this. so please tell me what to do and correct the code.

    1. Make sure that the table IT_MATNR is not getting updated inside the loop. Because it will then destroy the sorting.
    2. Secondly, if there are multiple records in IT_MATNR for the same material then it will search for the first record encountered in binary algo. So it is advisable that you may provide further filter criteria if possible. check if ITAB_RESULT & IT_MATNR have any other matching field that can be put in filter criteria.
    3.Thirdly, check if your requirement can be achieved by STABLE SORT.
    <b>SORT <itab> ... STABLE BY <f1>[ASCENDING/DESCENDING].</b>
    It will allows you to perform a stable sort, that is, the relative sequence of lines that are unchanged by the sort is not changed. If you do not use the STABLE option, the sort sequence is not preserved. If you sort a table several times by the same key, the sequence of the table entries will change in each sort. However, a stable sort takes longer than an unstable sort.
    4. Lastly, you can use parallel cursor technique of multiple loops which is given below:
    LOOP AT itab_result.
      READ TABLE it_matnr
        WITH KEY matnr = itab_result-matnr
        BINARY SEARCH.
    Process record
      LOOP AT it_matnr FROM sy-tabix.
        IF it_matnr <> itab_result-matnr.
          EXIT.
        ENDIF.
    Process record based on yuor condition
      ENDLOOP.
    ENDLOOP.

  • Performance Tuning in case of Database Access

    Hi,
      I am using following code...database access is huge for this code...pls help me out to make database access minimum. I am using 3 internal tables.
    select partner1 partner2 into (mtab-busi_part, mtab-BUT051_PART)
    from but051.
    Select  name_first name_last PARTNER_GUID into (mtab-bp_first, mtab-bp_last, MTAB-R_PARTNER_GUID)
    From but000 where partner = mtab-busi_part.
    *MTAB-OBJECT_ID = ITAB-OBJECT_ID.
    append mtab.
    endselect.
    ENDSELECT.
    *ENDLOOP.
    loop at mtab.
    CONCATENATE mtab-bp_FIRST mtab-bp_LAST INTO mTAB-bp_full
                                        separated BY SPACE.
    modify mtab.
    endloop.
    loop at mtab.
    if mtab-bp_full = ' '.
      select name_org1 into (mtab-bp_full)
      from but000 where partner = mtab-busi_part.
    append mtab.
      endselect.
    endif.
    modify mtab.
    clear mtab.
    endloop.
    SELECT OBJECT_ID GUID INTO (NTAB-object_id, Ntab-guid)
    FROM CRMD_ORDERADM_H
    for all entries in itab
    where process_type = '1001' and object_id in o_id.
    select single date_1 date_2 from crmv_item_index into (ntab-date_1, ntab-date_2 )
    where object_id = ntab-object_id.
    endselect.
    Select partner_no partner_fct into (Ntab-partner_guid, Ntab-partner_fct)
    from bbp_pdview_bup where guid_hi = Ntab-guid .
    *and partner_fct <> '00000015'
    Select partner name_org1 into (Ntab-partner_no2, Ntab-others)
    from but000 where partner_guid = Ntab-partner_guid.
      if sy-subrc = 0.
      SELECT SINGLE DESCRIPTION FROM CDBC_PARTNER_FT INTO NTAB-DESC
      WHERE PARTNER_FCT = NTAB-PARTNER_FCT AND SPRAS = 'EN'.
      endif.
      SELECT  PAFKT ABTNR PAAUTH
      FROM BUT051 INTO corresponding fields of  nTAB
      WHERE PARTNER2 = ntab-partner_no2  .
           if sy-subrc = 0.
           SELECT single BEZ30 FROM TB913
        INTO CORRESPONDING FIELDS OF nTAB
        WHERE PAFKT = nTAB-PAFKT AND SPRAS = 'E'.
        endif.
         if sy-subrc = 0.
        SELECT single BEZ20 FROM TB915
        INTO CORRESPONDING FIELDS OF nTAB
        WHERE PAAUTH = nTAB-PAAUTH AND SPRAS = 'E'.
        endif.
    *endselect.
            if sy-subrc = 0.
        SELECT  single BEZ20 FROM TB911
        INTO (nTAB-BEZ2)
        WHERE ABTNR = nTAB-ABTNR AND SPRAS = 'E'.
    endif.
    endselect.
    APPEND NTAB.
    *clear ntab.
    *ENDSELECT.
    ENDSELECT.
    *clear ntab.
    ENDSELECT.
    ENDSELECT.
    loop at ntab.
      if ntab-others = ' '.
        select name_first name_last into (ntab-first_name1, ntab-last_name1)
        from but000 where partner = ntab-partner_no2.
        endselect.
        CONCATENATE ntab-FIRST_NAME1 ntab-LAST_NAME1 INTO nTAB-others
                                        separated BY SPACE.
      endif.
      modify ntab.
      clear ntab.
    endloop.
    SORT NTAB BY GUID.
    SELECT OBJECT_ID GUID INTO (KTAB-object_id, Ktab-guid)
    FROM CRMD_ORDERADM_H
    for all entries in itab
    where process_type = '1001' and object_id in o_id.
    Select  partner_no into (Ktab-partner_no1)
    From crmd_order_index where header = Ktab-guid and pft_8 = 'X' and object_type = 'BUS2000126'.
    *endselect.
    Select name_first name_last into (Ktab-first_name, Ktab-last_name)
    From but000 where partner = Ktab-partner_no1.
    *endselect.
    APPEND KTAB.
    ENDSELECT.
    ENDSELECT.
    ENDSELECT.
    loop at Ktab.
    CONCATENATE Ktab-FIRST_NAME Ktab-LAST_NAME INTO KTAB-RESP_EMPLOYEE
                                        separated BY SPACE.
    MODIFY KTAB.
    clear Ktab.
    endloop.
    loop at Ktab.
      if Ktab-RESP_EMPLOYEE = ' '.
        select name_ORG1 into (Ktab-RESP_EMPLOYEE)
        from but000 where partner = Ktab-partner_no1.
        endselect.
        endif.
      modify Ktab.
      clear Ktab.
    endloop.
    SELECT OBJECT_ID GUID INTO (itab-object_id, itab-guid)
    FROM CRMD_ORDERADM_H
    where process_type = '1001' and object_id in o_id.
    append itab.
    endselect.
    LOOP AT iTAB.
       LOOP AT NTAB .
         IF NTAB-object_id = iTAB-object_id .
              itab-date_1 = ntab-date_1.
              ITAB-DESC = NTAB-DESC.
              itab-partner_no2 = NTab-partner_no2.
              itab-partner_fct = ntab-partner_fct.
              itab-bez30 = ntab-bez30.
              itab-bez20 = ntab-bez20.
              itab-bez2 = ntab-bez2.
              itab-others = ntab-others.
              INSERT lines of nTAB INTO ITAB.
              modify itab.
              CLEAR ITAB.
             delete itab where object_id = ' ' and partner_no2 = ' '.
         ENDIF.
      endloop.
    endloop.
    sort itab by OBJECT_ID descending PARTNER_NO2 .
              delete adjacent duplicates from itab comparing partner_no2 object_id.
    sort itab by OBJECT_ID descending PARTNER_NO2 .
    loop at iTab where partner_fct = '00000015'.
      LOOP AT mTAB WHERE BUT051_PART = iTAB-partner_no2 .
       itab-busi_part = mtab-busi_part.
       itab-bp_full = mtab-bp_full.
       ITAB-R_PARTNER_GUID = MTAB-R_PARTNER_GUID.
      INSERT  LINES OF mTAB INTO iTAB.
       modify itab transporting busi_part bp_full r_partner_guid.
        endloop.
    endloop.
    sort itab by busi_part descending partner_no2.
    delete itab where object_id = ' '.
    loop at ITab.
      LOOP AT KTAB.
       IF KTAB-GUID = ITAB-GUID.
        move Ktab-partner_no1 to itab-partner_no1.
       move Ktab-R_partner_GUID to itab-R_partner_GUID.
        move Ktab-RESP_EMPLOYEE to itab-RESP_EMPLOYEE.
        modify itab.
       ENDIF.
    endloop.
    endloop.

    Hi
    i will give you some tips to reduce the daya base load please apply that
    <b>Tips and Tricks</b>
    Optimizing the load of the database
    Using table buffering
         Using buffered tables improves the performance considerably. Note that in some cases a statement can not be used with a buffered table, so when using these statements the buffer will be bypassed. These statements are:
    Select DISTINCT
    ORDER BY / GROUP BY / HAVING clause
    Any WHERE clause that contains a sub query or IS NULL expression
    JOIN s
    A SELECT... FOR UPDATE
         If you wan t to explicitly bypass the buffer, use the BYPASS BUFFER addition to the SELECT clause.
         Optimizing the load of the database
    2.  Use the ABAP SORT Clause Instead of ORDER BY
    The ORDER BY clause is executed on the database server while the ABAP SORT statement is executed on the application server. The database server will usually be the bottleneck, so sometimes it is better to move the sort from the database server to the application server.
    If you are not sorting by the primary key ( E.g. using the ORDER BY PRIMARY key statement) but are sorting by another key, it could be better to use the ABAP SORT statement to sort the data in an internal table. Note however that for very large result sets it might not be a feasible solution and you would want to let the database server sort it.
    Optimizing the load of the database
    3.   Avoid the SELECT DISTINCT Statement
    As with the ORDER BY clause it could be better to avoid using SELECT DISTINCT, if some of the fields are not part of an index. Instead use ABAP SORT + DELETE ADJACENT DUPLICATES on an internal table, to delete duplicate rows.
    Additional Info
    Use of CONTEXT can highly optimize the code.
          Context can be created using Context Builder (SE33)
         Context advantages:  - no double fetch by DEMAND: 1. fetch, 2. get from buffer  - more performance (best SELECT-statement)  - better survey of code
    Use of PARALLEL CURSOR  increases the Performance to a great extent.
    INDEXES help to speed up selection from the database. The primary index is always created automatically in the SAP System. It consists of the primary key fields of the database table. If you cannot use the primary index to determine a selection result (for example, WHERE condition may not contain any primary index fields), you can create a secondary index.
    Optimal number of indexes for a table  You should not create more than five secondary indexes for any one table because:
    Whenever you change table fields that occur in the index, the index itself is also updated.
    The amount of data increases.
    The optimizer has too many chances to make mistakes by using the 'wrong' index.
             If you are using more than one index for a database table, ensure that they do not overlap.
    reward if useful

Maybe you are looking for

  • JDeveloper 10 (9.0.5.2) with Java 1.5

    Hi everyone, I've tried to use Java 1.5 SDk in conjunction with JDeveloper 10g with no success. I always get the following error message: Error: initialization error: class file has wrong version 49.0, should be 45.3 or 46.0 or 47.0 or 48.0 on classp

  • Calling a Web Template in RRI

    Hi All, In RRI I need to call Template for the receiver query and not the actual (called) report. How do I achive this? Thanks Kirk As always I promise to return the points for useful answer.

  • Strange problem with desktop

    Hi, I have a very strange problem with desktops and dashboards something else. For example, when I am on desktop 2 and i go to desktop 1, when I click with the mouse on it, it goes again to desktop 2. or when I am on desktop 1 and I go to ddashboard,

  • "reading mode" view on Firefox?

    when I come across an article I find on-line while browsing on Firefox I would like to continue reading it on "reading mode." How can I make that switch? does Mozilla support that?

  • Handling a schema URL that is also a container

    Greetings, I have two schema URLs, say "http://schema1" and "http://schema1/schema2". I successfully registered the first in Oracle 10g R2 XMLDB. When I attempt to register the second, I receive the following error: ORA-31002 Path name "http://schema