Application Development 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: 

Time Out error

Former Member
0 Kudos

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

7 REPLIES 7

Former Member
0 Kudos

Look at OSS notes 862337 and 636321.

Rob

0 Kudos

Can you please post the code of your LOOP... CALL FUNCTION.... ENDLOOP?

0 Kudos

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.

0 Kudos

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

0 Kudos

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

0 Kudos

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,

Ö

Former Member
0 Kudos

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.