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-options validation

Former Member
0 Likes
806

select-options: s_kunnr for kna1-kunnr.

In my requirement I need to validate the above selection-screen parameters (i.e. s_kna1-low and s_kna1-high contained in database or not). Can anybody give the logic for this.

Regards,

Naseer.

6 REPLIES 6
Read only

Former Member
0 Likes
767

In the At selection-screen event write select single queries as below


Data: gv_kunnr_low type kna1-kunnr.
Select Single kunnr from KNA1 into gv_kunnr_low where kunnr = s_kunnr-low.
if sy-subrc <> 0.
 error message.
endif.

Same as for high.

Regards,

Satish

Read only

Former Member
0 Likes
767

Hi nasser,

You will be writing select query depending up on ur select-options field. There you can validate as per given input values if the select qurey is fecting values into internal table it is ok if not the value donest exits.

Ex:

Select-options: S_kunnr for kna1-kunnr.

Select * from KNA1 into table itab where kunnr in s_kunnr.

<b>IF NOT ITAB IS INITIAL .</b>

loop at itab

write: itab-kunnr.

endloop.

else.

message E001 with 'NO RECORDS AVAILABLE FOR GIVEN INPUT'.

ENDIF.

Hope this will help u.....

<b>reward if useful</b>

Regards,

sunil kairam.

Read only

Former Member
0 Likes
767

Hi Naseer,

Check sy-subrc after the select statement if its success then proceed else thrw a error message.

For e.g

<b>AT SELECTION-SCREEN ON S_KUNNR.

Select single kunnr from kna 1

into loc_variable

where kunnr in s_kunnr.

if sy-subrc <> 0.

Write : 'No data'.

else.

..........

..........

........... (Your Coding).

Endif.</b>

Do it like this you will get error message if it error else you will proceed with your coding.

Hope its useful.

Thanks,

Sakthi C

*Rewards if useful*

Read only

former_member195698
Active Contributor
0 Likes
767

Try

select single * from kna1 where kunnr in s_kunnr.

if sy-subrc eq 0 , then atleast one entry is there in your select option that is valid.

You shouldn't just check the high and low parameter.

Regards,

Abhishek

Read only

Former Member
0 Likes
767

tables :

spfli.

select-options:

s_carr for spfli-carrid.

Hi,

i guess this code will solve ur problem.

data:

it_tab like table of spfli with header line.

select *

from spfli

into table it_tab

where carrid gt s_carr-low

and carrid le s_carr-high.

if sy-subrc eq 0.

loop at it_tab.

write: it_tab-carrid.

endloop.

endif.

plzz reward points if it helps.

Read only

Former Member
0 Likes
767

Hi Naseer,

Try this code it may help full.

tables spfli.

data w_carrid type spfli-carrid.

select-options s_carrid for spfli-carrid.

selection-screen on s_carrid.

Loop at s_carrid.

if s_carrid-low is not initial.

select single carrid

into w_carrid

from spfli

where carrid eq s_carrid-low

if sy-subrc ne 0.

clear w_carrid.

message e015 ( Error message here)

endif.

if s_carrid-high is not initial.

select single carrid

into w_carrid

from spfli

where carrid eq s_carrid-high

if sy-subrc ne 0.

clear w_carrid.

message e015 ( Error message here)

endif.

endloop.

Plzz Reward if it is Useful,

Mahi.