cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting views with the application

Former Member
0 Kudos

Hi,

I am new to web dynpro. I am designing a web dynpro application where I have a log in view, in which the user will enter the username and the password. On submitting the user will be able to log in to the application. I have developed a ztable wherein I have maintained the user name and the passwords. Now I am not able to connect the view , component controller and the ztable. Please guide me as to how should I proceed.

Regards,

Ashutosh

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

hi ashutosh ,

Please guide me as to how should I proceed.

please follow the steps in my first reply to this thread and in the OnActionSubmit method write the piece of code

which I posted in my second reply

You neednot map the view controller and comp controller.

when u create the attributes under node in ur component controller and map it to the views , the attributes created in this way r

global and can be accessed across differnt views. evn if u wish to use it in ur sinle view , thn also its recommended to craete it in component controller

u wud get it

if u r beginner in WD ABAP , follow these links to learn WD ABAP :

http://help.sap.com/saphelp_nw2004s/helpdata/en/03/0048413e466e24e10000000a155106/content.htm

Main Topic Page:

http://sdn.sap.com/irj/sdn/nw-wdabap#section2

Tutorials for Beginners:

[original link is broken]

eLearning Videos:

/people/thomas.jung/blog/2006/06/20/web-dynpro-abap-demonstration-videos

cheers

regards,

amit

Former Member
0 Kudos

hi ashutosh ,

Now I am not able to connect the view , component controller and the ztable.

proceed like this :

1 in the attribute's tab in ur component controller , create a context node

2 in the context node , create two attributes USERNAME , and PASSWORD of type string

3 map the context ( drag n drop the node) from ur component controller to the view , the attributes created shud be reflected in ur view now. attributees created in this way r global and cn be accessed by several views

4 in ur view , go to the layout tab

5 right click on ROOT ELEMENT CONTAINER , insert element

6 maintain the MATRIX DATA for ur ROOTelement container

7 insert the UI s , 2 input fields , and 1 button

8 maintain the layout data as MATRIX HEAD DATA for all the UIs , so that UIs appear in the beginning of ur line.

9 map the VALUE property of ur two input fields , with the context attributes created ie USERNAME and PASSWORD

9 in the Action property of ur Button , write the name of appropriate action , suppose u write SUBMIT

10 a method OnActionSubmit wud be created in the methods tab of ur view

11 in this method , get the values entered by user in the two fields

12 u can use code wizard for the same , press CNTL + F7 , choose the button read context node/attribute

13 thn using the GET_ATTRIBUTE method , u wud get values in ur local variables

14 u can use the value to update ur ztable

15 for ur this view , which u want to fire create a OUTBOUND PLUG

16 create INBOUND PLUG for ur next view , which u want to navigate

17 After this, create a navigation link mapping the outbound plug of your view and the inbound plug of the target window

I hope it wud surely help u

regards,

amit

Chaitanya_Priya
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

1.Create a view with has 2 fields User name(input field) and password(input field)

you can make the input field as password field by checking the property of the input field as passwordfield(flag the check box)

2.As user enters the username and password

Create a button login.

on action of it

lo_el_user_role->get_attribute(

EXPORTING

name = `USER_ID`

IMPORTING

value = lv_userid ).

lo_el_user_role->get_attribute(

EXPORTING

name = `password`

IMPORTING

value = lv_password. )

SELECT * FROM zrm_c_cv_overl INTO CORRESPONDING FIELDS OF TABLE lt_resume_info WHERE userid = lv_userid AND pasword = lv_password...

if sy-subrc = 0.

navigate to next view.

fire the plug which u r using to navigate to next view.

endif.

Plugs:

create an out bound plug for login view.

create an inbound plug for next view u want to navigate.

go to windows of the component and establish the navigation link.

Priya

Former Member
0 Kudos

hi,

Follow these steps:

1. Design your first view with User name and PAssword.

2. Use input fields so that user can enter username and password.

3. After user enters it, get the entered data using get_Attributes method.

4. On the click of button, check whether the values entered by user exist in database table or not.

