cancel
Showing results for 
Search instead for 
Did you mean: 

own custom message if date field is invalid.

Former Member
0 Kudos

Hello All

I am using data filed as one of the column in the table. when date field is worng format or if any character's found, validating by SAP and giving error message like '12/XX//2009' date is invalid. But I like to overwrite the standard message with my own custom message.

Please help me how we can do that?

Thank you, Rama.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

this can be achieved...i just tested this by creating a simple application...this application has two views...on first view i have some input fields....and one btn...this btn when pressed takes me to the next view which shows me all the input values from the first view....

on the first view i have a field which is a date field. what you do is following:

in WDDOBEFOREACTION....write the code to check if the date field has the correct value...what i noticed that when date field has XX in it or any other char in it....the date field variable is initial....this explanation will get to you after you look at my code at below...

here is what i have in my wddobeforeaction code: <----this method runs after every action...in my case when i press my btn to go to next view...

DATA lo_nd_node1 TYPE REF TO if_wd_context_node.

DATA lo_el_node1 TYPE REF TO if_wd_context_element.

DATA ls_node1 TYPE wd_this->element_node1.

DATA lv_date_field TYPE wd_this->element_node1-date_field.

  • navigate from <CONTEXT> to <NODE1> via lead selection

lo_nd_node1 = wd_context->get_child_node( name = wd_this->wdctx_node1 ).

  • get element via lead selection

lo_el_node1 = lo_nd_node1->get_element( ).

clear lv_date_field.

  • get single attribute

lo_el_node1->get_attribute(

EXPORTING

name = `DATE_FIELD`

IMPORTING

value = lv_date_field ).

if lv_date_field is initial. "if lv_date_field has a char this comes out as initial...

  • get message manager

DATA lo_api_controller TYPE REF TO if_wd_controller.

DATA lo_message_manager TYPE REF TO if_wd_message_manager.

lo_api_controller ?= wd_this->wd_get_api( ).

CALL METHOD lo_api_controller->get_message_manager

RECEIVING

message_manager = lo_message_manager

.

  • report message

CALL METHOD lo_message_manager->report_attribute_message

EXPORTING

message_text = 'Pls fill in the correct date'

element = lo_el_node1

attribute_name = `DATE_FIELD`

cancel_navigation = 'X'

.

endif.

hope this helps...you can follow the same approach and get some sort of idea how you can achieve this...i hope that date field is a mandatory field for you....since a user can leave this field empty too...so perhaps you can come with a generic message which can cover both scenario for you....a date with char in it....and an empty date field

Thanks...

AS...

Answers (0)