Application Development 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: 

PLease Help...

Former Member
0 Kudos

hello Guys!

how can i make faster the process in selection of data..please check this code..

SELECT belnr gjahr
     FROM bkpf
     INTO TABLE lt_belnr
     FOR ALL ENTRIES IN lt_vbeln
     WHERE  gjahr = lt_vbeln-fkdat+0(4)
      AND   monat = lt_vbeln-fkdat+4(2)
      AND   blart = 'RV'
      and   awkey = lt_vbeln-vbeln
      and   budat = lt_vbeln-fkdat



when executing this code process is very slow..what is the best thing to run this faster..



thank you.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hello guys this my code...

SELECT belnr gjahr
     FROM bkpf
     INTO TABLE lt_belnr
     FOR ALL ENTRIES IN lt_vbeln
     WHERE  gjahr = lt_vbeln-fkdat+0(4)
      AND   monat = lt_vbeln-fkdat+4(2)
      AND   blart = 'RV'
      and   awkey = lt_vbeln-vbeln
      and   budat = lt_vbeln-fkdat.  


CHECK lt_belnr IS NOT INITIAL.
   SORT lt_belnr BY belnr  .


DELETE ADJACENT DUPLICATES FROM lt_belnr COMPARING belnr.



thank you.

9 REPLIES 9

Former Member
0 Kudos

Hi John,

Please try using this 'Index':

So your sql statement like this:

SELECT belnr gjahr

     FROM bkpf

     INTO TABLE lt_belnr

     FOR ALL ENTRIES IN lt_vbeln

     WHERE  bukrs = lt_vbeln-bukrs

      AND   bstat in s_bstat

      AND   budat = lt_vbeln-fkdat,

     and   awkey = lt_vbeln-vbeln.


sort it_vbeln by gjahr monat blart.

Loop it_belnr.

lv_index = sy-tabix.

read it_vbeln with key gjahr = wa_belnr-gjahr monat = wa_belnr-monat blart = wa_belnr-blart binary search.

if sy-subrc ne 0.

    delete it_belnr index lv_index.

endif.

endloop.


Alternativly, to create a new 'index' or try other 'index'.

regards,

Archer

Pavithra_madhu
Participant
0 Kudos

Hi,

You can go to SE11 and check Indexes button...

There are several indexes..You can use indexes ( check they are active ). After select data using index field you can check other conditions and delete data.

OR else you can create new index if it frequently using you.. But make sure to use exist index..

Cheers,

Pavithra

Former Member
0 Kudos

Hi

Whenever for alla entries used, try to pass to BKPF all the primary keys, then it wil reduse some time.

thanks.

laxman

0 Kudos

Hi,

check for lt_vbeln table . if it is not initial put the select query.

select fields in the same sequence as given in database.

after where use primary fields and then the other fields and all these should be in sequence as given in database table bkpf.

after select query sort the internal table lt_belnr by primary key.

Regards,

Akansha

0 Kudos

Hello.

How can i do that..im new here in ABAP programming..im only know basic..

Thank you..

Former Member
0 Kudos

hello guys this my code...

SELECT belnr gjahr
     FROM bkpf
     INTO TABLE lt_belnr
     FOR ALL ENTRIES IN lt_vbeln
     WHERE  gjahr = lt_vbeln-fkdat+0(4)
      AND   monat = lt_vbeln-fkdat+4(2)
      AND   blart = 'RV'
      and   awkey = lt_vbeln-vbeln
      and   budat = lt_vbeln-fkdat.  


CHECK lt_belnr IS NOT INITIAL.
   SORT lt_belnr BY belnr  .


DELETE ADJACENT DUPLICATES FROM lt_belnr COMPARING belnr.



thank you.

0 Kudos

Hi

Try to create Secondary indexes for all the fields which you have used instead GJAHR and also write the select Query based on the order of fields which are present in BKPF table so that the Performance will be faster.

SELECT belnr gjahr
     FROM bkpf
     INTO TABLE lt_belnr
     FOR ALL ENTRIES IN lt_vbeln
     WHERE  gjahr = lt_vbeln-fkdat+0(4)

         AND   blart = 'RV'

          and   budat = lt_vbeln-fkdat
         AND   monat = lt_vbeln-fkdat+4(2)
          and   awkey = lt_vbeln-vbeln.

CHECK lt_belnr IS NOT INITIAL.
   SORT lt_belnr BY belnr  .
 


DELETE ADJACENT DUPLICATES FROM lt_belnr COMPARING belnr.

manish_shankar
Participant
0 Kudos

Hi John,

Transfer the records of it_vbeln in a temporary table and delete duplicates.

Hope it'll work.

IF it_vbeln[] is not initial.

it_vbeln_tmp[] = it_vbeln[].

SORT it_vbeln_tmp by fkdat vbeln.

DELETE ADJACENT RECORDS FROM it_vbeln_tmp comparing fkdat vbeln.

SELECT belnr gjahr

     FROM bkpf

     INTO TABLE lt_belnr

     FOR ALL ENTRIES IN lt_vbeln_tmp

       GJAHR = lt_vbeln_tmp-fkdat+0(4)

       BLART = 'RV'

       BUDAT = lt_vbeln_tmp-fkdat. 

       MONAT = lt_vbeln_tmp-fkdat+4(2)

       AWKEY = lt_vbeln_tmp-vbeln

Endif.

Phillip_Morgan
Contributor
0 Kudos

Michael,

Don't know what data you have available before your selection, but keep in mind the secondary indexes:

BSAD                       Accounting: Secondary Index for Customers (Cleared Items)
BSAK                       Accounting: Secondary Index for Vendors (Cleared Items)
BSAS                       Accounting: Secondary Index for G/L Accounts (Cleared Items)
BSID                       Accounting: Secondary Index for Customers
BSIK                       Accounting: Secondary Index for Vendors
BSIS                       Accounting: Secondary Index for G/L Accounts

For performance reasons, it is advisable to access BKPF, BSEG through one of these.

Each has its own indexes that may help.