‎2010 Dec 03 9:58 AM
Hi,
I need to run a ALV report in foreground ( no alternative .. ) and can not increase the time limit also.
Below is the code where there is a time out occuring:
loop at i_zmp_pledger_smry12 into wa_zmp_pledger_smry12.
idx = sy-tabix.
sort i_zmparas by werks.
read table i_zmparas into wa_zmparas
with key werks = wa_zmp_pledger_smry12-werks binary search.
sort i_zmparea by area_code.
read table i_zmparea into wa_zmparea
with key area_code = wa_zmparas-area_code binary search.
wa_zmp_pledger_smry12-area_name = wa_zmparea-area_name. " Area Name
sort i_zmpreas by area_code.
read table i_zmpreas into wa_zmpreas
with key area_code = wa_zmparas-area_code binary search.
sort i_zmpregi by region_code.
read table i_zmpregi into wa_zmpregi
with key region_code = wa_zmpreas-region_code binary search.
wa_zmp_pledger_smry12-region_name = wa_zmpregi-region_name. " Region Name
sort i_zmpt_uspt by werks.
read table i_zmpt_uspt into wa_zmpt_uspt
with key werks = wa_zmp_pledger_smry12-werks binary search.
wa_zmp_pledger_smry12-name1 = wa_zmpt_uspt-name1. " Plant Name
sort i_lfa1 by lifnr.
read table i_lfa1 into wa_lfa1
with key lifnr = wa_zmp_pledger_smry12-rep_id binary search.
wa_zmp_pledger_smry12-name1v = wa_lfa1-name1. " Vendor Name
modify i_zmp_pledger_smry12 index idx from wa_zmp_pledger_smry12
transporting area_name region_name
name1 name1v.
endloop.The internal table i_zmp_pledger_smry12 contains 1,08,000 records.
kindly suggest changes
-Dep
‎2010 Dec 03 10:44 AM
Hi,
sort i_zmparas by werks.
sort i_zmparea by area_code.
sort i_zmpreas by area_code.
sort i_zmpregi by region_code.
sort i_zmpt_uspt by werks.
sort i_lfa1 by lifnr.
loop at i_zmp_pledger_smry12 into wa_zmp_pledger_smry12.
idx = sy-tabix.
read table i_zmparas into wa_zmparas
with key werks = wa_zmp_pledger_smry12-werks binary search.
read table i_zmparea into wa_zmparea
with key area_code = wa_zmparas-area_code binary search.
if sy-subrc = 0.
wa_zmp_pledger_smry12-area_name = wa_zmparea-area_name. " Area Name
endif.
read table i_zmpreas into wa_zmpreas
with key area_code = wa_zmparas-area_code binary search.
read table i_zmpregi into wa_zmpregi
with key region_code = wa_zmpreas-region_code binary search.
wa_zmp_pledger_smry12-region_name = wa_zmpregi-region_name. " Region Name
read table i_zmpt_uspt into wa_zmpt_uspt
with key werks = wa_zmp_pledger_smry12-werks binary search.
wa_zmp_pledger_smry12-name1 = wa_zmpt_uspt-name1. " Plant Name
read table i_lfa1 into wa_lfa1
with key lifnr = wa_zmp_pledger_smry12-rep_id binary search.
if sy-subrc = 0.
wa_zmp_pledger_smry12-name1v = wa_lfa1-name1. " Vendor Name
endif.
if not i_zmp_pledger_smry12 is initial.
modify i_zmp_pledger_smry12 index idx from wa_zmp_pledger_smry12
transporting area_name region_name
name1 name1v.
endif.
endloop.
Regards,
muralii
‎2010 Dec 03 10:33 AM
Hi,
It looks like you're using too much tables for what you want to achieve.
You could use only one table to regroup data from I_ZMPARAS, I_ZMPAREA, I_ZMPREAS and I_ZMPREGI, and another one for I_ZMPT_USPT and I_LFA1. This way you will only have 2 READ statements in your loop.
Then, you can sort i_zmp_pledger_smry12 by werks and use AT NEW werks to only perform READ statements when they are really needed.
Regards.
Nicolas
‎2010 Dec 03 11:40 AM
regrouping this..
select werks area_code from zmparas
into corresponding fields of table i_zmparas.
select area_code area_name from zmparea
into corresponding fields of table i_zmparea.
select area_code region_code from zmpreas
into corresponding fields of table i_zmpreas.
if not p_region is initial.
select region_code region_name from zmpregi
into corresponding fields of table i_zmpregi
where region_name eq p_region.
elseif p_region is initial.
select region_code region_name from zmpregi
into corresponding fields of table i_zmpregi.
endif.
‎2010 Dec 03 10:44 AM
Hi,
sort i_zmparas by werks.
sort i_zmparea by area_code.
sort i_zmpreas by area_code.
sort i_zmpregi by region_code.
sort i_zmpt_uspt by werks.
sort i_lfa1 by lifnr.
loop at i_zmp_pledger_smry12 into wa_zmp_pledger_smry12.
idx = sy-tabix.
read table i_zmparas into wa_zmparas
with key werks = wa_zmp_pledger_smry12-werks binary search.
read table i_zmparea into wa_zmparea
with key area_code = wa_zmparas-area_code binary search.
if sy-subrc = 0.
wa_zmp_pledger_smry12-area_name = wa_zmparea-area_name. " Area Name
endif.
read table i_zmpreas into wa_zmpreas
with key area_code = wa_zmparas-area_code binary search.
read table i_zmpregi into wa_zmpregi
with key region_code = wa_zmpreas-region_code binary search.
wa_zmp_pledger_smry12-region_name = wa_zmpregi-region_name. " Region Name
read table i_zmpt_uspt into wa_zmpt_uspt
with key werks = wa_zmp_pledger_smry12-werks binary search.
wa_zmp_pledger_smry12-name1 = wa_zmpt_uspt-name1. " Plant Name
read table i_lfa1 into wa_lfa1
with key lifnr = wa_zmp_pledger_smry12-rep_id binary search.
if sy-subrc = 0.
wa_zmp_pledger_smry12-name1v = wa_lfa1-name1. " Vendor Name
endif.
if not i_zmp_pledger_smry12 is initial.
modify i_zmp_pledger_smry12 index idx from wa_zmp_pledger_smry12
transporting area_name region_name
name1 name1v.
endif.
endloop.
Regards,
muralii
‎2010 Dec 03 11:41 AM
yep put sorts outside loop and also added sy-subrc's..looking for more refinement...
‎2010 Dec 04 8:03 PM
hi,
sort the internal tables before using read statements and check for sy=subrc .
Regards,
Thiru
‎2010 Dec 06 9:30 AM
>..looking for more refinement...
how much more refinement do you expect, it is a very basic task.
If there is still a performance problem then it is probably before the LOOP when the data are created. I do not know what you do, but I would not be surprised, if the task could be solved inside the DB with one join, then you would save the whole single line processing.
Siegfried
‎2010 Dec 07 4:21 AM
Hi,
Follow the following step, It will help to improve the performance.
1) Used the fields symbol for modify the internal table i_zmp_pledger_smry12 contest instead of work area.
2) Avoid sorting inside the loop if possible or sort all the internal table contest before the loop and used binary search
while reading data (i.e you are doing).
‎2010 Dec 08 5:54 AM
In your case the best solution to improve the performance is .
1. Use field symbol's to directly change the contents and avoid using the assignment of index and then using that index for modify statement .
2 . Remove the sort stement inside the loop .
3. Instaed of having so many internal table with singlie line selection have as less number of internal tables as possible(But check to achieve one internal table you don not add up more no of loops then this ) .