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

How Vaildated DATE

Former Member
0 Likes
2,449

HI

I want to valid the Given Data is Vaild and not vaild using function module .

Enter date : 21032007

Output : Vaild Date:

Enter Date : 99999991

Output : invaild date

enter Date : aa93111b

Output : invaild format

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,361

Hi,

You can define date field of type numeric.So that it will not accept characters.I have done like that in my requirement.

Reward points

Regards

Shibin

Hi,

You can define date field of type numeric.So that it will not accept characters.I have done like that in my requirement.

Reward points

Regards

Shibin

18 REPLIES 18
Read only

Former Member
0 Likes
2,362

Hi,

You can define date field of type numeric.So that it will not accept characters.I have done like that in my requirement.

Reward points

Regards

Shibin

Read only

Former Member
0 Likes
2,361

Hi Jayendra,

You can chk this Function Module,

/OSP/VALIDATE_DATE_TIME

Regards,

Samson Rodrigues.

Read only

abapdeveloper20
Contributor
0 Likes
2,361

Hi,

Use this FM in SE37

DATE_CHECK_PLAUSIBILITY

Have a nice day

Reward if useful

~Lakshmiraj~

Edited by: LAKSHMIRAJ on Mar 27, 2008 5:26 AM

Read only

0 Likes
2,361

I don't want use this function . Pl explain me other way ..

Read only

Former Member
0 Likes
2,361

Hi,

Declare your filed like below .Automatically it will take care all validatins.

SELECT-OPTIONS : s_date FOR sy-datum.

Pls. reward if useful

Read only

0 Likes
2,361

pl exapin me more on that

Read only

0 Likes
2,361

try this FM

BUR_CHECK_VALID_DATES

reward if helpful

raam

Read only

0 Likes
2,361

HI

Please explain me detail

Read only

0 Likes
2,361

its simple yaar

give the date to the import parameter of the function module .

the FM itself check the date and gives the output.

or

the other way is that u need to take the given input and split using the offset and then check them wheather the given values r in valid range or not

reward if helpful

raam

Read only

0 Likes
2,361

Still i 'm not getting clearly

please explain step by step..

Read only

0 Likes
2,361

DATA: CHECK_YEAR_1 TYPE P.

DATA: CHECK_YEAR_2 TYPE P.

IF DATE CN '0123456789'.

MESSAGE S011 WITH DATE RAISING PLAUSIBILITY_CHECK_FAILED.

ENDIF.

IF DATE+4(2) LT '01'

OR DATE+4(2) GT '12'.

MESSAGE S003 WITH DATE+4(2) RAISING PLAUSIBILITY_CHECK_FAILED.

ENDIF.

IF DATE+6(2) LT '01'

OR DATE+6(2) GT '31'.

MESSAGE S006 WITH DATE+6(2) RAISING PLAUSIBILITY_CHECK_FAILED.

ENDIF.

IF DATE+4(2) EQ '01'

OR DATE+4(2) EQ '03'

OR DATE+4(2) EQ '05'

OR DATE+4(2) EQ '07'

OR DATE+4(2) EQ '08'

OR DATE+4(2) EQ '10'

OR DATE+4(2) EQ '12'.

IF DATE+6(2) GT '31'.

MESSAGE S004 WITH DATE6(2) DATE4(2)

RAISING PLAUSIBILITY_CHECK_FAILED.

ENDIF.

ELSEIF DATE+4(2) EQ '04'

OR DATE+4(2) EQ '06'

OR DATE+4(2) EQ '09'

OR DATE+4(2) EQ '11'.

IF DATE+6(2) GT '30'.

MESSAGE S004 WITH DATE6(2) DATE4(2)

RAISING PLAUSIBILITY_CHECK_FAILED.

ENDIF.

ELSE.

CHECK_YEAR_1 = DATE(4) MOD 4. " alle 4 Jahre ist schaltjahr

IF CHECK_YEAR_1 EQ 0.

CHECK_YEAR_1 = DATE(4) MOD 100. " aber nicht alle 100 Jahre

CHECK_YEAR_2 = DATE(4) MOD 400. " aber alle 400 Jahre

IF CHECK_YEAR_1 EQ 0

AND CHECK_YEAR_2 NE 0.

IF DATE+6(2) GT '28'.

MESSAGE S004 WITH DATE6(2) DATE4(2)

RAISING PLAUSIBILITY_CHECK_FAILED.

ENDIF.

ELSE.

IF DATE+6(2) GT '29'.

MESSAGE S004 WITH DATE6(2) DATE4(2)

RAISING PLAUSIBILITY_CHECK_FAILED.

ENDIF.

ENDIF.

ELSE.

IF DATE+6(2) GT '28'.

MESSAGE S004 WITH DATE6(2) DATE4(2)

RAISING PLAUSIBILITY_CHECK_FAILED.

ENDIF.

ENDIF.

ENDIF.

reward if helpful

raam

Read only

0 Likes
2,361

Hi

don't Copied and put here . Pl explain in OWN example .that Should be very simple and useful..

Step by step

1.....Define FM module

Interface (exporting and importing ) .....exception (if any)

declaration( local )

.............

In Report I want to Pass parameter

Enter Date : 23032007 : Output Value : Vaild Date

Enter Date:99992111 Output Value : invaild Date

Enter Date: aaaadddd OutPut Value: invaild Format

Read only

Former Member
0 Likes
2,361

Hi,

Use the type for date as SY-DATUM.

after that Use FM :

DATE_CHECK_PLAUSIBILITY

Reward if useful.

Regards,

Abhishek

Read only

Former Member
0 Likes
2,361

Hi,

You can define a constant k_date with value 99999991.

at selection-screen on p_date

If p_date > k_date.

Error message ........................

Endif.

Hope this will help

Reward points

Regards

Shibin

Read only

0 Likes
2,361

Hi

Make it Clear on this ..

Read only

0 Likes
2,361

Hi,

As i said early,if you define date field(P_Date) of type numeric,it will not accept characters.If you want to stop the program from further processing when date is invalid,then give error message at selection-screen on p_date event.if you want to display it on the screen,then use write statement in the start-of-selection event.

Reward points if helpful

Regards

Shibin

Read only

Former Member
0 Likes
2,361

Hi ,

You have to declare the type of date as Sy-datum.After that no need to use any FM

Read only

Former Member
0 Likes
2,361

This message was moderated.