cancel
Showing results for 
Search instead for 
Did you mean: 

date validation

Former Member
0 Kudos

Dear all,

I have two date inputs. In both inputs i have to select a date. I want to check that date in second date field is always equal or greater than date value in first field. for eg if i select 20/11/2008 from the first field then i should only be able to select a date value equal to 20/11/2008 or something greater than that. kindly help me how should i validate it.

Regards,

Bharath

Accepted Solutions (1)

Accepted Solutions (1)

uday_gubbala2
Active Contributor
0 Kudos

Hi Bharath,

You need to associate this validation with some event like button click or enter key... Read the values enetred by the user in to the 2 input fields and use 1 of the many FM's available within ABAP to get the difference between 2 dates like:

HR_99S_INTERVAL_BETWEEN_DATES, HR_HK_DIFF_BT_2_DATES, DAYS_BETWEEN_TWO_DATES etc,.. Check the number of days value returned by the FM & raise error messages accordingly.

Regards,

Uday

Answers (3)

Answers (3)

Former Member
0 Kudos

answered

Former Member
0 Kudos

Hi Bharath,

there is a method "WDDOBEFOREACTION" (Method for Validation of User Input).

You can use this method to validate the user input.

Within this method, get the attributes you want to check from the context node and do the validation.

Than use e.g. method REPORT_ATTRIBUTE_ERROR_MESSAGE.

Some sample coding:


         data: l_element type TYPE REF TO if_wd_context_element.
         data: l_attribute type string.
*todo: get l_element 
         (...)

* name of element
          l_attribute = 'NAME_OF_ELEMENT'.

          CALL METHOD lo_message_manager->REPORT_ATTRIBUTE_ERROR_MESSAGE
            EXPORTING
              MESSAGE_TEXT       = 'Test message'
              ELEMENT            = l_element
              ATTRIBUTE_NAME     = l_attribute.

Please have a look at message for handling messages in WDDOBEFOREACTION.

Regards,

Andreas

former_member188831
Contributor
0 Kudos

Hi Bharat,

you can validate it in 2 ways.

1. on enter of date field 2 you can get the field1 value by get_element then you compate it and valdiate it.

2. on save also the same validations you can do.

Regards,

mahesh.gattu