Skip to Content

Here is the Main concept of eliminating the high percentage of identical selects by local buffer.

  1. Two internal tables (A and B) are defined to buffer the result  of the “select statement “ on table bseg. Table A is for the search criteria that is existing in the database and table B is for the search criteria that is not existing in the database.

      

  2. Read internal table A, if existing, return the value. If not go to step 3.
      
  3. Read internal table B for the record that does not exist in the database, if it doesnot exist in the buffer, go to step 4.
      
  4. Make the database access and fetch the record and log the result in the two internal tables.

types: begin of s_bseg,

        bukrs like bsegbukrs,

        gjahr like bseggjahr,

        belnr like bsegbelnr,

        buzei like bsegbuzei,

        wskto like bsegwskto,

        shkzg like bsegshkzg,

       end of s_bseg.

      

data: itb_bseg_found type sorted table of s_bseg with non-unique key bukrs gjahr belnr buzei,

      itb_bseg_notfound type sorted table of s_bseg with non-unique key bukrs gjahr belnr buzeiwa_bseg s_bseg.

   

      Read table itb_bseg_found into wa_bseg with key

bukrs = bsasbukrs

                                  gjahr = bsasgjahr

                                  belnr = bsasbelnr

                               buzei = bsasbuzei.

      if sy-subrc = 0.

  bsegwskto = wa_bsegwskto.

       bsegshkzg = wa_bsegshkzg.                   

      else.

      Read table itb_bseg_notfound transporting no fields with key

bukrs = bsasbukrs

gjahr = bsasgjahr

belnr = bsasbelnr

buzei = bsasbuzei.

     

      if sysubrc <> 0. 

    SELECT SINGLE wskto shkzg

      FROM bseg

      INTO (bsegwskto, bsegshkzg)

      WHERE bukrs = bsasbukrs AND

            gjahr = bsasgjahr AND

            belnr = bsasbelnr AND

            buzei = bsasbuzei.

           

  wa_bsegbukrs = bsasbukrs.

              wa_bseggjahr = bsasgjahr.

              wa_bsegbelnr = bsasbelnr.

              wa_bsegbuzei = bsasbuzei.

              wa_bsegwskto = bsegwskto.

              wa_bsegshkzg = bsegshkzg.            

             

        if sysubrc = 0.

          insert wa_bseg into table itb_bseg_found.

        else.

          insert wa_bseg into table itb_bseg_notfound.

        endif.

    endif.

    endif.

Note: Change the data type of internal tables itb_bseg_found and itb_bseg_notfound to statistics if this is

called in the funcational module or form.

Welcome to comment on this topic.

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply