on 06-28-2007 11:03 AM
Hi,
i have one view Login view. when user logs in, i want to preserve user name between sessions.As we see in chat concept, when somebody logs in, he can see all the previously logged in users.
now, what i wants is to retain that logged in users till he logs off.and everone who logged on different system also be able to see that same set of users.
Please help.
Points will bw awarded.
I dont know if this is possible in web dynpro, but I can give you a work around.
Store the list of users logged in in a table. Every time a new user logs in, update the table. When a user logs off, delete the row so that the table does not grow. When a new user logs in, select from the table and bind to your context. Refresh the context with a bind_table.
Regards,
Nithya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
If you dont like the idea of creating a table you could use ABAP shared memory area and achieve the same .I have implemented the same functionality for one of our clients , where the client wants to see the previous 5 users logged in with the logged in time.
Points to be taken care.
1.How to show the list of users ? a table ? a pop up? a modal pop window with a table? Its your call.
2.Please do the fetching of the users in the WDDOMODIFY so that you could get an updated list of users whenever you change something in your UI.
3.As Sascha suggested , please paste the logout code in your DOEXIT method.
Thanks
ANZY
i think the following link will help http://help.sap.com/saphelp_nw2004s/helpdata/en/c5/85634e53d422409f0975aa9a551297/content.htm
Hi Amarr,
ZTABLE is the best approach if your customer agrees with that ...but sometimes people dont prefer creating extra tables..so the only alternative is shared memory in the apllication server.The shared memory is created with the unique id of your choice and you could get these details back when you want it using the unique id.
if you need more clarifications ...you can post....
Thanks
Anzy
Hi.
I am not sure with that. I always thought that the shared memory is also user session based. Otherwise user would overwrite other users shared memory when using reports or else at the same time where sames memory id is used??!!
I would go for ztable.
Cheers,
Sascha
Message was edited by:
Sascha Dingeldey
I just found this on the help site:
Shared Memory
The shared memory is a memory area on an application server, which is accessed <b>by all of this servers ABAP programs</b>. Before shared objects were implemented, ABAP programs could access this memory area using the EXPORTand IMPORT statements exclusively with the SHARED BUFFER or SHARED MEMORY additions, and instances of classes or anonymous data objects existed <b>exclusively in the internal session of an ABAP program</b>.
But anyway, use the ztable. It is easy and working.
Cheers,
Sascha
Message was edited by:
Sascha Dingeldey
Message was edited by:
Sascha Dingeldey
Hi Anzy.
I just was to curious and checked this here.
Two different user do not have the same shared memory. While I was exporting something to shared memory with one user and set a breakpoint afterwards the other user did not receive any data with the same memory ID afterwards.
So this would not work anyway, would it?
Cheers,
Sascha
Hi Saschaaa,
Even i had the same opiniion before...but somehow in my program it was allowing the other user to fetch the data..
btw the following SDN wiki clearly explians its working
Introduction
In this blog I want to tell you the way using which we can store the values in an internal table in the shared memory area and to access the data which is available in the internal table in the shared memory instance.
Shared memory can be used to store the commonly accessible data in a common memory area in the application server so that, <b>more than one user or program can access the data from there.<b> The shared memory area requires a root class which can be created using the class builder and making the class shared memory enabled. This root class name has to be given as the root class at the time of creation of the shared memory area using the transaction SHMA. The instances of the shared memory areas can be monitored using the transaction SHMM.
The shared memory area makes use of the object oriented concept and every new shared memory area created will automatically creates an inherited class from the abstract class CL_SHM_AREA.
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/profile/2007/05/04/storingandaccessingtheinternaltablevaluesinSharedMemoryArea.&
Yes, i have used table to display all the users and link to action has its cell editor.
and bind link to action UI Element text property to username in view context.
lead selection of that node has also been set.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When the first user logs in, there will be no previous entries and uname will be empty only. So when the first user logs in, you have to first insert the entry into the table and then fire the query. Infact, when each user logs in, insert and then select. Only then the latest logged in user name will also be fetched.
I hope this solves your problem.
Regards
Nithya
Hi
First , refine your logic and insert the data into the ztables.When a user logs into the system , it first query evryone's list and then insert teh current user into the table.Your table should have a provision to record the time the user logged in also.So tha you could refine your select query and show the details of users loggedin the past 5 hours or something like that.
thanks
Anzy
insert query is right, because values get add into ztable.
after selection, values also comes in internal table.
m_user = wd_context->get_child_node( 'NODE_USER_LOGIN' ).
m_user->get_static_attributes( IMPORTING static_attributes = stru_users ).
c_user = wd_context->get_child_node( 'NODE_USER' ).
WA-USERID = STRU_USERS-ID.
WA-USERNAME = STRU_USERS-NAME.
SELECT * FROM ZUSER_INFO INTO TABLE ITAB
WHERE USERNAME = WA-USERNAME.
IF SY-SUBRC NE 0.
APPEND WA TO ITAB.
INSERT INTO ZUSER_INFO VALUES WA.
ENDIF.
CLEAR ITAB[].
c_user = wd_context->get_child_node( 'NODE_USER' ).
ZCL_WD_CHAT=>get_users( importing it = itab ).
C_USER->BIND_ELEMENTS( itab ).
USER_COUNT = C_USER->GET_ELEMENT_COUNT( ).
in this code: it checks for if the user already logged in, if not, then get added into ztable, otherwise selection is done in class-method and in the end, user_count also shows the total count in ztable.
but usernames didn't get displayed in table.
Hi Amandeep,
If the code given is complete, then where are you doing the binding of the logged in username to the context? When the user logs in, after validating the details, you have to first do context binding to NODE_USER_LOGIN. Only after that stru_users will return a valid work area on doing get static attributes. Only then your query will also fetch data.
Regards
Nithya
Message was edited by:
Nithya S
first when the users logged in, then username get stored in view context. then through context mapping, i have passed that values to controller context. then in the code values get inserted into ztable, after that i am fetching the values from ztable into internal table and bind that internal table to node c_user.
then through this stmt ,values get binded to controller context. again mapping is done to map controller context to view context.
after that, i have binded that view context to link to action in layout.
this is all about what i have done.
in class method:
i have written :
select * from zuser_info into table it.
Firstly a couple of suggestions.
I assume that in the code of get_users, you will be fetching the users from the table firing a select query. Why would you want to use the select query twice? Instead, you can do the insert first. And then with one select statement get the list of users.
Also, I am not sure if the logged in time is a field in your table. If you include it as a field, you can handle the case where the same username is logged in from multiple systems. So if your insert query fails, fire an update query for the logged in time alone. And the latest logged in time will get updated for the same user.
Now coming to your problem,
Does m_user->get_static_attributes( ) return you a non empty work area? Please clarify me on that for further insight into your problem.
Regards,
Nithya
@ Anzy,
If you see the current code, after the insert, a select * is done. Which anyway would return all the rows including the current user. So I jus suggested to do away with one query.
@ Amandeep,
When you say "uname" is empty on debugging, which uname is empty? Is it stry_users-name thats empty? Or is your table it in method get_uses having a list of user ids without names? The code looks fine actually.
Regards
Nithya
Hi All,
As u all said i m using Ztable to store users who logs in,
i have fetched all the logged in users in component controller node of cardinality 0-n. and then, i have mapped that node to view context node of cardinality 0-n. After that,in the view layout, i have binded that link to action text property to user name in view context.
But, now problem i m facing is no values get displayed in that link to action at run time.but the values exists in controller context and view context as well.that i have checked through get_element_count().
Please help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ...
Do you use a table for all users or just one link to action element?
To see all users you should use a table and then as cell editor
link to action.
Using just one linktoaction makes not that much sense when you have multiple
elements in the node. However I would guess lead selection has not been set on the node.
Cheers,
Sascha
if i use an internal table, how can i retain user name between sessions, because everytime when new user logs in, internal table get flushed.
so, are you talking about ztable?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi.
Why don't you just create a table where you store an user when he/she logs in, for example in wddoinit of your main component.
In wddoexit you can delete the user from this table.
So all session have access to all logged in users.
The current user can be accesed from sy-uname.
Cheers,
Sascha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.