2010 Apr 05 7:52 AM
Following code is taking too much time to execute . (some time giving Time_out )
ind = sy-tabix.
SELECT SINGLE * FROM mseg INTO mseg
WHERE bwart = '102' AND
lfbnr = itab-mblnr AND
ebeln = itab-ebeln AND
ebelp = itab-ebelp.
IF sy-subrc = 0.
DELETE itab INDEX ind.
CONTINUE.
Is there any other way to write this code to reduce the output time.
Thanks
Following code is taking too much time to execute . (some time giving Time_out )
ind = sy-tabix.
SELECT SINGLE * FROM mseg INTO mseg
WHERE bwart = '102' AND
lfbnr = itab-mblnr AND
ebeln = itab-ebeln AND
ebelp = itab-ebelp.
IF sy-subrc = 0.
DELETE itab INDEX ind.
CONTINUE.
Is there any other way to write this code to reduce the output time.
Thanks
2010 Apr 05 7:58 AM
Why dont you select all the data from MSEG once??? Outside the loop
SELECT * FROM mseg INTO mseg
WHERE bwart = '102'.
sort mseg.
Now Read table mseg where mseg = itab-mblnr AND
ebeln = itab-ebeln AND
ebelp = itab-ebelp Binary Search.
This might work in a lesser time
2010 Apr 05 8:11 AM
Hi,
u can select what are all the field s u need to display in out put screen instead of taking all fields from the MSEG,
(other wise try UPTO ONE ROW statement .)
thanks
2010 Apr 05 8:12 AM
Hi,
I think you are executing this code in a loop which is causing the problem. The rule is "Never put SELECT statements inside a loop".
Try to rewrite the code as follows:
* Outside the loop
SELECT *
from MSEG
into table lt_mseg
for all entries in itab
where bwart = '102' AND
lfbnr = itab-mblnr AND
ebeln = itab-ebeln AND
ebelp = itab-ebelp.
Then inside the loop, do a READ on the internal table
Loop at itab.
*******
read table lt_mseg with key bwart = '102'. "plus other conditions
if sy-subrc ne 0.
delete itab. "index is automatically determined here from SY-TABIX
endif.
******
endloop.
I think this should optimise performance. You can check your code's performance using SE30 or ST05.
Hope this helps! Please revert if you need anything else!!
Cheers,
Shailesh.
Always provide feedback for helpful answers!
2010 Apr 05 12:52 PM
Hi sir, I tried your idea like
LOOP AT itab.
ind = sy-tabix.
SELECT SINGLE * FROM mseg INTO mseg
WHERE bwart = '102'.
loop at mseg .
read table itab with key bwart = '102'
mblnr = mseg-lfbnr
ebeln = mseg-ebeln
ebelp = mseg-ebelp binary search.
IF sy-subrc ne 0.
DELETE itab INDEX ind.
endif.
endloop.
It increase the performance but it is not deleting itab for condition bwart 102. Please do check me , what m doing wrong ?
Thanks
2010 Apr 05 2:06 PM
>
> Please do check me , what m doing wrong ?
Moderator message - Please see before posting - post locked
2010 Apr 05 8:16 AM
Hi,
You can try with creating secondary index with the same combination .It will reduce your time.
Thanks,
Ankita
2010 Apr 05 8:18 AM
hi,
i think the problem is that you are extracting the data from the same place and replacing it in the same place in the table....
try putting the extracted data into an internal table first and then use the update statement to update the table with the given data.
2010 Apr 05 8:18 AM
Try This
SELECT SINGLE * FROM mseg INTO mseg
WHERE bwart = '102'.
loop at mseg into wa_mseg.
read table itab into wa_itab with key mblnr = wa_mseg-lfbnr
ebeln = wa_mseg-ebeln
ebelp = wa_mseg-ebelp.
if sy-subrc eq 0.
ind = sy-tabix.
DELETE itab INDEX ind.
endif.
endloop.Regards
Vinod
2010 Apr 05 9:36 AM
Within standard SAP there's no appropriate index on MSEG to support your query. Thus instead of selecting the material document directly from MSEG via the purchase order number, you should first get the material documents via the purchase order history table EKBE. Then you can read the MSEG data you need using the material document number (mseg-mblnr=ekbe-belnr, mseg-mjahr=ekbe-gjahr, mseg-zeile=ekbe-buzei) or simply use a join on EKBE and MSEG.
This should give you the speed you're looking for...
Cheers, harald
2010 Apr 05 10:08 AM
Hello,
Try this way.
sELECT SINGLE * FROM mseg INTO mseg
WHERE
lfbnr = itab-mblnr AND
ebeln = itab-ebeln AND
ebelp = itab-ebelp and
bwart = '102'.
IF sy-subrc = 0.
DELETE itab INDEX ind.
CONTINUE.
This may help out.
Rgds
Siva
2010 Apr 05 10:11 AM
I welcome Mr Harold's suggestion too. You can try with that too.
Cheers
Siva
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |