‎2008 Apr 08 7:44 PM
In one of my programs I open a new session and want to delete the original session (like with a /i). Does anyone know how I could do this in an ABAP program? Thanks.
‎2008 Apr 08 7:52 PM
‎2008 Apr 08 7:52 PM
‎2008 Apr 08 7:54 PM
Yes, I tried it but I just get a short dump. It doesn't appear to view '/i' as a valid transaction.
‎2008 Apr 08 7:56 PM
‎2008 Apr 08 8:01 PM
Populate bdcdata_tab *
CALL FUNCTION 'ABAP4_CALL_TRANSACTION' STARTING NEW TASK 'NewTask' DESTINATION 'NONE'
EXPORTING
tcode = 'PP02'
"skip_screen = 'X'
"mode_val = 'E'
"update_val = 'A'
TABLES
using_tab = bdcdata_tab
EXCEPTIONS
call_transaction_denied = 1
OTHERS = 2.
Additional processing here *
LEAVE PROGRAM.
This works in that the existing program finishes and unlocks the records I need in the new session. It opens the new session and takes the original session back to the Easy Access Menu. However, I want to completely delete the original session so that the user can't miss the new one.
‎2008 Apr 08 8:06 PM
A quick look thru a few things didn't reveal anthing.
I wonder if you could issue a Windows command (ALT-F4) to do it.
Time to go home now.. I'll revisit this in the AM.
‎2008 Apr 08 8:07 PM
Thanks for the help anyhow Paul. Points awarded for the effort and interest.
‎2008 Apr 08 8:13 PM
I have been watching this thread since I too am interested (professional curiosity) in the answer.
Did you try and find out what (debug) when you delete / stop a report via SM50? I would search somewhere in that direction??!! My guess is that some sort of system call will be perfomed, some action on kernel level, but I'm note sure.
Hope anyone else sheds some light on this. Good luck.
‎2008 Apr 08 8:28 PM
‎2008 Apr 08 8:35 PM
The following code kills my current session... try it out.
DATA: i_messages LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE,
w_okcode LIKE sy-tcode,
w_host(30),
w_hostaddr LIKE msxxlist-hostadr,
w_terminal(40),
w_tid LIKE sy-index,
w_act_sessions LIKE sm04dic-counter,
w_max_sessions LIKE sm04dic-counter,
w_my_session LIKE sm04dic-counter,
w_my_internal_session LIKE sm04dic-counter,
w_task_state LIKE sm04dic-counter,
w_in_update LIKE sm04dic-counter,
w_strtid(4),
w_session_number(1) TYPE c, "Cannot be more than 6 anyways!
bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
CONSTANTS: opcode_usr_attr TYPE x VALUE 5,
opcode_list TYPE x VALUE 2.
"First get the current session number..
CALL 'ThUsrInfo' ID 'OPCODE' FIELD opcode_usr_attr
ID 'TERMINAL' FIELD w_terminal
ID 'TID' FIELD w_tid
ID 'HOST' FIELD w_host
ID 'HOSTADDR' FIELD w_hostaddr
ID 'ACT_SESSIONS' FIELD w_act_sessions
ID 'MAX_SESSIONS' FIELD w_max_sessions
ID 'MY_SESSION' FIELD w_my_session
ID 'MY_INTERNAL_SESSION' FIELD w_my_internal_session
ID 'TASK_STATUS' FIELD w_task_state
ID 'IN_UPDATE' FIELD w_in_update.
CLEAR: bdcdata, bdcdata[],
w_okcode.
w_session_number = w_my_session.
CONCATENATE '/i' w_session_number INTO w_okcode.
CONDENSE w_okcode NO-GAPS.
PERFORM bdc_dynpro USING 'SAPLSUU5' '0100'.
PERFORM bdc_field USING 'BDC_OKCODE' w_okcode.
PERFORM bdc_dynpro USING 'SAPLSUU5' '0100'.
PERFORM bdc_field USING 'BDC_OKCODE' '/ECANC'.
DATA: w_opt TYPE ctu_params.
w_opt-dismode = 'N'.
w_opt-updmode = 'A'.
CALL TRANSACTION 'SU3' USING bdcdata "Or some other transaction code!
OPTIONS FROM w_opt
MESSAGES INTO i_messages.
IF sy-subrc NE 0. "!!!!
ENDIF.
*---------------------------------------------------------------------*
* --> PROGRAM *
* --> DYNPRO *
*---------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM. "bdc_dynpro
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDFORM. "bdc_field
‎2008 Apr 08 8:51 PM
Many thanks to Guarav whose solution worked beautifully. I looked at Ken's solution and it looks like it should work as well and would be particularly useful for identifying a particular session to end.