Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Function module for VALIDATING USERNAME AND PASSWORD?

Hello,

I have a requirement wherein for the first screen I have to design two input fields for USERNAME & PASSWORD.

Once the user has entered these two fields, I need to validate both.* Is there any function module which has this

fuctionality to validate both the username and password?*

And is it possible to call this FM in webdynpro?

Former Member
Former Member replied

Hi,

You can write your own validation username and password codes:

DATA lr_current_controller TYPE REF TO if_wd_controller.

DATA lr_message_manager TYPE REF TO if_wd_message_manager.

DATA lo_nd_name TYPE REF TO if_wd_context_node.

DATA lo_el_name TYPE REF TO if_wd_context_element.

DATA ls_name TYPE wd_this->Element_name.

DATA lv_message TYPE string.

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

lo_nd_name = wd_context->get_child_node( name = wd_this->wdctx_node_name ).

  • get element via lead selection

lo_el_name = lo_nd_name->get_element( ).

  • get all declared attributes

lo_el_name->get_static_attributes(

IMPORTING

static_attributes = ls_node_name ).

IF ls_node_name-password <> 'YOUR_PASSWORD_NAME'.

lv_message = 'Wrong password'.

lr_current_controller ?= wd_this->wd_get_api( ).

lr_message_manager = lr_current_controller->get_message_manager( ).

lr_message_manager->report_error_message(

EXPORTING

message_text = lv_message

show_as_popup = abap_false ).

clear lv_message.

ENDIF.

IF ls_node_name-username <> 'YOUR_USERNAME'.

lv_message = 'Wrong username'.

lr_current_controller ?= wd_this->wd_get_api( ).

lr_message_manager = lr_current_controller->get_message_manager( ).

lr_message_manager->report_error_message(

EXPORTING

message_text = lv_message

show_as_popup = abap_false ).

clear lv_message.

ENDIF.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question