‎2009 Feb 03 10:46 AM
Hi,
What is the best way to start a new session programatically?
Basically I have my logic inside a method (I could also include the logic inside a function). I have a button in my dynpro, and when I click this button, I want that a new session is opened. I think that it is possible to start a new transaction into a new session, but in my case I see it very unnecessary to create a new transaction for something that doesn't really require a transaction
Regards,
Karri
Additional requirement: I was wondering that is it also possible to close the session programatically. So when the user has completed his task in the new opened session, the session would close automatically. I think that a bit similar thing happens in SU01 when you go to see the user's authorisations (new session is opened), and if you click "back" after you have checked the authorisations, the session will be closed automatically.
Edited by: Karri Kemppi on Feb 3, 2009 12:47 PM
‎2009 Feb 03 11:17 AM
Hello,
To create a new session programmatically, call the function TH_CREATE_FOREIGN_MODE with tcode SESSION_MANAGER.
Regards,
Shailaja
‎2009 Feb 03 11:23 AM
Here's an example of starting and ending a session.
START-OF-SELECTION.
CALL FUNCTION 'ABAP4_CALL_TRANSACTION'
STARTING NEW TASK 'NewTask'
DESTINATION 'NONE'
EXPORTING
tcode = 'ZLEADS'
"skip_screen = 'X'
"mode_val = 'E'
"update_val = 'A'
* TABLES
* using_tab = bdcdata_tab
EXCEPTIONS
call_transaction_denied = 1
OTHERS = 2.
* additional processing here *
** closes the current session.
CALL FUNCTION 'TH_DELETE_MODE'
** EXPORTING
** MODE = -1
.
LEAVE PROGRAM.
‎2009 Feb 03 11:50 AM
check this.
[new session using program|https://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=23658609]
‎2009 Feb 03 11:57 AM
Hi,
try this:
CALL FUNCTION 'TH_CREATE_MODE'.
or this
CALL FUNCTION 'TH_CREATE_MODE'
EXPORTING
TRANSAKTION = 'FB03'.
Regards, Dieter
‎2009 Mar 11 8:12 AM
Well, everybody seemed to instruct to use function modules to launch a transaction (which was something I wanted to avoid). Anyhow, I finally included the needed logic into a function module, and used the "NEW TASK" addition when calling the function. This was a perfect solution. Thanks for all answers.