cancel
Showing results for 
Search instead for 
Did you mean: 

Validation on date of birth

Former Member
0 Kudos

Hi,

  

   i Have a senario for Date Of Birth validation..

      In Webui  when ever Click on SAVE Button i need to rise a error message on Date of Birth

    Condition : Date of Birth is in between "Current date"  and below "18years to current date" rise a error msg.

Please Help me How to do this.

    

Regards

Nagendra

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

clear lv_string1.
DATA: lv_date TYPE sy-datum.

*
lv_string1 = lr_node->get_property_as_string( iv_attr_name = 'BIRTHDATE').

if lv_string1 is not INITIAL.
CALL FUNCTION 'CONVERT_DATE_INPUT'
EXPORTING
INPUT                           lv_string1
PLAUSIBILITY_CHECK              = 'X'
IMPORTING
OUTPUT                          = lv_date
EXCEPTIONS
PLAUSIBILITY_CHECK_FAILED       = 1
WRONG_FORMAT_IN_INPUT           = 2
OTHERS                          = 3
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
EXPORTING
I_DATE_FROM          lv_date
I_KEY_DAY_FROM       = '00'
I_DATE_TO            = sy-datum
I_KEY_DAY_TO         = '00'
IMPORTING
E_DAYS               = days.
*         E_MONTHS             =
*         E_YEARS              =

IF days LE 6570.

lr_msg_srv = me->view_manager->get_message_service( ).
IF lr_msg_srv IS BOUND.
lr_msg_srv->add_message( iv_msg_type   'E'
iv_msg_id     = '/RCRM/D_MSG'
  iv_msg_number = '031' ).
EXIT.
ENDIF.
ENDIF.
ENDIF.

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks Arden

  Any Other Approch for doing this without  BADI

navn_metts
Active Participant
0 Kudos

Hello,

yes you can do this in the event handler of the button. Mostly the save button will have event handler name as "EH_ONSAVE" of the _IMPL class.

second approach is use "order_save" badi method "check_before_save" method, use raise do_not_save if you dont want to save the transaction

Br,

Navn

Former Member
0 Kudos

Hi Naveen,

   i written code in "eh_onSave" in overview page impl classs

   Can u pls provide the code for this Condition.

Regards

Nagendra.

navn_metts
Active Participant
0 Kudos

Hello,

This is simple..

Say you were born on 22nd Feb 1983 and today is 26th April 2015.

You can get the number of days = Today date - Birth Date.

Now you can divide number of days by 365 .. to get the year and months !!

Br,

Navn

navn_metts
Active Participant
0 Kudos

Hello,

I cant give you the exact code. but you can use your logic like below.

     lv_dob = '19880217'.
     lv_date = sy-datum - lv_dob.
     lv_age = lv_date / 365.


*lv_age will hold the age.


if lv_age LT 18.


*raise the error message


else.

*

endif.

Br,

Navn

Former Member
0 Kudos

thanks for replying me.

i got a solution for this.

if lv_string1 is not INITIAL.
CALL FUNCTION 'CONVERT_DATE_INPUT'
EXPORTING
INPUT                           lv_string1
PLAUSIBILITY_CHECK              = 'X'
IMPORTING
OUTPUT                          = lv_date
EXCEPTIONS
PLAUSIBILITY_CHECK_FAILED       = 1
WRONG_FORMAT_IN_INPUT           = 2
OTHERS                          = 3
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
EXPORTING
I_DATE_FROM          lv_date
I_KEY_DAY_FROM       = '00'
I_DATE_TO            = sy-datum
I_KEY_DAY_TO         = '00'
IMPORTING
E_DAYS               = days.
*         E_MONTHS             =
*         E_YEARS              =

IF days LE 6570.

lr_msg_srv = me->view_manager->get_message_service( ).
IF lr_msg_srv IS BOUND.
lr_msg_srv->add_message( iv_msg_type   'E'
iv_msg_id     = '/RCRM/D_MSG'
  iv_msg_number = '031' ).
EXIT.
ENDIF.
ENDIF.
ENDIF.

Former Member
0 Kudos

Hi Nagendra

There is a PARTNER_UPDATE BADI which can be used for this purpose.

Regards

Arden