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

selection from bkpf & bseg

Former Member
0 Likes
2,867

Hi experts,

Iam trying to get the data from bkpf & bseg tables.

It is consuming lot of time.What is the better way to improve the performance using select statement..


select bukrs belnr gjahr blart bldat
       budat cpudt kursf usnam waers xblnr
from bkpf into corresponding fields of table t_bkpf
                  where bukrs in s_bukrs and
                        belnr in s_belnr and
                        gjahr in s_gjahr and
                        budat in s_budat and
                        blart in s_blart and
                        xblnr in s_xblnr.

loop at t_bkpf.
    select * from bseg where belnr = t_bkpf-belnr and
                                    bukrs = t_bkpf-bukrs and
                                    gjahr = t_bkpf-gjahr.
      move-corresponding bseg to t_bseg.

      if sy-subrc = 0.
        append t_bseg.
        clear t_bseg.
      endif.
    endselect.
  endloop.

<REMOVED BY MODERATOR - REQUEST OR OFFER POINTS ARE FORBIDDEN>

thanks

kaki

Edited by: Alvaro Tejada Galindo on Dec 26, 2008 11:05 AM

Hi experts,

Iam trying to get the data from bkpf & bseg tables.

It is consuming lot of time.What is the better way to improve the performance using select statement..


select bukrs belnr gjahr blart bldat
       budat cpudt kursf usnam waers xblnr
from bkpf into corresponding fields of table t_bkpf
                  where bukrs in s_bukrs and
                        belnr in s_belnr and
                        gjahr in s_gjahr and
                        budat in s_budat and
                        blart in s_blart and
                        xblnr in s_xblnr.

loop at t_bkpf.
    select * from bseg where belnr = t_bkpf-belnr and
                                    bukrs = t_bkpf-bukrs and
                                    gjahr = t_bkpf-gjahr.
      move-corresponding bseg to t_bseg.

      if sy-subrc = 0.
        append t_bseg.
        clear t_bseg.
      endif.
    endselect.
  endloop.

<REMOVED BY MODERATOR - REQUEST OR OFFER POINTS ARE FORBIDDEN>

thanks

kaki

Edited by: Alvaro Tejada Galindo on Dec 26, 2008 11:05 AM

10 REPLIES 10
Read only

Former Member
0 Likes
2,226

hi,

try with this

select bukrs belnr gjahr blart bldat

budat cpudt kursf usnam waers xblnr

from bkpf into corresponding fields of table t_bkpf

where bukrs in s_bukrs and

belnr in s_belnr and

gjahr in s_gjahr and

budat in s_budat and

blart in s_blart and

xblnr in s_xblnr.

select (specify the fields and avoid *) from bseg

into table t_bseg for all entries in t_bkpf

where where belnr = t_bkpf-belnr and

bukrs = t_bkpf-bukrs and

gjahr = t_bkpf-gjahr.

cheers,

sasi

Read only

0 Likes
2,226

hi,

if you are specific to customer / vendor then we can go for BSAD/BSAK instead of BSEG

cheers,

sasi

Read only

Former Member
0 Likes
2,226

Hi Kaki,

First things first, Please avoid using selects in a loop.

This is a performance over head.Instead , use "for all entries" statement.

MOre over when you make selects on huge tables like BKPF and BSEG, use indexing for those tables in se11.

Regards,

ravi

Read only

Former Member
0 Likes
2,226

Kaki,

If your itab t_bkpf has the same structure as that of selection fields, then dont use the "Corresponding fields".

using corresponding fields will add additional load for matching the field name.

Also if you can, instead of using "IN" operants use "="...like BUKRS = '2929' . This will depend on your requirement.

This will help in improving some what.

Btw, keep in mind your query will take time depending on how many rows exists.

Read only

Former Member
0 Likes
2,226

Hi,

Try with Logical database. For example you can use BRM - Accounting documents.

Svetlin

Read only

0 Likes
2,226

Hi experts..

Thanks for all the replies.

Mr.Sasi solution was workedout.

Thank u

kaki

Read only

0 Likes
2,226

Hi Lavanya,

We can not use Clustered tables(bseg) & pooled tables

(ex: a001) in joins.

cheers

kaki

Read only

Former Member
0 Likes
2,226

hi

You can use joins in this to reduce the overhead of two selects as there are common selection fields bukrs gjahr and belnnr.

Select (whatever fields u want) from bkpf

join bseg

on bsegbelnr = bkpfbelnr and

bsegbukrs = bkpfbukrs and

bseggjahr = bkpfgjahr

where (give the selection conditions).

Regards.

Read only

0 Likes
2,226

hi,

i think this will not work because we cannot use join condition on cluster tables.

thanks,

anupama.

Read only

Former Member
0 Likes
2,226

Make sure that s_bukrs is not empty.

If s_belnr is empty, retrieve all of the document statuses from the domain and use them in the select and ensure that at least one of s_xblnr and s_budat is not empty. This will allow an index to be used.

Rob