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

select?

Former Member
0 Likes
792

Hai all,

While validating a field which is better to opt and why?

1.data: l_matnr like mara-matnr.

select single matnr from mara where matnr in p_matnr into l_matnr.

where p_matnr is a selection-screen element

2.with out declaring a local variable using

select count *

if 2. is best plz provide me with code

Regards,

Madhu

6 REPLIES 6
Read only

Former Member
0 Likes
763

First one is better. Its simple!!!

reward points if u find answer well enough.

Read only

Former Member
0 Likes
763

hi,

i think the first method is better and less time consuming

Read only

anversha_s
Active Contributor
0 Likes
763

hi,

u don want to declare local variable,

just do this.

tables mara.

SELECT SINGLE matnr FROM mara

WHERE matnr in p_matnr.

if mara-matnr is initail.

no value available.

endif.

Read only

anversha_s
Active Contributor
0 Likes
763

hi,

u don want to declare local variable,

just do this.

tables mara.

SELECT SINGLE matnr FROM mara

WHERE matnr in p_matnr.

if mara-matnr is initail.

no value available.

endif.

Read only

Former Member
0 Likes
763

In this particular case, neither!

I would use BAPI_MATERIAL_EXISTENCECHECK or MARA_SINGLE_READ to check/read the material instead of using select statements etc. etc.

The development approach should be to levarage as much as possible from SAP standard objects/methods/FMs. One should only write code as the very last option when SAP standard functionalities are not available.

Read only

Former Member
0 Likes
763

Hi,

I belive the first statement is better as it does single hit to database and will terminate the connection once the first row is encountered, where as the count * will loop through all the occurences of the records before returning the count.

Hope this helps.