‎2006 Mar 20 7:05 AM
hi frnd's,
how to do the validation
for each row that is found,
no rows found,
more than one row found,
equal to one row found.
‎2006 Mar 20 7:26 AM
Hi suganya,
1. SY-DBCNT
2. After we write any Sql,
this system field
is filled with
NUMBER OF ROWS retrieved using the sql.
3. check this out (just copy paste in new program)
REPORT abc.
TABLES : t001.
SELECT-OPTIONS : bukrs FOR t001-bukrs.
*----
DATA : itab LIKE TABLE OF t001 WITH HEADER LINE.
*----
SELECT * FROM t001 INTO TABLE itab
WHERE bukrs IN bukrs.
*----
WRITE sy-dbcnt.
regards,
amit m.
‎2006 Mar 20 7:09 AM
Loop at the table....
Get the count of rows..if reqd using DEscribe statement..
and validate each field..
Vinotha M.
‎2006 Mar 20 7:12 AM
using the return code how do i validate ie
sy-subrc = 0 ,sy-dbcnt > 0,
like that
‎2006 Mar 20 7:12 AM
Hello Suganya,
I am assuming u r talking abt internal table rows..
U can use firstly DESCRIBE tbale <xyz> LINES lin. this will indicate the number of lines. Using this u can slove ur point 2. For rest u can
loop through and do the checks which u want to do.
‎2006 Mar 20 7:14 AM
I am not sure when you filled your internal table. If you filled your internal table in the INITIALIZATION event, then you can do the validation in AT SELECTION-SCREEN event. If you fill the internal table in START-OF-SELECTION event, you can validate it there.
Remember a select option can be a range of values or just single values or combination of both. So logically even if one value out of the select option values is valid, the user should not be given an error message. Only if all the values in the select-option are invalid, then the user should get the error message.
Now coming to the logic of validating the select option, you need to get all the possible values for the given select option into another internal table. Then you need to loop at both the internal tables to validate the select option. I don't see any other option unless your requirement is something else.
Message was edited by: kishan negi
‎2006 Mar 20 7:18 AM
Hi,
You have the answer.
If you want to validate on number of records,
use sy-dbcnt.
If you want to validate the values in the internal table,
loop thru the table and check the conditions.
Regards,
Shashank
‎2006 Mar 20 7:26 AM
Hi suganya,
1. SY-DBCNT
2. After we write any Sql,
this system field
is filled with
NUMBER OF ROWS retrieved using the sql.
3. check this out (just copy paste in new program)
REPORT abc.
TABLES : t001.
SELECT-OPTIONS : bukrs FOR t001-bukrs.
*----
DATA : itab LIKE TABLE OF t001 WITH HEADER LINE.
*----
SELECT * FROM t001 INTO TABLE itab
WHERE bukrs IN bukrs.
*----
WRITE sy-dbcnt.
regards,
amit m.
‎2006 Mar 20 8:02 AM
Hi Suganya,
Considering the <b>context of internal table</b>
Assuming itab is my internal table with record A, B, C, A, D, A
how to do the validation for each row that is found,
Describe table itab lines N.
Say if u want to validate for record 'A' of internal tables itab.
Loop at itab into wa_itab where record = 'A'.
Do processing
Endloop
<b>*no rows found,</b>
IF N is initial.
Do processing
<b>*equal to one row found.</b>
ELSEIF N EQ '1'.
Do processing
Else
<b>*more than one row found,</b>
Do Processing
Endif.
<b>Considering Select context .</b>
Sy-subrc
Sy-dbcnt.
Hope this will help you.
Cheers
Sunny
Rewrd points, if found helpful