Application Development and Automation 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: 
Read only

performance

Former Member
0 Likes
611

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

5 REPLIES 5
Read only

Former Member
0 Likes
563

> 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

Read only

0 Likes
563

hi Ravi sorry for late rely..

ravi can u tell me which one is performance wise better.

Read only

Former Member
0 Likes
563

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.

Read only

Former Member
0 Likes
563

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.

Read only

anversha_s
Active Contributor
0 Likes
563

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