Skip to Content
0
Former Member
Sep 17, 2010 at 10:58 AM

Performance Tuning for a report

211 Views

Hi,

We have developed a program which updates 2 fields namely Reorder Point and Rounding Value on the MRP1 tab in TCode MM03.

To update the fields, we are using the BAPI BAPI_MATERIAL_SAVEDATA.

The problem is that when we upload the data using a txt file, the program takes a very long time. Recently when we uploaded a file containing 2,00,000 records, it took 27 hours. Below is the main portion of the code (have ommitted the open data set etc). Please help us fine tune this, so that we can upload these 2,00,000 records in 2-3 hours.

select matnr from mara into table t_mara.

select werks from t001w into corresponding fields of table t_t001w .

select matnr werks from marc into corresponding fields of table t_marc.

loop at str_table into wa_table.

 if not wa_table-partnumber is initial.

 CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
   EXPORTING
     INPUT         =  wa_table-partnumber

     IMPORTING
    OUTPUT        = wa_table-partnumber
           .
 endif.

 clear wa_message.

read table t_mara into wa_mara with key matnr = wa_table-partnumber.

if sy-subrc is not initial.

concatenate 'material ' wa_table-partnumber ' doesnot exists'
into wa_message.

append wa_message to t_message.

endif.

 read table t_t001w into wa_t001w with key werks = wa_table-HostLocID.

  if sy-subrc is not initial.

  concatenate 'plant ' wa_table-HostLocID  ' doesnot exists' into
  wa_message.
  append wa_message to t_message.
  else.

  case wa_t001w-werks.
when 'DE40'
 or  'DE42'
 or  'DE44'
 or  'CN61'
 or  'US62'
 or  'SG70'
 or  'FI40'
.
read table t_marc into wa_marc with key matnr = wa_table-partnumber
                                        werks = wa_table-HostLocID.
if sy-subrc is not initial.

concatenate 'material' wa_table-partnumber  ' not extended to plant'
wa_table-HostLocID  into  wa_message.
append wa_message to t_message.

endif.

when others.

concatenate 'plant ' wa_table-HostLocID ' not allowed'
  into wa_message.

append wa_message to t_message.
 endcase.
 endif.

    if wa_message is initial.

      data: wa_headdata type BAPIMATHEAD,
      wa_PLANTDATA type BAPI_MARC,
      wa_PLANTDATAx type BAPI_MARCX.

      wa_headdata-MATERIAL = wa_table-PartNumber.
      wa_PLANTDATA-plant = wa_table-HostLocID.
      wa_PLANTDATAX-plant = wa_table-HostLocID.

      wa_PLANTDATA-REORDER_PT = wa_table-ROP.
      wa_PLANTDATAX-REORDER_PT = 'X'.

      wa_plantdata-ROUND_VAL = wa_table-EOQ.
      wa_plantdatax-round_val =  'X'.

      CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
        EXPORTING
          HEADDATA                   = wa_headdata
         PLANTDATA                  = wa_PLANTDATA
         PLANTDATAX                 = wa_PLANTDATAX

      IMPORTING
         RETURN                     =  t_bapiret
                .
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
                .
write t_bapiret-message.
endif.

clear: wa_mara, wa_t001w, wa_marc.
endloop.

loop at t_message into wa_message.
write wa_message.
endloop.

Thanks in advance.

Peter

Edited by: kishan P on Sep 17, 2010 4:50 PM