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

DATE VALIDATION

Former Member
0 Likes
692

I am entering the date into my transparent table through /nsm30 transaction.when i do the following in my report and debug the if condition is not implemented couz the formats of date are different in s_Date and sy-datum.s_date is a selection option with type DATS.

AT SELECTION-SCREEN ON S_DATE.

loop at screen.

if s_date < sy-datum.

message i001(z77_message).

endif.

endloop.

And also how can we subtract dates for validation?does subtraction of 2 dates give us duration in months ?

THANKS

6 REPLIES 6
Read only

Former Member
0 Likes
663

substraction of 2 dates gives you difference in DAYS

Read only

Former Member
0 Likes
663

Hi,

You're not getting a match in your logic because S_DATE is the whole line of the select-option (ie the from, to, option and sign). You need to use either S_DATE-HIGH or S_DATE-LOW, depending on your exact requirement.

Also, subtracting one date from another gives the difference in days. There are function modules to find the difference in months. Search the forum, they are mentioned frequently.

Regards,

Nick

Read only

0 Likes
663

sorry i for got 2 mention that s_Date has been declared with no extension and no intervals.

Read only

0 Likes
663

change your code as

AT SELECTION-SCREEN ON S_DATE.

if s_date-low < sy-datum.

message i001(z77_message).

endif.

Regards,

Atish

Read only

0 Likes
663

Ok, then LOOP at S_DATE comparing S_DATE-LOW to SY-DATUM.

Regards,

Nick

Read only

0 Likes
663

Write as :

Even if the select option is declared with no extension and no intervals.

U'll have s_date-low ...

AT SELECTION-SCREEN ON S_DATE.

loop at screen.

if s_date-low < sy-datum.

message i001(z77_message).

endif.

endloop.