Sunteți pe pagina 1din 11

Step 1: goto se11, enter table name usr01. In contents check for bname=sapuser, what is bcode?

for example in my ides, bname = sapuser , bcode = 805557B9D4E7A994(encrypted password for india123). Step 2: goto se80, create webdynpro component, Goto component controller and create a node LOGON, dictionary structure = usr02 and add attributes from this structure BNAME and BCODE.

Step 3 : Create 2 views say login_view and Second_view.

Step 4: Create an Application and Run. Code:


1. Login Application.
method ONACTIONGO . data: Node_logon type ref to If_Wd_Context_Node, Elem_logon type ref to If_Wd_Context_Element, Stru_logon type If_LOGIN_VIEW=>Element_logon , Item_id TYPE usr02-bname, item_pwd TYPE usr02-bcode. * Check user input wd_this->check_input( ).

* wd_this->fire_from_input_view_plg( ). IF ITEM_ID NE ' ' AND ITEM_PWD NE ' '. wd_This->Fire_Go_Plg( ). ENDIF. endmethod.

For OnEnter of password


method ONACTIONGO1 . data: Node_logon type ref to If_Wd_Context_Node, Elem_logon type ref to If_Wd_Context_Element, Stru_logon type If_LOGIN_VIEW=>Element_logon , Item_id TYPE usr02-bname, item_pwd TYPE usr02-bcode.

* Check user input wd_this->check_input( ).

* wd_this->fire_from_input_view_plg( ). IF ITEM_ID NE ' ' AND ITEM_PWD NE ' '. wd_This->Fire_Go_Plg( ). ENDIF. endmethod. method CHECK_INPUT . data: Node_logon Elem_logon Stru_logon Item_id item_pwd type ref to If_Wd_Context_Node, type ref to If_Wd_Context_Element, type If_LOGIN_VIEW=>Element_logon , TYPE usr02-bname, TYPE usr02-bcode.

* ** navigate from <CONTEXT> to <logon> via lead selection Node_logon = wd_Context->get_Child_Node( Name = `LOGON` ). * ** get element via lead selection Elem_logon = Node_LOGON->get_Element( ). * * ** get single attribute Elem_logon->get_Attribute( exporting Name = `BNAME` importing Value = Item_id ). * get single attribute Elem_logon->get_Attribute( exporting Name = `BCODE` importing Value = Item_PWD ). * 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( ). if Item_id NE 'SAPUSER' OR ITEM_PWD NE '805557B9D4E7A994' ." OR ( ITEM_ID = ' ' AND ITEM_PWD = ' ' ). *IF ITEM_ID NE ' ' AND ITEM_PWD NE ' '. 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 = 'Enter the Valid User Name and Password. If you do not have authorization contact system Administrator.'. ELSE. wd_This->Fire_Go_Plg( ). endif. endmethod.

Second View Logoff Button

method ONACTIONBACK . data: Node_logon type ref to If_Wd_Context_Node, Elem_logon type ref to If_Wd_Context_Element, Stru_logon type If_second_VIEW=>Element_logon , Item_id TYPE usr02-bname, item_pwd TYPE usr02-bcode. ** navigate from <CONTEXT> to <logon> via lead selection Node_logon = wd_Context->get_Child_Node( Name = `LOGON` ). * ** get element via lead selection Elem_logon = Node_LOGON->get_Element( ). * Elem_logon->get_Attribute( exporting Name = `BNAME` importing Value = Item_id ). CLEAR ITEM_ID. ELEM_LOGON->SET_ATTRIBUTE( EXPORTING NAME = 'BNAME' VALUE = ITEM_ID ). * get single attribute Elem_logon->get_Attribute( exporting Name = `BCODE` importing Value = Item_PWD ). CLEAR ITEM_PWD. ELEM_LOGON->SET_ATTRIBUTE( EXPORTING NAME = 'BCODE' VALUE = ITEM_PWD ). wd_This->Fire_Back_Plg( ).

endmethod.

Output:

When you click on logoff, it navigates to the first view clearing the user name and password.

And validations for the empty username and wrong password,

S-ar putea să vă placă și