Skip to Content
avatar image
Former Member

date validation on selm screen

Hi

On selection selection screen user has selection field DATE by default sy-datum. i.e 6.10.2008

Now I should validate it i.e user can enter only last five days i.e .6.10.08 to 2.10.08

If user enters 1.10.08 he should get an error on selection screen .

Have A Pleasant Day.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • avatar image
    Former Member
    Oct 06, 2008 at 02:02 PM

    Hi,

    Try like below

     
     parameters :datum like sy-datum.
     ranges : r_datum for sy-datum.
     at selection-screen on datum.
      r_datum-high = sy-datum.
      r_datum-low = sy-datum - 6.
      r_datum-sign = 'I'.
      r_datum-option = 'BT'.
      append r_datum.
    
      if datum not in r_datum.
    message <<<Insert message here>>>
      endif. 
    

    Regards,

    Himanshu V

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 06, 2008 at 02:02 PM

    refer bellow example.

    REPORT  ztest.
    TABLES: vbak..
    DATA: date_diff TYPE p.
    SELECT-OPTIONS: s_date FOR vbak-audat.
    
    start-of-selection.
    date_diff = s_date-high - s_date-low.
    IF date_diff > 5.
    MESSAGE 'Invalid to date' TYPE 'S'.
    EXIT.
    ENDIF.
    
    write: / 'Hi'.
    

    Thanks

    Ganesh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 06, 2008 at 02:22 PM

    Hi,

    At your coding in

    AT SELECTION-SCREEN.

    event.

    do something like date = sy-datum - 5

    if p_date < date

    message......

    endif.

    Regards

    Stu

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 06, 2008 at 02:46 PM

    hi,

    AT SELECTION-SCREEN.

    IF SY-UCOMM = 'ONLI' OR SY-UCOMM IS INITIAL.

    data : v_date type sy-datum.

    v_date = sy-datum - 5.

    if p_date >= v date and p_date <= sy-datum.

    *success message

    else.

    *error message

    endif.

    ENDIF.

    regards,

    johnson

    Edited by: johnson george on Oct 6, 2008 8:17 PM

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 06, 2008 at 02:56 PM

    Hi...

    Check this simple logic..,

    data: today like sy-datum.
    today = sy-datum.
    
    parameter: date like sy-datum default today.
    
    at selection-screen.
    today = sy-datum - 5.
    
    if date < today.
    
    error message.
    
    elseif date > sy-datum.
    
    error message.
    
    endif.

    Thanks,

    naveen.I

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 08, 2008 at 08:51 AM

    Thank u all

    Add comment
    10|10000 characters needed characters exceeded