2006 May 11 8:26 PM
I have the material number and the plant. What is the most efficient select to get the latest kalnr(costing estimate) based on date. Doing a select-endselect to find the last record is a performance problem.
Current code:
select kalnr kadky
from keko
where matnr = mbew-matnr
werks = werks-low.
endselect.
Suggestions? Thank you.
2006 May 11 8:40 PM
report zrich_0001.
data: ikeko type table of keko with header line..
parameters: p_matnr type mara-matnr,
p_werks type marc-werks.
select * from keko into table ikeko
where matnr = p_matnr
and werks = p_werks.
sort ikeko descending by kadky.
read table ikeko index 1.
write:/ ikeko-kadky, ikeko-matnr, ikeko-werks, ikeko-LOSGR.Regards,
Rich Heilman
I have the material number and the plant. What is the most efficient select to get the latest kalnr(costing estimate) based on date. Doing a select-endselect to find the last record is a performance problem.
Current code:
select kalnr kadky
from keko
where matnr = mbew-matnr
werks = werks-low.
endselect.
Suggestions? Thank you.
2006 May 11 8:40 PM
report zrich_0001.
data: ikeko type table of keko with header line..
parameters: p_matnr type mara-matnr,
p_werks type marc-werks.
select * from keko into table ikeko
where matnr = p_matnr
and werks = p_werks.
sort ikeko descending by kadky.
read table ikeko index 1.
write:/ ikeko-kadky, ikeko-matnr, ikeko-werks, ikeko-LOSGR.Regards,
Rich Heilman
2006 May 11 8:42 PM
Hello Janet,
Rather than using Select-EndSelect, you can used Select into internal table....which wll be much faster while processing data.
So query will be...
Select Kalnr kadky
into itab1
from keko
where matnr = mbew-matnr
werks = werks-low.
and then you can loop into itab1 if you want to process data.
Cheers,
Nilesh
2006 May 11 8:44 PM
The SELECT... ENDSELECT is a slower method.
You have no keys fields here so your DB engine will be using the INDEX on MATNR.
select Kalnr kadky
into table The_Table
from keko
where matnr = mbew-matnr
werks = werks-low
descending by kadky.
read table The_table index 1.
2006 May 11 8:46 PM
Or
select single Kalnr kadky into (keko-kalnr, keko-kadky)
from keko
where matnr = mbew-matnr
werks = werks-low
descending by kadky.
2006 May 11 8:44 PM
Or you can do something like this.
report zrich_0001.
data: xkeko type keko .
parameters: p_matnr type mara-matnr,
p_werks type marc-werks.
select * from keko up to 1 rows into xkeko
where matnr = p_matnr
and werks = p_werks
order by kadky descending.
endselect.
write:/ xkeko-kadky, xkeko-matnr, xkeko-werks, xkeko-losgr.
Regards,
Rich Heilman
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |