‎2008 Nov 11 7:33 AM
hi all,
while doing validation like below
if s_proj[] is not initial.
select aufnr
from aufk
into table it_val_aufk UP TO 1 ROWS
where aufnr
in s_proj.
if it_val_aufk[] is initial.
message e012(ZXM7).
endif.
endif.
If i enter aufnr in ranges like 1234 "valid
4567 "not valid
still it wont validate for the second record
can you people suggest a better way to solve the above problem
regards
‎2008 Nov 11 7:38 AM
Hi,
Remove up 1 ROW and remove second IF condition, use Sy-Subrc
if s_proj[] is not initial.
select aufnr
from aufk
into table it_val_aufk where aufnr
in s_proj.
IF sy-subrc NE 0
message e012(ZXM7).
endif.
Regards
Bala Krishna
Edited by: Bala Krishna on Nov 11, 2008 1:08 PM
‎2008 Nov 11 7:51 AM
Try this code:
if s_proj[] is not initial.
select aufnr
from aufk
into table it_val_aufk
where aufnr
in s_proj.
if it_val_aufk[] is initial.
message e012(ZXM7).
endif.
endif.
Here it_val_aufk[] returns all the valid records for the data entered in the selection screen. Now If you want to check which record(s) that is entered in the screen is not valid, then u need to write ur logic to do that.
‎2008 Nov 11 8:04 AM
Hi,
Its right that you need to remove UP TO 1 ROWS.
If i enter aufnr in ranges like 1234 "valid
4567 "not valid
still it wont validate for the second record
can you people suggest a better way to solve the above problem
It is alright and thats how it works with select options. When you enter search criteria in the select-options, you can enter ranges. And at times it is not always necessary that there will be a correspding database record for each value of the the serach criteria.
For select-options, you should therefore only give error message if nothing was found and leave it otherwise.
In your example, imagine if the user gives a range of 1234 to 4567 around 3000 records. Imagine there are only 5 valid records among these 3000. In that case you don't want to end up giving message for the remaining invalid values. Besides that, the moment you give an error message for any one of the record, the program will stop executing and the user will have to restarat his selection once again.
So I would say that for select-options, do not try to validate each and every value.
regards,
Advait.
‎2008 Nov 11 8:08 AM