‎2006 Sep 17 4:50 PM
Hi frnds .
Hope everything is working fine for all.
Frnds i hav a doubt.
which one is better and what is the diff between the statements below.
here so_matnr is my select-options
stmt1 :
select matnr from mara into wa_matnr where matnr in so_matnr.
stm2 :
select single matnr from mara into wa_matnr where matnr in so_matnr.
with regards,
sahakla
‎2006 Sep 17 5:03 PM
> stmt1 :
> select matnr from mara into wa_matnr where matnr in
> so_matnr.
This will have a ENDSELECT. This will process all the selections satisfying the selection crieria one by one. In effect this is a loop.
>
> stm2 :
> select single matnr from mara into wa_matnr where
> matnr in so_matnr.
This one selects only row from the database.
These two cannot be compared directly as the first one process mulitple row where as the second process processes only one row.
If you are looking for only row then go with the second, if looking for multiple rows, change to this.
SELECT MATNR ... INTO TABLE T_MATNR FROM MARA WHERE MATNR IN S_MATNR.
This will directly put the data into table without a loop.
Regards,
Ravi
Note : Please mark all the helpful answers
‎2006 Sep 17 5:58 PM
hi Ravi sorry for late rely..
ravi can u tell me which one is performance wise better.
‎2006 Sep 17 5:07 PM
Both the statements will return only one value, even though you pass the MATNR in ranges.
You need to use the select single statement only when we have all primary keys in the search criteria.
Statement 2, as you have mentioned the primary key in the search criteria but it is based on ranges i.e so_matnr
Both the statements will return only one value.
The first statment has to have a ENDSELECT statement.
The select.. Endselect would be in a loop.
Best way is to get the MATNR is an internal table and do the processing:
data: begin of itab occurs 0,
matnr like mara-matnr,
end of itab.
select matnr into table itab
from mara
where matnr in so_matnr.
The intenal table itab will have all the valid MATNR and you can do the necesarry processing.
‎2006 Sep 18 4:36 AM
hi,
select single performance is better when compared to the other select. As, we are selecting all the records that satisfies the selection criteria specified in the select options.
In case of select single, we are fetching only one record. Once a record is found, execution of the select is completed.
Regards,
Sailaja.
‎2006 Sep 18 5:05 AM
hi,
kindly chk this,
stmt1 :
select matnr from mara into wa_matnr where matnr in so_matnr.
HERE WE NEED END SELECT.
BUT NEVERE USE SELECT - END SELECT.
IT WILL RESULT IN VERY LOW PERFORMANCE.
SO THE OPTION FOR U IS
select matnr from mara into<b> table</b> int_matnr where matnr in so_matnr.
then manipulate the internal table.
stm2 :
select single matnr from mara into wa_matnr where matnr in so_matnr.
THE STMNT2 HAS HIGH PERFORMANCE.
IF U WANT ONLY ONE MATNR THN GO WITH THIS.
oTHER WISE <b>INTO TABLE</b> WILL BE THE BEST METHOD.
rgds
anver
if helepd mark points