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: 

Program Execution time out

Former Member
0 Kudos

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.

3 REPLIES 3

former_member386202
Active Contributor
0 Kudos

Hi,

Don't use select...endselect, use for all entries and collect data into one internal table using read statement. It will work.

Regards,

Prashant

Former Member
0 Kudos

Do not use select and end select

and try use the key fields for the retreval of data

do not select useless data by using single *

select only the required fields.

Regards,

Siva chalasani.

Former Member
0 Kudos

Hi

remove this select from VBAP

SELECT VBAP~ARKTX INTO ITAB1-ARKTX FROM VBAP

WHERE MATNR IN S_MATNR.

ENDSELECT.

this is fetching Material description only which you already getting from MAKT table.

Also use Select data internal table and for all entries of that fetch and use

remove the endselect..

Regards

Anji