11-14-2007 5:48 AM
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.
11-14-2007 5:51 AM
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
11-14-2007 5:54 AM
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.
11-14-2007 5:56 AM
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