‎2008 Mar 04 2:00 PM
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
‎2008 Mar 04 2:02 PM
‎2008 Mar 04 2:04 PM
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
‎2008 Mar 04 2:06 PM
sorry i for got 2 mention that s_Date has been declared with no extension and no intervals.
‎2008 Mar 04 2:10 PM
change your code as
AT SELECTION-SCREEN ON S_DATE.
if s_date-low < sy-datum.
message i001(z77_message).
endif.
Regards,
Atish
‎2008 Mar 04 2:15 PM
Ok, then LOOP at S_DATE comparing S_DATE-LOW to SY-DATUM.
Regards,
Nick
‎2008 Mar 04 2:16 PM
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.