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

Code Optimization - Performance Issue

Former Member
0 Likes
390

Dear All,

I have written the below code, which basically does what CS15 does, since it is recursive in nature, the execution time is very long. Is there anyway i can modify this code, to reduce the run-time.

  • Function call
  • IMPORTING
  • TOPMAT =
IF VA_REF NE EBAN-MATNR. WHILE NOT VA_MATNR IS INITIAL. CALL FUNCTION 'CS_WHERE_USED_MAT' EXPORTING DATUB = SYST-DATUM DATUV = SYST-DATUM MATNR = VA_MATNR WERKS = EBAN-WERKS TABLES WULTB = IT_WULTB[] EQUICAT = IT_EQUICAT[] KNDCAT = IT_KNDCAT[] MATCAT = IT_MATCAT[] STDCAT = IT_STDCAT[] TPLCAT = IT_TPLCAT[] PRJCAT = IT_PRJCAT[] EXCEPTIONS CALL_INVALID = 1 MATERIAL_NOT_FOUND = 2 NO_WHERE_USED_REC_FOUND = 3 NO_WHERE_USED_REC_SELECTED = 4 NO_WHERE_USED_REC_VALID = 5. IF SY-SUBRC EQ 0. LOOP AT IT_MATCAT[] INTO HT_MATCAT FROM '0'. SEARCH HT_MATCAT-MATNR FOR 'MM'. IF SY-FDPOS NE SPACE AND VA_MM IS INITIAL. VA_MM = 'X'. CONCATENATE 'NUT' '~' A_MTL INTO A_MTL. ENDIF. SEARCH HT_MATCAT-MATNR FOR 'DM'. IF SY-FDPOS NE SPACE AND VA_PM IS INITIAL. VA_PM = 'X'. CONCATENATE 'WASHER' '~' A_MTL INTO A_MTL. ENDIF. SEARCH HT_MATCAT-MATNR FOR 'CM'. IF SY-FDPOS NE SPACE AND VA_CM IS INITIAL. VA_CM = 'X'. CONCATENATE 'SPRING' '~' A_MTL INTO A_MTL. ENDIF. ITAB-MATNR = HT_MATCAT-MATNR. APPEND ITAB. CLEAR ITAB. ENDLOOP. ENDIF. CLEAR: VA_MATNR, HT_MATCAT. REFRESH IT_MATCAT[]. READ TABLE ITAB INTO VA_MATNR INDEX VA_KEY. "Value assignment VA_KEY = VA_KEY + 1. ENDWHILE. ENDIF. VA_REF = EBAN-MATNR.

Any inputs????

Edited by: Vivek on Apr 16, 2008 12:24 AM

1 REPLY 1
Read only

former_member194669
Active Contributor
0 Likes
340

May be you can avoid the SEARCH HT_MATCAT-MATNR. If your MM CM DM are coming in an exact position in MATNR field

Say for example in MT_MATCAT-MATNR is something like 'MATMM001' or 'MATDM001' or 'MATCM001'

then

if MT_MATCAT-MATNR+3(2) = 'MM' AND VA_MM IS INITIAL.

VA_MM = 'X'.

CONCATENATE 'NUT' '~' A_MTL INTO A_MTL.

ENDIF.

a®