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

field validation at selection-screen

Former Member
0 Likes
2,276

Hi Experts,

I have a parameter in the selection-screen like ths:

Parameters: p_mail type string.

So when we run report we can give email address there.

But i want to validate that.How can we do this:

Suppose if i give value for p_mail like: [email protected]

or [email protected]

Regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,834

Hi Ravi, I understand your query, to validate that parameter, I am posting a sample code. Reward points if helpful

AT SELECTION-SCREEN.

if not p_mail CP '%@%.com'.

message I000(YMSG) with 'Please enter a valid mail id'.

endif.

hope it will work. Reward poinrs if helpful

Hi Experts,

I have a parameter in the selection-screen like ths:

Parameters: p_mail type string.

So when we run report we can give email address there.

But i want to validate that.How can we do this:

Suppose if i give value for p_mail like: [email protected]

or [email protected]

Regards

15 REPLIES 15
Read only

Former Member
0 Likes
1,834

Hi,

Declare the fields with their master tables after declaring those tables with TABLES statement.for few I will give the code, rest you practice.

You have to write this code in AT SELECTION-SCREEN event.

S_WERKS FOR T001W-WERKS,

S_KUNNR FOR KUNNR-KUNNR,

  • Validation of Customer

clear kna1.

if not s_kunnr is initial.

select kunnr from kna1 up to 1 rows

into kna1-kunnr

where kunnr in s_kunnr.

endselect.

if sy-subrc ne 0.

message e014. " Invalid Customer Number

endif.

endif.

  • Validation of Plant

clear t001w.

if not s_werks is initial.

select werks from t001w up to 1 rows

into t001w-werks

where werks in s_werks.

endselect.

if sy-subrc ne 0.

message e004. " Invalid Plant Number

endif.

endif.

reward if useful

regards,

rewards point.

Read only

Former Member
0 Likes
1,834

Use the event AT SELECTION SCREE ON <Feild Name> for each selection screen element.

For each element perform the following checks.

1. Value has been entered

IF <Feild_name > is initial.

give error message.

endif.

2. Valid value is entered

Select single <feild>

from <table>

where <feild_t> = <feild_name>.

if sy-subrc = 0 .

  • Give success message

else

  • Give error message

endif.

Hope this helps

Regards

rewards point

Read only

Former Member
0 Likes
1,834

Here it is...

SELECT-OPTIONS sel_opt1 FOR field1.

SELECTION-SCREEN BEGIN OF BLOCK block1.

PARAMETERS: test1(10) TYPE c,

test2(10) TYPE c.

SELECTION-SCREEN END OF BLOCK block1.

AT SELECTION-SCREEN ON BLOCK block1.

MESSAGE i888 WITH 'AT SELECTION-SCREEN'

'ON BLOCK BLOCK1'.

Have a look at the demo program demo_selection_screen_events for more details.

Regards,

rewards point .

Read only

Former Member
0 Likes
1,835

Hi Ravi, I understand your query, to validate that parameter, I am posting a sample code. Reward points if helpful

AT SELECTION-SCREEN.

if not p_mail CP '%@%.com'.

message I000(YMSG) with 'Please enter a valid mail id'.

endif.

hope it will work. Reward poinrs if helpful

Read only

0 Likes
1,834

Hi all,

Thanks.Suppose my parameter contais:

data : w_str type string.

[email protected]

Here i want to check whether dot ('.') is there or not before @ and after @ .

How can i check this?

Regards

Read only

0 Likes
1,834

Hi

do one thing

first find the positions of @ and .

if the position of (first occurance of ). is lessthan @ raise a error message

and if . is more than one position of @ raise a error message ( [email protected])

reward points to all helpful answers

kiran.M

Read only

0 Likes
1,834

Hi,

Thanks

But i need the code

regards

Read only

0 Likes
1,834

Hi,

As u want to check whether '.' present before and after @, split w_str at @ into w_str1 and w_str2.

Then u can search for '.' in both w_str1 and w_str2.

Reward if it helps....

Regards,

Sankar

Read only

0 Likes
1,834

Hi Ravi

y cant u use this one

AT SELECTION-SCREEN on p_mail.

if not p_mail CP '%@%.com' or p_mail CP '%.%@%.COM.

message I000(YMSG) with 'Please enter a valid mail id'.

endif.

reward points to all helpful answers

kiran.M

Read only

0 Likes
1,834

Hi,

SPLIT W_STR AT '@' INTO W_STR1 W_STR2.

SEARCH W_STR1 FOR '.'.

IF SY-SUBRC NE '0'.

MESSAGE..

ENDIF.

SEARCH W_STR2 FOR '.'.

IF SY-SUBRC NE '0'.

MESSAGE..

ENDIF.

Regards,

Sankar,

Read only

0 Likes
1,834

Hi Ravi...This is the Code for u..

parameters: p_mail(40).

AT SELECTION-SCREEN ON P_MAIL.

IF P_MAIL NP '.@.'.

Message 'Enter Email Id in proper format' type 'E'.

ENDIF.

<b>Reward if Helpful</b>

Read only

0 Likes
1,834

Hi Thanks. But i wnat to check like this:

str1 = ravi.babu

str2= gmail.com

i want to check whether '.' is there after 'u' in str1 and

'.' is there or not after 'm' in str2

How can i do this?

Read only

0 Likes
1,834

Hii Ravi, according to your requirement.

Sample coding

IF NOT STR1 CA '%U.'.

MESSAGE.

ELSE.

MESSAGE.

ENDIF.

IF NOT STR2 CA '%M.'.

MESSAGE.

ELSE.

MESSAGE.

ENDIF.

but there is a problem that u have m in str2 twice. so instead of all these use the below sample code it will work.

IF NOT P_MAIL CP '%@%.com'.

MESSAGE

ENDIF.

Reward points if helpful

Read only

Former Member
0 Likes
1,834

hi ravi

try this....

at selection-screen.

select single * from table where fieldname = p_name.

if sy-subrc <>0.

message e001(zerror).

endif.

REWARD IF USEFUL........!!!

Read only

Former Member
0 Likes
1,834

Hi,

make your email parameter like this adr6-AD_SMTPADR then no need to maintain it at your side.

Like

Parameters : p_email like adr6-AD_SMTPADR.

rewards points if it is useful;.