Application Development and Automation 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: 
Read only

Dump in 'BAPI_MATERIAL_AVAILABILITY' for mass materials....

Former Member
0 Likes
1,222

Hi Experts,

pl. help us for following abap. I have fetched nearly 40,000 materials in itab and when i am executing it is taking long time 10-20 minutes or it is giving dump.

**************************

DATA: iwmdvsx TYPE TABLE OF bapiwmdvs WITH HEADER LINE,

iwmdvex TYPE TABLE OF bapiwmdve WITH HEADER LINE.

***********

DATA: r TYPE bapireturn, " Check it once.

FQty TYPE MENGV13.

***********

jtab[] = itab[].

LOOP AT itab.

CALL FUNCTION 'BAPI_MATERIAL_AVAILABILITY'

EXPORTING

plant = 'HIP' "p_werks

material = itab-matnr "p_matnr

unit = 'EA' "p_meins

stge_loc = 'BSR'

IMPORTING

return = r

TABLES

wmdvsx = iwmdvsx

wmdvex = iwmdvex.

IF r-type is initial OR r-type = 'S'.

LOOP AT iwmdvex.

FQty = FQty + iwmdvex-com_qty.

ENDLOOP.

jtab-free_qty = FQty.

MODIFY jtab TRANSPORTING free_qty WHERE matnr = itab-matnr.

FQty = 0.

ENDIF.

REFRESH iwmdvex.

CLEAR: itab.

REFRESH iwmdvsx.

ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,019

Please see note 362617.

Rob

7 REPLIES 7
Read only

Former Member
0 Likes
1,020

Please see note 362617.

Rob

Read only

0 Likes
1,019

Actually, now that I look at it more carefully. I think your problem is an implied nested loop. The MODIFY...FROM... causes a full table scan. So try:



DATA: iwmdvsx TYPE TABLE OF bapiwmdvs WITH HEADER LINE,
      iwmdvex TYPE TABLE OF bapiwmdve WITH HEADER LINE.

***********
DATA: r TYPE bapireturn, " Check it once.
      fqty TYPE mengv13.
***********

SORT jtab BY matnr.
DELETE ADJACENT DUPLICATES FROM itab COMPARING matnr.

jtab[] = itab[].

LOOP AT itab.

  CALL FUNCTION 'BAPI_MATERIAL_AVAILABILITY'
    EXPORTING
      plant    = 'HIP' "p_werks
      material = itab-matnr "p_matnr
      unit     = 'EA' "p_meins
      stge_loc = 'BSR'
    IMPORTING
      return   = r
    TABLES
      wmdvsx   = iwmdvsx
      wmdvex   = iwmdvex.

  IF r-type IS INITIAL OR r-type = 'S'.
    LOOP AT iwmdvex.
      fqty = fqty + iwmdvex-com_qty.
    ENDLOOP.
    jtab-free_qty = fqty.
    READ TABLE jtab WITH KEY
      matnr = itab-matnr
      BINARY SEARCH.
    jtab-free_qty = itab-free_qty.
    MODIFY jtab index sy-tabix.
    fqty = 0.
  ENDIF.

  REFRESH iwmdvex.
  CLEAR: itab.

  REFRESH iwmdvsx.

ENDLOOP.

If you have to keep itab and jtab intact, create two new temporary tables and use these instead.

Rob

Read only

former_member194669
Active Contributor
0 Likes
1,019

Hi,

Try to run your report in "background" mode . I think the dump is due to system timeout.

aRs.

Read only

Former Member
0 Likes
1,019

This is the way i do it. See if it helps:

LOOP AT I_WERKS.

refresh: return.

CALL FUNCTION 'BAPI_MATERIAL_AVAILABILITY'

EXPORTING

plant = I_WERKS-LOW

material = I_MARA-MATNR

unit = 'EA'

IMPORTING

av_qty_plt = bapi_onhand

return = return

TABLES

wmdvsx = atp1

wmdvex = atp2.

IF return IS INITIAL.

READ TABLE atp2 WITH TABLE KEY bdcnt = 0

req_date = sy-datum

com_date = sy-datum.

IF atp2-com_qty <> '9999999999.000'.

ONHAND = ONHAND + atp2-com_qty.

ELSE.

ONHAND = ONHAND + bapi_onhand.

ENDIF.

ENDIF.

Read only

Former Member
0 Likes
1,019

Hi,

Incase if the FM has any select statements, in such case inside a loop statement, if any selects exists then it will definetly take lot of time. if it is unavoidable since you are calling a function module then the best option is execute in background mode.

thanks,

sksingh

Read only

0 Likes
1,019

Hi Srinivas,

How to execute in background mode ? through which transaction ?

And also how to see output after background processing ?

pl. give detail.

Yusuf.

Message was edited by:

YUSUF BHORI

Read only

Former Member
0 Likes
1,019

It helped me lot, and i solved my problem.