cancel
Showing results for 
Search instead for 
Did you mean: 

how to do the feild validations in web dynpro abap

Former Member
0 Kudos

dear all,

how to do the feild validations for the screen in web dynpro abap.

thanks,

jyothi.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi jyothi,

There are diffrent ways of doing validations for fields of screen in webdynpro abap depending on the requirements.

I am giving simplest way of doing this validation(it may fullfil your requirement also)

For e.g you want that without entering value in particular field user should not proceed to submit the data in screen.

DATA lo_message_manager TYPE REF TO if_wd_message_manager.

DATA lo_api_controller TYPE REF TO if_wd_controller.

lo_api_controller ?= wd_this->wd_get_api( ).

lo_message_manager = lo_api_controller->get_message_manager( ).

DATA var1 type string.

DATA: node TYPE REF TO if_wd_context_node.

node = wd_context->get_child_node( 'DATA' ).

node->get_attribute( EXPORTING name = ' VALUE'

IMPORTING value = var1 ).

IF var1 IS INITIAL.

CALL METHOD lo_message_manager->report_error_message

EXPORTING

message_text = 'Please enter the value'.

EXIT.

ENDIF.

Now in above code VALUE is the attribute with whome your input field is bound .So if user doesnt enter any value into it he will get above msg (u have to use message are ui element to use this method)

If you have any other doubt feel free to ask.

regards

Panky

Former Member
0 Kudos

hi Panky

thnks for u r help.can u please give the another example for exception handling in web dynpro.

thanks,

jyothi

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi jyothi,

As for as exception handling is concerned it has no unique relation ship with webdynpro concept i.e its common for whole abap programming .

Now if you want to implement exception handling in your method then defenetaly you have to use TRY and CATCH block.

Just refer the following pdf its simple and will teach you how to implememt exception handling in webdynpro(or in whole abap)

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f86c9290-0201-0010-7a93-dda3716d....

regards

panky

Former Member
0 Kudos

WE CAN DO IN 2 WAYS

1.raise error message using method of message manager class.

2.Using Message Area UI element

Please check below examples.

WDR_TEST_INPUT

WDR_MESSAGE_AREA

also check this link

http://help.sap.com/SAPHELP_NW04S/helpdata/EN/45/19bf8c16f25d7ae10000000a11466f/frameset.htm

Thanks

Suman

abhimanyu_lagishetti7
Active Contributor
0 Kudos

for mandatory fields validation

use CHECK_MANDATORY_ATTRIBUTES method of CL_WD_DYNAMIC_TOOL.

for actual value validation code in WDDOBEFOREACTION

read the context and write your logic to validate it

if fails use code wizard to call the message manager methods

Abhi