‎2006 Oct 05 6:54 AM
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
‎2006 Oct 05 6:56 AM
First one is better. Its simple!!!
reward points if u find answer well enough.
‎2006 Oct 05 6:57 AM
‎2006 Oct 05 7:00 AM
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.
‎2006 Oct 05 7:00 AM
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.
‎2006 Oct 05 7:02 AM
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.
‎2006 Oct 05 7:02 AM
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.