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

ABAP Query Performance Issue .

Former Member
0 Likes
413

Hii

I need to print a very simple list of materials & there corresponding latest movement date for a specified period of say '365 Days'.

Now for this i have written a join on MSEG & MKPF tables .but the issue is,this join gives me a very large number of records as all the material documents for that material in that period are fetched ,then i sort this table descending on date & delete other records.

I just need to get that record of latest date (material document with latest date).How could that be done without fetching the other records ?

Regards

Ajitabh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
357

1. try to create/ use secondary indexes on MSEG and MKPF.

2. Dont use For all Entries in this Join .

it should be like this.

if s_matnr[] is not initial.

select a~mblnr
         a~mjahr
         a~vgart
         a~budat
         a~xblnr
         b~zeile
         b~bwart
         b~matnr
         b~werks
         b~kunnr
         b~shkzg
         b~menge
         b~meins
   from  ( mkpf as a join mseg as b
   on    a~mblnr = b~mblnr  and
         a~mjahr = b~mjahr )
   into  table t_mseg
   where a~budat ge s_date-low     and
         a~vgart in ('WA' ,'WL')   and
         b~matnr in s_matnr        and
         b~werks in s_werks1       and
         b~sobkz eq 'V'            and
         b~kunnr eq w_cust         .

endif.

Regards

Prabhu

2 REPLIES 2
Read only

Former Member
0 Likes
358

1. try to create/ use secondary indexes on MSEG and MKPF.

2. Dont use For all Entries in this Join .

it should be like this.

if s_matnr[] is not initial.

select a~mblnr
         a~mjahr
         a~vgart
         a~budat
         a~xblnr
         b~zeile
         b~bwart
         b~matnr
         b~werks
         b~kunnr
         b~shkzg
         b~menge
         b~meins
   from  ( mkpf as a join mseg as b
   on    a~mblnr = b~mblnr  and
         a~mjahr = b~mjahr )
   into  table t_mseg
   where a~budat ge s_date-low     and
         a~vgart in ('WA' ,'WL')   and
         b~matnr in s_matnr        and
         b~werks in s_werks1       and
         b~sobkz eq 'V'            and
         b~kunnr eq w_cust         .

endif.

Regards

Prabhu

Read only

Former Member
0 Likes
357

hi

good

write the select statement like this

use the CORRESPONDING FIELDS OF TABLE in select statement

while joining between two tables give some condition that ll make your join more close to the field value and it ll reduce the time period of accessing the data.

thanks

mrutyun