Skip to Content
0
Former Member
Nov 14, 2007 at 05:48 AM

Program Execution time out

16 Views

Hi,

In start of selection my code is taking a lot of time in execution for getting material description. I tried to write using joins the program is retriving wrong data. I paste the code can any one kindly help me in writing the code correctly so that it will not take more time in execution. If any small change I do it is not giving any result.

Awaiting for a positive answer. Thanks in adv.

My Internal Table

DATA: BEGIN OF ITAB1 OCCURS 0 ,

MATNR LIKE A503-MATNR, " Material No.

VKORG LIKE A503-VKORG,

UOM LIKE KONP-KMEIN,

WAERS LIKE KONP-KONWS,

MFRNR LIKE MARA-MFRNR, " MFRN NO.

MATKL LIKE MARA-MATKL, " Mat.grp.

WERKS LIKE MARC-WERKS,

  • ARKTX LIKE VBAP-ARKTX, " Material Desc.

MAKTX LIKE MAKT-MAKTX,

NETPR LIKE VBAP-NETPR, "SALES PRICE

COSTPR LIKE VBAP-NETPR, "COST PRICE

MARGIN LIKE VBAP-NETPR,

END OF ITAB1.

****Start-of-selection.

SELECT * FROM A503 WHERE KAPPL = 'V'

AND VKORG IN S_SORG

AND MATNR IN S_MATNR

AND KSCHL = 'PR00'

AND DATBI GT SY-DATUM.

SELECT SINGLE * FROM MARA WHERE MATNR = A503-MATNR

AND MATKL IN S_MATGRP.

SELECT VBAP~ARKTX INTO ITAB1-ARKTX FROM VBAP

WHERE MATNR IN S_MATNR.

ENDSELECT.

SELECT SINGLE * FROM MAKT WHERE MATNR IN S_MATNR.

IF SY-SUBRC EQ 0.

SELECT SINGLE * FROM KONP WHERE KNUMH = A503-KNUMH.

ITAB1-MATNR = A503-MATNR.

ITAB1-VKORG = A503-VKORG.

ITAB1-NETPR = KONP-KBETR.

ITAB1-UOM = KONP-KMEIN.

ITAB1-WAERS = KONP-KONWS.

ITAB1-ARKTX = VBAP-ARKTX.

SELECT * FROM MBEW WHERE MATNR = ITAB1-MATNR AND BWKEY IN S_PLANT.

IF MBEW-VPRSV = 'V'.

ITAB1-COSTPR = MBEW-VERPR * MBEW-PEINH .

ELSE.

ITAB1-COSTPR = MBEW-STPRS * MBEW-PEINH .

ENDIF.

ITAB1-MARGIN = ITAB1-NETPR - ITAB1-COSTPR.

ITAB1-WERKS = MBEW-BWKEY.

APPEND ITAB1.

ENDSELECT.

CLEAR ITAB1.

ENDIF.

ENDSELECT.

SORT ITAB1 BY MATNR WERKS.

DELETE ADJACENT DUPLICATES FROM ITAB1 COMPARING MATNR WERKS.

DELETE ITAB1 WHERE MATNR EQ SPACE.