cancel
Showing results for 
Search instead for 
Did you mean: 

Webdynpro ABAP Application with User Session

former_member187651
Active Participant
0 Kudos

Hello gurus,

I am new to webdynpro. I have developed one Webdynpro ABAP application with 20 view. My application is having one login view which is default of application. Requirement is while logging to the application, user can switch to second view. Once login he should not come back to the login page until click on logout button of application.

Now problem is while refreshing the application on window, it navigate to default page that is login page. I understand, we need to maintain the session for the user in the application. But I don't know how to maintain the session for the application so that once user get logged in, there session get started and lasts till the user logout.

Please let me guide for the same. Any answer will be helpful to me. I have gone through the SDN but did not found any relevant answer for me.

Thanks in advance.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Chandan,

There is no specific session handling mechanism in webdynpro abap and the data in the context remains through out the application state so if you refresh the browser without saving your data will be lost . In that case you have to implement auto save functionality on exit/refresh of the application.

In the scenario when user is in view/screen 3, has already entered some data till screen3 and at that point refreshes the browser without logout.

Requirement : The application should open from screen 3 and entered data should be available.

You should fix your idle session time validity for example 2 minutes.

You can try the following to achieve your requirement.

1.Create a custom table which will store the user id , application start time( you can consider this as application session start time(sy-uzeit)) and last active view number.

2. Create an context attribute(viz. a_logout_clicked ) of type WDY_BOOLEAN which will work as flag and set the flag whenever 'Logout' button is clicked.

3.Populate this table once during login i.e WDDOINIT or HANDLEDEFAULT of Window. and update the current view number whenever you will navigate to a view through navigation plug.

4. In WDDOEXIT method gets called during application exit (either by browser refresh or clicking the 'logout' button ). When this method will be called check whether the value of the  'a_logout_clicked' is set or not (in this way you can identify whether it is a browser refresh or a logout ).

If set (i.e log out ) then do nothing and if this flag is not checked i.e browser refresh write a code to auto save the data. providing the session is valid i.e the value of sy-uzeit at that time is within 2 mins from the application start time that you have saved earlier.

5. Create an inbound plug for all the views and when window HANDLEDEFAULD method will be called you just check the saved value of the 'current view number' and fire that corresponding flag to set that view as default view in the application.(Provided the application session is valid i.e user has refreshed browser with in 2 minutes)

Hope this helps.

Regards,

Sonia

former_member184578
Active Contributor
0 Kudos

Hi,

There is no such provision to maintain session like in JSP/Java or any other web application. When we refresh the browser, the application will load again using the Default Plug of the window.

To achieve this,

1. Keep a refresh button in your View ( where you want to reload the data ) and on Click of the refresh button, get the new data and set to the context.

OR,

2. In the onActionLogon of the main view, You concatenate the user ID and Password to the Web Dynpro URL. Now in HANDLEDEFAULT method of window, read the user ID and Password and log in directly.

OR,

3. Set the data to Shared memory and read it and remove from shared memory at logoff. ( You may need to handle window close with out logoff, which am not sure )

Except first option, other options has its limitations.

Hope this helps u.,

Regards,

Kiran

former_member187651
Active Participant
0 Kudos

Thanks for your reply Kiran.

For maintaining session, I have gone with SDN and found something called:.CLIENTSESSION_SCOPE.

Check thread : https://scn.sap.com/thread/1548232

I am looking for the same but don't know how to implement it.

My 2nd Issue: working with refresh button.

My requirement is while pressing F5 on browser, current view should open, not the default view of application.

Thanks.

former_member184578
Active Contributor
0 Kudos

Hi,

The thread which you referred is related to  Web Dynpro Java. As far i knew there is no such function in Web Dynpro ABAP.

And regarding your issue, When you press F5 in the browser, the application will load again and the default view will be called.

To open the current view, when ever you navigate to any view, in the view WDDOINIT method, concatenate( change) the view number to the Web dynpro URL. And in the HANDLEDEFAULT method of Window read the current view from the URL parameter and navigate to that view.

Remember that the data which you entered in the current view or in the other views will not be saved.

You need to create temporary data base tables to store the data when you are navigating to other views and when pressing F5, get the data and set to the context.

Regards,

Kiran