Skip to Content
author's profile photo Former Member
Former Member

DATE VALIDATION

1) My requirment is to validate

current date of system(sy-datum) and past date in selection screen.

If difference between these

two dates more than six months than one error must display.

for example assume

current date = 02/21/2008 &

past date =

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Apr 11, 2008 at 08:48 AM

    Hi,

    Use the below code.

    parameters: p_date type sy-datum.

    data: v_date type sy-datum.

    CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

    EXPORTING

    DATE = sy-datum

    DAYS = 0

    MONTHS = '06'

    SIGNUM = '-'

    YEARS = 0

    IMPORTING

    CALC_DATE = v_date.

    if p_date lt v_date.

    write:/ 'Invalid date'.

    else.

    write:/ 'Valid date'.

    endif.

    Add a comment
    10|10000 characters needed characters exceeded

    • THIS IS VIGNESh CODE...BUT FOR VALIDATION PURPOSES U NEED TO use at selection-screen .

      Use the below code.

      
      select-options: p_date type sy-datum.
      *at selection-screen .*
      data: v_date type sy-datum.
      
      CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
      EXPORTING
      DATE = sy-datum
      DAYS = 0
      MONTHS = '06'
      SIGNUM = '-'
      YEARS = 0
      IMPORTING
      CALC_DATE = v_date.
      
      if p_date lt v_date.
      write:/ 'Invalid date'.
      else.
      write:/ 'Valid date'.
      endif.

      Edited by: saslove sap on Apr 11, 2008 10:52 AM

  • author's profile photo Former Member
    Former Member
    Posted on Apr 11, 2008 at 08:43 AM

    Hi,

    You can make use of Function module 'HR_AUPBS_MONTH_DAY' to get the number of months b/w the current date and the end date.

    <REMOVED BY MODERATOR>

    Thanks,

    Asha

    Edited by: Alvaro Tejada Galindo on Apr 11, 2008 5:34 PM

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      try this:

      PARAMETERS: P_DATE LIKE SY-DATUM.

      *

      DATA CH_DATE LIKE SY-DATUM.

      *

      CALL FUNCTION 'CALCULATE_DATE'

      EXPORTING

      MONTHS = '-6'

      START_DATE = SY-DATUM

      IMPORTING

      RESULT_DATE = CH_DATE.

      *

      IF P_DATE < CH_DATE.

      WRITE: 'ERROR', P_DATE.

      ELSE.

      WRITE: 'OK', P_DATE.

      ENDIF.

      Regards, Dieter

  • Posted on Apr 11, 2008 at 08:36 AM

    sy-datum is always valid

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 11, 2008 at 09:13 AM

    HI,

    Use the FM:

    MONTH_PLUS_DETERMINE – add or subtract month from a date

    Hope this helps.

    <REMOVED BY MODERATOR>

    Regards,

    Sipra

    Edited by: Alvaro Tejada Galindo on Apr 11, 2008 5:35 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 11, 2008 at 09:22 AM

    Hi,

    Now, in your case the current date = 02/21/2008 ( mm/dd/yyyy)

    and Past date = 08/19/2007.

    1. Use the FM ' HR_AUPBS_MONTH_DAY' to get the number of months b/w these two dates.

    2. You will get the no. of months in the parameter NO_MONTH.

    3. Take it into a variable V_MONTH and then check if V_MONTH GE '6'.

    4. If so, give the error message otherwise sucessfully carry out the your rest processing.

    Please reward points if useful.

    If you have any query revert back to me.

    thanks,

    Asha

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 11, 2008 at 10:11 AM

    Hi,

    Please refer the code below :

    tables : bsis.
    
    data : month like VTBBEWE-ATAGE.
    
    parameters : sp_date like sy-datum.
    
    
    at selection-screen.
    
    CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
      EXPORTING
        i_date_from          = sp_date
    *   I_KEY_DAY_FROM       = I_KEY_DAY_FROM
        i_date_to            = sy-datum
    *   I_KEY_DAY_TO         = I_KEY_DAY_TO
    *   I_FLG_SEPARATE       = ' '
     IMPORTING
    *   E_DAYS               = E_DAYS
       E_MONTHS             = month
    *   E_YEARS              = E_YEARS
              .
    
    if month GT '6'.
    message 'Invalid date' type 'E'.
    endif.
    

    OR

    Try using FM MONTHS_BETWEEN_TWO_DATES.

    Thanks,

    Sriram Ponna.

    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.