‎2008 Mar 06 7:05 AM
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 .
‎2008 Mar 06 7:08 AM
Use the DATE data type
do not use Char (10).
u cant do any calculations on char(10)
Reward if useful
‎2008 Mar 06 7:10 AM
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
‎2008 Mar 06 7:12 AM
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
‎2008 Mar 06 7:13 AM
Hi
use the data type for your element as sy-datum.
You wont need to do any validation then
regrads
Ravish
‎2008 Mar 06 7:13 AM
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.
‎2008 Mar 06 7:17 AM
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
‎2008 Mar 06 7:19 AM
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
‎2008 Mar 06 7:41 AM
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