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

validations

Former Member
0 Likes
860

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
843

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.

7 REPLIES 7
Read only

vinotha_m
Participant
0 Likes
843

Loop at the table....

Get the count of rows..if reqd using DEscribe statement..

and validate each field..

Vinotha M.

Read only

Former Member
0 Likes
843

using the return code how do i validate ie

sy-subrc = 0 ,sy-dbcnt > 0,

like that

Read only

Former Member
0 Likes
843

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.

Read only

0 Likes
843

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

Read only

Former Member
0 Likes
843

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

Read only

Former Member
0 Likes
844

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.

Read only

Former Member
0 Likes
843

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