cancel
Showing results for 
Search instead for 
Did you mean: 

preserve the value between sessions

0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

mohammed_anzys
Contributor
0 Kudos

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

0 Kudos

Hi Anzy,

can u provide me some code of that so that i could have some idea,Or

can u please elaborate on this thing, hoe we can achieve this functionality.

Former Member
0 Kudos

Hi.

What solutions do you want to try?

ztable

or shared memory?

Cheers,

Sascha

mohammed_anzys
Contributor
0 Kudos

I am more comfortable using ztable. but, i also want to know that how to achieve this functinality using shared memory as it is new for me.

Former Member
0 Kudos

@ Anzy,

Just a clarification. When we do export and import, will the data be available across user sessions?

Regards,

Nithya

mohammed_anzys
Contributor
0 Kudos

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

mohammed_anzys
Contributor
0 Kudos

@ nitya , the import and export in the FMs? .....

@ Saschaaaa..calling help for nitya's question

Former Member
0 Kudos

Not import and export in FMs.. Export to memory ID and import from memory ID.. Are they user-independent?

mohammed_anzys
Contributor
0 Kudos

they are not user session based

mohammed_anzys
Contributor
0 Kudos

Hi

They are not user session based.

Thanks

Anzy

Former Member
0 Kudos

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

mohammed_anzys
Contributor
0 Kudos

Hi,

I have checked it in one of my projects , the data is user independent and finally we had to create ztable to achieve user dependency

Thanks

Anzy

Former Member
0 Kudos

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 server’s 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

Former Member
0 Kudos

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

mohammed_anzys
Contributor
0 Kudos

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.&

Former Member
0 Kudos

Hi Anzy.

So this is for shared memory areas only and not for shared memory itself?

Getting confused here

Cheers,

Sascha

mohammed_anzys
Contributor
0 Kudos

Hi

i used , shared memory area.

Thanks

Anzy

Former Member
0 Kudos

Hey don't get me wrong ... I think this is a very coll possibilty to store singleton classes in shared memory area where evrybody has access to ...

Thinking about it I would prefer this instead of building a ztable ...

You live and learn ...

mohammed_anzys
Contributor
0 Kudos

hey come on saschaaaaaa...it was a very fruitful discussion..and most of the times you provide us with good solutions. which helps us to resolve our problems ....and i do agree with the ZTABLE ..and my preference is also for that , because the implementation will be simple..

/Anzy

Former Member
0 Kudos

hey hey .. seems to be a misunderstanding .. I did not feel defensive ...

everything is fine ...

except for .... most of the times ??? hehehe

have a nice day ...

Cheers,

Sascha

Former Member
0 Kudos

by the way amandeep is your problem solved now ??

Former Member
0 Kudos

I have also thought that exporting and importing to memory IDs is based on user sessions. But set and get parameter are globally available I think.

Amandeep, ztable would be the simplest approach. Go ahead with it.

Regards,

Nithya

Answers (4)

Answers (4)

0 Kudos

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.

Former Member
0 Kudos

Then I would say, that uname is empty for each element in your node.

Did you check it with the debugger? You just used get_element_count( ) but this only tells you the count of elements, not that uname is set for each element.

Just check how you fill the node.

Cheers,

Sascha

mohammed_anzys
Contributor
0 Kudos

Yeah , as sascha said , the uname would be empty.

0 Kudos

using select query, i have fetched the data from ztable into internal table.and binded that internal table using bind_elements( itab ).

i have checked in debugger that uname is empty. how to solve it?

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi.

Seems that you do not only want to see the current user but also other online users. If all uname entries are empty in your itab just check the insert qurry for correctness.

Cheers,

Sascha

mohammed_anzys
Contributor
0 Kudos

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

0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

pls post code of get_users.

0 Kudos

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.

Former Member
0 Kudos

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

0 Kudos

No, m_user->get_static_attribute( ) returns current user logged in.

mohammed_anzys
Contributor
0 Kudos

@ nitya , if you insert the current user first , whenever a user logs in , it will show his name also first ..Actually it should only show the users who are logged in before the current users login..

Former Member
0 Kudos

hmmmm

is the structure of itab zuser_info? is structure of C_USER like zuser_info?

Former Member
0 Kudos

@ 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

Former Member
0 Kudos

What happened finally? Did you get this working?

Regards

Nithya

mohammed_anzys
Contributor
0 Kudos

Seems like its working for him

Former Member
0 Kudos

This seems to be the longest thread, so he could at least tell us if it is working

mohammed_anzys
Contributor
0 Kudos

Heh heh ..true sascha...we had long discussions.......

Former Member
0 Kudos

LOL yeah! Amandeep, if your problem is solved, do let us know how you got it working. And please close the thread!

mohammed_anzys
Contributor
0 Kudos

else....sascha ,nithya and I will spam this thread....

right sascha....??

Former Member
0 Kudos

YUP .. until the moderator kicks our A..S

0 Kudos

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.

mohammed_anzys
Contributor
0 Kudos

Hi

Amardeep ,i guess the problem is with how you bind the value to the UI element.can you just tell me how you are displaying teh values in teh view?

Inside a table or something?

Thanks

Anzy

Former Member
0 Kudos

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

0 Kudos

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?

mohammed_anzys
Contributor
0 Kudos

Yeah ztables only..

Former Member
0 Kudos

Yes, create a database table only. The performance will not be hit until you have a really large number of users logged in.

Former Member
0 Kudos

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