cancel
Showing results for 
Search instead for 
Did you mean: 

Input field Validation???

Former Member
0 Kudos

Hi Experts,

I would like to know how to do Input field validation in WD4A.

I'm having a field in my iView which should accept only number and if user enters other than number it should validate and give message to end-user.

How to do it???

Responses are appreciated and rewarded.

Thanks,

Suba

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Suba,

First the read the attribute[User entered input]. Then using CO statement for validation.

Check this code.

Consider input is the attribute name and it contains user entered input. Then,

If Input CO '0123456789'.

"write tour coding.

else.

* get message manager
DATA: l_current_controller TYPE REF TO if_wd_controller,
      l_message_manager    TYPE REF TO if_wd_message_manager.

l_current_controller ?= wd_this->wd_get_api( ).

CALL METHOD l_current_controller->get_message_manager
  RECEIVING
    message_manager = l_message_manager
    .

* report message
CALL METHOD l_message_manager->report_error_message
  EXPORTING
    message_text             = 'Please Enter Numeric value'.
endif.

Thanks.

Former Member
0 Kudos

Viji,

ur response helped me a lot.

I do have another couple of question.

1.Can we display the error message at the bottom of the page. By default error message is displayed at the top.

2.Can u help me in giving code sample for report_attribute_error_message

Looking forward to reward u.

Thanks,

Suba

Former Member
0 Kudos

Hi Suba,

Yes defaultly all messages will displays at the top of the page. If you want to put the message at the bottom means you can use the UI element "Message area".

You can put the message area where ever you want. Then write the code for generating message.

Then it will display at where you fixed your message area.

Check the below code for report_attribute_error_message.

Write this code under your condition.

Before write this code ensure that the Context node should contains the data. Otherwise it will raise the error.

* get message manager
DATA: l_current_controller TYPE REF TO if_wd_controller,
      l_message_manager    TYPE REF TO if_wd_message_manager.

l_current_controller ?= wd_this->wd_get_api( ).

CALL METHOD l_current_controller->get_message_manager
  RECEIVING
    message_manager = l_message_manager
    .

* report message
CALL METHOD l_message_manager->report_attribute_error_message
  EXPORTING
    message_text        = 'error'
    element             = elem_node1
    attribute_name      = 'CARD_NO'.

Thanks.

Any issues let me know.

Former Member
0 Kudos

Viji,

Thanks a lot for ur valuable response.

I trying to play around message area.

if u have working on displaying messages at the bottom, can u send some sample code.

u can also reach me subafriends@yahoo.com

Once again thanks so much.

Thanks,

Suba

Former Member
0 Kudos

Hi,

for displaying the error message, first simply insert an UI element called MessageArea at the bottom.

code:

if <<check ur input field here(condition)>>.

"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->RAISE_ERROR_MESSAGE

EXPORTING

MESSAGE_TEXT = '<ERROR TEXT GOES HERE>'.

  • PARAMS =

  • MSG_USER_DATA = .

endif.

Former Member
0 Kudos

Hi Suba,

For Message area UI element there is no need for any code.

Just place the message area at the bottom of the page and then write the code for message.

When ever message is present at your view it will be displayed at the message area.

For more information about message area you can refer the standard application WDR_TEST_EVENTS --> Message area view.

Thanks.

Former Member
0 Kudos

Viji,

Hope u might have worked on File upload.

I have an issue in file upload.

I could able to upload only CSV file alone.

But my requirement is to accept notepad, word, excel type files.

Can u tell me how to resolve and if u have any sample code it will be much useful..

Thanks,

Suba

Former Member
0 Kudos

Hi Suba,

Dont ask many questions in single thread. If you ask this question in separate thread means you will get more responces from our experts.

Ok for File upload check this thread. It may help you.

Thanks.

former_member515618
Active Participant
0 Kudos

Hi Suba,

If the field on the View is defined as an integer (Type I) Or NUMC (Numeric Chars), SAP checks for entries other than Numeric values and throws a messaga ' The Entered Value Can Only Contain Numerical Characters'

Regards,

Sravan Varagani