04-07-2006 4:30 PM
Hello All,
I am callign ina LOOP a FM say (I wish i had better way)MD_STOCK_REQUIREMENTS_LIST_API
I get a timeout error, we have given good amount of time limit with basis settings.
Dump points me to one of the select in FM .
Is there any global dat i should clear before using this FM or anythign is there to improve it.
This is not a problem with lime limit assigned. I feel it is more to use FM in Loop for 10 K records.
For each material and plant i get the details in loop.
Will be glad if some one helps me on this.
Rgds,
Manohar
04-07-2006 4:41 PM
04-07-2006 7:11 PM
Can you please post the code of your LOOP... CALL FUNCTION.... ENDLOOP?
04-08-2006 8:33 AM
LOOP AT it_vendor_det INTO wa_vendor_dat. "LOOP1 Vendor
LOOP AT it_matnr_det INTO wa_matnr_det
WHERE werks = wa_vendor_dat-werks AND
lifnr = wa_vendor_dat-lifnr AND
ekorg = wa_vendor_dat-ekorg.
IF r_weeks = c_x.
inper = c_w.
ELSEIF r_months = c_x OR
r_quater = c_x.
inper = c_m.
ENDIF.
*-- REQUIREMNTS Q1 / Q2 / Q3
CLEAR : mdsux,
mdsux[].
CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API'
EXPORTING
matnr = wa_matnr_det-matnr
werks = wa_vendor_dat-werks
inper = inper
TABLES
mdsux = mdsux
EXCEPTIONS
material_plant_not_found = 1
plant_not_found = 2
OTHERS = 3.
IF sy-subrc = 0.
IF inper = c_w.
IF it_date_week[] IS INITIAL.
PERFORM data_week_det.
ENDIF.
PERFORM move_mrp_data.
ELSEIF inper = c_m.
IF it_month_date[] IS INITIAL.
PERFORM month_date_det.
ENDIF.
PERFORM move_mrp_month_data.
ENDIF.
ENDIF.
endloop.
endloop.
This is the part of code which times out, i count use the code frm FM directly as it is having multiple FM in itself.
Any ideas are appreciated.
04-09-2006 4:17 AM
Your problem is likely the nested loops. Instead of:
LOOP AT it_matnr_det INTO wa_matnr_det
WHERE werks = wa_vendor_dat-werks AND
lifnr = wa_vendor_dat-lifnr AND
ekorg = wa_vendor_dat-ekorg.
Try:
SORT it_matnr_det BY werks lifnr ekorg.
READ TABLE matnr_det WITH KEY
werks = wa_vendor_dat-werks
lifnr = wa_vendor_dat-lifnr
ekorg = wa_vendor_dat-ekorg
BINARY SEARCH.
If you have more questions, you can check the <a href="/people/rob.burbank/blog/2006/02/07/performance-of-nested-loops">blog</a> I wrote. If you have to get more than one record from the second table, you will need to do in indexed read on it. The blog explains that.
Rob
Rob
04-10-2006 3:39 AM
Or you can just cut and paste:
DATA: mat_index LIKE sy-tabix.
SORT it_matnr_det BY werks lifnr ekorg.
LOOP AT it_vendor_det INTO wa_vendor_dat. "LOOP1 Vendor
READ TABLE it_matnr_det INTO wa_matnr_det WITH KEY
werks = wa_vendor_dat-werks
lifnr = wa_vendor_dat-lifnr
ekorg = wa_vendor_dat-ekorg
BINARY SEARCH.
mat_index = sy-tabix.
WHILE sy-subrc = 0.
IF r_weeks = c_x.
inper = c_w.
ELSEIF r_months = c_x OR
r_quater = c_x.
inper = c_m.
ENDIF.
*-- REQUIREMNTS Q1 / Q2 / Q3
CLEAR : mdsux,
mdsux[].
CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API'
EXPORTING
matnr = wa_matnr_det-matnr
werks = wa_vendor_dat-werks
inper = inper
TABLES
mdsux = mdsux
EXCEPTIONS
material_plant_not_found = 1
plant_not_found = 2
OTHERS = 3.
IF sy-subrc = 0.
IF inper = c_w.
IF it_date_week[] IS INITIAL.
PERFORM data_week_det.
ENDIF.
PERFORM move_mrp_data.
ELSEIF inper = c_m.
IF it_month_date[] IS INITIAL.
PERFORM month_date_det.
ENDIF.
PERFORM move_mrp_month_data.
ENDIF.
ENDIF.
mat_index = mat_index + 1.
READ TABLE it_matnr_det INTO wa_matnr_det INDEX mat_index.
IF wa_matnr_det-werks <> wa_vendor_det-werks OR
wa_matnr_det-lifnr <> wa_vendor_det-lifnr OR
wa_matnr_det-ekorg <> wa_vendor_det-ekorg.
sy_subrc = 99.
ENDIF.
ENDWHILE.
ENDLOOP.
I wasn't able to test this code, so if you decide to try it, you will have to test it thoroughly.
Rob
04-10-2006 8:03 AM
Rob,
Thanks for nice blog, it invoked curiousity to look at things differently.
It did address the time out issue, i need to fine tune a bit more to make it near perfect.
I am still trying to assign points, will do it as an when system allows me to do so.
Thanks,
Ö
04-08-2006 9:57 AM
hello one family,
when it is giving you time out error jus try this statement
COMMIT WORK
in the loop where you are getting dump next time you will not get dump.