5. If not, throw an error message.

Former Member
0 Kudos

The steps given by you looks good. Can you please elaborate them a little bit in technical terms. I mean how should I connect view context and the controller context. And also where to write the code. The method that you have suggested , I am not able to find that out.

Regards,

Ashutosh

Chaitanya_Priya
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

You can refer this link for navigation.

[http://files.abapwebdynpro.webnode.com/200000002-c8eb2c9e58/Tutorial%203.pdf]

please let me know if you have any dbts,

Priya

Chaitanya_Priya
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

till where have you designed the application so that i can continue from that.

did u design the view ?

Priya

Former Member
0 Kudos

hi,

And also where to write the code

You got to have one button in your first view.

In the OnAction of button, write the code to get the data entered by user and validate it.

mean how should I connect view context and the controller context.

You neednot map the view controller and comp controller.

Just make the two context attributes in Context Tab of View Controller for UserName and Password.

And you can read them in button onAction using Code Wizard (control + F7 ).

Chaitanya_Priya
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi ,

1Create a node in component controller with name Logindata

Create the attributes userid and password .the attributes should be of the type where u have cretaed the fields in the table where u storing all the usernames and pass words.

2.Go to the view .

go to context tab.

drag and drop the node to the view's context.

3.desiging the lay out.

a..Create a view with has 2 fields User name(input field) and password(input field)

you can make the input field as password field by checking the property of the input field as passwordfield(flag the check box)

b.Create a button login.

.As user enters the username and password

in the events of the buttons

i.e n action of the button

write the below code.

lo_el_user_role->get_attribute(

EXPORTING

name = `USER_ID`

IMPORTING

value = lv_userid ).

lo_el_user_role->get_attribute(

EXPORTING

name = `password`

IMPORTING

value = lv_password. )

SELECT * FROM zrm_c_cv_overl INTO CORRESPONDING FIELDS OF TABLE lt_resume_info WHERE userid = lv_userid AND pasword = lv_password...

if sy-subrc = 0.

navigate to next view.

fire the plug which u r using to navigate to next view.

endif.

And you can refer the link which i mentioned to navigate between the views.

Priya

Former Member
0 Kudos

hi Ashutosh ,

here is the code for ur reference , which u wud write ( or be able to genrate some of it thru code wizrad)

by pressing CONTROL+F7



// *read the context attribute USERNAME and PASSWORD under context node cn_all*
DATA lo_nd_cn_all TYPE REF TO if_wd_context_node.
     DATA lo_el_cn_all TYPE REF TO if_wd_context_element.
     DATA ls_cn_all TYPE wd_this->element_cn_all.
     DATA lv_username  LIKE ls_cn_all-username.
     DATA lv_password   LIKE ls_cn_all-password.
*    navigate from <CONTEXT> to <CN_ALL> via lead selection
     lo_nd_cn_all = wd_context->get_child_node(
     name = wd_this->wdctx_cn_all ).
 
*    get element via lead selection
     lo_el_cn_all = lo_nd_cn_all->get_element(  ).
 
*    get single attribute
     lo_el_cn_all->get_attribute(
       EXPORTING
         name  =  `USERNAME`
         value = lv_username) .
*    get single attribute
     lo_el_cn_all->get_attribute(
       EXPORTING
         name  =  `PASSWORD`
         value = lv_password) .

next is ur ABAP code


DATA : itab type standard table of ztable.

SELECT * FROM ztable INTO CORRESPONDING FIELDS OF TABLE ltab  WHERE 
userid = lv_username  AND pasword = lv_password.

refer this thread for navigating between views :


//fire to ur next view
wd_this->FIRE_PLUG( ) .

do let me know in case of further queries

regards,

amit

Former Member
0 Kudos

Hi ashutosh,

you can get the method get_attribute in yourr own code when you try to read the context node ar attribute using ctrl+f7. there you can see get_attribute method and for navigation relate thin you can get tutorial name as tutorial3 on navigation in wd abap.

hope it helps you

regards,

anand