04-01-2009 4:39 PM
Hi gurus!
I have added few fields to the copy of a standard program mb51 . In DEV it runs fine
as the amount of data is less , but when I moved it to QAT it keeps on running and
goes to rntime error. Is theer a way to minimise the runtime in my extar code added
so that it dosent go into runtime . Any suggestions ?
select mblnr
mjahr
xblnr
from mkpf
into table i_mkpf
for all entries in list[]
where mblnr = list-mblnr
and mjahr = list-mjahr.
loop at i_mkpf into s_mkpf.
move s_mkpf-xblnr to s_xblnr-xblnr.
append s_xblnr to i_xblnr.
clear s_mkpf.
endloop.
select vbeln
posnr
vgbel
vgpos
from lips
into table i_lips
for all entries in i_xblnr
where vbeln = i_xblnr-xblnr.
select vbeln
posnr
parvw
kunnr
from vbpa
into table i_vbpa
for all entries in i_lips
where vbeln = i_lips-vgbel.
select vbeln
kunnr
from vbak
into table i_vbak
for all entries in i_lips
where vbeln = i_lips-vgbel.
select vbeln
posnr
zzeubcd
mvgr1
from vbap
into table i_vbap
for all entries in i_vbak
where vbeln = i_vbak-vbeln.
select kunnr
name1
oipbl
from kna1
into table i_kna1.
select pblnr
kunnr
parfn
from oifbbp1
into table i_oifbbp1
for all entries in i_kna1
where pblnr = i_kna1-oipbl.
loop at list.
v_tabix = sy-tabix.
read table i_mkpf into s_mkpf with key mblnr = list-mblnr
mjahr = list-mjahr.
read table i_lips into s_lips with key vbeln = s_mkpf-xblnr.
read table i_vbap into s_vbap with key vbeln = s_lips-vgbel
posnr = s_lips-vgpos.
if sy-subrc = 0.
list-zzeubcd = s_vbap-zzeubcd.
list-mvgr1 = s_vbap-mvgr1.
endif.
read table i_vbpa into s_vbpa with key vbeln = s_lips-vgbel
parvw = 'WE'.
read table i_kna1 into s_kna1 with key kunnr = s_vbpa-kunnr.
if sy-subrc = 0.
list-shi_nam = s_kna1-name1.
list-oipbl = s_kna1-oipbl.
endif.
if sy-subrc = 0.
endif.
read table i_oifbbp1 into s_oifbbp1 with key pblnr = s_kna1-oipbl
parfn = 'ZFAC'.
if sy-subrc = 0.
list-par_id = s_oifbbp1-kunnr.
list-parfn = s_oifbbp1-parfn.
endif.
read table i_kna1 into s_kna1 with key kunnr = s_oifbbp1-kunnr.
if sy-subrc = 0.
list-par_nam = s_kna1-name1.
endif.
modify list index v_tabix transporting zzeubcd
mvgr1
shi_nam
parfn
par_id
par_nam
oipbl.
clear : s_mkpf,
s_lips,
s_vbpa,
s_kna1,
s_vbap,
s_vbak,
s_oifbbp1.
endloop.
endform. " ADD_NEW_FIELDS
.
04-01-2009 4:45 PM
sort all the table you are reading , with the keys you are using and use binary search addition in read table syntax.
04-01-2009 4:45 PM
sort all the table you are reading , with the keys you are using and use binary search addition in read table syntax.
04-01-2009 4:57 PM
I did the sorting by key fields and added binary search , but that has eliminated some of my ourputs , ie the few fields that I was getting populated with values vansihed when i added the sorting and binary search.
04-01-2009 4:59 PM
they might have not washed off , but might be settled on the bottom as sort default is taken as ascending..
make sure the sort field of table and the read table keys are same.... binary search is very particular on these.
04-01-2009 5:08 PM
HI,
Check this code
select mblnr
mjahr
xblnr
from mkpf
into table i_mkpf
for all entries in list[]
where mblnr = list-mblnr
and mjahr = list-mjahr.
loop at i_mkpf into s_mkpf.
move s_mkpf-xblnr to s_xblnr-xblnr.
append s_xblnr to i_xblnr.
clear s_mkpf.
endloop.
IF NOT i_xblnr[] IS INITIAL.
select vbeln
posnr
vgbel
vgpos
from lips
into table i_lips
for all entries in i_xblnr
where vbeln = i_xblnr-xblnr.
IF SY-SUBRC EQ 0.
select vbeln
posnr
parvw
kunnr
from vbpa
into table i_vbpa
for all entries in i_lips
where vbeln = i_lips-vgbel.
select vbeln
kunnr
from vbak
into table i_vbak
for all entries in i_lips
where vbeln = i_lips-vgbel.
IF SY-SUBRC EQ 0.
select vbeln
posnr
zzeubcd
mvgr1
from vbap
into table i_vbap
for all entries in i_vbak
where vbeln = i_vbak-vbeln.
ENDIF.
ENDIF.
ENDIF.
select kunnr
name1
oipbl
from kna1
into table i_kna1.
IF SY_SUBRC EQ 0.
select pblnr
kunnr
parfn
from oifbbp1
into table i_oifbbp1
for all entries in i_kna1
where pblnr = i_kna1-oipbl.
ENDIF.
SORT TABLE i_mkpf BY mblnr mjahr .
SORT TABLE i_lips BY vbeln .
SORT TABLE I_VBAP BY VBELN POSNR.
SORT TABLE I_VBPA BY VBELN PARVW.
SORT TABLE I_KNA1 BY KUNNR.
SORT TABLE i_oifbbp1 BY pblnr Parfn.
loop at list.
v_tabix = sy-tabix.
CLEAR s_mkpf.
read table i_mkpf into s_mkpf with key mblnr = list-mblnr
mjahr = list-mjahr BINARY SEARCH.
CLEAR s_lips.
read table i_lips into s_lips with key vbeln = s_mkpf-xblnr BINARY SEARCH.
CLEAR s_VBAP.
read table i_vbap into s_vbap with key vbeln = s_lips-vgbel
posnr = s_lips-vgpos BINARY SEARCH.
if sy-subrc = 0.
list-zzeubcd = s_vbap-zzeubcd.
list-mvgr1 = s_vbap-mvgr1.
endif.
CLEAR s_vbpa.
read table i_vbpa into s_vbpa with key vbeln = s_lips-vgbel
parvw = 'WE' BINARY SEARCH.
CLEAR s_kna1.
read table i_kna1 into s_kna1 with key kunnr = s_vbpa-kunnr BINARY SEARCH.
if sy-subrc = 0.
list-shi_nam = s_kna1-name1.
list-oipbl = s_kna1-oipbl.
endif.
if sy-subrc = 0.
endif.
Clear i_oifbbp1.
read table i_oifbbp1 into s_oifbbp1 with key pblnr = s_kna1-oipbl
parfn = 'ZFAC' BINARY SEARCH.
if sy-subrc = 0.
list-par_id = s_oifbbp1-kunnr.
list-parfn = s_oifbbp1-parfn.
endif.
CLEAR s_kna1.
read table i_kna1 into s_kna1 with key kunnr = s_oifbbp1-kunnr BINARY SEARCH.
if sy-subrc = 0.
list-par_nam = s_kna1-name1.
endif.
modify list index v_tabix transporting zzeubcd
mvgr1
shi_nam
parfn
par_id
par_nam
oipbl.
clear : s_mkpf,
s_lips,
s_vbpa,
s_kna1,
s_vbap,
s_vbak,
s_oifbbp1.
endloop.
endform. " ADD_NEW_FIELDS
04-01-2009 5:10 PM
Yes , I beleiev they are the same and when I remove the binary search the correct display comes in , but I am still concerned with teh time it is taking in DEV itself as I dont see much difference from before.
Thanks
04-01-2009 5:12 PM
Or is theer something that can be done with teh select and read statements to optimize the time .
04-01-2009 5:18 PM
Hi Avinash!
I applied your code still what happens is that the partner id and partner name for a particluar slection that I am making vansihes off , as to initially it was appearing without sort and binary search. I wonder how is it vansihing when sort and binary serach applied.Time taken is also sort of not much difference.
Thanks
04-01-2009 6:35 PM
field-symbols: <fs> like line of list.
loop at list assingning <fs>.
read....
<fs>- field = lv_field....
with this you can remove the modify and transporting at the end...
you are dealing with big table vbak, vbap, MKPF etc... it ill take some time... try to use all the keys of the tables you are using..
04-01-2009 7:52 PM
Yes tahts right I am using big tables but to extract the relevant records i needed them . I tried doing it the way mentioned but the time taken it almost teh same to run the program.
Thanks
04-01-2009 8:00 PM
run it in background or run using sm30 and then evaluate the time. I am sure batabase effort will be more than ABAP effort.. joining two tables is ok .. try using join table
04-01-2009 8:35 PM
Will it be ok to join so many tables together , wont it miss out on records for the table?
I mean I am not sure how will I join those tables to extarct the same data as I am getting now
04-01-2009 8:41 PM
Use this link to find out [how to join table|http://www.sapdb.info/wp-content/uploads/2008/05/sqvi.pdf] and find out relations between tables