Skip to Content
0
Former Member
Oct 25, 2010 at 03:38 PM

MKPF and MSEG join based upon entries in an internal table

638 Views

Hello all,

I have spent alot of today searching different forums and have finally had to ask for help. Any advice you can give will be greatly appreciated as I can find many conflicting posts on this subject. I am not an expert so please bear this in mind on any advice that you can give.

I have an internal table containg around 0.8 million records detailing site, article, date based information. From this, I need to find any movements that happened to that article, at that site on that date.

The execution time is long and sm66 shows it being in sequential read mode on mkpf. I will leave it running overnight and see if the program finishes or crashes.

Here is the code fragment:

select t1~budat t2~matnr t2~werks t2~MBLNR t2~SHKZG t2~menge t2~DMBTR t2~VKWRT t2~VKWRA
  into CORRESPONDING FIELDS OF table it_movements_tmp
  from mkpf as t1
  inner join mseg as t2
  on t1~MBLNR = t2~MBLNR
  and t1~MJAHR = t2~MJAHR
  for ALL ENTRIES IN it_ZXSITEHISSTK_all
  where t1~budat = it_ZXSITEHISSTK_all-udate
  and   t2~matnr = it_ZXSITEHISSTK_all-matnr
  and   t2~werks = it_ZXSITEHISSTK_all-bwkey.

I am not sure whether it is better to :

1) Use for all entries from my internal table to the mkpf / mseg join or to put the whole thing into a loop around the internal table and for each pass do a select on mkpf joined with mseg.

2) Also, after reading other posts, I came to the conclusion that I was better off using a simple inner join between mkpf and mseg and not another for all entries.

Anything that you can suggest to make this code more efficient would be much appreciated.

Thanks...Cathy

Edited by: Thomas Zloch on Oct 25, 2010 5:49 PM - code formatting added