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: 

performance

Former Member
0 Kudos
262

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
152

HI,

Please dont use INTO CORRESPONDING FIELDS OF,

Always check the driver internal tables is not empty, while using FOR ALL ENTRIES

Avoid for all entries in JOINS

Try to avoid joins and use FOR ALL ENTRIES.

Try to restrict the joins to 1 level only ie only for tables

Avoid using Select *.

Avoid having multiple Selects from the same table in the same object.

Try to minimize the number of variables to save memory.

The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)

Avoid creation of index as far as possible

Avoid operators like <>, > , < & like % in where clause conditions

Avoid select/select single statements in loops.

Try to use 'binary search' in READ internal table. Ensure table is sorted before using BINARY SEARCH.

Avoid using aggregate functions (SUM, MAX etc) in selects ( GROUP BY , HAVING,)

Avoid using ORDER BY in selects

Avoid Nested Selects

Avoid Nested Loops of Internal Tables

Try to use FIELD SYMBOLS.

Try to avoid into Corresponding Fields of

Avoid using Select Distinct, Use DELETE ADJACENT

PLS:AWARD POINTS IF USEFUL

SRI

8 REPLIES 8

Former Member
0 Kudos
152

Hi,

Try not using the inner join , this will increase the speed of data feth

Regards,

Sunmit.

0 Kudos
152

thank u Sunmit.

is there any way possible that i can read all mrp, nbr and assesible values at one go using joins r something else...

regards,

maya.

Former Member
0 Kudos
152

Hi,

Use INTO TABLE by changing the sequence of the internal table fields.

Use spras in where codn when fetching data from MAKT.

Sort the ITAB's for reading and use Binary search.

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

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

INNER JOIN makt AS c ON amatnr = cmatnr

WHERE awerks = plant and cspras = sy-langu.

Regards,

anji

Former Member
0 Kudos
152

Hi

Remove all corresponding statement in select statement.

Where ever you are using Read..try to use binary search and make sure u will keep sort.

Try to remove using same table (ex a508) multiple times.

When you are using modify,write Transporting fields after modify.

Make sure you are using proper index in select statements and also in select stmnt write the fields in aoder as declared in database table.

For other details check in st05

Former Member
0 Kudos
152

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

Instead of the above code u can directly use the below.. code.

LOOP AT ITAB.

SELECT SINGLE matnr knumh FROM A509 INTO (ITAB-MATNR, ITAB-KNUMH)

WHERE matnr = itab-matnr.

IF SY-SUBRC = 0.

SELECT SINGLE ......OTHER SELCT STATEMENTS AS ABOVE

ENDIF.

MODIFY ITAB INDEX SY-TABIX.

ENDLOOP.

i hope it helps..

please gve points is your questions are answered

Former Member
0 Kudos
152

Do not use INTO CORRESPONDING FIELDS OF TABLE,,,

define the internal tables with the required structure using field string or type decalarations then go for the select statement with INTO TABLE <ITAB>.

this would improve the performance..

regards,

Sai ramesh.

0 Kudos
152

THANK U GUYS FOR UR RESPONSE....

NOW ITS OK TO SOME EXTENT......

PLS SEND ME IF THERE R ANYOTHER TIPS....

REGARDS,

MAYA.

Former Member
0 Kudos
153

HI,

Please dont use INTO CORRESPONDING FIELDS OF,

Always check the driver internal tables is not empty, while using FOR ALL ENTRIES

Avoid for all entries in JOINS

Try to avoid joins and use FOR ALL ENTRIES.

Try to restrict the joins to 1 level only ie only for tables

Avoid using Select *.

Avoid having multiple Selects from the same table in the same object.

Try to minimize the number of variables to save memory.

The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)

Avoid creation of index as far as possible

Avoid operators like <>, > , < & like % in where clause conditions

Avoid select/select single statements in loops.

Try to use 'binary search' in READ internal table. Ensure table is sorted before using BINARY SEARCH.

Avoid using aggregate functions (SUM, MAX etc) in selects ( GROUP BY , HAVING,)

Avoid using ORDER BY in selects

Avoid Nested Selects

Avoid Nested Loops of Internal Tables

Try to use FIELD SYMBOLS.

Try to avoid into Corresponding Fields of

Avoid using Select Distinct, Use DELETE ADJACENT

PLS:AWARD POINTS IF USEFUL

SRI