Skip to Content
-5

how to validate future date ?

I need a validation for, example if user enter a future date that should be catched in error table.? Below is my code.

SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; } .L0S32 { color: #3399FF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; }

SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }

PARAMETERS : P_DATE LIKE SY-DATUM.
data: lv_date type sy-datum.

lv_date = p_date + 1.
if p_date > lv_date.
MESSAGE 'you entered a future date' type 'E'.
else.
MESSAGE 'you entered acorrect date' type 'I'.
ENDIF.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Jul 01, 2019 at 06:57 PM

    As Raymond Giuseppi mentioned, the problem is quite obvious: it's adding 1 to a variable and the comparing the result with the original variable. When Y = X + 1 then the condition IF Y > X will always be true. This code does not validate whether the date is in future, it's really just meaningless.

    To determine if the date is in future you need to establish first what exactly is the definition of "future". What time zone and what date do you want to use as a base for comparison? When the criteria is clear then you can simply compare two date fields.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.