cancel
Showing results for 
Search instead for 
Did you mean: 

Function module for VALIDATING USERNAME AND PASSWORD?

Former Member
0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

siongchao_ng
Contributor
0 Kudos

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.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Payal,

Try by using, SUSR_CHECK_LOGON_DATA.

You need to provide auth_method (P for password check), userid and password.

Be careful when you execute the function in test mode because it converts the input into upper case hence if you have lower case characters in your password it will return with invalid password. If you pass the lower case into the function in a program everything is fine.

Cheers,

Kris.