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

Selection-screen validation

Former Member
0 Likes
885

Hi all

I have a doubt in the selection-screen validation .

In my selection screen i have a field for date which is of character type (10) . The date formate to be entered should be of 2006/01/25 in the input field .

If the user is giving any other date formate like 2006.01.25 then an error message to be displayed in the selection screen .

Can anyone tell me a smaple code for this senario .

8 REPLIES 8
Read only

Former Member
0 Likes
862

Use the DATE data type

do not use Char (10).

u cant do any calculations on char(10)

Reward if useful

Read only

Former Member
0 Likes
862

Hi Vignesh,

why don't you use the Date Field directly ?

parameters : NewDate type datum.

Regards,

Sai

Edited by: Sai Krishna Kowluri on Mar 6, 2008 8:11 AM

Read only

Former Member
0 Likes
862

hI

YOU HAD DECLARED DATE FIELD AS CHAR SO PUTTING VALIDATION FOR THAT IS TYPICAL

REFER THAT TO DATE FIELD AND YOU DO VALIDATION FOR THAT UNDER AT SELECTIO-SCREEN EVENT

Read only

Former Member
0 Likes
862

Hi

use the data type for your element as sy-datum.

You wont need to do any validation then

regrads

Ravish

Read only

Former Member
0 Likes
862

Hi,

DATA : v_cnt1 TYPE i,

v_cnt2 TYPE i VALUE 1.

SELECT-OPTIONS : s_date(10).

AT SELECTION-SCREEN.

DO 10 TIMES.

IF s_date-low+v_cnt1(v_cnt2) EQ '.' .

MESSAGE e001(zzz) WITH TEXT 'Please Enter in yyyy/mm/dd Format.'

ENDIF.

v_cnt1 = v_cnt1 + 1.

ENDDO.

Read only

Former Member
0 Likes
862

Hi,

if you want date to be in that format then you can do in following way.

Ex:

V_date = '2006\02\11'.

then validate with if conditions.

If V_date+4(1) NE '/' and

V_date+6(1) NE '/'.

Error Message

Regards,

Jallu

Read only

former_member188827
Active Contributor
0 Likes
862

try dis:

parameters:zdate(10).

data msk type string value '--//--'.

at selection-screen.

describe field zdate edit mask msk.

if sy-subrc ne 0.

message 'Give date in format -


//' type 'E'.

endif.

start-of-selection.

write zdate.

plz reward points if dis helps

Read only

i048168
Product and Topic Expert
Product and Topic Expert
0 Likes
862

Hi,

It is still possible to validate the date format of a select option even when it is string.

Try the following:

data: ch type char10.

data: separator type char4.

data: numbers type char16.

select-options sel1 for ch.

at selection-screen output.

concatenate sel1-low4(1) sel1-low7(1) sel1-high4(1) sel1-high7(1) into separator.

concatenate sel1-low0(4) sel1-low5(2) sel1-low8(2) sel1-high0(4) sel1-high5(2) sel1-high8(2) into numbers.

if ( separator NE '////' ) or ( numbers CN '0123456789' ).

message 'type the date in the format yyyy/dd/mm' type 'I'.

endif.

Regards

Vadi