Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Performance issue

Former Member
0 Likes
617

Moved by moderator to the correct forum. Please use a more meaningful subject in future.

Hi All,

Here below the code the Loop under Read statement i have used and have to use the binary search where have to use can any one suggest me to execute it fast .

SORT gvt_item   BY vbeln posnr.
  Read table gvt_item with key vbeln = ls_header-vbeln
                             posnr = ls_header-posnr.
   if sy-subrc = 0.
      wa_index = sy-tabix.

      gvt_item-zz_crm_id = ls_header-zz_crm_id.
      gvt_item-ktext     = ls_header-ktext.
      gvt_item-faksk     = ls_header-faksk.
      gvt_item-fpbez     = ls_header-fpbez.
      gvt_item-bezeich   = ls_header-bezeich.
      gvt_item-faksp     = ls_header-faksp.
      gvt_item-anndat    = ls_header-anndat.
      gvt_item-candat    = ls_header-candat.
      gvt_item-stats     = ls_header-stats.
      gvt_item-autte     = ls_header-autte.
      gvt_item-cmana     = ls_header-cmana.
      gvt_item-ename     = ls_header-ename.
      gvt_item-pstyv     = ls_header-pstyv.
      gvt_item-fpart     = ls_header-fpart.

* Insert by BRDK933549, modify the anniversary logic

* End of BRDK933549

      MODIFY gvt_item INDEX sy-tabix
             TRANSPORTING zz_crm_id ktext faksk fpbez bezeich
              faksp anndat candat stats autte cmana ename pstyv fpart.

    Endif.
*    ENDLOOP.

Thanks in Advance

Edited by: Matt on Nov 16, 2008 8:22 AM Don't forget to put tages around your code to keep the formatting

5 REPLIES 5
Read only

Former Member
0 Likes
592

Do F1 on binary search.

And post thread at their relevant place.

Read only

Former Member
0 Likes
592

Hi,

SORT gvt_item BY vbeln posnr. .

loop XXXXXX.

Read table gvt_item with key vbeln = ls_header-vbeln

posnr = ls_header-posnr

binary search.

endloop.

Thanks,

Sree,

Read only

matt
Active Contributor
0 Likes
592

The absolute fastest way, if you've a reasonable amount of data is to us ASSIGNING for your read - you can change the data directly in the table, and a HASHED table - no BINARY SEARCH required.

Assuming your data is of type "table_type". First, define your table to be HASHED.

DATA: gvt_time TYPE HASHED TABLE OF table_type WITH NON-UNIQUE KEY vbeln posnr.

FIELD-SYMBOLS: <ls_wa> TYPE LINE OF table_type.

then


  Read table gvt_item with TABLE key vbeln = ls_header-vbeln
                             posnr = ls_header-posnr ASSIGNING <ls_wa>.
   if sy-subrc = 0.
"     wa_index = sy-tabix.
 
      <ls_wa>-zz_crm_id = ls_header-zz_crm_id.
      <ls_wa>-ktext     = ls_header-ktext.
      <ls_wa>-faksk     = ls_header-faksk.
      <ls_wa>-fpbez     = ls_header-fpbez.
      <ls_wa>-bezeich   = ls_header-bezeich.
      <ls_wa>-faksp     = ls_header-faksp.
      <ls_wa>-anndat    = ls_header-anndat.
      <ls_wa>-candat    = ls_header-candat.
      <ls_wa>-stats     = ls_header-stats.
      <ls_wa>-autte     = ls_header-autte.
      <ls_wa>-cmana     = ls_header-cmana.
      <ls_wa>-ename     = ls_header-ename.
      <ls_wa>-pstyv     = ls_header-pstyv.
      <ls_wa>-fpart     = ls_header-fpart.
 
* Insert by BRDK933549, modify the anniversary logic
 
* End of BRDK933549
 
"     MODIFY gvt_item INDEX sy-tabix
"           TRANSPORTING zz_crm_id ktext faksk fpbez bezeich
"           faksp anndat candat stats autte cmana ename pstyv fpart.
 
    Endif.
"    ENDLOOP.

Note, the use of tables with header-lines is bad programming practice. Avoid where possible.

matt

Read only

Former Member
0 Likes
592

Hi,

Just place binary search after read stmt.

remember when soring the table before reading it, use 'binary search' for fast execution.


  Read table gvt_item with key vbeln = ls_header-vbeln
                             posnr = ls_header-posnr binary search.

Tks,

Krishna

Read only

Former Member
0 Likes
592

dd

.