on 06-27-2009 2:06 AM
Hi,
Can anyone explain how to do data validation for the i/p fields in the WD View???Pleasegive an example with coding.
Thanks!
hi
for any action or event in ur program the flow will be
wddobeforeaction
Action
wddoafteraction
and then other methods....So normally all validations will be written in the method wddobeforeaction
Regards
Sajid
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
As Thomas pointed out in his reply that do the validation at WDDOBEFOREACTION method
say you have a date to validate:
DATA lo_nd_importing TYPE REF TO if_wd_context_node.
DATA lo_el_importing TYPE REF TO if_wd_context_element.
DATA ls_importing TYPE wd_this->element_importing.
DATA lv_startdate LIKE ls_importing-startdate.
navigate from <CONTEXT> to <IMPORTING> via lead selection
lo_nd_importing = wd_context->get_child_node( name = wd_this->wdctx_importing ).
get element via lead selection
lo_el_importing = lo_nd_importing->get_element( ).
get single attribute
lo_el_importing->get_attribute(
EXPORTING
name = `STARTDATE`
IMPORTING
value = lv_startdate ).
if lv_startdate is 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_error_message
EXPORTING
message_text = 'Please input start date'
params =
msg_user_data =
is_permanent = ABAP_FALSE
scope_permanent_msg = CO_MSG_SCOPE_CONTROLLER
view =
show_as_popup =
controller_permanent_msg =
msg_index =
cancel_navigation = 'X' "this parameter will stop the program at the same view
.
endif.
this will stop the user at the same view and will give the error message out.....
you can also check the code wizard and try different type of methods to give out the error messages....the code wizard is right beside the external break point button...
Thanks...
AS.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What kind of data validation do you want? For application specific validation, all the data from input is automatically restored back into the context during each server event. You simply must read the context and perform the logic you want to take place.
Error messages are issued using the Message Manager:
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/d8/2a934259a5cb6ae10000000a155106/frameset.htm
If you want to do other types of validations - say for instance Required Field checks; there are SAP provided APIs to help with that:
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/d7/ef8841e3af1609e10000000a155106/frameset.htm
Second section: Checking Required Entry Fields
Also for validation related logic - study the phase model:
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/d2/8acd409cc4dd50e10000000a1550b0/frameset.htm
In particular the method of the phase model WDDOBEFOREACTION. This is generally where you perform custom validation so that error messages can break the flow of the event.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Say you have an input field,Field1.
Get value entered by the user through,Get_attribute method.
get single attribute
lo_el_nd_<node_name>->get_attribute(
EXPORTING
name = <Attribute_name>
IMPORTING
value = lv_attr ).
Then check the value with ur req.validation, if yes,throw error meaage as
MESSAGE e<err_no>(<package_name>) INTO lv_message.
CALL FUNCTION 'BALW_BAPIRETURN_GET2'
EXPORTING
type = sy-msgty
cl = sy-msgid
number = sy-msgno
par1 = sy-msgv1
par2 = sy-msgv2
par3 = sy-msgv3
par4 = sy-msgv4
IMPORTING
return = ls_return.
Now your ls_retrurn-message will have your message text.
Thanks,
Divya.S
sir even i want to validate the data .
like i have username and password input fields in The view of a webdynpro component .
and i have already a table in my se11 which i created named 'zuserpass'. with fields zusername and zpassword.
i have created a node in view context with the data dictionary 'zuserpass' and added 2 attributes zusername and zpassword .
now if user enters any values in the WD application , then it should check or validate the data from table which i created in the se11 named 'zuserpass' .
and i should display a succesfully logon message .
can u plz try this ?
Hi Praveen,
Why are you manually authenticating user logon data? It would be advisable instead to delegate this task to the ICF and use the logon procedures that are available in transaction SICF. Please refer to Maintaining Logon Procedures - User Authentication and Single Sign-On - SAP Library.
Cheers,
Amy
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.