Application Development 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: 

how to validate input's in selection-screen

moniabap_moni
Explorer
0 Kudos
8,445

Hi ,

can any one how to validate input's field's in selection-screen and each field has diffirent tables and what is the table name which has all the validating fields??

Thank's in advance..

7 REPLIES 7

Former Member
0 Kudos
553

Hi,

If you're talking about validating the users input in the selection screen, use at selection event then validate the input.

Hope this helps.

Kenny

Former Member
0 Kudos
553

hi,

Get the chect table for that perticular field and write query..............

ex: select adrnr from T100 into p_adrnr where adrnr = p_adrnr.

if sy-subrc ne 0.

message e001.

endif.

thanx.

reward if help ful.

Former Member
0 Kudos
553

Hi,

Use AT SELECTION-SCREEN block.

Reward if helpful.

regards,

Kenny

Former Member
0 Kudos
553

Hi,

declare the tables first.

and declare selection screen:

select-options:s_bukrs for t001-bukrs no intervals no-extension

obligatory,

s_vkorg for tvko-vkorg no intervals no-extension,

s_vtweg for tvtw-vtweg no intervals no-extension.

and write the validations in AT selection screen event.

  • Validation of Sales Organization

clear tvko.

if not s_vkorg-low is initial.

select vkorg from tvko up to 1 rows

into tvko-vkorg

where vkorg in s_vkorg.

endselect.

if sy-subrc ne 0.

message e009. " Invalid Sales Organization

endif.

endif.

  • Validation of Distribution Channel

clear tvtw.

if not s_vtweg-low is initial.

select vtweg from tvtw up to 1 rows

into tvtw-vtweg

where vtweg in s_vtweg.

endselect.

if sy-subrc ne 0.

message e010. " Invalid Distribution Channel

endif.

endif.

  • Validation of Division

clear tspa.

if not s_spart-low is initial.

select spart from tspa up to 1 rows

into tspa-spart

where spart in s_spart.

endselect.

if sy-subrc ne 0.

message e011. " Invalid Division

endif.

endif.

reward ifuseful

regards,

ANJI

Former Member
0 Kudos
553

hi,

write the below logic In the event

at selection-screen.

perform validate_material.

form validate_material.

data: v_matnr type mara-matnr.

if not s_matnr is initial.

select matnr

from mara up to 1 rows

into v_matnr

where matnr in s_matnr.

endselect.

if sy-subrc <> 0.

message exxx(message-id) with 'Please enter valid Material'.

endif.

endif.

endform.

~~Guduri

former_member673464
Active Contributor
0 Kudos
553

hi,

You can use validate selct-options using select query by obtaining the realtionship from table .Using the selection-screen events You can write code for validation as follows.

tables:

kna1. " General Customer data

*"Selection screen elements............................................

select-options:

s_kunnr for kna1-kunnr. " Customer number

*"Data declarations...................................................

"----


  • Data declaration of the structure to hold kna1 details *

"----


data:

begin of fs_customer,

kunnr type kna1-kunnr, " Customer number

adrnr type kna1-adrnr, " Address

anred type kna1-anred, " Title

erdat type kna1-erdat, " Created on

ernam type kna1-ernam, " Created by

end of fs_customer.

*"Constants declarations..............................................

constants

w_path type string value 'D:\DOWNLOAD\CUSTOMER'.

"----


  • Internal table to hold customer details *

"----


data:

t_customer like

standard table

of fs_customer.

"----


  • AT SELECTION SCREEN OUTPUT *

"----


at selection-screen.

perform retrieve.

----


  • Form RETRIEVE *

----


  • This subroutine retrieve customer data from table kna1 *

----


  • There are no interface parameters to be passed to this subroutine. *

----


form retrieve .

select kunnr " Customer number

adrnr " Address

anred " Title

erdat " Created on

ernam " Created by

into corresponding fields of table t_customer

from kna1

where kunnr in s_kunnr. " END SELECT

if sy-subrc ne 0.

message text-001 type 'E'.

exit.

endif. " IF SY-SUBRC NE 0

endform. " RETRIEVE

regards,

veeresh

Former Member
0 Kudos
553

hi,

If the fields u want to declare in selectioin screen are standard fields of some dbtable then declare that element( parameter, select option etc) as type of that table field, when u do so the input values are automatically validated and u dont need to do any separate validation for that.

If the fields u define are custom fields then u need to write a separate validation for that, this u can do in the at selection screen output event. and write your check there.