Skip to Content
0
Former Member
Mar 01, 2007 at 06:32 AM

performance

72 Views

hello abapers,

in a report am trying to display NBR value, MRP value and ASSE value for all materials present in a given plant... but the performance is very very poor.....pls help me to increase the performance...here am sending the code .....

PERFORM get_data.

PERFORM get_costprice.

PERFORM get_acc_value.

PERFORM get_nbr_value.

PERFORM get_mrp_value.

FORM get_data .

SELECT DISTINCT awerks bmatnr bmtart bmatkl c~maktx INTO CORRESPONDING FIELDS OF TABLE itab

FROM ( marc AS a INNER JOIN mara AS b ON amatnr = bmatnr )

INNER JOIN makt AS c ON amatnr = cmatnr

WHERE werks = plant.

ENDFORM. " GET_DATA

FORM get_costprice .

IF itab[] IS NOT INITIAL.

SELECT matnr stprs FROM mbew INTO CORRESPONDING FIELDS OF TABLE t_mbew

FOR ALL ENTRIES IN itab WHERE matnr = itab-matnr AND bwkey = itab-werks.

IF sy-subrc = 0.

LOOP AT itab.

READ TABLE t_mbew WITH KEY matnr = itab-matnr.

IF sy-subrc = 0.

itab-stprs = t_mbew-stprs.

MODIFY itab.

ENDIF.

ENDLOOP.

ENDIF.

ENDIF.

ENDFORM. " GET_COSTPRICE

FORM get_nbr_value .

CLEAR: it_a508, it_nbr, v_knumh.

IF itab[] IS NOT INITIAL.

SELECT matnr knumh INTO CORRESPONDING FIELDS OF TABLE it_a508

FROM a508 FOR ALL ENTRIES IN itab WHERE matnr = itab-matnr.

IF sy-subrc = 0.

SELECT knumh kbetr INTO CORRESPONDING FIELDS OF TABLE it_nbr

FROM konp FOR ALL ENTRIES IN it_a508 WHERE knumh = it_a508-knumh.

IF sy-subrc = 0.

LOOP AT itab.

READ TABLE it_a508 WITH KEY matnr = itab-matnr.

v_knumh = it_a508-knumh.

READ TABLE it_nbr WITH KEY knumh = v_knumh.

itab-kbetr = it_nbr-kbetr.

MODIFY itab.

CLEAR itab.

CLEAR: it_a508, it_nbr, v_knumh.

ENDLOOP.

ENDIF.

ENDIF.

ENDIF.

ENDFORM. " GET_NBR_VALUE

FORM get_acc_value .

REFRESH: it_a508, it_nbr.

CLEAR: it_a508, it_nbr, v_knumh.

IF itab[] IS NOT INITIAL.

SELECT matnr knumh INTO CORRESPONDING FIELDS OF TABLE it_a508

FROM a509 FOR ALL ENTRIES IN itab WHERE matnr = itab-matnr.

IF sy-subrc = 0.

SELECT knumh kbetr INTO CORRESPONDING FIELDS OF TABLE it_nbr

FROM konp FOR ALL ENTRIES IN it_a508 WHERE knumh = it_a508-knumh.

IF sy-subrc = 0.

LOOP AT itab.

READ TABLE it_a508 WITH KEY matnr = itab-matnr.

v_knumh = it_a508-knumh.

READ TABLE it_nbr WITH KEY knumh = v_knumh.

itab-kbetr1 = it_nbr-kbetr.

MODIFY itab.

CLEAR itab.

CLEAR: it_a508, it_nbr, v_knumh.

ENDLOOP.

ENDIF.

ENDIF.

ENDIF.

ENDFORM. " GET_ACC_VALUE

FORM get_mrp_value .

REFRESH: it_a508, it_nbr.

CLEAR: it_a508, it_nbr, v_knumh.

IF itab[] IS NOT INITIAL.

SELECT matnr knumh INTO CORRESPONDING FIELDS OF TABLE it_a508

FROM a506 FOR ALL ENTRIES IN itab WHERE matnr = itab-matnr.

IF sy-subrc = 0.

SELECT knumh kbetr INTO CORRESPONDING FIELDS OF TABLE it_nbr

FROM konp FOR ALL ENTRIES IN it_a508 WHERE knumh = it_a508-knumh.

IF sy-subrc = 0.

LOOP AT itab.

READ TABLE it_a508 WITH KEY matnr = itab-matnr.

v_knumh = it_a508-knumh.

READ TABLE it_nbr WITH KEY knumh = v_knumh.

itab-kbetr2 = it_nbr-kbetr.

MODIFY itab.

CLEAR itab.

CLEAR: it_a508, it_nbr, v_knumh.

ENDLOOP.

ENDIF.

ENDIF.

ENDIF.

ENDFORM. " GET_MRP_VALUE

thanx in advance...

regards,

maya.